login_radius 3.0.0 → 10.0.0.pre.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +5 -5
  2. data/LICENSE.txt +21 -0
  3. data/README.md +58 -52
  4. data/lib/login_radius.rb +30 -15
  5. data/lib/login_radius/api/account/account_api.rb +581 -0
  6. data/lib/login_radius/api/account/role_api.rb +330 -0
  7. data/lib/login_radius/api/account/sott_api.rb +47 -0
  8. data/lib/login_radius/api/advanced/configuration_api.rb +57 -0
  9. data/lib/login_radius/api/advanced/consent_management_api.rb +161 -0
  10. data/lib/login_radius/api/advanced/custom_object_api.rb +316 -0
  11. data/lib/login_radius/api/advanced/custom_registration_data_api.rb +195 -0
  12. data/lib/login_radius/api/advanced/multi_factor_authentication_api.rb +606 -0
  13. data/lib/login_radius/api/advanced/re_authentication_api.rb +243 -0
  14. data/lib/login_radius/api/advanced/web_hook_api.rb +101 -0
  15. data/lib/login_radius/api/authentication/authentication_api.rb +986 -0
  16. data/lib/login_radius/api/authentication/one_touch_login_api.rb +160 -0
  17. data/lib/login_radius/api/authentication/password_less_login_api.rb +158 -0
  18. data/lib/login_radius/api/authentication/phone_authentication_api.rb +329 -0
  19. data/lib/login_radius/api/authentication/pin_authentication_api.rb +316 -0
  20. data/lib/login_radius/api/authentication/risk_based_authentication_api.rb +286 -0
  21. data/lib/login_radius/api/authentication/smart_login_api.rb +146 -0
  22. data/lib/login_radius/api/social/native_social_api.rb +193 -0
  23. data/lib/login_radius/api/social/social_api.rb +802 -0
  24. data/lib/login_radius/error.rb +7 -0
  25. data/lib/login_radius/request_client.rb +295 -0
  26. data/lib/login_radius/response.rb +12 -0
  27. data/lib/login_radius/version.rb +3 -3
  28. data/login_radius.gemspec +36 -0
  29. metadata +61 -20
  30. data/LICENSE +0 -22
  31. data/lib/hash.rb +0 -12
  32. data/lib/login_radius/advanced_api.rb +0 -133
  33. data/lib/login_radius/authentication_api.rb +0 -597
  34. data/lib/login_radius/exception.rb +0 -4
  35. data/lib/login_radius/management_api.rb +0 -327
  36. data/lib/login_radius/rest_request.rb +0 -142
  37. data/lib/login_radius/social_api.rb +0 -402
  38. data/lib/login_radius/two_fa_api.rb +0 -191
  39. data/lib/string.rb +0 -8
@@ -0,0 +1,243 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Created by LoginRadius Development Team
4
+ # Copyright 2019 LoginRadius Inc. All rights reserved.
5
+ require_relative '../../request_client'
6
+
7
+ module LoginRadius
8
+ # ReAuthenticationApi module
9
+ class ReAuthenticationApi
10
+ include RequestClient
11
+
12
+ attr_accessor :site_name, :api_key, :api_secret
13
+
14
+ # Initializes a LoginRadius Account object with an apikey and secret
15
+ # Takes in a hash containing site_name(required), api_key(required), api_secret(required)
16
+ def initialize
17
+ @site_name = ENV['SITE_NAME']
18
+ @api_key = ENV['API_KEY']
19
+ @api_secret = ENV['API_SECRET']
20
+ raise LoginRadius::Error.new, "'site_name' is a required option for Account class initialization." \
21
+ unless @site_name != '' && @site_name != nil
22
+ raise LoginRadius::Error.new, "'api_key' is a required option for Account class initialization." \
23
+ unless @api_key != '' && @api_key != nil
24
+ raise LoginRadius::Error.new, "'api_secret is a required option for Account class initialization." \
25
+ unless @api_secret != '' && @api_secret != nil
26
+ end
27
+
28
+ # This API is used to trigger the Multi-Factor Autentication workflow for the provided access token
29
+ #
30
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
31
+ # @param sms_template2_f_a - SMS Template Name
32
+ #
33
+ # @return Response containing Definition of Complete Multi-Factor Authentication Settings data
34
+ # 14.3
35
+ def mfa_re_authenticate(access_token, sms_template2_f_a = '')
36
+ if isNullOrWhiteSpace(access_token)
37
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
38
+ end
39
+
40
+ query_parameters = {}
41
+ query_parameters['access_token'] = access_token
42
+ query_parameters['apiKey'] = @api_key
43
+ unless isNullOrWhiteSpace(sms_template2_f_a)
44
+ query_parameters['smsTemplate2FA'] = sms_template2_f_a
45
+ end
46
+
47
+ resource_path = 'identity/v2/auth/account/reauth/2fa'
48
+ get_request(resource_path, query_parameters, nil)
49
+ end
50
+
51
+ # This API is used to re-authenticate via Multi-factor authentication by passing the One Time Password received via SMS
52
+ #
53
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
54
+ # @param reauth_by_otp_model - Model Class containing Definition for MFA Reauthentication by OTP
55
+ #
56
+ # @return Complete user Multi-Factor Authentication Token data
57
+ # 14.4
58
+ def mfa_re_authenticate_by_otp(access_token, reauth_by_otp_model)
59
+ if isNullOrWhiteSpace(access_token)
60
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
61
+ end
62
+ if reauth_by_otp_model.blank?
63
+ raise LoginRadius::Error.new, getValidationMessage('reauth_by_otp_model')
64
+ end
65
+
66
+ query_parameters = {}
67
+ query_parameters['access_token'] = access_token
68
+ query_parameters['apiKey'] = @api_key
69
+
70
+ resource_path = 'identity/v2/auth/account/reauth/2fa/otp'
71
+ put_request(resource_path, query_parameters, reauth_by_otp_model)
72
+ end
73
+
74
+ # This API is used to re-authenticate by set of backup codes via access token on the site that has Multi-factor authentication enabled in re-authentication for the user that does not have the device
75
+ #
76
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
77
+ # @param reauth_by_backup_code_model - Model Class containing Definition for MFA Reauthentication by Backup code
78
+ #
79
+ # @return Complete user Multi-Factor Authentication Token data
80
+ # 14.5
81
+ def mfa_re_authenticate_by_backup_code(access_token, reauth_by_backup_code_model)
82
+ if isNullOrWhiteSpace(access_token)
83
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
84
+ end
85
+ if reauth_by_backup_code_model.blank?
86
+ raise LoginRadius::Error.new, getValidationMessage('reauth_by_backup_code_model')
87
+ end
88
+
89
+ query_parameters = {}
90
+ query_parameters['access_token'] = access_token
91
+ query_parameters['apiKey'] = @api_key
92
+
93
+ resource_path = 'identity/v2/auth/account/reauth/2fa/backupcode'
94
+ put_request(resource_path, query_parameters, reauth_by_backup_code_model)
95
+ end
96
+
97
+ # This API is used to re-authenticate via Multi-factor-authentication by passing the google authenticator code
98
+ #
99
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
100
+ # @param reauth_by_google_authenticator_code_model - Model Class containing Definition for MFA Reauthentication by Google Authenticator
101
+ #
102
+ # @return Complete user Multi-Factor Authentication Token data
103
+ # 14.6
104
+ def mfa_re_authenticate_by_google_auth(access_token, reauth_by_google_authenticator_code_model)
105
+ if isNullOrWhiteSpace(access_token)
106
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
107
+ end
108
+ if reauth_by_google_authenticator_code_model.blank?
109
+ raise LoginRadius::Error.new, getValidationMessage('reauth_by_google_authenticator_code_model')
110
+ end
111
+
112
+ query_parameters = {}
113
+ query_parameters['access_token'] = access_token
114
+ query_parameters['apiKey'] = @api_key
115
+
116
+ resource_path = 'identity/v2/auth/account/reauth/2fa/googleauthenticatorcode'
117
+ put_request(resource_path, query_parameters, reauth_by_google_authenticator_code_model)
118
+ end
119
+
120
+ # This API is used to re-authenticate via Multi-factor-authentication by passing the password
121
+ #
122
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
123
+ # @param password_event_based_auth_model_with_lockout - Model Class containing Definition of payload for PasswordEventBasedAuthModel with Lockout API
124
+ # @param sms_template2_f_a - SMS Template Name
125
+ #
126
+ # @return Complete user Multi-Factor Authentication Token data
127
+ # 14.7
128
+ def mfa_re_authenticate_by_password(access_token, password_event_based_auth_model_with_lockout, sms_template2_f_a = '')
129
+ if isNullOrWhiteSpace(access_token)
130
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
131
+ end
132
+ if password_event_based_auth_model_with_lockout.blank?
133
+ raise LoginRadius::Error.new, getValidationMessage('password_event_based_auth_model_with_lockout')
134
+ end
135
+
136
+ query_parameters = {}
137
+ query_parameters['access_token'] = access_token
138
+ query_parameters['apiKey'] = @api_key
139
+ unless isNullOrWhiteSpace(sms_template2_f_a)
140
+ query_parameters['smsTemplate2FA'] = sms_template2_f_a
141
+ end
142
+
143
+ resource_path = 'identity/v2/auth/account/reauth/password'
144
+ put_request(resource_path, query_parameters, password_event_based_auth_model_with_lockout)
145
+ end
146
+
147
+ # This API is used on the server-side to validate and verify the re-authentication token created by the MFA re-authentication API. This API checks re-authentications created by OTP.
148
+ #
149
+ # @param event_based_multi_factor_token - Model Class containing Definition for SecondFactorValidationToken
150
+ # @param uid - UID, the unified identifier for each user account
151
+ #
152
+ # @return Response containing Definition of Complete Validation data
153
+ # 18.38
154
+ def verify_multi_factor_otp_reauthentication(event_based_multi_factor_token, uid)
155
+ if event_based_multi_factor_token.blank?
156
+ raise LoginRadius::Error.new, getValidationMessage('event_based_multi_factor_token')
157
+ end
158
+ if isNullOrWhiteSpace(uid)
159
+ raise LoginRadius::Error.new, getValidationMessage('uid')
160
+ end
161
+
162
+ query_parameters = {}
163
+ query_parameters['apiKey'] = @api_key
164
+ query_parameters['apiSecret'] = @api_secret
165
+
166
+ resource_path = 'identity/v2/manage/account/' + uid + '/reauth/2fa'
167
+ post_request(resource_path, query_parameters, event_based_multi_factor_token)
168
+ end
169
+
170
+ # This API is used on the server-side to validate and verify the re-authentication token created by the MFA re-authentication API. This API checks re-authentications created by password.
171
+ #
172
+ # @param event_based_multi_factor_token - Model Class containing Definition for SecondFactorValidationToken
173
+ # @param uid - UID, the unified identifier for each user account
174
+ #
175
+ # @return Response containing Definition of Complete Validation data
176
+ # 18.39
177
+ def verify_multi_factor_password_reauthentication(event_based_multi_factor_token, uid)
178
+ if event_based_multi_factor_token.blank?
179
+ raise LoginRadius::Error.new, getValidationMessage('event_based_multi_factor_token')
180
+ end
181
+ if isNullOrWhiteSpace(uid)
182
+ raise LoginRadius::Error.new, getValidationMessage('uid')
183
+ end
184
+
185
+ query_parameters = {}
186
+ query_parameters['apiKey'] = @api_key
187
+ query_parameters['apiSecret'] = @api_secret
188
+
189
+ resource_path = 'identity/v2/manage/account/' + uid + '/reauth/password'
190
+ post_request(resource_path, query_parameters, event_based_multi_factor_token)
191
+ end
192
+
193
+ # This API is used on the server-side to validate and verify the re-authentication token created by the MFA re-authentication API. This API checks re-authentications created by PIN.
194
+ #
195
+ # @param event_based_multi_factor_token - Model Class containing Definition for SecondFactorValidationToken
196
+ # @param uid - UID, the unified identifier for each user account
197
+ #
198
+ # @return Response containing Definition of Complete Validation data
199
+ # 18.40
200
+ def verify_multi_factor_pin_reauthentication(event_based_multi_factor_token, uid)
201
+ if event_based_multi_factor_token.blank?
202
+ raise LoginRadius::Error.new, getValidationMessage('event_based_multi_factor_token')
203
+ end
204
+ if isNullOrWhiteSpace(uid)
205
+ raise LoginRadius::Error.new, getValidationMessage('uid')
206
+ end
207
+
208
+ query_parameters = {}
209
+ query_parameters['apiKey'] = @api_key
210
+ query_parameters['apiSecret'] = @api_secret
211
+
212
+ resource_path = 'identity/v2/manage/account/' + uid + '/reauth/pin'
213
+ post_request(resource_path, query_parameters, event_based_multi_factor_token)
214
+ end
215
+
216
+ # This API is used to validate the triggered MFA authentication flow with a password.
217
+ #
218
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
219
+ # @param pin_auth_event_based_auth_model_with_lockout - Model Class containing Definition of payload for PIN
220
+ # @param sms_template2_f_a - SMS Template Name
221
+ #
222
+ # @return Response containing Definition response of MFA reauthentication
223
+ # 42.13
224
+ def verify_pin_authentication(access_token, pin_auth_event_based_auth_model_with_lockout, sms_template2_f_a = '')
225
+ if isNullOrWhiteSpace(access_token)
226
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
227
+ end
228
+ if pin_auth_event_based_auth_model_with_lockout.blank?
229
+ raise LoginRadius::Error.new, getValidationMessage('pin_auth_event_based_auth_model_with_lockout')
230
+ end
231
+
232
+ query_parameters = {}
233
+ query_parameters['access_token'] = access_token
234
+ query_parameters['apiKey'] = @api_key
235
+ unless isNullOrWhiteSpace(sms_template2_f_a)
236
+ query_parameters['smsTemplate2FA'] = sms_template2_f_a
237
+ end
238
+
239
+ resource_path = 'identity/v2/auth/account/reauth/pin'
240
+ put_request(resource_path, query_parameters, pin_auth_event_based_auth_model_with_lockout)
241
+ end
242
+ end
243
+ end
@@ -0,0 +1,101 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Created by LoginRadius Development Team
4
+ # Copyright 2019 LoginRadius Inc. All rights reserved.
5
+ require_relative '../../request_client'
6
+
7
+ module LoginRadius
8
+ # WebHookApi module
9
+ class WebHookApi
10
+ include RequestClient
11
+
12
+ attr_accessor :site_name, :api_key, :api_secret
13
+
14
+ # Initializes a LoginRadius Account object with an apikey and secret
15
+ # Takes in a hash containing site_name(required), api_key(required), api_secret(required)
16
+ def initialize
17
+ @site_name = ENV['SITE_NAME']
18
+ @api_key = ENV['API_KEY']
19
+ @api_secret = ENV['API_SECRET']
20
+ raise LoginRadius::Error.new, "'site_name' is a required option for Account class initialization." \
21
+ unless @site_name != '' && @site_name != nil
22
+ raise LoginRadius::Error.new, "'api_key' is a required option for Account class initialization." \
23
+ unless @api_key != '' && @api_key != nil
24
+ raise LoginRadius::Error.new, "'api_secret is a required option for Account class initialization." \
25
+ unless @api_secret != '' && @api_secret != nil
26
+ end
27
+
28
+ # This API is used to fatch all the subscribed URLs, for particular event
29
+ #
30
+ # @param event - Allowed events: Login, Register, UpdateProfile, ResetPassword, ChangePassword, emailVerification, AddEmail, RemoveEmail, BlockAccount, DeleteAccount, SetUsername, AssignRoles, UnassignRoles, SetPassword, LinkAccount, UnlinkAccount, UpdatePhoneId, VerifyPhoneNumber, CreateCustomObject, UpdateCustomobject, DeleteCustomObject
31
+ #
32
+ # @return Response Containing List of Webhhook Data
33
+ # 40.1
34
+ def get_web_hook_subscribed_u_r_ls(event)
35
+ if isNullOrWhiteSpace(event)
36
+ raise LoginRadius::Error.new, getValidationMessage('event')
37
+ end
38
+
39
+ query_parameters = {}
40
+ query_parameters['apikey'] = @api_key
41
+ query_parameters['apisecret'] = @api_secret
42
+ query_parameters['event'] = event
43
+
44
+ resource_path = 'api/v2/webhook'
45
+ get_request(resource_path, query_parameters, nil)
46
+ end
47
+
48
+ # API can be used to configure a WebHook on your LoginRadius site. Webhooks also work on subscribe and notification model, subscribe your hook and get a notification. Equivalent to RESThook but these provide security on basis of signature and RESThook work on unique URL. Following are the events that are allowed by LoginRadius to trigger a WebHook service call.
49
+ #
50
+ # @param web_hook_subscribe_model - Model Class containing Definition of payload for Webhook Subscribe API
51
+ #
52
+ # @return Response containing Definition of Complete Validation data
53
+ # 40.2
54
+ def web_hook_subscribe(web_hook_subscribe_model)
55
+ if web_hook_subscribe_model.blank?
56
+ raise LoginRadius::Error.new, getValidationMessage('web_hook_subscribe_model')
57
+ end
58
+
59
+ query_parameters = {}
60
+ query_parameters['apikey'] = @api_key
61
+ query_parameters['apisecret'] = @api_secret
62
+
63
+ resource_path = 'api/v2/webhook'
64
+ post_request(resource_path, query_parameters, web_hook_subscribe_model)
65
+ end
66
+
67
+ # API can be used to test a subscribed WebHook.
68
+ #
69
+ #
70
+ # @return Response containing Definition of Complete Validation data
71
+ # 40.3
72
+ def webhook_test()
73
+
74
+ query_parameters = {}
75
+ query_parameters['apikey'] = @api_key
76
+ query_parameters['apisecret'] = @api_secret
77
+
78
+ resource_path = 'api/v2/webhook/test'
79
+ get_request(resource_path, query_parameters, nil)
80
+ end
81
+
82
+ # API can be used to unsubscribe a WebHook configured on your LoginRadius site.
83
+ #
84
+ # @param web_hook_subscribe_model - Model Class containing Definition of payload for Webhook Subscribe API
85
+ #
86
+ # @return Response containing Definition of Delete Request
87
+ # 40.4
88
+ def web_hook_unsubscribe(web_hook_subscribe_model)
89
+ if web_hook_subscribe_model.blank?
90
+ raise LoginRadius::Error.new, getValidationMessage('web_hook_subscribe_model')
91
+ end
92
+
93
+ query_parameters = {}
94
+ query_parameters['apikey'] = @api_key
95
+ query_parameters['apisecret'] = @api_secret
96
+
97
+ resource_path = 'api/v2/webhook'
98
+ delete_request(resource_path, query_parameters, web_hook_subscribe_model)
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,986 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Created by LoginRadius Development Team
4
+ # Copyright 2019 LoginRadius Inc. All rights reserved.
5
+ require_relative '../../request_client'
6
+
7
+ module LoginRadius
8
+ # AuthenticationApi module
9
+ class AuthenticationApi
10
+ include RequestClient
11
+
12
+ attr_accessor :site_name, :api_key, :api_secret
13
+
14
+ # Initializes a LoginRadius Account object with an apikey and secret
15
+ # Takes in a hash containing site_name(required), api_key(required), api_secret(required)
16
+ def initialize
17
+ @site_name = ENV['SITE_NAME']
18
+ @api_key = ENV['API_KEY']
19
+ @api_secret = ENV['API_SECRET']
20
+ raise LoginRadius::Error.new, "'site_name' is a required option for Account class initialization." \
21
+ unless @site_name != '' && @site_name != nil
22
+ raise LoginRadius::Error.new, "'api_key' is a required option for Account class initialization." \
23
+ unless @api_key != '' && @api_key != nil
24
+ raise LoginRadius::Error.new, "'api_secret is a required option for Account class initialization." \
25
+ unless @api_secret != '' && @api_secret != nil
26
+ end
27
+
28
+ # This API is used to retrieve the list of questions that are configured on the respective LoginRadius site.
29
+ #
30
+ # @param email - Email of the user
31
+ #
32
+ # @return Response containing Definition for Complete SecurityQuestions data
33
+ # 2.1
34
+ def get_security_questions_by_email(email)
35
+ if isNullOrWhiteSpace(email)
36
+ raise LoginRadius::Error.new, getValidationMessage('email')
37
+ end
38
+
39
+ query_parameters = {}
40
+ query_parameters['apiKey'] = @api_key
41
+ query_parameters['email'] = email
42
+
43
+ resource_path = 'identity/v2/auth/securityquestion/email'
44
+ get_request(resource_path, query_parameters, nil)
45
+ end
46
+
47
+ # This API is used to retrieve the list of questions that are configured on the respective LoginRadius site.
48
+ #
49
+ # @param user_name - UserName of the user
50
+ #
51
+ # @return Response containing Definition for Complete SecurityQuestions data
52
+ # 2.2
53
+ def get_security_questions_by_user_name(user_name)
54
+ if isNullOrWhiteSpace(user_name)
55
+ raise LoginRadius::Error.new, getValidationMessage('user_name')
56
+ end
57
+
58
+ query_parameters = {}
59
+ query_parameters['apiKey'] = @api_key
60
+ query_parameters['userName'] = user_name
61
+
62
+ resource_path = 'identity/v2/auth/securityquestion/username'
63
+ get_request(resource_path, query_parameters, nil)
64
+ end
65
+
66
+ # This API is used to retrieve the list of questions that are configured on the respective LoginRadius site.
67
+ #
68
+ # @param phone - The Registered Phone Number
69
+ #
70
+ # @return Response containing Definition for Complete SecurityQuestions data
71
+ # 2.3
72
+ def get_security_questions_by_phone(phone)
73
+ if isNullOrWhiteSpace(phone)
74
+ raise LoginRadius::Error.new, getValidationMessage('phone')
75
+ end
76
+
77
+ query_parameters = {}
78
+ query_parameters['apiKey'] = @api_key
79
+ query_parameters['phone'] = phone
80
+
81
+ resource_path = 'identity/v2/auth/securityquestion/phone'
82
+ get_request(resource_path, query_parameters, nil)
83
+ end
84
+
85
+ # This API is used to retrieve the list of questions that are configured on the respective LoginRadius site.
86
+ #
87
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
88
+ #
89
+ # @return Response containing Definition for Complete SecurityQuestions data
90
+ # 2.4
91
+ def get_security_questions_by_access_token(access_token)
92
+ if isNullOrWhiteSpace(access_token)
93
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
94
+ end
95
+
96
+ query_parameters = {}
97
+ query_parameters['access_token'] = access_token
98
+ query_parameters['apiKey'] = @api_key
99
+
100
+ resource_path = 'identity/v2/auth/securityquestion/accesstoken'
101
+ get_request(resource_path, query_parameters, nil)
102
+ end
103
+
104
+ # This api validates access token, if valid then returns a response with its expiry otherwise error.
105
+ #
106
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
107
+ #
108
+ # @return Response containing Definition of Complete Token data
109
+ # 4.1
110
+ def auth_validate_access_token(access_token)
111
+ if isNullOrWhiteSpace(access_token)
112
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
113
+ end
114
+
115
+ query_parameters = {}
116
+ query_parameters['access_token'] = access_token
117
+ query_parameters['apiKey'] = @api_key
118
+
119
+ resource_path = 'identity/v2/auth/access_token/validate'
120
+ get_request(resource_path, query_parameters, nil)
121
+ end
122
+
123
+ # This api call invalidates the active access token or expires an access token's validity.
124
+ #
125
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
126
+ # @param prevent_refresh - Boolean value that when set as true, in addition of the access token being invalidated, it will no longer have the capability of being refreshed.
127
+ #
128
+ # @return Response containing Definition of Complete Validation data
129
+ # 4.2
130
+ def auth_in_validate_access_token(access_token, prevent_refresh = false)
131
+ if isNullOrWhiteSpace(access_token)
132
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
133
+ end
134
+
135
+ query_parameters = {}
136
+ query_parameters['access_token'] = access_token
137
+ query_parameters['apiKey'] = @api_key
138
+ unless prevent_refresh == false
139
+ query_parameters['preventRefresh'] = prevent_refresh
140
+ end
141
+
142
+ resource_path = 'identity/v2/auth/access_token/invalidate'
143
+ get_request(resource_path, query_parameters, nil)
144
+ end
145
+
146
+ # This api call provide the active access token Information
147
+ #
148
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
149
+ #
150
+ # @return Response containing Definition of Token Information
151
+ # 4.3
152
+ def get_access_token_info(access_token)
153
+ if isNullOrWhiteSpace(access_token)
154
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
155
+ end
156
+
157
+ query_parameters = {}
158
+ query_parameters['access_token'] = access_token
159
+ query_parameters['apiKey'] = @api_key
160
+
161
+ resource_path = 'identity/v2/auth/access_token'
162
+ get_request(resource_path, query_parameters, nil)
163
+ end
164
+
165
+ # This API retrieves a copy of the user data based on the access token.
166
+ #
167
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
168
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
169
+ #
170
+ # @return Response containing Definition for Complete profile data
171
+ # 5.2
172
+ def get_profile_by_access_token(access_token, fields = '')
173
+ if isNullOrWhiteSpace(access_token)
174
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
175
+ end
176
+
177
+ query_parameters = {}
178
+ query_parameters['access_token'] = access_token
179
+ query_parameters['apiKey'] = @api_key
180
+ unless isNullOrWhiteSpace(fields)
181
+ query_parameters['fields'] = fields
182
+ end
183
+
184
+ resource_path = 'identity/v2/auth/account'
185
+ get_request(resource_path, query_parameters, nil)
186
+ end
187
+
188
+ # This API sends a welcome email
189
+ #
190
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
191
+ # @param welcome_email_template - Name of the welcome email template
192
+ #
193
+ # @return Response containing Definition of Complete Validation data
194
+ # 5.3
195
+ def send_welcome_email(access_token, welcome_email_template = '')
196
+ if isNullOrWhiteSpace(access_token)
197
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
198
+ end
199
+
200
+ query_parameters = {}
201
+ query_parameters['access_token'] = access_token
202
+ query_parameters['apiKey'] = @api_key
203
+ unless isNullOrWhiteSpace(welcome_email_template)
204
+ query_parameters['welcomeEmailTemplate'] = welcome_email_template
205
+ end
206
+
207
+ resource_path = 'identity/v2/auth/account/sendwelcomeemail'
208
+ get_request(resource_path, query_parameters, nil)
209
+ end
210
+
211
+ # This API is used to update the user's profile by passing the access token.
212
+ #
213
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
214
+ # @param user_profile_update_model - Model Class containing Definition of payload for User Profile update API
215
+ # @param email_template - Email template name
216
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
217
+ # @param null_support - Boolean, pass true if you wish to update any user profile field with a NULL value, You can get the details
218
+ # @param sms_template - SMS Template name
219
+ # @param verification_url - Email verification url
220
+ #
221
+ # @return Response containing Definition of Complete Validation and UserProfile data
222
+ # 5.4
223
+ def update_profile_by_access_token(access_token, user_profile_update_model, email_template = '', fields = '', null_support = false, sms_template = '', verification_url = '')
224
+ if isNullOrWhiteSpace(access_token)
225
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
226
+ end
227
+ if user_profile_update_model.blank?
228
+ raise LoginRadius::Error.new, getValidationMessage('user_profile_update_model')
229
+ end
230
+
231
+ query_parameters = {}
232
+ query_parameters['access_token'] = access_token
233
+ query_parameters['apiKey'] = @api_key
234
+ unless isNullOrWhiteSpace(email_template)
235
+ query_parameters['emailTemplate'] = email_template
236
+ end
237
+ unless isNullOrWhiteSpace(fields)
238
+ query_parameters['fields'] = fields
239
+ end
240
+ unless null_support == false
241
+ query_parameters['nullSupport'] = null_support
242
+ end
243
+ unless isNullOrWhiteSpace(sms_template)
244
+ query_parameters['smsTemplate'] = sms_template
245
+ end
246
+ unless isNullOrWhiteSpace(verification_url)
247
+ query_parameters['verificationUrl'] = verification_url
248
+ end
249
+
250
+ resource_path = 'identity/v2/auth/account'
251
+ put_request(resource_path, query_parameters, user_profile_update_model)
252
+ end
253
+
254
+ # This API will send a confirmation email for account deletion to the customer's email when passed the customer's access token
255
+ #
256
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
257
+ # @param delete_url - Url of the site
258
+ # @param email_template - Email template name
259
+ #
260
+ # @return Response containing Definition of Delete Request
261
+ # 5.5
262
+ def delete_account_with_email_confirmation(access_token, delete_url = '', email_template = '')
263
+ if isNullOrWhiteSpace(access_token)
264
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
265
+ end
266
+
267
+ query_parameters = {}
268
+ query_parameters['access_token'] = access_token
269
+ query_parameters['apiKey'] = @api_key
270
+ unless isNullOrWhiteSpace(delete_url)
271
+ query_parameters['deleteUrl'] = delete_url
272
+ end
273
+ unless isNullOrWhiteSpace(email_template)
274
+ query_parameters['emailTemplate'] = email_template
275
+ end
276
+
277
+ resource_path = 'identity/v2/auth/account'
278
+ delete_request(resource_path, query_parameters, nil)
279
+ end
280
+
281
+ # This API is used to delete an account by passing it a delete token.
282
+ #
283
+ # @param deletetoken - Delete token received in the email
284
+ #
285
+ # @return Response containing Definition of Complete Validation data
286
+ # 5.6
287
+ def delete_account_by_delete_token(deletetoken)
288
+ if isNullOrWhiteSpace(deletetoken)
289
+ raise LoginRadius::Error.new, getValidationMessage('deletetoken')
290
+ end
291
+
292
+ query_parameters = {}
293
+ query_parameters['apiKey'] = @api_key
294
+ query_parameters['deletetoken'] = deletetoken
295
+
296
+ resource_path = 'identity/v2/auth/account/delete'
297
+ get_request(resource_path, query_parameters, nil)
298
+ end
299
+
300
+ # This API is used to allow a customer with a valid access token to unlock their account provided that they successfully pass the prompted Bot Protection challenges. The Block or Suspend block types are not applicable for this API. For additional details see our Auth Security Configuration documentation.You are only required to pass the Post Parameters that correspond to the prompted challenges.
301
+ #
302
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
303
+ # @param unlock_profile_model - Payload containing Unlock Profile API
304
+ #
305
+ # @return Response containing Definition of Complete Validation data
306
+ # 5.15
307
+ def unlock_account_by_token(access_token, unlock_profile_model)
308
+ if isNullOrWhiteSpace(access_token)
309
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
310
+ end
311
+ if unlock_profile_model.blank?
312
+ raise LoginRadius::Error.new, getValidationMessage('unlock_profile_model')
313
+ end
314
+
315
+ query_parameters = {}
316
+ query_parameters['access_token'] = access_token
317
+ query_parameters['apiKey'] = @api_key
318
+
319
+ resource_path = 'identity/v2/auth/account/unlock'
320
+ put_request(resource_path, query_parameters, unlock_profile_model)
321
+ end
322
+
323
+ # This API is used to check the email exists or not on your site.
324
+ #
325
+ # @param email - Email of the user
326
+ #
327
+ # @return Response containing Definition Complete ExistResponse data
328
+ # 8.1
329
+ def check_email_availability(email)
330
+ if isNullOrWhiteSpace(email)
331
+ raise LoginRadius::Error.new, getValidationMessage('email')
332
+ end
333
+
334
+ query_parameters = {}
335
+ query_parameters['apiKey'] = @api_key
336
+ query_parameters['email'] = email
337
+
338
+ resource_path = 'identity/v2/auth/email'
339
+ get_request(resource_path, query_parameters, nil)
340
+ end
341
+
342
+ # This API is used to verify the email of user. Note: This API will only return the full profile if you have 'Enable auto login after email verification' set in your LoginRadius Admin Console's Email Workflow settings under 'Verification Email'.
343
+ #
344
+ # @param verification_token - Verification token received in the email
345
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
346
+ # @param url - Mention URL to log the main URL(Domain name) in Database.
347
+ # @param welcome_email_template - Name of the welcome email template
348
+ #
349
+ # @return Response containing Definition of Complete Validation, UserProfile data and Access Token
350
+ # 8.2
351
+ def verify_email(verification_token, fields = '', url = '', welcome_email_template = '')
352
+ if isNullOrWhiteSpace(verification_token)
353
+ raise LoginRadius::Error.new, getValidationMessage('verification_token')
354
+ end
355
+
356
+ query_parameters = {}
357
+ query_parameters['apiKey'] = @api_key
358
+ query_parameters['verificationToken'] = verification_token
359
+ unless isNullOrWhiteSpace(fields)
360
+ query_parameters['fields'] = fields
361
+ end
362
+ unless isNullOrWhiteSpace(url)
363
+ query_parameters['url'] = url
364
+ end
365
+ unless isNullOrWhiteSpace(welcome_email_template)
366
+ query_parameters['welcomeEmailTemplate'] = welcome_email_template
367
+ end
368
+
369
+ resource_path = 'identity/v2/auth/email'
370
+ get_request(resource_path, query_parameters, nil)
371
+ end
372
+
373
+ # This API is used to verify the email of user when the OTP Email verification flow is enabled, please note that you must contact LoginRadius to have this feature enabled.
374
+ #
375
+ # @param email_verification_by_otp_model - Model Class containing Definition for EmailVerificationByOtpModel API
376
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
377
+ # @param url - Mention URL to log the main URL(Domain name) in Database.
378
+ # @param welcome_email_template - Name of the welcome email template
379
+ #
380
+ # @return Response containing Definition of Complete Validation, UserProfile data and Access Token
381
+ # 8.3
382
+ def verify_email_by_otp(email_verification_by_otp_model, fields = '', url = '', welcome_email_template = '')
383
+ if email_verification_by_otp_model.blank?
384
+ raise LoginRadius::Error.new, getValidationMessage('email_verification_by_otp_model')
385
+ end
386
+
387
+ query_parameters = {}
388
+ query_parameters['apiKey'] = @api_key
389
+ unless isNullOrWhiteSpace(fields)
390
+ query_parameters['fields'] = fields
391
+ end
392
+ unless isNullOrWhiteSpace(url)
393
+ query_parameters['url'] = url
394
+ end
395
+ unless isNullOrWhiteSpace(welcome_email_template)
396
+ query_parameters['welcomeEmailTemplate'] = welcome_email_template
397
+ end
398
+
399
+ resource_path = 'identity/v2/auth/email'
400
+ put_request(resource_path, query_parameters, email_verification_by_otp_model)
401
+ end
402
+
403
+ # This API is used to add additional emails to a user's account.
404
+ #
405
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
406
+ # @param email - user's email
407
+ # @param type - String to identify the type of parameter
408
+ # @param email_template - Email template name
409
+ # @param verification_url - Email verification url
410
+ #
411
+ # @return Response containing Definition of Complete Validation data
412
+ # 8.5
413
+ def add_email(access_token, email, type, email_template = '', verification_url = '')
414
+ if isNullOrWhiteSpace(access_token)
415
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
416
+ end
417
+ if isNullOrWhiteSpace(email)
418
+ raise LoginRadius::Error.new, getValidationMessage('email')
419
+ end
420
+ if isNullOrWhiteSpace(type)
421
+ raise LoginRadius::Error.new, getValidationMessage('type')
422
+ end
423
+
424
+ query_parameters = {}
425
+ query_parameters['access_token'] = access_token
426
+ query_parameters['apiKey'] = @api_key
427
+ unless isNullOrWhiteSpace(email_template)
428
+ query_parameters['emailTemplate'] = email_template
429
+ end
430
+ unless isNullOrWhiteSpace(verification_url)
431
+ query_parameters['verificationUrl'] = verification_url
432
+ end
433
+
434
+ body_parameters = {}
435
+ body_parameters['email'] = email
436
+ body_parameters['type'] = type
437
+
438
+ resource_path = 'identity/v2/auth/email'
439
+ post_request(resource_path, query_parameters, body_parameters)
440
+ end
441
+
442
+ # This API is used to remove additional emails from a user's account.
443
+ #
444
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
445
+ # @param email - user's email
446
+ #
447
+ # @return Response containing Definition of Delete Request
448
+ # 8.6
449
+ def remove_email(access_token, email)
450
+ if isNullOrWhiteSpace(access_token)
451
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
452
+ end
453
+ if isNullOrWhiteSpace(email)
454
+ raise LoginRadius::Error.new, getValidationMessage('email')
455
+ end
456
+
457
+ query_parameters = {}
458
+ query_parameters['access_token'] = access_token
459
+ query_parameters['apiKey'] = @api_key
460
+
461
+ body_parameters = {}
462
+ body_parameters['email'] = email
463
+
464
+ resource_path = 'identity/v2/auth/email'
465
+ delete_request(resource_path, query_parameters, body_parameters)
466
+ end
467
+
468
+ # This API retrieves a copy of the user data based on the Email
469
+ #
470
+ # @param email_authentication_model - Model Class containing Definition of payload for Email Authentication API
471
+ # @param email_template - Email template name
472
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
473
+ # @param login_url - Url where the user is logging from
474
+ # @param verification_url - Email verification url
475
+ #
476
+ # @return Response containing User Profile Data and access token
477
+ # 9.2.1
478
+ def login_by_email(email_authentication_model, email_template = '', fields = '', login_url = '', verification_url = '')
479
+ if email_authentication_model.blank?
480
+ raise LoginRadius::Error.new, getValidationMessage('email_authentication_model')
481
+ end
482
+
483
+ query_parameters = {}
484
+ query_parameters['apiKey'] = @api_key
485
+ unless isNullOrWhiteSpace(email_template)
486
+ query_parameters['emailTemplate'] = email_template
487
+ end
488
+ unless isNullOrWhiteSpace(fields)
489
+ query_parameters['fields'] = fields
490
+ end
491
+ unless isNullOrWhiteSpace(login_url)
492
+ query_parameters['loginUrl'] = login_url
493
+ end
494
+ unless isNullOrWhiteSpace(verification_url)
495
+ query_parameters['verificationUrl'] = verification_url
496
+ end
497
+
498
+ resource_path = 'identity/v2/auth/login'
499
+ post_request(resource_path, query_parameters, email_authentication_model)
500
+ end
501
+
502
+ # This API retrieves a copy of the user data based on the Username
503
+ #
504
+ # @param user_name_authentication_model - Model Class containing Definition of payload for Username Authentication API
505
+ # @param email_template - Email template name
506
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
507
+ # @param login_url - Url where the user is logging from
508
+ # @param verification_url - Email verification url
509
+ #
510
+ # @return Response containing User Profile Data and access token
511
+ # 9.2.2
512
+ def login_by_user_name(user_name_authentication_model, email_template = '', fields = '', login_url = '', verification_url = '')
513
+ if user_name_authentication_model.blank?
514
+ raise LoginRadius::Error.new, getValidationMessage('user_name_authentication_model')
515
+ end
516
+
517
+ query_parameters = {}
518
+ query_parameters['apiKey'] = @api_key
519
+ unless isNullOrWhiteSpace(email_template)
520
+ query_parameters['emailTemplate'] = email_template
521
+ end
522
+ unless isNullOrWhiteSpace(fields)
523
+ query_parameters['fields'] = fields
524
+ end
525
+ unless isNullOrWhiteSpace(login_url)
526
+ query_parameters['loginUrl'] = login_url
527
+ end
528
+ unless isNullOrWhiteSpace(verification_url)
529
+ query_parameters['verificationUrl'] = verification_url
530
+ end
531
+
532
+ resource_path = 'identity/v2/auth/login'
533
+ post_request(resource_path, query_parameters, user_name_authentication_model)
534
+ end
535
+
536
+ # This API is used to send the reset password url to a specified account. Note: If you have the UserName workflow enabled, you may replace the 'email' parameter with 'username'
537
+ #
538
+ # @param email - user's email
539
+ # @param reset_password_url - Url to which user should get re-directed to for resetting the password
540
+ # @param email_template - Email template name
541
+ #
542
+ # @return Response containing Definition of Complete Validation data
543
+ # 10.1
544
+ def forgot_password(email, reset_password_url, email_template = '')
545
+ if isNullOrWhiteSpace(email)
546
+ raise LoginRadius::Error.new, getValidationMessage('email')
547
+ end
548
+ if isNullOrWhiteSpace(reset_password_url)
549
+ raise LoginRadius::Error.new, getValidationMessage('reset_password_url')
550
+ end
551
+
552
+ query_parameters = {}
553
+ query_parameters['apiKey'] = @api_key
554
+ query_parameters['resetPasswordUrl'] = reset_password_url
555
+ unless isNullOrWhiteSpace(email_template)
556
+ query_parameters['emailTemplate'] = email_template
557
+ end
558
+
559
+ body_parameters = {}
560
+ body_parameters['email'] = email
561
+
562
+ resource_path = 'identity/v2/auth/password'
563
+ post_request(resource_path, query_parameters, body_parameters)
564
+ end
565
+
566
+ # This API is used to reset password for the specified account by security question
567
+ #
568
+ # @param reset_password_by_security_answer_and_email_model - Model Class containing Definition of payload for ResetPasswordBySecurityAnswerAndEmail API
569
+ #
570
+ # @return Response containing Definition of Validation data and access token
571
+ # 10.3.1
572
+ def reset_password_by_security_answer_and_email(reset_password_by_security_answer_and_email_model)
573
+ if reset_password_by_security_answer_and_email_model.blank?
574
+ raise LoginRadius::Error.new, getValidationMessage('reset_password_by_security_answer_and_email_model')
575
+ end
576
+
577
+ query_parameters = {}
578
+ query_parameters['apiKey'] = @api_key
579
+
580
+ resource_path = 'identity/v2/auth/password/securityanswer'
581
+ put_request(resource_path, query_parameters, reset_password_by_security_answer_and_email_model)
582
+ end
583
+
584
+ # This API is used to reset password for the specified account by security question
585
+ #
586
+ # @param reset_password_by_security_answer_and_phone_model - Model Class containing Definition of payload for ResetPasswordBySecurityAnswerAndPhone API
587
+ #
588
+ # @return Response containing Definition of Validation data and access token
589
+ # 10.3.2
590
+ def reset_password_by_security_answer_and_phone(reset_password_by_security_answer_and_phone_model)
591
+ if reset_password_by_security_answer_and_phone_model.blank?
592
+ raise LoginRadius::Error.new, getValidationMessage('reset_password_by_security_answer_and_phone_model')
593
+ end
594
+
595
+ query_parameters = {}
596
+ query_parameters['apiKey'] = @api_key
597
+
598
+ resource_path = 'identity/v2/auth/password/securityanswer'
599
+ put_request(resource_path, query_parameters, reset_password_by_security_answer_and_phone_model)
600
+ end
601
+
602
+ # This API is used to reset password for the specified account by security question
603
+ #
604
+ # @param reset_password_by_security_answer_and_user_name_model - Model Class containing Definition of payload for ResetPasswordBySecurityAnswerAndUserName API
605
+ #
606
+ # @return Response containing Definition of Validation data and access token
607
+ # 10.3.3
608
+ def reset_password_by_security_answer_and_user_name(reset_password_by_security_answer_and_user_name_model)
609
+ if reset_password_by_security_answer_and_user_name_model.blank?
610
+ raise LoginRadius::Error.new, getValidationMessage('reset_password_by_security_answer_and_user_name_model')
611
+ end
612
+
613
+ query_parameters = {}
614
+ query_parameters['apiKey'] = @api_key
615
+
616
+ resource_path = 'identity/v2/auth/password/securityanswer'
617
+ put_request(resource_path, query_parameters, reset_password_by_security_answer_and_user_name_model)
618
+ end
619
+
620
+ # This API is used to set a new password for the specified account.
621
+ #
622
+ # @param reset_password_by_reset_token_model - Model Class containing Definition of payload for ResetToken API
623
+ #
624
+ # @return Response containing Definition of Validation data and access token
625
+ # 10.7.1
626
+ def reset_password_by_reset_token(reset_password_by_reset_token_model)
627
+ if reset_password_by_reset_token_model.blank?
628
+ raise LoginRadius::Error.new, getValidationMessage('reset_password_by_reset_token_model')
629
+ end
630
+
631
+ query_parameters = {}
632
+ query_parameters['apiKey'] = @api_key
633
+
634
+ resource_path = 'identity/v2/auth/password/reset'
635
+ put_request(resource_path, query_parameters, reset_password_by_reset_token_model)
636
+ end
637
+
638
+ # This API is used to set a new password for the specified account.
639
+ #
640
+ # @param reset_password_by_email_and_otp_model - Model Class containing Definition of payload for ResetPasswordByEmailAndOtp API
641
+ #
642
+ # @return Response containing Definition of Validation data and access token
643
+ # 10.7.2
644
+ def reset_password_by_email_otp(reset_password_by_email_and_otp_model)
645
+ if reset_password_by_email_and_otp_model.blank?
646
+ raise LoginRadius::Error.new, getValidationMessage('reset_password_by_email_and_otp_model')
647
+ end
648
+
649
+ query_parameters = {}
650
+ query_parameters['apiKey'] = @api_key
651
+
652
+ resource_path = 'identity/v2/auth/password/reset'
653
+ put_request(resource_path, query_parameters, reset_password_by_email_and_otp_model)
654
+ end
655
+
656
+ # This API is used to set a new password for the specified account if you are using the username as the unique identifier in your workflow
657
+ #
658
+ # @param reset_password_by_user_name_model - Model Class containing Definition of payload for ResetPasswordByUserName API
659
+ #
660
+ # @return Response containing Definition of Validation data and access token
661
+ # 10.7.3
662
+ def reset_password_by_otp_and_user_name(reset_password_by_user_name_model)
663
+ if reset_password_by_user_name_model.blank?
664
+ raise LoginRadius::Error.new, getValidationMessage('reset_password_by_user_name_model')
665
+ end
666
+
667
+ query_parameters = {}
668
+ query_parameters['apiKey'] = @api_key
669
+
670
+ resource_path = 'identity/v2/auth/password/reset'
671
+ put_request(resource_path, query_parameters, reset_password_by_user_name_model)
672
+ end
673
+
674
+ # This API is used to change the accounts password based on the previous password
675
+ #
676
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
677
+ # @param new_password - New password
678
+ # @param old_password - User's current password
679
+ #
680
+ # @return Response containing Definition of Complete Validation data
681
+ # 10.8
682
+ def change_password(access_token, new_password, old_password)
683
+ if isNullOrWhiteSpace(access_token)
684
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
685
+ end
686
+ if isNullOrWhiteSpace(new_password)
687
+ raise LoginRadius::Error.new, getValidationMessage('new_password')
688
+ end
689
+ if isNullOrWhiteSpace(old_password)
690
+ raise LoginRadius::Error.new, getValidationMessage('old_password')
691
+ end
692
+
693
+ query_parameters = {}
694
+ query_parameters['access_token'] = access_token
695
+ query_parameters['apiKey'] = @api_key
696
+
697
+ body_parameters = {}
698
+ body_parameters['newPassword'] = new_password
699
+ body_parameters['oldPassword'] = old_password
700
+
701
+ resource_path = 'identity/v2/auth/password/change'
702
+ put_request(resource_path, query_parameters, body_parameters)
703
+ end
704
+
705
+ # This API is used to link up a social provider account with the specified account based on the access token and the social providers user access token.
706
+ #
707
+ # @param access_token - Access_Token
708
+ # @param candidate_token - Access token of the account to be linked
709
+ #
710
+ # @return Response containing Definition of Complete Validation data
711
+ # 12.1
712
+ def link_social_identities(access_token, candidate_token)
713
+ if isNullOrWhiteSpace(access_token)
714
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
715
+ end
716
+ if isNullOrWhiteSpace(candidate_token)
717
+ raise LoginRadius::Error.new, getValidationMessage('candidate_token')
718
+ end
719
+
720
+ query_parameters = {}
721
+ query_parameters['access_token'] = access_token
722
+ query_parameters['apiKey'] = @api_key
723
+
724
+ body_parameters = {}
725
+ body_parameters['candidateToken'] = candidate_token
726
+
727
+ resource_path = 'identity/v2/auth/socialidentity'
728
+ put_request(resource_path, query_parameters, body_parameters)
729
+ end
730
+
731
+ # This API is used to unlink up a social provider account with the specified account based on the access token and the social providers user access token. The unlinked account will automatically get removed from your database.
732
+ #
733
+ # @param access_token - Access_Token
734
+ # @param provider - Name of the provider
735
+ # @param provider_id - Unique ID of the linked account
736
+ #
737
+ # @return Response containing Definition of Delete Request
738
+ # 12.2
739
+ def unlink_social_identities(access_token, provider, provider_id)
740
+ if isNullOrWhiteSpace(access_token)
741
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
742
+ end
743
+ if isNullOrWhiteSpace(provider)
744
+ raise LoginRadius::Error.new, getValidationMessage('provider')
745
+ end
746
+ if isNullOrWhiteSpace(provider_id)
747
+ raise LoginRadius::Error.new, getValidationMessage('provider_id')
748
+ end
749
+
750
+ query_parameters = {}
751
+ query_parameters['access_token'] = access_token
752
+ query_parameters['apiKey'] = @api_key
753
+
754
+ body_parameters = {}
755
+ body_parameters['provider'] = provider
756
+ body_parameters['providerId'] = provider_id
757
+
758
+ resource_path = 'identity/v2/auth/socialidentity'
759
+ delete_request(resource_path, query_parameters, body_parameters)
760
+ end
761
+
762
+ # This API is called just after account linking API and it prevents the raas profile of the second account from getting created.
763
+ #
764
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
765
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
766
+ #
767
+ # @return Response containing Definition for Complete SocialUserProfile data
768
+ # 12.3
769
+ def get_social_identity(access_token, fields = '')
770
+ if isNullOrWhiteSpace(access_token)
771
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
772
+ end
773
+
774
+ query_parameters = {}
775
+ query_parameters['access_token'] = access_token
776
+ query_parameters['apiKey'] = @api_key
777
+ unless isNullOrWhiteSpace(fields)
778
+ query_parameters['fields'] = fields
779
+ end
780
+
781
+ resource_path = 'identity/v2/auth/socialidentity'
782
+ get_request(resource_path, query_parameters, nil)
783
+ end
784
+
785
+ # This API is used to set or change UserName by access token.
786
+ #
787
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
788
+ # @param username - Username of the user
789
+ #
790
+ # @return Response containing Definition of Complete Validation data
791
+ # 13.1
792
+ def set_or_change_user_name(access_token, username)
793
+ if isNullOrWhiteSpace(access_token)
794
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
795
+ end
796
+ if isNullOrWhiteSpace(username)
797
+ raise LoginRadius::Error.new, getValidationMessage('username')
798
+ end
799
+
800
+ query_parameters = {}
801
+ query_parameters['access_token'] = access_token
802
+ query_parameters['apiKey'] = @api_key
803
+
804
+ body_parameters = {}
805
+ body_parameters['username'] = username
806
+
807
+ resource_path = 'identity/v2/auth/username'
808
+ put_request(resource_path, query_parameters, body_parameters)
809
+ end
810
+
811
+ # This API is used to check the UserName exists or not on your site.
812
+ #
813
+ # @param username - UserName of the user
814
+ #
815
+ # @return Response containing Definition Complete ExistResponse data
816
+ # 13.2
817
+ def check_user_name_availability(username)
818
+ if isNullOrWhiteSpace(username)
819
+ raise LoginRadius::Error.new, getValidationMessage('username')
820
+ end
821
+
822
+ query_parameters = {}
823
+ query_parameters['apiKey'] = @api_key
824
+ query_parameters['username'] = username
825
+
826
+ resource_path = 'identity/v2/auth/username'
827
+ get_request(resource_path, query_parameters, nil)
828
+ end
829
+
830
+ # This API is used to update the privacy policy stored in the user's profile by providing the access token of the user accepting the privacy policy
831
+ #
832
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
833
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
834
+ #
835
+ # @return Response containing Definition for Complete profile data
836
+ # 15.1
837
+ def accept_privacy_policy(access_token, fields = '')
838
+ if isNullOrWhiteSpace(access_token)
839
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
840
+ end
841
+
842
+ query_parameters = {}
843
+ query_parameters['access_token'] = access_token
844
+ query_parameters['apiKey'] = @api_key
845
+ unless isNullOrWhiteSpace(fields)
846
+ query_parameters['fields'] = fields
847
+ end
848
+
849
+ resource_path = 'identity/v2/auth/privacypolicy/accept'
850
+ get_request(resource_path, query_parameters, nil)
851
+ end
852
+
853
+ # This API will return all the accepted privacy policies for the user by providing the access token of that user.
854
+ #
855
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
856
+ #
857
+ # @return Complete Policy History data
858
+ # 15.2
859
+ def get_privacy_policy_history_by_access_token(access_token)
860
+ if isNullOrWhiteSpace(access_token)
861
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
862
+ end
863
+
864
+ query_parameters = {}
865
+ query_parameters['access_token'] = access_token
866
+ query_parameters['apiKey'] = @api_key
867
+
868
+ resource_path = 'identity/v2/auth/privacypolicy/history'
869
+ get_request(resource_path, query_parameters, nil)
870
+ end
871
+
872
+ # This API creates a user in the database as well as sends a verification email to the user.
873
+ #
874
+ # @param auth_user_registration_model - Model Class containing Definition of payload for Auth User Registration API
875
+ # @param sott - LoginRadius Secured One Time Token
876
+ # @param email_template - Email template name
877
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
878
+ # @param options - PreventVerificationEmail (Specifying this value prevents the verification email from being sent. Only applicable if you have the optional email verification flow)
879
+ # @param verification_url - Email verification url
880
+ # @param welcome_email_template - Name of the welcome email template
881
+ #
882
+ # @return Response containing Definition of Complete Validation, UserProfile data and Access Token
883
+ # 17.1.1
884
+ def user_registration_by_email(auth_user_registration_model, sott, email_template = '', fields = '', options = '', verification_url = '', welcome_email_template = '')
885
+ if auth_user_registration_model.blank?
886
+ raise LoginRadius::Error.new, getValidationMessage('auth_user_registration_model')
887
+ end
888
+ if isNullOrWhiteSpace(sott)
889
+ raise LoginRadius::Error.new, getValidationMessage('sott')
890
+ end
891
+
892
+ query_parameters = {}
893
+ query_parameters['apiKey'] = @api_key
894
+ query_parameters['sott'] = sott
895
+ unless isNullOrWhiteSpace(email_template)
896
+ query_parameters['emailTemplate'] = email_template
897
+ end
898
+ unless isNullOrWhiteSpace(fields)
899
+ query_parameters['fields'] = fields
900
+ end
901
+ unless isNullOrWhiteSpace(options)
902
+ query_parameters['options'] = options
903
+ end
904
+ unless isNullOrWhiteSpace(verification_url)
905
+ query_parameters['verificationUrl'] = verification_url
906
+ end
907
+ unless isNullOrWhiteSpace(welcome_email_template)
908
+ query_parameters['welcomeEmailTemplate'] = welcome_email_template
909
+ end
910
+
911
+ resource_path = 'identity/v2/auth/register'
912
+ post_request(resource_path, query_parameters, auth_user_registration_model)
913
+ end
914
+
915
+ # This API creates a user in the database as well as sends a verification email to the user.
916
+ #
917
+ # @param auth_user_registration_model_with_captcha - Model Class containing Definition of payload for Auth User Registration by Recaptcha API
918
+ # @param email_template - Email template name
919
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
920
+ # @param options - PreventVerificationEmail (Specifying this value prevents the verification email from being sent. Only applicable if you have the optional email verification flow)
921
+ # @param sms_template - SMS Template name
922
+ # @param verification_url - Email verification url
923
+ # @param welcome_email_template - Name of the welcome email template
924
+ #
925
+ # @return Response containing Definition of Complete Validation, UserProfile data and Access Token
926
+ # 17.2
927
+ def user_registration_by_captcha(auth_user_registration_model_with_captcha, email_template = '', fields = '', options = '', sms_template = '', verification_url = '', welcome_email_template = '')
928
+ if auth_user_registration_model_with_captcha.blank?
929
+ raise LoginRadius::Error.new, getValidationMessage('auth_user_registration_model_with_captcha')
930
+ end
931
+
932
+ query_parameters = {}
933
+ query_parameters['apiKey'] = @api_key
934
+ unless isNullOrWhiteSpace(email_template)
935
+ query_parameters['emailTemplate'] = email_template
936
+ end
937
+ unless isNullOrWhiteSpace(fields)
938
+ query_parameters['fields'] = fields
939
+ end
940
+ unless isNullOrWhiteSpace(options)
941
+ query_parameters['options'] = options
942
+ end
943
+ unless isNullOrWhiteSpace(sms_template)
944
+ query_parameters['smsTemplate'] = sms_template
945
+ end
946
+ unless isNullOrWhiteSpace(verification_url)
947
+ query_parameters['verificationUrl'] = verification_url
948
+ end
949
+ unless isNullOrWhiteSpace(welcome_email_template)
950
+ query_parameters['welcomeEmailTemplate'] = welcome_email_template
951
+ end
952
+
953
+ resource_path = 'identity/v2/auth/register/captcha'
954
+ post_request(resource_path, query_parameters, auth_user_registration_model_with_captcha)
955
+ end
956
+
957
+ # This API resends the verification email to the user.
958
+ #
959
+ # @param email - user's email
960
+ # @param email_template - Email template name
961
+ # @param verification_url - Email verification url
962
+ #
963
+ # @return Response containing Definition of Complete Validation data
964
+ # 17.3
965
+ def auth_resend_email_verification(email, email_template = '', verification_url = '')
966
+ if isNullOrWhiteSpace(email)
967
+ raise LoginRadius::Error.new, getValidationMessage('email')
968
+ end
969
+
970
+ query_parameters = {}
971
+ query_parameters['apiKey'] = @api_key
972
+ unless isNullOrWhiteSpace(email_template)
973
+ query_parameters['emailTemplate'] = email_template
974
+ end
975
+ unless isNullOrWhiteSpace(verification_url)
976
+ query_parameters['verificationUrl'] = verification_url
977
+ end
978
+
979
+ body_parameters = {}
980
+ body_parameters['email'] = email
981
+
982
+ resource_path = 'identity/v2/auth/register'
983
+ put_request(resource_path, query_parameters, body_parameters)
984
+ end
985
+ end
986
+ end