class Stormpath::Authentication::CreateFactor
Attributes
account[R]
challenge[R]
client[R]
custom_options[R]
phone[R]
type[R]
Public Class Methods
new(client, account, type, options = {})
click to toggle source
# File lib/stormpath-sdk/auth/create_factor.rb 21 def initialize(client, account, type, options = {}) 22 @client = client 23 @account = account 24 @type = determine_type(type) 25 @phone = options[:phone] || nil 26 @challenge = options[:challenge] || nil 27 @custom_options = options[:custom_options] || nil 28 end
Public Instance Methods
save()
click to toggle source
# File lib/stormpath-sdk/auth/create_factor.rb 30 def save 31 data_store.execute_raw_request(href, resource, Stormpath::Resource::Factor) 32 end
Private Instance Methods
add_custom_options(body)
click to toggle source
# File lib/stormpath-sdk/auth/create_factor.rb 54 def add_custom_options(body) 55 if custom_options 56 body[:accountName] = custom_options[:account_name] if custom_options[:account_name] 57 body[:issuer] = custom_options[:issuer] if custom_options[:issuer] 58 body[:status] = custom_options[:status] if custom_options[:status] 59 end 60 body 61 end
determine_type(type)
click to toggle source
# File lib/stormpath-sdk/auth/create_factor.rb 49 def determine_type(type) 50 raise Stormpath::Error unless type == :sms || type == :google_authenticator 51 type.to_s.sub('_', '-') 52 end
href()
click to toggle source
# File lib/stormpath-sdk/auth/create_factor.rb 36 def href 37 "#{account.href}/factors#{'?challenge=true' if challenge}" 38 end
resource()
click to toggle source
# File lib/stormpath-sdk/auth/create_factor.rb 40 def resource 41 {}.tap do |body| 42 body[:type] = type 43 body[:phone] = phone if phone 44 body[:challenge] = { message: "#{challenge[:message]} ${code}" } if challenge 45 add_custom_options(body) 46 end 47 end