login_radius 11.0.0 → 11.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +21 -21
  3. data/README.md +58 -58
  4. data/lib/login_radius/api/account/account_api.rb +581 -581
  5. data/lib/login_radius/api/account/role_api.rb +330 -330
  6. data/lib/login_radius/api/account/sott_api.rb +47 -47
  7. data/lib/login_radius/api/advanced/configuration_api.rb +57 -57
  8. data/lib/login_radius/api/advanced/consent_management_api.rb +161 -161
  9. data/lib/login_radius/api/advanced/custom_object_api.rb +316 -316
  10. data/lib/login_radius/api/advanced/custom_registration_data_api.rb +195 -195
  11. data/lib/login_radius/api/advanced/multi_factor_authentication_api.rb +942 -606
  12. data/lib/login_radius/api/advanced/re_authentication_api.rb +317 -243
  13. data/lib/login_radius/api/advanced/web_hook_api.rb +101 -101
  14. data/lib/login_radius/api/authentication/authentication_api.rb +1036 -989
  15. data/lib/login_radius/api/authentication/one_touch_login_api.rb +160 -160
  16. data/lib/login_radius/api/authentication/password_less_login_api.rb +202 -158
  17. data/lib/login_radius/api/authentication/phone_authentication_api.rb +329 -329
  18. data/lib/login_radius/api/authentication/pin_authentication_api.rb +316 -316
  19. data/lib/login_radius/api/authentication/risk_based_authentication_api.rb +286 -286
  20. data/lib/login_radius/api/authentication/smart_login_api.rb +146 -146
  21. data/lib/login_radius/api/social/native_social_api.rb +255 -255
  22. data/lib/login_radius/api/social/social_api.rb +784 -806
  23. data/lib/login_radius/error.rb +7 -7
  24. data/lib/login_radius/request_client.rb +311 -295
  25. data/lib/login_radius/response.rb +18 -12
  26. data/lib/login_radius/version.rb +2 -2
  27. data/lib/login_radius.rb +30 -30
  28. data/login_radius.gemspec +25 -28
  29. metadata +7 -7
@@ -1,989 +1,1036 @@
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 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.
706
- #
707
- # @param access_token - Access_Token
708
- # @param provider - Name of the provider
709
- # @param provider_id - Unique ID of the linked account
710
- #
711
- # @return Response containing Definition of Delete Request
712
- # 12.2
713
- def unlink_social_identities(access_token, provider, provider_id)
714
- if isNullOrWhiteSpace(access_token)
715
- raise LoginRadius::Error.new, getValidationMessage('access_token')
716
- end
717
- if isNullOrWhiteSpace(provider)
718
- raise LoginRadius::Error.new, getValidationMessage('provider')
719
- end
720
- if isNullOrWhiteSpace(provider_id)
721
- raise LoginRadius::Error.new, getValidationMessage('provider_id')
722
- end
723
-
724
- query_parameters = {}
725
- query_parameters['access_token'] = access_token
726
- query_parameters['apiKey'] = @api_key
727
-
728
- body_parameters = {}
729
- body_parameters['provider'] = provider
730
- body_parameters['providerId'] = provider_id
731
-
732
- resource_path = 'identity/v2/auth/socialidentity'
733
- delete_request(resource_path, query_parameters, body_parameters)
734
- end
735
-
736
- # This API is used to link up a social provider account with an existing LoginRadius account on the basis of access token and the social providers user access token.
737
- #
738
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
739
- # @param candidate_token - Access token of the account to be linked
740
- #
741
- # @return Response containing Definition of Complete Validation data
742
- # 12.4
743
- def link_social_identities(access_token, candidate_token)
744
- if isNullOrWhiteSpace(access_token)
745
- raise LoginRadius::Error.new, getValidationMessage('access_token')
746
- end
747
- if isNullOrWhiteSpace(candidate_token)
748
- raise LoginRadius::Error.new, getValidationMessage('candidate_token')
749
- end
750
-
751
- query_parameters = {}
752
- query_parameters['access_token'] = access_token
753
- query_parameters['apiKey'] = @api_key
754
-
755
- body_parameters = {}
756
- body_parameters['candidateToken'] = candidate_token
757
-
758
- resource_path = 'identity/v2/auth/socialidentity'
759
- post_request(resource_path, query_parameters, body_parameters)
760
- end
761
-
762
- # This API is used to link up a social provider account with an existing LoginRadius account on the basis of ping and the social providers user access token.
763
- #
764
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
765
- # @param client_guid - Unique ID generated by client
766
- #
767
- # @return Response containing Definition of Complete Validation data
768
- # 12.5
769
- def link_social_identities_by_ping(access_token, client_guid)
770
- if isNullOrWhiteSpace(access_token)
771
- raise LoginRadius::Error.new, getValidationMessage('access_token')
772
- end
773
- if isNullOrWhiteSpace(client_guid)
774
- raise LoginRadius::Error.new, getValidationMessage('client_guid')
775
- end
776
-
777
- query_parameters = {}
778
- query_parameters['access_token'] = access_token
779
- query_parameters['apiKey'] = @api_key
780
-
781
- body_parameters = {}
782
- body_parameters['clientGuid'] = client_guid
783
-
784
- resource_path = 'identity/v2/auth/socialidentity'
785
- post_request(resource_path, query_parameters, body_parameters)
786
- end
787
-
788
- # This API is used to set or change UserName by access token.
789
- #
790
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
791
- # @param username - Username of the user
792
- #
793
- # @return Response containing Definition of Complete Validation data
794
- # 13.1
795
- def set_or_change_user_name(access_token, username)
796
- if isNullOrWhiteSpace(access_token)
797
- raise LoginRadius::Error.new, getValidationMessage('access_token')
798
- end
799
- if isNullOrWhiteSpace(username)
800
- raise LoginRadius::Error.new, getValidationMessage('username')
801
- end
802
-
803
- query_parameters = {}
804
- query_parameters['access_token'] = access_token
805
- query_parameters['apiKey'] = @api_key
806
-
807
- body_parameters = {}
808
- body_parameters['username'] = username
809
-
810
- resource_path = 'identity/v2/auth/username'
811
- put_request(resource_path, query_parameters, body_parameters)
812
- end
813
-
814
- # This API is used to check the UserName exists or not on your site.
815
- #
816
- # @param username - UserName of the user
817
- #
818
- # @return Response containing Definition Complete ExistResponse data
819
- # 13.2
820
- def check_user_name_availability(username)
821
- if isNullOrWhiteSpace(username)
822
- raise LoginRadius::Error.new, getValidationMessage('username')
823
- end
824
-
825
- query_parameters = {}
826
- query_parameters['apiKey'] = @api_key
827
- query_parameters['username'] = username
828
-
829
- resource_path = 'identity/v2/auth/username'
830
- get_request(resource_path, query_parameters, nil)
831
- end
832
-
833
- # 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
834
- #
835
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
836
- # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
837
- #
838
- # @return Response containing Definition for Complete profile data
839
- # 15.1
840
- def accept_privacy_policy(access_token, fields = '')
841
- if isNullOrWhiteSpace(access_token)
842
- raise LoginRadius::Error.new, getValidationMessage('access_token')
843
- end
844
-
845
- query_parameters = {}
846
- query_parameters['access_token'] = access_token
847
- query_parameters['apiKey'] = @api_key
848
- unless isNullOrWhiteSpace(fields)
849
- query_parameters['fields'] = fields
850
- end
851
-
852
- resource_path = 'identity/v2/auth/privacypolicy/accept'
853
- get_request(resource_path, query_parameters, nil)
854
- end
855
-
856
- # This API will return all the accepted privacy policies for the user by providing the access token of that user.
857
- #
858
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
859
- #
860
- # @return Complete Policy History data
861
- # 15.2
862
- def get_privacy_policy_history_by_access_token(access_token)
863
- if isNullOrWhiteSpace(access_token)
864
- raise LoginRadius::Error.new, getValidationMessage('access_token')
865
- end
866
-
867
- query_parameters = {}
868
- query_parameters['access_token'] = access_token
869
- query_parameters['apiKey'] = @api_key
870
-
871
- resource_path = 'identity/v2/auth/privacypolicy/history'
872
- get_request(resource_path, query_parameters, nil)
873
- end
874
-
875
- # This API creates a user in the database as well as sends a verification email to the user.
876
- #
877
- # @param auth_user_registration_model - Model Class containing Definition of payload for Auth User Registration API
878
- # @param sott - LoginRadius Secured One Time Token
879
- # @param email_template - Email template name
880
- # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
881
- # @param options - PreventVerificationEmail (Specifying this value prevents the verification email from being sent. Only applicable if you have the optional email verification flow)
882
- # @param verification_url - Email verification url
883
- # @param welcome_email_template - Name of the welcome email template
884
- #
885
- # @return Response containing Definition of Complete Validation, UserProfile data and Access Token
886
- # 17.1.1
887
- def user_registration_by_email(auth_user_registration_model, sott, email_template = '', fields = '', options = '', verification_url = '', welcome_email_template = '')
888
- if auth_user_registration_model.blank?
889
- raise LoginRadius::Error.new, getValidationMessage('auth_user_registration_model')
890
- end
891
- if isNullOrWhiteSpace(sott)
892
- raise LoginRadius::Error.new, getValidationMessage('sott')
893
- end
894
-
895
- query_parameters = {}
896
- query_parameters['apiKey'] = @api_key
897
- query_parameters['sott'] = sott
898
- unless isNullOrWhiteSpace(email_template)
899
- query_parameters['emailTemplate'] = email_template
900
- end
901
- unless isNullOrWhiteSpace(fields)
902
- query_parameters['fields'] = fields
903
- end
904
- unless isNullOrWhiteSpace(options)
905
- query_parameters['options'] = options
906
- end
907
- unless isNullOrWhiteSpace(verification_url)
908
- query_parameters['verificationUrl'] = verification_url
909
- end
910
- unless isNullOrWhiteSpace(welcome_email_template)
911
- query_parameters['welcomeEmailTemplate'] = welcome_email_template
912
- end
913
-
914
- resource_path = 'identity/v2/auth/register'
915
- post_request(resource_path, query_parameters, auth_user_registration_model)
916
- end
917
-
918
- # This API creates a user in the database as well as sends a verification email to the user.
919
- #
920
- # @param auth_user_registration_model_with_captcha - Model Class containing Definition of payload for Auth User Registration by Recaptcha API
921
- # @param email_template - Email template name
922
- # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
923
- # @param options - PreventVerificationEmail (Specifying this value prevents the verification email from being sent. Only applicable if you have the optional email verification flow)
924
- # @param sms_template - SMS Template name
925
- # @param verification_url - Email verification url
926
- # @param welcome_email_template - Name of the welcome email template
927
- #
928
- # @return Response containing Definition of Complete Validation, UserProfile data and Access Token
929
- # 17.2
930
- def user_registration_by_captcha(auth_user_registration_model_with_captcha, email_template = '', fields = '', options = '', sms_template = '', verification_url = '', welcome_email_template = '')
931
- if auth_user_registration_model_with_captcha.blank?
932
- raise LoginRadius::Error.new, getValidationMessage('auth_user_registration_model_with_captcha')
933
- end
934
-
935
- query_parameters = {}
936
- query_parameters['apiKey'] = @api_key
937
- unless isNullOrWhiteSpace(email_template)
938
- query_parameters['emailTemplate'] = email_template
939
- end
940
- unless isNullOrWhiteSpace(fields)
941
- query_parameters['fields'] = fields
942
- end
943
- unless isNullOrWhiteSpace(options)
944
- query_parameters['options'] = options
945
- end
946
- unless isNullOrWhiteSpace(sms_template)
947
- query_parameters['smsTemplate'] = sms_template
948
- end
949
- unless isNullOrWhiteSpace(verification_url)
950
- query_parameters['verificationUrl'] = verification_url
951
- end
952
- unless isNullOrWhiteSpace(welcome_email_template)
953
- query_parameters['welcomeEmailTemplate'] = welcome_email_template
954
- end
955
-
956
- resource_path = 'identity/v2/auth/register/captcha'
957
- post_request(resource_path, query_parameters, auth_user_registration_model_with_captcha)
958
- end
959
-
960
- # This API resends the verification email to the user.
961
- #
962
- # @param email - user's email
963
- # @param email_template - Email template name
964
- # @param verification_url - Email verification url
965
- #
966
- # @return Response containing Definition of Complete Validation data
967
- # 17.3
968
- def auth_resend_email_verification(email, email_template = '', verification_url = '')
969
- if isNullOrWhiteSpace(email)
970
- raise LoginRadius::Error.new, getValidationMessage('email')
971
- end
972
-
973
- query_parameters = {}
974
- query_parameters['apiKey'] = @api_key
975
- unless isNullOrWhiteSpace(email_template)
976
- query_parameters['emailTemplate'] = email_template
977
- end
978
- unless isNullOrWhiteSpace(verification_url)
979
- query_parameters['verificationUrl'] = verification_url
980
- end
981
-
982
- body_parameters = {}
983
- body_parameters['email'] = email
984
-
985
- resource_path = 'identity/v2/auth/register'
986
- put_request(resource_path, query_parameters, body_parameters)
987
- end
988
- end
989
- end
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, {})
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, {})
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, {})
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, {})
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, {})
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, {})
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, {})
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
+ # @param email_template -
170
+ # @param verification_url -
171
+ # @param welcome_email_template -
172
+ #
173
+ # @return Response containing Definition for Complete profile data
174
+ # 5.2
175
+ def get_profile_by_access_token(access_token, fields = '', email_template = '', verification_url = '', welcome_email_template = '')
176
+ if isNullOrWhiteSpace(access_token)
177
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
178
+ end
179
+
180
+ query_parameters = {}
181
+ query_parameters['access_token'] = access_token
182
+ query_parameters['apiKey'] = @api_key
183
+ unless isNullOrWhiteSpace(fields)
184
+ query_parameters['fields'] = fields
185
+ end
186
+ unless isNullOrWhiteSpace(email_template)
187
+ query_parameters['emailTemplate'] = email_template
188
+ end
189
+ unless isNullOrWhiteSpace(verification_url)
190
+ query_parameters['verificationUrl'] = verification_url
191
+ end
192
+ unless isNullOrWhiteSpace(welcome_email_template)
193
+ query_parameters['welcomeEmailTemplate'] = welcome_email_template
194
+ end
195
+
196
+ resource_path = 'identity/v2/auth/account'
197
+ get_request(resource_path, query_parameters, {})
198
+ end
199
+
200
+ # This API sends a welcome email
201
+ #
202
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
203
+ # @param welcome_email_template - Name of the welcome email template
204
+ #
205
+ # @return Response containing Definition of Complete Validation data
206
+ # 5.3
207
+ def send_welcome_email(access_token, welcome_email_template = '')
208
+ if isNullOrWhiteSpace(access_token)
209
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
210
+ end
211
+
212
+ query_parameters = {}
213
+ query_parameters['access_token'] = access_token
214
+ query_parameters['apiKey'] = @api_key
215
+ unless isNullOrWhiteSpace(welcome_email_template)
216
+ query_parameters['welcomeEmailTemplate'] = welcome_email_template
217
+ end
218
+
219
+ resource_path = 'identity/v2/auth/account/sendwelcomeemail'
220
+ get_request(resource_path, query_parameters, {})
221
+ end
222
+
223
+ # This API is used to update the user's profile by passing the access token.
224
+ #
225
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
226
+ # @param user_profile_update_model - Model Class containing Definition of payload for User Profile update API
227
+ # @param email_template - Email template name
228
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
229
+ # @param null_support - Boolean, pass true if you wish to update any user profile field with a NULL value, You can get the details
230
+ # @param sms_template - SMS Template name
231
+ # @param verification_url - Email verification url
232
+ #
233
+ # @return Response containing Definition of Complete Validation and UserProfile data
234
+ # 5.4
235
+ def update_profile_by_access_token(access_token, user_profile_update_model, email_template = '', fields = '', null_support = false, sms_template = '', verification_url = '')
236
+ if isNullOrWhiteSpace(access_token)
237
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
238
+ end
239
+ if user_profile_update_model.blank?
240
+ raise LoginRadius::Error.new, getValidationMessage('user_profile_update_model')
241
+ end
242
+
243
+ query_parameters = {}
244
+ query_parameters['access_token'] = access_token
245
+ query_parameters['apiKey'] = @api_key
246
+ unless isNullOrWhiteSpace(email_template)
247
+ query_parameters['emailTemplate'] = email_template
248
+ end
249
+ unless isNullOrWhiteSpace(fields)
250
+ query_parameters['fields'] = fields
251
+ end
252
+ unless null_support == false
253
+ query_parameters['nullSupport'] = null_support
254
+ end
255
+ unless isNullOrWhiteSpace(sms_template)
256
+ query_parameters['smsTemplate'] = sms_template
257
+ end
258
+ unless isNullOrWhiteSpace(verification_url)
259
+ query_parameters['verificationUrl'] = verification_url
260
+ end
261
+
262
+ resource_path = 'identity/v2/auth/account'
263
+ put_request(resource_path, query_parameters, user_profile_update_model)
264
+ end
265
+
266
+ # This API will send a confirmation email for account deletion to the customer's email when passed the customer's access token
267
+ #
268
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
269
+ # @param delete_url - Url of the site
270
+ # @param email_template - Email template name
271
+ #
272
+ # @return Response containing Definition of Delete Request
273
+ # 5.5
274
+ def delete_account_with_email_confirmation(access_token, delete_url = '', email_template = '')
275
+ if isNullOrWhiteSpace(access_token)
276
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
277
+ end
278
+
279
+ query_parameters = {}
280
+ query_parameters['access_token'] = access_token
281
+ query_parameters['apiKey'] = @api_key
282
+ unless isNullOrWhiteSpace(delete_url)
283
+ query_parameters['deleteUrl'] = delete_url
284
+ end
285
+ unless isNullOrWhiteSpace(email_template)
286
+ query_parameters['emailTemplate'] = email_template
287
+ end
288
+
289
+ resource_path = 'identity/v2/auth/account'
290
+ delete_request(resource_path, query_parameters, {})
291
+ end
292
+
293
+ # This API is used to delete an account by passing it a delete token.
294
+ #
295
+ # @param deletetoken - Delete token received in the email
296
+ #
297
+ # @return Response containing Definition of Complete Validation data
298
+ # 5.6
299
+ def delete_account_by_delete_token(deletetoken)
300
+ if isNullOrWhiteSpace(deletetoken)
301
+ raise LoginRadius::Error.new, getValidationMessage('deletetoken')
302
+ end
303
+
304
+ query_parameters = {}
305
+ query_parameters['apiKey'] = @api_key
306
+ query_parameters['deletetoken'] = deletetoken
307
+
308
+ resource_path = 'identity/v2/auth/account/delete'
309
+ get_request(resource_path, query_parameters, {})
310
+ end
311
+
312
+ # 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.
313
+ #
314
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
315
+ # @param unlock_profile_model - Payload containing Unlock Profile API
316
+ #
317
+ # @return Response containing Definition of Complete Validation data
318
+ # 5.15
319
+ def unlock_account_by_token(access_token, unlock_profile_model)
320
+ if isNullOrWhiteSpace(access_token)
321
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
322
+ end
323
+ if unlock_profile_model.blank?
324
+ raise LoginRadius::Error.new, getValidationMessage('unlock_profile_model')
325
+ end
326
+
327
+ query_parameters = {}
328
+ query_parameters['access_token'] = access_token
329
+ query_parameters['apiKey'] = @api_key
330
+
331
+ resource_path = 'identity/v2/auth/account/unlock'
332
+ put_request(resource_path, query_parameters, unlock_profile_model)
333
+ end
334
+
335
+ # This API is used to get a user's profile using the clientGuid parameter if no callback feature enabled
336
+ #
337
+ # @param client_guid - ClientGuid
338
+ # @param email_template - EmailTemplate
339
+ # @param fields - Fields
340
+ # @param verification_url - VerificationUrl
341
+ # @param welcome_email_template - WelcomeEmailTemplate
342
+ #
343
+ # @return Response containing User Profile Data and access token
344
+ # 5.16
345
+ def get_profile_by_ping(client_guid, email_template = '', fields = '', verification_url = '', welcome_email_template = '')
346
+ if isNullOrWhiteSpace(client_guid)
347
+ raise LoginRadius::Error.new, getValidationMessage('client_guid')
348
+ end
349
+
350
+ query_parameters = {}
351
+ query_parameters['apiKey'] = @api_key
352
+ query_parameters['clientGuid'] = client_guid
353
+ unless isNullOrWhiteSpace(email_template)
354
+ query_parameters['emailTemplate'] = email_template
355
+ end
356
+ unless isNullOrWhiteSpace(fields)
357
+ query_parameters['fields'] = fields
358
+ end
359
+ unless isNullOrWhiteSpace(verification_url)
360
+ query_parameters['verificationUrl'] = verification_url
361
+ end
362
+ unless isNullOrWhiteSpace(welcome_email_template)
363
+ query_parameters['welcomeEmailTemplate'] = welcome_email_template
364
+ end
365
+
366
+ resource_path = 'identity/v2/auth/account/ping'
367
+ get_request(resource_path, query_parameters, {})
368
+ end
369
+
370
+ # This API is used to check the email exists or not on your site.
371
+ #
372
+ # @param email - Email of the user
373
+ #
374
+ # @return Response containing Definition Complete ExistResponse data
375
+ # 8.1
376
+ def check_email_availability(email)
377
+ if isNullOrWhiteSpace(email)
378
+ raise LoginRadius::Error.new, getValidationMessage('email')
379
+ end
380
+
381
+ query_parameters = {}
382
+ query_parameters['apiKey'] = @api_key
383
+ query_parameters['email'] = email
384
+
385
+ resource_path = 'identity/v2/auth/email'
386
+ get_request(resource_path, query_parameters, {})
387
+ end
388
+
389
+ # 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'.
390
+ #
391
+ # @param verification_token - Verification token received in the email
392
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
393
+ # @param url - Mention URL to log the main URL(Domain name) in Database.
394
+ # @param welcome_email_template - Name of the welcome email template
395
+ #
396
+ # @return Response containing Definition of Complete Validation, UserProfile data and Access Token
397
+ # 8.2
398
+ def verify_email(verification_token, fields = '', url = '', welcome_email_template = '')
399
+ if isNullOrWhiteSpace(verification_token)
400
+ raise LoginRadius::Error.new, getValidationMessage('verification_token')
401
+ end
402
+
403
+ query_parameters = {}
404
+ query_parameters['apiKey'] = @api_key
405
+ query_parameters['verificationToken'] = verification_token
406
+ unless isNullOrWhiteSpace(fields)
407
+ query_parameters['fields'] = fields
408
+ end
409
+ unless isNullOrWhiteSpace(url)
410
+ query_parameters['url'] = url
411
+ end
412
+ unless isNullOrWhiteSpace(welcome_email_template)
413
+ query_parameters['welcomeEmailTemplate'] = welcome_email_template
414
+ end
415
+
416
+ resource_path = 'identity/v2/auth/email'
417
+ get_request(resource_path, query_parameters, {})
418
+ end
419
+
420
+ # 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.
421
+ #
422
+ # @param email_verification_by_otp_model - Model Class containing Definition for EmailVerificationByOtpModel API
423
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
424
+ # @param url - Mention URL to log the main URL(Domain name) in Database.
425
+ # @param welcome_email_template - Name of the welcome email template
426
+ #
427
+ # @return Response containing Definition of Complete Validation, UserProfile data and Access Token
428
+ # 8.3
429
+ def verify_email_by_otp(email_verification_by_otp_model, fields = '', url = '', welcome_email_template = '')
430
+ if email_verification_by_otp_model.blank?
431
+ raise LoginRadius::Error.new, getValidationMessage('email_verification_by_otp_model')
432
+ end
433
+
434
+ query_parameters = {}
435
+ query_parameters['apiKey'] = @api_key
436
+ unless isNullOrWhiteSpace(fields)
437
+ query_parameters['fields'] = fields
438
+ end
439
+ unless isNullOrWhiteSpace(url)
440
+ query_parameters['url'] = url
441
+ end
442
+ unless isNullOrWhiteSpace(welcome_email_template)
443
+ query_parameters['welcomeEmailTemplate'] = welcome_email_template
444
+ end
445
+
446
+ resource_path = 'identity/v2/auth/email'
447
+ put_request(resource_path, query_parameters, email_verification_by_otp_model)
448
+ end
449
+
450
+ # This API is used to add additional emails to a user's account.
451
+ #
452
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
453
+ # @param email - user's email
454
+ # @param type - String to identify the type of parameter
455
+ # @param email_template - Email template name
456
+ # @param verification_url - Email verification url
457
+ #
458
+ # @return Response containing Definition of Complete Validation data
459
+ # 8.5
460
+ def add_email(access_token, email, type, email_template = '', verification_url = '')
461
+ if isNullOrWhiteSpace(access_token)
462
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
463
+ end
464
+ if isNullOrWhiteSpace(email)
465
+ raise LoginRadius::Error.new, getValidationMessage('email')
466
+ end
467
+ if isNullOrWhiteSpace(type)
468
+ raise LoginRadius::Error.new, getValidationMessage('type')
469
+ end
470
+
471
+ query_parameters = {}
472
+ query_parameters['access_token'] = access_token
473
+ query_parameters['apiKey'] = @api_key
474
+ unless isNullOrWhiteSpace(email_template)
475
+ query_parameters['emailTemplate'] = email_template
476
+ end
477
+ unless isNullOrWhiteSpace(verification_url)
478
+ query_parameters['verificationUrl'] = verification_url
479
+ end
480
+
481
+ body_parameters = {}
482
+ body_parameters['email'] = email
483
+ body_parameters['type'] = type
484
+
485
+ resource_path = 'identity/v2/auth/email'
486
+ post_request(resource_path, query_parameters, body_parameters)
487
+ end
488
+
489
+ # This API is used to remove additional emails from a user's account.
490
+ #
491
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
492
+ # @param email - user's email
493
+ #
494
+ # @return Response containing Definition of Delete Request
495
+ # 8.6
496
+ def remove_email(access_token, email)
497
+ if isNullOrWhiteSpace(access_token)
498
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
499
+ end
500
+ if isNullOrWhiteSpace(email)
501
+ raise LoginRadius::Error.new, getValidationMessage('email')
502
+ end
503
+
504
+ query_parameters = {}
505
+ query_parameters['access_token'] = access_token
506
+ query_parameters['apiKey'] = @api_key
507
+
508
+ body_parameters = {}
509
+ body_parameters['email'] = email
510
+
511
+ resource_path = 'identity/v2/auth/email'
512
+ delete_request(resource_path, query_parameters, body_parameters)
513
+ end
514
+
515
+ # This API retrieves a copy of the user data based on the Email
516
+ #
517
+ # @param email_authentication_model - Model Class containing Definition of payload for Email Authentication API
518
+ # @param email_template - Email template name
519
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
520
+ # @param login_url - Url where the user is logging from
521
+ # @param verification_url - Email verification url
522
+ #
523
+ # @return Response containing User Profile Data and access token
524
+ # 9.2.1
525
+ def login_by_email(email_authentication_model, email_template = '', fields = '', login_url = '', verification_url = '')
526
+ if email_authentication_model.blank?
527
+ raise LoginRadius::Error.new, getValidationMessage('email_authentication_model')
528
+ end
529
+
530
+ query_parameters = {}
531
+ query_parameters['apiKey'] = @api_key
532
+ unless isNullOrWhiteSpace(email_template)
533
+ query_parameters['emailTemplate'] = email_template
534
+ end
535
+ unless isNullOrWhiteSpace(fields)
536
+ query_parameters['fields'] = fields
537
+ end
538
+ unless isNullOrWhiteSpace(login_url)
539
+ query_parameters['loginUrl'] = login_url
540
+ end
541
+ unless isNullOrWhiteSpace(verification_url)
542
+ query_parameters['verificationUrl'] = verification_url
543
+ end
544
+
545
+ resource_path = 'identity/v2/auth/login'
546
+ post_request(resource_path, query_parameters, email_authentication_model)
547
+ end
548
+
549
+ # This API retrieves a copy of the user data based on the Username
550
+ #
551
+ # @param user_name_authentication_model - Model Class containing Definition of payload for Username Authentication API
552
+ # @param email_template - Email template name
553
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
554
+ # @param login_url - Url where the user is logging from
555
+ # @param verification_url - Email verification url
556
+ #
557
+ # @return Response containing User Profile Data and access token
558
+ # 9.2.2
559
+ def login_by_user_name(user_name_authentication_model, email_template = '', fields = '', login_url = '', verification_url = '')
560
+ if user_name_authentication_model.blank?
561
+ raise LoginRadius::Error.new, getValidationMessage('user_name_authentication_model')
562
+ end
563
+
564
+ query_parameters = {}
565
+ query_parameters['apiKey'] = @api_key
566
+ unless isNullOrWhiteSpace(email_template)
567
+ query_parameters['emailTemplate'] = email_template
568
+ end
569
+ unless isNullOrWhiteSpace(fields)
570
+ query_parameters['fields'] = fields
571
+ end
572
+ unless isNullOrWhiteSpace(login_url)
573
+ query_parameters['loginUrl'] = login_url
574
+ end
575
+ unless isNullOrWhiteSpace(verification_url)
576
+ query_parameters['verificationUrl'] = verification_url
577
+ end
578
+
579
+ resource_path = 'identity/v2/auth/login'
580
+ post_request(resource_path, query_parameters, user_name_authentication_model)
581
+ end
582
+
583
+ # 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'
584
+ #
585
+ # @param email - user's email
586
+ # @param reset_password_url - Url to which user should get re-directed to for resetting the password
587
+ # @param email_template - Email template name
588
+ #
589
+ # @return Response containing Definition of Complete Validation data
590
+ # 10.1
591
+ def forgot_password(email, reset_password_url, email_template = '')
592
+ if isNullOrWhiteSpace(email)
593
+ raise LoginRadius::Error.new, getValidationMessage('email')
594
+ end
595
+ if isNullOrWhiteSpace(reset_password_url)
596
+ raise LoginRadius::Error.new, getValidationMessage('reset_password_url')
597
+ end
598
+
599
+ query_parameters = {}
600
+ query_parameters['apiKey'] = @api_key
601
+ query_parameters['resetPasswordUrl'] = reset_password_url
602
+ unless isNullOrWhiteSpace(email_template)
603
+ query_parameters['emailTemplate'] = email_template
604
+ end
605
+
606
+ body_parameters = {}
607
+ body_parameters['email'] = email
608
+
609
+ resource_path = 'identity/v2/auth/password'
610
+ post_request(resource_path, query_parameters, body_parameters)
611
+ end
612
+
613
+ # This API is used to reset password for the specified account by security question
614
+ #
615
+ # @param reset_password_by_security_answer_and_email_model - Model Class containing Definition of payload for ResetPasswordBySecurityAnswerAndEmail API
616
+ #
617
+ # @return Response containing Definition of Validation data and access token
618
+ # 10.3.1
619
+ def reset_password_by_security_answer_and_email(reset_password_by_security_answer_and_email_model)
620
+ if reset_password_by_security_answer_and_email_model.blank?
621
+ raise LoginRadius::Error.new, getValidationMessage('reset_password_by_security_answer_and_email_model')
622
+ end
623
+
624
+ query_parameters = {}
625
+ query_parameters['apiKey'] = @api_key
626
+
627
+ resource_path = 'identity/v2/auth/password/securityanswer'
628
+ put_request(resource_path, query_parameters, reset_password_by_security_answer_and_email_model)
629
+ end
630
+
631
+ # This API is used to reset password for the specified account by security question
632
+ #
633
+ # @param reset_password_by_security_answer_and_phone_model - Model Class containing Definition of payload for ResetPasswordBySecurityAnswerAndPhone API
634
+ #
635
+ # @return Response containing Definition of Validation data and access token
636
+ # 10.3.2
637
+ def reset_password_by_security_answer_and_phone(reset_password_by_security_answer_and_phone_model)
638
+ if reset_password_by_security_answer_and_phone_model.blank?
639
+ raise LoginRadius::Error.new, getValidationMessage('reset_password_by_security_answer_and_phone_model')
640
+ end
641
+
642
+ query_parameters = {}
643
+ query_parameters['apiKey'] = @api_key
644
+
645
+ resource_path = 'identity/v2/auth/password/securityanswer'
646
+ put_request(resource_path, query_parameters, reset_password_by_security_answer_and_phone_model)
647
+ end
648
+
649
+ # This API is used to reset password for the specified account by security question
650
+ #
651
+ # @param reset_password_by_security_answer_and_user_name_model - Model Class containing Definition of payload for ResetPasswordBySecurityAnswerAndUserName API
652
+ #
653
+ # @return Response containing Definition of Validation data and access token
654
+ # 10.3.3
655
+ def reset_password_by_security_answer_and_user_name(reset_password_by_security_answer_and_user_name_model)
656
+ if reset_password_by_security_answer_and_user_name_model.blank?
657
+ raise LoginRadius::Error.new, getValidationMessage('reset_password_by_security_answer_and_user_name_model')
658
+ end
659
+
660
+ query_parameters = {}
661
+ query_parameters['apiKey'] = @api_key
662
+
663
+ resource_path = 'identity/v2/auth/password/securityanswer'
664
+ put_request(resource_path, query_parameters, reset_password_by_security_answer_and_user_name_model)
665
+ end
666
+
667
+ # This API is used to set a new password for the specified account.
668
+ #
669
+ # @param reset_password_by_reset_token_model - Model Class containing Definition of payload for ResetToken API
670
+ #
671
+ # @return Response containing Definition of Validation data and access token
672
+ # 10.7.1
673
+ def reset_password_by_reset_token(reset_password_by_reset_token_model)
674
+ if reset_password_by_reset_token_model.blank?
675
+ raise LoginRadius::Error.new, getValidationMessage('reset_password_by_reset_token_model')
676
+ end
677
+
678
+ query_parameters = {}
679
+ query_parameters['apiKey'] = @api_key
680
+
681
+ resource_path = 'identity/v2/auth/password/reset'
682
+ put_request(resource_path, query_parameters, reset_password_by_reset_token_model)
683
+ end
684
+
685
+ # This API is used to set a new password for the specified account.
686
+ #
687
+ # @param reset_password_by_email_and_otp_model - Model Class containing Definition of payload for ResetPasswordByEmailAndOtp API
688
+ #
689
+ # @return Response containing Definition of Validation data and access token
690
+ # 10.7.2
691
+ def reset_password_by_email_otp(reset_password_by_email_and_otp_model)
692
+ if reset_password_by_email_and_otp_model.blank?
693
+ raise LoginRadius::Error.new, getValidationMessage('reset_password_by_email_and_otp_model')
694
+ end
695
+
696
+ query_parameters = {}
697
+ query_parameters['apiKey'] = @api_key
698
+
699
+ resource_path = 'identity/v2/auth/password/reset'
700
+ put_request(resource_path, query_parameters, reset_password_by_email_and_otp_model)
701
+ end
702
+
703
+ # 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
704
+ #
705
+ # @param reset_password_by_user_name_model - Model Class containing Definition of payload for ResetPasswordByUserName API
706
+ #
707
+ # @return Response containing Definition of Validation data and access token
708
+ # 10.7.3
709
+ def reset_password_by_otp_and_user_name(reset_password_by_user_name_model)
710
+ if reset_password_by_user_name_model.blank?
711
+ raise LoginRadius::Error.new, getValidationMessage('reset_password_by_user_name_model')
712
+ end
713
+
714
+ query_parameters = {}
715
+ query_parameters['apiKey'] = @api_key
716
+
717
+ resource_path = 'identity/v2/auth/password/reset'
718
+ put_request(resource_path, query_parameters, reset_password_by_user_name_model)
719
+ end
720
+
721
+ # This API is used to change the accounts password based on the previous password
722
+ #
723
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
724
+ # @param new_password - New password
725
+ # @param old_password - User's current password
726
+ #
727
+ # @return Response containing Definition of Complete Validation data
728
+ # 10.8
729
+ def change_password(access_token, new_password, old_password)
730
+ if isNullOrWhiteSpace(access_token)
731
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
732
+ end
733
+ if isNullOrWhiteSpace(new_password)
734
+ raise LoginRadius::Error.new, getValidationMessage('new_password')
735
+ end
736
+ if isNullOrWhiteSpace(old_password)
737
+ raise LoginRadius::Error.new, getValidationMessage('old_password')
738
+ end
739
+
740
+ query_parameters = {}
741
+ query_parameters['access_token'] = access_token
742
+ query_parameters['apiKey'] = @api_key
743
+
744
+ body_parameters = {}
745
+ body_parameters['newPassword'] = new_password
746
+ body_parameters['oldPassword'] = old_password
747
+
748
+ resource_path = 'identity/v2/auth/password/change'
749
+ put_request(resource_path, query_parameters, body_parameters)
750
+ end
751
+
752
+ # 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.
753
+ #
754
+ # @param access_token - Access_Token
755
+ # @param provider - Name of the provider
756
+ # @param provider_id - Unique ID of the linked account
757
+ #
758
+ # @return Response containing Definition of Delete Request
759
+ # 12.2
760
+ def unlink_social_identities(access_token, provider, provider_id)
761
+ if isNullOrWhiteSpace(access_token)
762
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
763
+ end
764
+ if isNullOrWhiteSpace(provider)
765
+ raise LoginRadius::Error.new, getValidationMessage('provider')
766
+ end
767
+ if isNullOrWhiteSpace(provider_id)
768
+ raise LoginRadius::Error.new, getValidationMessage('provider_id')
769
+ end
770
+
771
+ query_parameters = {}
772
+ query_parameters['access_token'] = access_token
773
+ query_parameters['apiKey'] = @api_key
774
+
775
+ body_parameters = {}
776
+ body_parameters['provider'] = provider
777
+ body_parameters['providerId'] = provider_id
778
+
779
+ resource_path = 'identity/v2/auth/socialidentity'
780
+ delete_request(resource_path, query_parameters, body_parameters)
781
+ end
782
+
783
+ # This API is used to link up a social provider account with an existing LoginRadius account on the basis of access token and the social providers user access token.
784
+ #
785
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
786
+ # @param candidate_token - Access token of the account to be linked
787
+ #
788
+ # @return Response containing Definition of Complete Validation data
789
+ # 12.4
790
+ def link_social_identities(access_token, candidate_token)
791
+ if isNullOrWhiteSpace(access_token)
792
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
793
+ end
794
+ if isNullOrWhiteSpace(candidate_token)
795
+ raise LoginRadius::Error.new, getValidationMessage('candidate_token')
796
+ end
797
+
798
+ query_parameters = {}
799
+ query_parameters['access_token'] = access_token
800
+ query_parameters['apiKey'] = @api_key
801
+
802
+ body_parameters = {}
803
+ body_parameters['candidateToken'] = candidate_token
804
+
805
+ resource_path = 'identity/v2/auth/socialidentity'
806
+ post_request(resource_path, query_parameters, body_parameters)
807
+ end
808
+
809
+ # This API is used to link up a social provider account with an existing LoginRadius account on the basis of ping and the social providers user access token.
810
+ #
811
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
812
+ # @param client_guid - Unique ID generated by client
813
+ #
814
+ # @return Response containing Definition of Complete Validation data
815
+ # 12.5
816
+ def link_social_identities_by_ping(access_token, client_guid)
817
+ if isNullOrWhiteSpace(access_token)
818
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
819
+ end
820
+ if isNullOrWhiteSpace(client_guid)
821
+ raise LoginRadius::Error.new, getValidationMessage('client_guid')
822
+ end
823
+
824
+ query_parameters = {}
825
+ query_parameters['access_token'] = access_token
826
+ query_parameters['apiKey'] = @api_key
827
+
828
+ body_parameters = {}
829
+ body_parameters['clientGuid'] = client_guid
830
+
831
+ resource_path = 'identity/v2/auth/socialidentity'
832
+ post_request(resource_path, query_parameters, body_parameters)
833
+ end
834
+
835
+ # This API is used to set or change UserName by access token.
836
+ #
837
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
838
+ # @param username - Username of the user
839
+ #
840
+ # @return Response containing Definition of Complete Validation data
841
+ # 13.1
842
+ def set_or_change_user_name(access_token, username)
843
+ if isNullOrWhiteSpace(access_token)
844
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
845
+ end
846
+ if isNullOrWhiteSpace(username)
847
+ raise LoginRadius::Error.new, getValidationMessage('username')
848
+ end
849
+
850
+ query_parameters = {}
851
+ query_parameters['access_token'] = access_token
852
+ query_parameters['apiKey'] = @api_key
853
+
854
+ body_parameters = {}
855
+ body_parameters['username'] = username
856
+
857
+ resource_path = 'identity/v2/auth/username'
858
+ put_request(resource_path, query_parameters, body_parameters)
859
+ end
860
+
861
+ # This API is used to check the UserName exists or not on your site.
862
+ #
863
+ # @param username - UserName of the user
864
+ #
865
+ # @return Response containing Definition Complete ExistResponse data
866
+ # 13.2
867
+ def check_user_name_availability(username)
868
+ if isNullOrWhiteSpace(username)
869
+ raise LoginRadius::Error.new, getValidationMessage('username')
870
+ end
871
+
872
+ query_parameters = {}
873
+ query_parameters['apiKey'] = @api_key
874
+ query_parameters['username'] = username
875
+
876
+ resource_path = 'identity/v2/auth/username'
877
+ get_request(resource_path, query_parameters, {})
878
+ end
879
+
880
+ # 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
881
+ #
882
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
883
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
884
+ #
885
+ # @return Response containing Definition for Complete profile data
886
+ # 15.1
887
+ def accept_privacy_policy(access_token, fields = '')
888
+ if isNullOrWhiteSpace(access_token)
889
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
890
+ end
891
+
892
+ query_parameters = {}
893
+ query_parameters['access_token'] = access_token
894
+ query_parameters['apiKey'] = @api_key
895
+ unless isNullOrWhiteSpace(fields)
896
+ query_parameters['fields'] = fields
897
+ end
898
+
899
+ resource_path = 'identity/v2/auth/privacypolicy/accept'
900
+ get_request(resource_path, query_parameters, {})
901
+ end
902
+
903
+ # This API will return all the accepted privacy policies for the user by providing the access token of that user.
904
+ #
905
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
906
+ #
907
+ # @return Complete Policy History data
908
+ # 15.2
909
+ def get_privacy_policy_history_by_access_token(access_token)
910
+ if isNullOrWhiteSpace(access_token)
911
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
912
+ end
913
+
914
+ query_parameters = {}
915
+ query_parameters['access_token'] = access_token
916
+ query_parameters['apiKey'] = @api_key
917
+
918
+ resource_path = 'identity/v2/auth/privacypolicy/history'
919
+ get_request(resource_path, query_parameters, {})
920
+ end
921
+
922
+ # This API creates a user in the database as well as sends a verification email to the user.
923
+ #
924
+ # @param auth_user_registration_model - Model Class containing Definition of payload for Auth User Registration API
925
+ # @param sott - LoginRadius Secured One Time Token
926
+ # @param email_template - Email template name
927
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
928
+ # @param options - PreventVerificationEmail (Specifying this value prevents the verification email from being sent. Only applicable if you have the optional email verification flow)
929
+ # @param verification_url - Email verification url
930
+ # @param welcome_email_template - Name of the welcome email template
931
+ #
932
+ # @return Response containing Definition of Complete Validation, UserProfile data and Access Token
933
+ # 17.1.1
934
+ def user_registration_by_email(auth_user_registration_model, sott, email_template = '', fields = '', options = '', verification_url = '', welcome_email_template = '')
935
+ if auth_user_registration_model.blank?
936
+ raise LoginRadius::Error.new, getValidationMessage('auth_user_registration_model')
937
+ end
938
+ if isNullOrWhiteSpace(sott)
939
+ raise LoginRadius::Error.new, getValidationMessage('sott')
940
+ end
941
+
942
+ query_parameters = {}
943
+ query_parameters['apiKey'] = @api_key
944
+ query_parameters['sott'] = sott
945
+ unless isNullOrWhiteSpace(email_template)
946
+ query_parameters['emailTemplate'] = email_template
947
+ end
948
+ unless isNullOrWhiteSpace(fields)
949
+ query_parameters['fields'] = fields
950
+ end
951
+ unless isNullOrWhiteSpace(options)
952
+ query_parameters['options'] = options
953
+ end
954
+ unless isNullOrWhiteSpace(verification_url)
955
+ query_parameters['verificationUrl'] = verification_url
956
+ end
957
+ unless isNullOrWhiteSpace(welcome_email_template)
958
+ query_parameters['welcomeEmailTemplate'] = welcome_email_template
959
+ end
960
+
961
+ resource_path = 'identity/v2/auth/register'
962
+ post_request(resource_path, query_parameters, auth_user_registration_model)
963
+ end
964
+
965
+ # This API creates a user in the database as well as sends a verification email to the user.
966
+ #
967
+ # @param auth_user_registration_model_with_captcha - Model Class containing Definition of payload for Auth User Registration by Recaptcha API
968
+ # @param email_template - Email template name
969
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
970
+ # @param options - PreventVerificationEmail (Specifying this value prevents the verification email from being sent. Only applicable if you have the optional email verification flow)
971
+ # @param sms_template - SMS Template name
972
+ # @param verification_url - Email verification url
973
+ # @param welcome_email_template - Name of the welcome email template
974
+ #
975
+ # @return Response containing Definition of Complete Validation, UserProfile data and Access Token
976
+ # 17.2
977
+ def user_registration_by_captcha(auth_user_registration_model_with_captcha, email_template = '', fields = '', options = '', sms_template = '', verification_url = '', welcome_email_template = '')
978
+ if auth_user_registration_model_with_captcha.blank?
979
+ raise LoginRadius::Error.new, getValidationMessage('auth_user_registration_model_with_captcha')
980
+ end
981
+
982
+ query_parameters = {}
983
+ query_parameters['apiKey'] = @api_key
984
+ unless isNullOrWhiteSpace(email_template)
985
+ query_parameters['emailTemplate'] = email_template
986
+ end
987
+ unless isNullOrWhiteSpace(fields)
988
+ query_parameters['fields'] = fields
989
+ end
990
+ unless isNullOrWhiteSpace(options)
991
+ query_parameters['options'] = options
992
+ end
993
+ unless isNullOrWhiteSpace(sms_template)
994
+ query_parameters['smsTemplate'] = sms_template
995
+ end
996
+ unless isNullOrWhiteSpace(verification_url)
997
+ query_parameters['verificationUrl'] = verification_url
998
+ end
999
+ unless isNullOrWhiteSpace(welcome_email_template)
1000
+ query_parameters['welcomeEmailTemplate'] = welcome_email_template
1001
+ end
1002
+
1003
+ resource_path = 'identity/v2/auth/register/captcha'
1004
+ post_request(resource_path, query_parameters, auth_user_registration_model_with_captcha)
1005
+ end
1006
+
1007
+ # This API resends the verification email to the user.
1008
+ #
1009
+ # @param email - user's email
1010
+ # @param email_template - Email template name
1011
+ # @param verification_url - Email verification url
1012
+ #
1013
+ # @return Response containing Definition of Complete Validation data
1014
+ # 17.3
1015
+ def auth_resend_email_verification(email, email_template = '', verification_url = '')
1016
+ if isNullOrWhiteSpace(email)
1017
+ raise LoginRadius::Error.new, getValidationMessage('email')
1018
+ end
1019
+
1020
+ query_parameters = {}
1021
+ query_parameters['apiKey'] = @api_key
1022
+ unless isNullOrWhiteSpace(email_template)
1023
+ query_parameters['emailTemplate'] = email_template
1024
+ end
1025
+ unless isNullOrWhiteSpace(verification_url)
1026
+ query_parameters['verificationUrl'] = verification_url
1027
+ end
1028
+
1029
+ body_parameters = {}
1030
+ body_parameters['email'] = email
1031
+
1032
+ resource_path = 'identity/v2/auth/register'
1033
+ put_request(resource_path, query_parameters, body_parameters)
1034
+ end
1035
+ end
1036
+ end