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,329 +1,329 @@
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
- # PhoneAuthenticationApi module
9
- class PhoneAuthenticationApi
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 retrieves a copy of the user data based on the Phone
29
- #
30
- # @param phone_authentication_model - Model Class containing Definition of payload for PhoneAuthenticationModel API
31
- # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
32
- # @param login_url - Url where the user is logging from
33
- # @param sms_template - SMS Template name
34
- #
35
- # @return Response containing User Profile Data and access token
36
- # 9.2.3
37
- def login_by_phone(phone_authentication_model, fields = '', login_url = '', sms_template = '')
38
- if phone_authentication_model.blank?
39
- raise LoginRadius::Error.new, getValidationMessage('phone_authentication_model')
40
- end
41
-
42
- query_parameters = {}
43
- query_parameters['apiKey'] = @api_key
44
- unless isNullOrWhiteSpace(fields)
45
- query_parameters['fields'] = fields
46
- end
47
- unless isNullOrWhiteSpace(login_url)
48
- query_parameters['loginUrl'] = login_url
49
- end
50
- unless isNullOrWhiteSpace(sms_template)
51
- query_parameters['smsTemplate'] = sms_template
52
- end
53
-
54
- resource_path = 'identity/v2/auth/login'
55
- post_request(resource_path, query_parameters, phone_authentication_model)
56
- end
57
-
58
- # This API is used to send the OTP to reset the account password.
59
- #
60
- # @param phone - New Phone Number
61
- # @param sms_template - SMS Template name
62
- #
63
- # @return Response Containing Validation Data and SMS Data
64
- # 10.4
65
- def forgot_password_by_phone_otp(phone, sms_template = '')
66
- if isNullOrWhiteSpace(phone)
67
- raise LoginRadius::Error.new, getValidationMessage('phone')
68
- end
69
-
70
- query_parameters = {}
71
- query_parameters['apiKey'] = @api_key
72
- unless isNullOrWhiteSpace(sms_template)
73
- query_parameters['smsTemplate'] = sms_template
74
- end
75
-
76
- body_parameters = {}
77
- body_parameters['phone'] = phone
78
-
79
- resource_path = 'identity/v2/auth/password/otp'
80
- post_request(resource_path, query_parameters, body_parameters)
81
- end
82
-
83
- # This API is used to reset the password
84
- #
85
- # @param reset_password_by_otp_model - Model Class containing Definition of payload for ResetPasswordByOTP API
86
- #
87
- # @return Response containing Definition of Complete Validation data
88
- # 10.5
89
- def reset_password_by_phone_otp(reset_password_by_otp_model)
90
- if reset_password_by_otp_model.blank?
91
- raise LoginRadius::Error.new, getValidationMessage('reset_password_by_otp_model')
92
- end
93
-
94
- query_parameters = {}
95
- query_parameters['apiKey'] = @api_key
96
-
97
- resource_path = 'identity/v2/auth/password/otp'
98
- put_request(resource_path, query_parameters, reset_password_by_otp_model)
99
- end
100
-
101
- # This API is used to validate the verification code sent to verify a user's phone number
102
- #
103
- # @param otp - The Verification Code
104
- # @param phone - New Phone Number
105
- # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
106
- # @param sms_template - SMS Template name
107
- #
108
- # @return Response containing User Profile Data and access token
109
- # 11.1.1
110
- def phone_verification_by_otp(otp, phone, fields = '', sms_template = '')
111
- if isNullOrWhiteSpace(otp)
112
- raise LoginRadius::Error.new, getValidationMessage('otp')
113
- end
114
- if isNullOrWhiteSpace(phone)
115
- raise LoginRadius::Error.new, getValidationMessage('phone')
116
- end
117
-
118
- query_parameters = {}
119
- query_parameters['apiKey'] = @api_key
120
- query_parameters['otp'] = otp
121
- unless isNullOrWhiteSpace(fields)
122
- query_parameters['fields'] = fields
123
- end
124
- unless isNullOrWhiteSpace(sms_template)
125
- query_parameters['smsTemplate'] = sms_template
126
- end
127
-
128
- body_parameters = {}
129
- body_parameters['phone'] = phone
130
-
131
- resource_path = 'identity/v2/auth/phone/otp'
132
- put_request(resource_path, query_parameters, body_parameters)
133
- end
134
-
135
- # This API is used to consume the verification code sent to verify a user's phone number. Use this call for front-end purposes in cases where the user is already logged in by passing the user's access token.
136
- #
137
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
138
- # @param otp - The Verification Code
139
- # @param sms_template - SMS Template name
140
- #
141
- # @return Response containing Definition of Complete Validation data
142
- # 11.1.2
143
- def phone_verification_otp_by_access_token(access_token, otp, sms_template = '')
144
- if isNullOrWhiteSpace(access_token)
145
- raise LoginRadius::Error.new, getValidationMessage('access_token')
146
- end
147
- if isNullOrWhiteSpace(otp)
148
- raise LoginRadius::Error.new, getValidationMessage('otp')
149
- end
150
-
151
- query_parameters = {}
152
- query_parameters['access_token'] = access_token
153
- query_parameters['apiKey'] = @api_key
154
- query_parameters['otp'] = otp
155
- unless isNullOrWhiteSpace(sms_template)
156
- query_parameters['smsTemplate'] = sms_template
157
- end
158
-
159
- resource_path = 'identity/v2/auth/phone/otp'
160
- put_request(resource_path, query_parameters, nil)
161
- end
162
-
163
- # This API is used to resend a verification OTP to verify a user's Phone Number. The user will receive a verification code that they will need to input
164
- #
165
- # @param phone - New Phone Number
166
- # @param sms_template - SMS Template name
167
- #
168
- # @return Response Containing Validation Data and SMS Data
169
- # 11.2.1
170
- def phone_resend_verification_otp(phone, sms_template = '')
171
- if isNullOrWhiteSpace(phone)
172
- raise LoginRadius::Error.new, getValidationMessage('phone')
173
- end
174
-
175
- query_parameters = {}
176
- query_parameters['apiKey'] = @api_key
177
- unless isNullOrWhiteSpace(sms_template)
178
- query_parameters['smsTemplate'] = sms_template
179
- end
180
-
181
- body_parameters = {}
182
- body_parameters['phone'] = phone
183
-
184
- resource_path = 'identity/v2/auth/phone/otp'
185
- post_request(resource_path, query_parameters, body_parameters)
186
- end
187
-
188
- # This API is used to resend a verification OTP to verify a user's Phone Number in cases in which an active token already exists
189
- #
190
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
191
- # @param phone - New Phone Number
192
- # @param sms_template - SMS Template name
193
- #
194
- # @return Response Containing Validation Data and SMS Data
195
- # 11.2.2
196
- def phone_resend_verification_otp_by_token(access_token, phone, sms_template = '')
197
- if isNullOrWhiteSpace(access_token)
198
- raise LoginRadius::Error.new, getValidationMessage('access_token')
199
- end
200
- if isNullOrWhiteSpace(phone)
201
- raise LoginRadius::Error.new, getValidationMessage('phone')
202
- end
203
-
204
- query_parameters = {}
205
- query_parameters['access_token'] = access_token
206
- query_parameters['apiKey'] = @api_key
207
- unless isNullOrWhiteSpace(sms_template)
208
- query_parameters['smsTemplate'] = sms_template
209
- end
210
-
211
- body_parameters = {}
212
- body_parameters['phone'] = phone
213
-
214
- resource_path = 'identity/v2/auth/phone/otp'
215
- post_request(resource_path, query_parameters, body_parameters)
216
- end
217
-
218
- # This API is used to update the login Phone Number of users
219
- #
220
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
221
- # @param phone - New Phone Number
222
- # @param sms_template - SMS Template name
223
- #
224
- # @return Response Containing Validation Data and SMS Data
225
- # 11.5
226
- def update_phone_number(access_token, phone, sms_template = '')
227
- if isNullOrWhiteSpace(access_token)
228
- raise LoginRadius::Error.new, getValidationMessage('access_token')
229
- end
230
- if isNullOrWhiteSpace(phone)
231
- raise LoginRadius::Error.new, getValidationMessage('phone')
232
- end
233
-
234
- query_parameters = {}
235
- query_parameters['access_token'] = access_token
236
- query_parameters['apiKey'] = @api_key
237
- unless isNullOrWhiteSpace(sms_template)
238
- query_parameters['smsTemplate'] = sms_template
239
- end
240
-
241
- body_parameters = {}
242
- body_parameters['phone'] = phone
243
-
244
- resource_path = 'identity/v2/auth/phone'
245
- put_request(resource_path, query_parameters, body_parameters)
246
- end
247
-
248
- # This API is used to check the Phone Number exists or not on your site.
249
- #
250
- # @param phone - The Registered Phone Number
251
- #
252
- # @return Response containing Definition Complete ExistResponse data
253
- # 11.6
254
- def check_phone_number_availability(phone)
255
- if isNullOrWhiteSpace(phone)
256
- raise LoginRadius::Error.new, getValidationMessage('phone')
257
- end
258
-
259
- query_parameters = {}
260
- query_parameters['apiKey'] = @api_key
261
- query_parameters['phone'] = phone
262
-
263
- resource_path = 'identity/v2/auth/phone'
264
- get_request(resource_path, query_parameters, nil)
265
- end
266
-
267
- # This API is used to delete the Phone ID on a user's account via the access token
268
- #
269
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
270
- #
271
- # @return Response containing Definition of Delete Request
272
- # 11.7
273
- def remove_phone_id_by_access_token(access_token)
274
- if isNullOrWhiteSpace(access_token)
275
- raise LoginRadius::Error.new, getValidationMessage('access_token')
276
- end
277
-
278
- query_parameters = {}
279
- query_parameters['access_token'] = access_token
280
- query_parameters['apiKey'] = @api_key
281
-
282
- resource_path = 'identity/v2/auth/phone'
283
- delete_request(resource_path, query_parameters, nil)
284
- end
285
-
286
- # This API registers the new users into your Cloud Storage and triggers the phone verification process.
287
- #
288
- # @param auth_user_registration_model - Model Class containing Definition of payload for Auth User Registration API
289
- # @param sott - LoginRadius Secured One Time Token
290
- # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
291
- # @param options - PreventVerificationEmail (Specifying this value prevents the verification email from being sent. Only applicable if you have the optional email verification flow)
292
- # @param sms_template - SMS Template name
293
- # @param verification_url - Email verification url
294
- # @param welcome_email_template - Name of the welcome email template
295
- #
296
- # @return Response containing Definition of Complete Validation, UserProfile data and Access Token
297
- # 17.1.2
298
- def user_registration_by_phone(auth_user_registration_model, sott, fields = '', options = '', sms_template = '', verification_url = '', welcome_email_template = '')
299
- if auth_user_registration_model.blank?
300
- raise LoginRadius::Error.new, getValidationMessage('auth_user_registration_model')
301
- end
302
- if isNullOrWhiteSpace(sott)
303
- raise LoginRadius::Error.new, getValidationMessage('sott')
304
- end
305
-
306
- query_parameters = {}
307
- query_parameters['apiKey'] = @api_key
308
- query_parameters['sott'] = sott
309
- unless isNullOrWhiteSpace(fields)
310
- query_parameters['fields'] = fields
311
- end
312
- unless isNullOrWhiteSpace(options)
313
- query_parameters['options'] = options
314
- end
315
- unless isNullOrWhiteSpace(sms_template)
316
- query_parameters['smsTemplate'] = sms_template
317
- end
318
- unless isNullOrWhiteSpace(verification_url)
319
- query_parameters['verificationUrl'] = verification_url
320
- end
321
- unless isNullOrWhiteSpace(welcome_email_template)
322
- query_parameters['welcomeEmailTemplate'] = welcome_email_template
323
- end
324
-
325
- resource_path = 'identity/v2/auth/register'
326
- post_request(resource_path, query_parameters, auth_user_registration_model)
327
- end
328
- end
329
- 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
+ # PhoneAuthenticationApi module
9
+ class PhoneAuthenticationApi
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 retrieves a copy of the user data based on the Phone
29
+ #
30
+ # @param phone_authentication_model - Model Class containing Definition of payload for PhoneAuthenticationModel API
31
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
32
+ # @param login_url - Url where the user is logging from
33
+ # @param sms_template - SMS Template name
34
+ #
35
+ # @return Response containing User Profile Data and access token
36
+ # 9.2.3
37
+ def login_by_phone(phone_authentication_model, fields = '', login_url = '', sms_template = '')
38
+ if phone_authentication_model.blank?
39
+ raise LoginRadius::Error.new, getValidationMessage('phone_authentication_model')
40
+ end
41
+
42
+ query_parameters = {}
43
+ query_parameters['apiKey'] = @api_key
44
+ unless isNullOrWhiteSpace(fields)
45
+ query_parameters['fields'] = fields
46
+ end
47
+ unless isNullOrWhiteSpace(login_url)
48
+ query_parameters['loginUrl'] = login_url
49
+ end
50
+ unless isNullOrWhiteSpace(sms_template)
51
+ query_parameters['smsTemplate'] = sms_template
52
+ end
53
+
54
+ resource_path = 'identity/v2/auth/login'
55
+ post_request(resource_path, query_parameters, phone_authentication_model)
56
+ end
57
+
58
+ # This API is used to send the OTP to reset the account password.
59
+ #
60
+ # @param phone - New Phone Number
61
+ # @param sms_template - SMS Template name
62
+ #
63
+ # @return Response Containing Validation Data and SMS Data
64
+ # 10.4
65
+ def forgot_password_by_phone_otp(phone, sms_template = '')
66
+ if isNullOrWhiteSpace(phone)
67
+ raise LoginRadius::Error.new, getValidationMessage('phone')
68
+ end
69
+
70
+ query_parameters = {}
71
+ query_parameters['apiKey'] = @api_key
72
+ unless isNullOrWhiteSpace(sms_template)
73
+ query_parameters['smsTemplate'] = sms_template
74
+ end
75
+
76
+ body_parameters = {}
77
+ body_parameters['phone'] = phone
78
+
79
+ resource_path = 'identity/v2/auth/password/otp'
80
+ post_request(resource_path, query_parameters, body_parameters)
81
+ end
82
+
83
+ # This API is used to reset the password
84
+ #
85
+ # @param reset_password_by_otp_model - Model Class containing Definition of payload for ResetPasswordByOTP API
86
+ #
87
+ # @return Response containing Definition of Complete Validation data
88
+ # 10.5
89
+ def reset_password_by_phone_otp(reset_password_by_otp_model)
90
+ if reset_password_by_otp_model.blank?
91
+ raise LoginRadius::Error.new, getValidationMessage('reset_password_by_otp_model')
92
+ end
93
+
94
+ query_parameters = {}
95
+ query_parameters['apiKey'] = @api_key
96
+
97
+ resource_path = 'identity/v2/auth/password/otp'
98
+ put_request(resource_path, query_parameters, reset_password_by_otp_model)
99
+ end
100
+
101
+ # This API is used to validate the verification code sent to verify a user's phone number
102
+ #
103
+ # @param otp - The Verification Code
104
+ # @param phone - New Phone Number
105
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
106
+ # @param sms_template - SMS Template name
107
+ #
108
+ # @return Response containing User Profile Data and access token
109
+ # 11.1.1
110
+ def phone_verification_by_otp(otp, phone, fields = '', sms_template = '')
111
+ if isNullOrWhiteSpace(otp)
112
+ raise LoginRadius::Error.new, getValidationMessage('otp')
113
+ end
114
+ if isNullOrWhiteSpace(phone)
115
+ raise LoginRadius::Error.new, getValidationMessage('phone')
116
+ end
117
+
118
+ query_parameters = {}
119
+ query_parameters['apiKey'] = @api_key
120
+ query_parameters['otp'] = otp
121
+ unless isNullOrWhiteSpace(fields)
122
+ query_parameters['fields'] = fields
123
+ end
124
+ unless isNullOrWhiteSpace(sms_template)
125
+ query_parameters['smsTemplate'] = sms_template
126
+ end
127
+
128
+ body_parameters = {}
129
+ body_parameters['phone'] = phone
130
+
131
+ resource_path = 'identity/v2/auth/phone/otp'
132
+ put_request(resource_path, query_parameters, body_parameters)
133
+ end
134
+
135
+ # This API is used to consume the verification code sent to verify a user's phone number. Use this call for front-end purposes in cases where the user is already logged in by passing the user's access token.
136
+ #
137
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
138
+ # @param otp - The Verification Code
139
+ # @param sms_template - SMS Template name
140
+ #
141
+ # @return Response containing Definition of Complete Validation data
142
+ # 11.1.2
143
+ def phone_verification_otp_by_access_token(access_token, otp, sms_template = '')
144
+ if isNullOrWhiteSpace(access_token)
145
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
146
+ end
147
+ if isNullOrWhiteSpace(otp)
148
+ raise LoginRadius::Error.new, getValidationMessage('otp')
149
+ end
150
+
151
+ query_parameters = {}
152
+ query_parameters['access_token'] = access_token
153
+ query_parameters['apiKey'] = @api_key
154
+ query_parameters['otp'] = otp
155
+ unless isNullOrWhiteSpace(sms_template)
156
+ query_parameters['smsTemplate'] = sms_template
157
+ end
158
+
159
+ resource_path = 'identity/v2/auth/phone/otp'
160
+ put_request(resource_path, query_parameters, {})
161
+ end
162
+
163
+ # This API is used to resend a verification OTP to verify a user's Phone Number. The user will receive a verification code that they will need to input
164
+ #
165
+ # @param phone - New Phone Number
166
+ # @param sms_template - SMS Template name
167
+ #
168
+ # @return Response Containing Validation Data and SMS Data
169
+ # 11.2.1
170
+ def phone_resend_verification_otp(phone, sms_template = '')
171
+ if isNullOrWhiteSpace(phone)
172
+ raise LoginRadius::Error.new, getValidationMessage('phone')
173
+ end
174
+
175
+ query_parameters = {}
176
+ query_parameters['apiKey'] = @api_key
177
+ unless isNullOrWhiteSpace(sms_template)
178
+ query_parameters['smsTemplate'] = sms_template
179
+ end
180
+
181
+ body_parameters = {}
182
+ body_parameters['phone'] = phone
183
+
184
+ resource_path = 'identity/v2/auth/phone/otp'
185
+ post_request(resource_path, query_parameters, body_parameters)
186
+ end
187
+
188
+ # This API is used to resend a verification OTP to verify a user's Phone Number in cases in which an active token already exists
189
+ #
190
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
191
+ # @param phone - New Phone Number
192
+ # @param sms_template - SMS Template name
193
+ #
194
+ # @return Response Containing Validation Data and SMS Data
195
+ # 11.2.2
196
+ def phone_resend_verification_otp_by_token(access_token, phone, sms_template = '')
197
+ if isNullOrWhiteSpace(access_token)
198
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
199
+ end
200
+ if isNullOrWhiteSpace(phone)
201
+ raise LoginRadius::Error.new, getValidationMessage('phone')
202
+ end
203
+
204
+ query_parameters = {}
205
+ query_parameters['access_token'] = access_token
206
+ query_parameters['apiKey'] = @api_key
207
+ unless isNullOrWhiteSpace(sms_template)
208
+ query_parameters['smsTemplate'] = sms_template
209
+ end
210
+
211
+ body_parameters = {}
212
+ body_parameters['phone'] = phone
213
+
214
+ resource_path = 'identity/v2/auth/phone/otp'
215
+ post_request(resource_path, query_parameters, body_parameters)
216
+ end
217
+
218
+ # This API is used to update the login Phone Number of users
219
+ #
220
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
221
+ # @param phone - New Phone Number
222
+ # @param sms_template - SMS Template name
223
+ #
224
+ # @return Response Containing Validation Data and SMS Data
225
+ # 11.5
226
+ def update_phone_number(access_token, phone, sms_template = '')
227
+ if isNullOrWhiteSpace(access_token)
228
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
229
+ end
230
+ if isNullOrWhiteSpace(phone)
231
+ raise LoginRadius::Error.new, getValidationMessage('phone')
232
+ end
233
+
234
+ query_parameters = {}
235
+ query_parameters['access_token'] = access_token
236
+ query_parameters['apiKey'] = @api_key
237
+ unless isNullOrWhiteSpace(sms_template)
238
+ query_parameters['smsTemplate'] = sms_template
239
+ end
240
+
241
+ body_parameters = {}
242
+ body_parameters['phone'] = phone
243
+
244
+ resource_path = 'identity/v2/auth/phone'
245
+ put_request(resource_path, query_parameters, body_parameters)
246
+ end
247
+
248
+ # This API is used to check the Phone Number exists or not on your site.
249
+ #
250
+ # @param phone - The Registered Phone Number
251
+ #
252
+ # @return Response containing Definition Complete ExistResponse data
253
+ # 11.6
254
+ def check_phone_number_availability(phone)
255
+ if isNullOrWhiteSpace(phone)
256
+ raise LoginRadius::Error.new, getValidationMessage('phone')
257
+ end
258
+
259
+ query_parameters = {}
260
+ query_parameters['apiKey'] = @api_key
261
+ query_parameters['phone'] = phone
262
+
263
+ resource_path = 'identity/v2/auth/phone'
264
+ get_request(resource_path, query_parameters, {})
265
+ end
266
+
267
+ # This API is used to delete the Phone ID on a user's account via the access token
268
+ #
269
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
270
+ #
271
+ # @return Response containing Definition of Delete Request
272
+ # 11.7
273
+ def remove_phone_id_by_access_token(access_token)
274
+ if isNullOrWhiteSpace(access_token)
275
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
276
+ end
277
+
278
+ query_parameters = {}
279
+ query_parameters['access_token'] = access_token
280
+ query_parameters['apiKey'] = @api_key
281
+
282
+ resource_path = 'identity/v2/auth/phone'
283
+ delete_request(resource_path, query_parameters, {})
284
+ end
285
+
286
+ # This API registers the new users into your Cloud Storage and triggers the phone verification process.
287
+ #
288
+ # @param auth_user_registration_model - Model Class containing Definition of payload for Auth User Registration API
289
+ # @param sott - LoginRadius Secured One Time Token
290
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
291
+ # @param options - PreventVerificationEmail (Specifying this value prevents the verification email from being sent. Only applicable if you have the optional email verification flow)
292
+ # @param sms_template - SMS Template name
293
+ # @param verification_url - Email verification url
294
+ # @param welcome_email_template - Name of the welcome email template
295
+ #
296
+ # @return Response containing Definition of Complete Validation, UserProfile data and Access Token
297
+ # 17.1.2
298
+ def user_registration_by_phone(auth_user_registration_model, sott, fields = '', options = '', sms_template = '', verification_url = '', welcome_email_template = '')
299
+ if auth_user_registration_model.blank?
300
+ raise LoginRadius::Error.new, getValidationMessage('auth_user_registration_model')
301
+ end
302
+ if isNullOrWhiteSpace(sott)
303
+ raise LoginRadius::Error.new, getValidationMessage('sott')
304
+ end
305
+
306
+ query_parameters = {}
307
+ query_parameters['apiKey'] = @api_key
308
+ query_parameters['sott'] = sott
309
+ unless isNullOrWhiteSpace(fields)
310
+ query_parameters['fields'] = fields
311
+ end
312
+ unless isNullOrWhiteSpace(options)
313
+ query_parameters['options'] = options
314
+ end
315
+ unless isNullOrWhiteSpace(sms_template)
316
+ query_parameters['smsTemplate'] = sms_template
317
+ end
318
+ unless isNullOrWhiteSpace(verification_url)
319
+ query_parameters['verificationUrl'] = verification_url
320
+ end
321
+ unless isNullOrWhiteSpace(welcome_email_template)
322
+ query_parameters['welcomeEmailTemplate'] = welcome_email_template
323
+ end
324
+
325
+ resource_path = 'identity/v2/auth/register'
326
+ post_request(resource_path, query_parameters, auth_user_registration_model)
327
+ end
328
+ end
329
+ end