Class: LoginRadius::OneTouchLoginApi

Inherits:
Object
  • Object
show all
Includes:
RequestClient
Defined in:
lib/login_radius/api/authentication/one_touch_login_api.rb

Overview

OneTouchLoginApi module

Constant Summary

Constants included from RequestClient

RequestClient::API_V2_BASE_URL, RequestClient::API_V2_BASE_URL_CONFIG, RequestClient::INIT_VECTOR, RequestClient::KEY_SIZE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RequestClient

#build_new_uri_obj, #create_hash_secret, #delete_request, #getValidationMessage, #get_request, #get_sott, #isNullOrWhiteSpace, #local_generate_sott, #post_request, #put_request

Constructor Details

#initializeOneTouchLoginApi

Initializes a LoginRadius Account object with an apikey and secret Takes in a hash containing site_name(required), api_key(required), api_secret(required)

Raises:



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/login_radius/api/authentication/one_touch_login_api.rb', line 16

def initialize
  @site_name = ENV['SITE_NAME']
  @api_key = ENV['API_KEY']
  @api_secret = ENV['API_SECRET']
  raise LoginRadius::Error.new, "'site_name' is a required option for Account class initialization." \
    unless @site_name != '' && @site_name != nil
  raise LoginRadius::Error.new, "'api_key' is a required option for Account class initialization." \
    unless @api_key != '' && @api_key != nil
  raise LoginRadius::Error.new, "'api_secret is a required option for Account class initialization." \
    unless @api_secret != '' && @api_secret != nil
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



12
13
14
# File 'lib/login_radius/api/authentication/one_touch_login_api.rb', line 12

def api_key
  @api_key
end

#api_secretObject

Returns the value of attribute api_secret.



12
13
14
# File 'lib/login_radius/api/authentication/one_touch_login_api.rb', line 12

def api_secret
  @api_secret
end

#site_nameObject

Returns the value of attribute site_name.



12
13
14
# File 'lib/login_radius/api/authentication/one_touch_login_api.rb', line 12

def site_name
  @site_name
end

Instance Method Details

#one_touch_email_verification(verification_token, welcome_email_template = '') ⇒ Object

This API verifies the provided token for One Touch Login

8.4.2

Parameters:

  • verification_token
    • Verification token received in the email

  • welcome_email_template (defaults to: '')
    • Name of the welcome email template

Returns:

  • Complete verified response data



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/login_radius/api/authentication/one_touch_login_api.rb', line 121

def one_touch_email_verification(verification_token, welcome_email_template = '')
  if isNullOrWhiteSpace(verification_token)
    raise LoginRadius::Error.new, getValidationMessage('verification_token')
  end

  query_parameters = {}
  query_parameters['apiKey'] = @api_key
  query_parameters['verificationToken'] = verification_token
  unless isNullOrWhiteSpace(welcome_email_template)
    query_parameters['welcomeEmailTemplate'] = welcome_email_template
  end

  resource_path = 'identity/v2/auth/email/onetouchlogin'
  get_request(resource_path, query_parameters, {})
end

#one_touch_login_by_email(one_touch_login_by_email_model, one_touch_login_email_template = '', redirecturl = '', welcomeemailtemplate = '') ⇒ Object

This API is used to send a link to a specified email for a frictionless login/registration

1.2

Parameters:

  • one_touch_login_by_email_model
    • Model Class containing Definition of payload for OneTouchLogin By EmailModel API

  • one_touch_login_email_template (defaults to: '')
    • Name of the One Touch Login Email Template

  • redirecturl (defaults to: '')
    • Url where the user will redirect after success authentication

  • welcomeemailtemplate (defaults to: '')
    • Name of the welcome email template

Returns:

  • Response containing Definition of Complete Validation data



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/login_radius/api/authentication/one_touch_login_api.rb', line 37

def (,  = '', redirecturl = '', welcomeemailtemplate = '')
  if .blank?
    raise LoginRadius::Error.new, getValidationMessage('one_touch_login_by_email_model')
  end

  query_parameters = {}
  query_parameters['apiKey'] = @api_key
  unless isNullOrWhiteSpace()
    query_parameters['oneTouchLoginEmailTemplate'] = 
  end
  unless isNullOrWhiteSpace(redirecturl)
    query_parameters['redirecturl'] = redirecturl
  end
  unless isNullOrWhiteSpace(welcomeemailtemplate)
    query_parameters['welcomeemailtemplate'] = welcomeemailtemplate
  end

  resource_path = 'identity/v2/auth/onetouchlogin/email'
  post_request(resource_path, query_parameters, )
end

#one_touch_login_by_phone(one_touch_login_by_phone_model, sms_template = '') ⇒ Object

This API is used to send one time password to a given phone number for a frictionless login/registration.

1.4

Parameters:

  • one_touch_login_by_phone_model
    • Model Class containing Definition of payload for OneTouchLogin By PhoneModel API

  • sms_template (defaults to: '')
    • SMS Template name

Returns:

  • Response containing Definition of Complete Validation data



65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/login_radius/api/authentication/one_touch_login_api.rb', line 65

def (, sms_template = '')
  if .blank?
    raise LoginRadius::Error.new, getValidationMessage('one_touch_login_by_phone_model')
  end

  query_parameters = {}
  query_parameters['apiKey'] = @api_key
  unless isNullOrWhiteSpace(sms_template)
    query_parameters['smsTemplate'] = sms_template
  end

  resource_path = 'identity/v2/auth/onetouchlogin/phone'
  post_request(resource_path, query_parameters, )
end

#one_touch_login_otp_verification(otp, phone, fields = '', sms_template = '') ⇒ Object

This API is used to verify the otp for One Touch Login.

1.5

Parameters:

  • otp
    • The Verification Code

  • phone
    • New Phone Number

  • fields (defaults to: '')
    • The fields parameter filters the API response so that the response only includes a specific set of fields

  • sms_template (defaults to: '')
    • SMS Template name

Returns:

  • Response Containing Access Token and Complete Profile Data



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/login_radius/api/authentication/one_touch_login_api.rb', line 89

def (otp, phone, fields = '', sms_template = '')
  if isNullOrWhiteSpace(otp)
    raise LoginRadius::Error.new, getValidationMessage('otp')
  end
  if isNullOrWhiteSpace(phone)
    raise LoginRadius::Error.new, getValidationMessage('phone')
  end

  query_parameters = {}
  query_parameters['apiKey'] = @api_key
  query_parameters['otp'] = otp
  unless isNullOrWhiteSpace(fields)
    query_parameters['fields'] = fields
  end
  unless isNullOrWhiteSpace(sms_template)
    query_parameters['smsTemplate'] = sms_template
  end

  body_parameters = {}
  body_parameters['phone'] = phone

  resource_path = 'identity/v2/auth/onetouchlogin/phone/verify'
  put_request(resource_path, query_parameters, body_parameters)
end

#one_touch_login_ping(client_guid, fields = '') ⇒ Object

This API is used to check if the One Touch Login link has been clicked or not.

9.21.2

Parameters:

  • client_guid
    • Unique string used in the Smart Login request

  • fields (defaults to: '')
    • The fields parameter filters the API response so that the response only includes a specific set of fields

Returns:

  • Response containing User Profile Data and access token



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/login_radius/api/authentication/one_touch_login_api.rb', line 144

def (client_guid, fields = '')
  if isNullOrWhiteSpace(client_guid)
    raise LoginRadius::Error.new, getValidationMessage('client_guid')
  end

  query_parameters = {}
  query_parameters['apiKey'] = @api_key
  query_parameters['clientGuid'] = client_guid
  unless isNullOrWhiteSpace(fields)
    query_parameters['fields'] = fields
  end

  resource_path = 'identity/v2/auth/login/smartlogin/ping'
  get_request(resource_path, query_parameters, {})
end