login_radius 10.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 -986
  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 -193
  22. data/lib/login_radius/api/social/social_api.rb +784 -802
  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,802 +1,784 @@
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
- # SocialApi module
9
- class SocialApi
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 translate the Request Token returned during authentication into an Access Token that can be used with other API calls.
29
- #
30
- # @param token - Token generated from a successful oauth from social platform
31
- #
32
- # @return Response containing Definition of Complete Token data
33
- # 20.1
34
- def exchange_access_token(token)
35
- if isNullOrWhiteSpace(token)
36
- raise LoginRadius::Error.new, getValidationMessage('token')
37
- end
38
-
39
- query_parameters = {}
40
- query_parameters['secret'] = @api_secret
41
- query_parameters['token'] = token
42
-
43
- resource_path = 'api/v2/access_token'
44
- get_request(resource_path, query_parameters, nil)
45
- end
46
-
47
- # The Refresh Access Token API is used to refresh the provider access token after authentication. It will be valid for up to 60 days on LoginRadius depending on the provider. In order to use the access token in other APIs, always refresh the token using this API.<br><br><b>Supported Providers :</b> Facebook,Yahoo,Google,Twitter, Linkedin.<br><br> Contact LoginRadius support team to enable this API.
48
- #
49
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
50
- # @param expires_in - Allows you to specify a desired expiration time in minutes for the newly issued access token.
51
- #
52
- # @return Response containing Definition of Complete Token data
53
- # 20.2
54
- def refresh_access_token(access_token, expires_in)
55
- if isNullOrWhiteSpace(access_token)
56
- raise LoginRadius::Error.new, getValidationMessage('access_token')
57
- end
58
-
59
- query_parameters = {}
60
- query_parameters['access_token'] = access_token
61
- query_parameters['secret'] = @api_secret
62
- unless expires_in == false
63
- query_parameters['expiresIn'] = expires_in
64
- end
65
-
66
- resource_path = 'api/v2/access_token/refresh'
67
- get_request(resource_path, query_parameters, nil)
68
- end
69
-
70
- # This API validates access token, if valid then returns a response with its expiry otherwise error.
71
- #
72
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
73
- #
74
- # @return Response containing Definition of Complete Token data
75
- # 20.9
76
- def validate_access_token(access_token)
77
- if isNullOrWhiteSpace(access_token)
78
- raise LoginRadius::Error.new, getValidationMessage('access_token')
79
- end
80
-
81
- query_parameters = {}
82
- query_parameters['access_token'] = access_token
83
- query_parameters['key'] = @api_key
84
- query_parameters['secret'] = @api_secret
85
-
86
- resource_path = 'api/v2/access_token/validate'
87
- get_request(resource_path, query_parameters, nil)
88
- end
89
-
90
- # This api invalidates the active access token or expires an access token validity.
91
- #
92
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
93
- #
94
- # @return Response containing Definition for Complete Validation data
95
- # 20.10
96
- def in_validate_access_token(access_token)
97
- if isNullOrWhiteSpace(access_token)
98
- raise LoginRadius::Error.new, getValidationMessage('access_token')
99
- end
100
-
101
- query_parameters = {}
102
- query_parameters['access_token'] = access_token
103
- query_parameters['key'] = @api_key
104
- query_parameters['secret'] = @api_secret
105
-
106
- resource_path = 'api/v2/access_token/invalidate'
107
- get_request(resource_path, query_parameters, nil)
108
- end
109
-
110
- # This api is use to get all active session by Access Token.
111
- #
112
- # @param token - Token generated from a successful oauth from social platform
113
- #
114
- # @return Response containing Definition for Complete active sessions
115
- # 20.11.1
116
- def get_active_session(token)
117
- if isNullOrWhiteSpace(token)
118
- raise LoginRadius::Error.new, getValidationMessage('token')
119
- end
120
-
121
- query_parameters = {}
122
- query_parameters['key'] = @api_key
123
- query_parameters['secret'] = @api_secret
124
- query_parameters['token'] = token
125
-
126
- resource_path = 'api/v2/access_token/activesession'
127
- get_request(resource_path, query_parameters, nil)
128
- end
129
-
130
- # This api is used to get all active sessions by AccountID(UID).
131
- #
132
- # @param account_id - UID, the unified identifier for each user account
133
- #
134
- # @return Response containing Definition for Complete active sessions
135
- # 20.11.2
136
- def get_active_session_by_account_id(account_id)
137
- if isNullOrWhiteSpace(account_id)
138
- raise LoginRadius::Error.new, getValidationMessage('account_id')
139
- end
140
-
141
- query_parameters = {}
142
- query_parameters['accountId'] = account_id
143
- query_parameters['key'] = @api_key
144
- query_parameters['secret'] = @api_secret
145
-
146
- resource_path = 'api/v2/access_token/activesession'
147
- get_request(resource_path, query_parameters, nil)
148
- end
149
-
150
- # This api is used to get all active sessions by ProfileId.
151
- #
152
- # @param profile_id - Social Provider Id
153
- #
154
- # @return Response containing Definition for Complete active sessions
155
- # 20.11.3
156
- def get_active_session_by_profile_id(profile_id)
157
- if isNullOrWhiteSpace(profile_id)
158
- raise LoginRadius::Error.new, getValidationMessage('profile_id')
159
- end
160
-
161
- query_parameters = {}
162
- query_parameters['key'] = @api_key
163
- query_parameters['profileId'] = profile_id
164
- query_parameters['secret'] = @api_secret
165
-
166
- resource_path = 'api/v2/access_token/activesession'
167
- get_request(resource_path, query_parameters, nil)
168
- end
169
-
170
- # <b>Supported Providers:</b> Facebook, Google, Live, Vkontakte.<br><br> This API returns the photo albums associated with the passed in access tokens Social Profile.
171
- #
172
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
173
- #
174
- # @return Response Containing List of Album Data
175
- # 22.2.1
176
- def get_albums(access_token)
177
- if isNullOrWhiteSpace(access_token)
178
- raise LoginRadius::Error.new, getValidationMessage('access_token')
179
- end
180
-
181
- query_parameters = {}
182
- query_parameters['access_token'] = access_token
183
-
184
- resource_path = 'api/v2/album'
185
- get_request(resource_path, query_parameters, nil)
186
- end
187
-
188
- # <b>Supported Providers:</b> Facebook, Google, Live, Vkontakte.<br><br> This API returns the photo albums associated with the passed in access tokens Social Profile.
189
- #
190
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
191
- # @param next_cursor - Cursor value if not all contacts can be retrieved once.
192
- #
193
- # @return Response Model containing Albums with next cursor
194
- # 22.2.2
195
- def get_albums_with_cursor(access_token, next_cursor)
196
- if isNullOrWhiteSpace(access_token)
197
- raise LoginRadius::Error.new, getValidationMessage('access_token')
198
- end
199
- if isNullOrWhiteSpace(next_cursor)
200
- raise LoginRadius::Error.new, getValidationMessage('next_cursor')
201
- end
202
-
203
- query_parameters = {}
204
- query_parameters['access_token'] = access_token
205
- query_parameters['nextCursor'] = next_cursor
206
-
207
- resource_path = 'api/v2/album'
208
- get_request(resource_path, query_parameters, nil)
209
- end
210
-
211
- # The Audio API is used to get audio files data from the user's social account.<br><br><b>Supported Providers:</b> Live, Vkontakte
212
- #
213
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
214
- #
215
- # @return Response Containing List of Audio Data
216
- # 24.2.1
217
- def get_audios(access_token)
218
- if isNullOrWhiteSpace(access_token)
219
- raise LoginRadius::Error.new, getValidationMessage('access_token')
220
- end
221
-
222
- query_parameters = {}
223
- query_parameters['access_token'] = access_token
224
-
225
- resource_path = 'api/v2/audio'
226
- get_request(resource_path, query_parameters, nil)
227
- end
228
-
229
- # The Audio API is used to get audio files data from the user's social account.<br><br><b>Supported Providers:</b> Live, Vkontakte
230
- #
231
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
232
- # @param next_cursor - Cursor value if not all contacts can be retrieved once.
233
- #
234
- # @return Response Model containing Audio with next cursor
235
- # 24.2.2
236
- def get_audios_with_cursor(access_token, next_cursor)
237
- if isNullOrWhiteSpace(access_token)
238
- raise LoginRadius::Error.new, getValidationMessage('access_token')
239
- end
240
- if isNullOrWhiteSpace(next_cursor)
241
- raise LoginRadius::Error.new, getValidationMessage('next_cursor')
242
- end
243
-
244
- query_parameters = {}
245
- query_parameters['access_token'] = access_token
246
- query_parameters['nextCursor'] = next_cursor
247
-
248
- resource_path = 'api/v2/audio'
249
- get_request(resource_path, query_parameters, nil)
250
- end
251
-
252
- # The Check In API is used to get check Ins data from the user's social account.<br><br><b>Supported Providers:</b> Facebook, Foursquare, Vkontakte
253
- #
254
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
255
- #
256
- # @return Response Containing List of CheckIn Data
257
- # 25.2.1
258
- def get_check_ins(access_token)
259
- if isNullOrWhiteSpace(access_token)
260
- raise LoginRadius::Error.new, getValidationMessage('access_token')
261
- end
262
-
263
- query_parameters = {}
264
- query_parameters['access_token'] = access_token
265
-
266
- resource_path = 'api/v2/checkin'
267
- get_request(resource_path, query_parameters, nil)
268
- end
269
-
270
- # The Check In API is used to get check Ins data from the user's social account.<br><br><b>Supported Providers:</b> Facebook, Foursquare, Vkontakte
271
- #
272
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
273
- # @param next_cursor - Cursor value if not all contacts can be retrieved once.
274
- #
275
- # @return Response Model containing Checkins with next cursor
276
- # 25.2.2
277
- def get_check_ins_with_cursor(access_token, next_cursor)
278
- if isNullOrWhiteSpace(access_token)
279
- raise LoginRadius::Error.new, getValidationMessage('access_token')
280
- end
281
- if isNullOrWhiteSpace(next_cursor)
282
- raise LoginRadius::Error.new, getValidationMessage('next_cursor')
283
- end
284
-
285
- query_parameters = {}
286
- query_parameters['access_token'] = access_token
287
- query_parameters['nextCursor'] = next_cursor
288
-
289
- resource_path = 'api/v2/checkin'
290
- get_request(resource_path, query_parameters, nil)
291
- end
292
-
293
- # The Contact API is used to get contacts/friends/connections data from the user's social account.This is one of the APIs that makes up the LoginRadius Friend Invite System. The data will normalized into LoginRadius' standard data format. This API requires setting permissions in your LoginRadius Dashboard. <br><br><b>Note:</b> Facebook restricts access to the list of friends that is returned. When using the Contacts API with Facebook you will only receive friends that have accepted some permissions with your app. <br><br><b>Supported Providers:</b> Facebook, Foursquare, Google, LinkedIn, Live, Twitter, Vkontakte, Yahoo
294
- #
295
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
296
- # @param next_cursor - Cursor value if not all contacts can be retrieved once.
297
- #
298
- # @return Response containing Definition of Contact Data with Cursor
299
- # 27.1
300
- def get_contacts(access_token, next_cursor = '')
301
- if isNullOrWhiteSpace(access_token)
302
- raise LoginRadius::Error.new, getValidationMessage('access_token')
303
- end
304
-
305
- query_parameters = {}
306
- query_parameters['access_token'] = access_token
307
- unless isNullOrWhiteSpace(next_cursor)
308
- query_parameters['nextCursor'] = next_cursor
309
- end
310
-
311
- resource_path = 'api/v2/contact'
312
- get_request(resource_path, query_parameters, nil)
313
- end
314
-
315
- # The Event API is used to get the event data from the user's social account.<br><br><b>Supported Providers:</b> Facebook, Live
316
- #
317
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
318
- #
319
- # @return Response Containing List of Events Data
320
- # 28.2.1
321
- def get_events(access_token)
322
- if isNullOrWhiteSpace(access_token)
323
- raise LoginRadius::Error.new, getValidationMessage('access_token')
324
- end
325
-
326
- query_parameters = {}
327
- query_parameters['access_token'] = access_token
328
-
329
- resource_path = 'api/v2/event'
330
- get_request(resource_path, query_parameters, nil)
331
- end
332
-
333
- # The Event API is used to get the event data from the user's social account.<br><br><b>Supported Providers:</b> Facebook, Live
334
- #
335
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
336
- # @param next_cursor - Cursor value if not all contacts can be retrieved once.
337
- #
338
- # @return Response Model containing Events with next cursor
339
- # 28.2.2
340
- def get_events_with_cursor(access_token, next_cursor)
341
- if isNullOrWhiteSpace(access_token)
342
- raise LoginRadius::Error.new, getValidationMessage('access_token')
343
- end
344
- if isNullOrWhiteSpace(next_cursor)
345
- raise LoginRadius::Error.new, getValidationMessage('next_cursor')
346
- end
347
-
348
- query_parameters = {}
349
- query_parameters['access_token'] = access_token
350
- query_parameters['nextCursor'] = next_cursor
351
-
352
- resource_path = 'api/v2/event'
353
- get_request(resource_path, query_parameters, nil)
354
- end
355
-
356
- # Get the following user list from the user's social account.<br><br><b>Supported Providers:</b> Twitter
357
- #
358
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
359
- #
360
- # @return Response Containing List of Contacts Data
361
- # 29.2.1
362
- def get_followings(access_token)
363
- if isNullOrWhiteSpace(access_token)
364
- raise LoginRadius::Error.new, getValidationMessage('access_token')
365
- end
366
-
367
- query_parameters = {}
368
- query_parameters['access_token'] = access_token
369
-
370
- resource_path = 'api/v2/following'
371
- get_request(resource_path, query_parameters, nil)
372
- end
373
-
374
- # Get the following user list from the user's social account.<br><br><b>Supported Providers:</b> Twitter
375
- #
376
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
377
- # @param next_cursor - Cursor value if not all contacts can be retrieved once.
378
- #
379
- # @return Response containing Definition of Contact Data with Cursor
380
- # 29.2.2
381
- def get_followings_with_cursor(access_token, next_cursor)
382
- if isNullOrWhiteSpace(access_token)
383
- raise LoginRadius::Error.new, getValidationMessage('access_token')
384
- end
385
- if isNullOrWhiteSpace(next_cursor)
386
- raise LoginRadius::Error.new, getValidationMessage('next_cursor')
387
- end
388
-
389
- query_parameters = {}
390
- query_parameters['access_token'] = access_token
391
- query_parameters['nextCursor'] = next_cursor
392
-
393
- resource_path = 'api/v2/following'
394
- get_request(resource_path, query_parameters, nil)
395
- end
396
-
397
- # The Group API is used to get group data from the user's social account.<br><br><b>Supported Providers:</b> Facebook, Vkontakte
398
- #
399
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
400
- #
401
- # @return Response Containing List of Groups Data
402
- # 30.2.1
403
- def get_groups(access_token)
404
- if isNullOrWhiteSpace(access_token)
405
- raise LoginRadius::Error.new, getValidationMessage('access_token')
406
- end
407
-
408
- query_parameters = {}
409
- query_parameters['access_token'] = access_token
410
-
411
- resource_path = 'api/v2/group'
412
- get_request(resource_path, query_parameters, nil)
413
- end
414
-
415
- # The Group API is used to get group data from the user's social account.<br><br><b>Supported Providers:</b> Facebook, Vkontakte
416
- #
417
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
418
- # @param next_cursor - Cursor value if not all contacts can be retrieved once.
419
- #
420
- # @return Response Model containing Groups with next cursor
421
- # 30.2.2
422
- def get_groups_with_cursor(access_token, next_cursor)
423
- if isNullOrWhiteSpace(access_token)
424
- raise LoginRadius::Error.new, getValidationMessage('access_token')
425
- end
426
- if isNullOrWhiteSpace(next_cursor)
427
- raise LoginRadius::Error.new, getValidationMessage('next_cursor')
428
- end
429
-
430
- query_parameters = {}
431
- query_parameters['access_token'] = access_token
432
- query_parameters['nextCursor'] = next_cursor
433
-
434
- resource_path = 'api/v2/group'
435
- get_request(resource_path, query_parameters, nil)
436
- end
437
-
438
- # The Like API is used to get likes data from the user's social account.<br><br><b>Supported Providers:</b> Facebook
439
- #
440
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
441
- #
442
- # @return Response Containing List of Likes Data
443
- # 31.2.1
444
- def get_likes(access_token)
445
- if isNullOrWhiteSpace(access_token)
446
- raise LoginRadius::Error.new, getValidationMessage('access_token')
447
- end
448
-
449
- query_parameters = {}
450
- query_parameters['access_token'] = access_token
451
-
452
- resource_path = 'api/v2/like'
453
- get_request(resource_path, query_parameters, nil)
454
- end
455
-
456
- # The Like API is used to get likes data from the user's social account.<br><br><b>Supported Providers:</b> Facebook
457
- #
458
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
459
- # @param next_cursor - Cursor value if not all contacts can be retrieved once.
460
- #
461
- # @return Response Model containing Likes with next cursor
462
- # 31.2.2
463
- def get_likes_with_cursor(access_token, next_cursor)
464
- if isNullOrWhiteSpace(access_token)
465
- raise LoginRadius::Error.new, getValidationMessage('access_token')
466
- end
467
- if isNullOrWhiteSpace(next_cursor)
468
- raise LoginRadius::Error.new, getValidationMessage('next_cursor')
469
- end
470
-
471
- query_parameters = {}
472
- query_parameters['access_token'] = access_token
473
- query_parameters['nextCursor'] = next_cursor
474
-
475
- resource_path = 'api/v2/like'
476
- get_request(resource_path, query_parameters, nil)
477
- end
478
-
479
- # The Mention API is used to get mentions data from the user's social account.<br><br><b>Supported Providers:</b> Twitter
480
- #
481
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
482
- #
483
- # @return Response Containing List of Status Data
484
- # 32.1
485
- def get_mentions(access_token)
486
- if isNullOrWhiteSpace(access_token)
487
- raise LoginRadius::Error.new, getValidationMessage('access_token')
488
- end
489
-
490
- query_parameters = {}
491
- query_parameters['access_token'] = access_token
492
-
493
- resource_path = 'api/v2/mention'
494
- get_request(resource_path, query_parameters, nil)
495
- end
496
-
497
- # Post Message API is used to post messages to the user's contacts.<br><br><b>Supported Providers:</b> Twitter, LinkedIn <br><br>The Message API is used to post messages to the user?s contacts. This is one of the APIs that makes up the LoginRadius Friend Invite System. After using the Contact API, you can send messages to the retrieved contacts. This API requires setting permissions in your LoginRadius Dashboard.<br><br>GET & POST Message API work the same way except the API method is different
498
- #
499
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
500
- # @param message - Body of your message
501
- # @param subject - Subject of your message
502
- # @param to - Recipient's social provider's id
503
- #
504
- # @return Response containing Definition for Complete Validation data
505
- # 33.1
506
- def post_message(access_token, message, subject, to)
507
- if isNullOrWhiteSpace(access_token)
508
- raise LoginRadius::Error.new, getValidationMessage('access_token')
509
- end
510
- if isNullOrWhiteSpace(message)
511
- raise LoginRadius::Error.new, getValidationMessage('message')
512
- end
513
- if isNullOrWhiteSpace(subject)
514
- raise LoginRadius::Error.new, getValidationMessage('subject')
515
- end
516
- if isNullOrWhiteSpace(to)
517
- raise LoginRadius::Error.new, getValidationMessage('to')
518
- end
519
-
520
- query_parameters = {}
521
- query_parameters['access_token'] = access_token
522
- query_parameters['message'] = message
523
- query_parameters['subject'] = subject
524
- query_parameters['to'] = to
525
-
526
- resource_path = 'api/v2/message'
527
- post_request(resource_path, query_parameters, nil)
528
- end
529
-
530
- # The Page API is used to get the page data from the user's social account.<br><br><b>Supported Providers:</b> Facebook, LinkedIn
531
- #
532
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
533
- # @param page_name - Name of the page you want to retrieve info from
534
- #
535
- # @return Response containing Definition of Complete page data
536
- # 34.1
537
- def get_page(access_token, page_name)
538
- if isNullOrWhiteSpace(access_token)
539
- raise LoginRadius::Error.new, getValidationMessage('access_token')
540
- end
541
- if isNullOrWhiteSpace(page_name)
542
- raise LoginRadius::Error.new, getValidationMessage('page_name')
543
- end
544
-
545
- query_parameters = {}
546
- query_parameters['access_token'] = access_token
547
- query_parameters['pageName'] = page_name
548
-
549
- resource_path = 'api/v2/page'
550
- get_request(resource_path, query_parameters, nil)
551
- end
552
-
553
- # The Photo API is used to get photo data from the user's social account.<br><br><b>Supported Providers:</b> Facebook, Foursquare, Google, Live, Vkontakte
554
- #
555
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
556
- # @param album_id - The id of the album you want to retrieve info from
557
- #
558
- # @return Response Containing List of Photos Data
559
- # 35.1
560
- def get_photos(access_token, album_id)
561
- if isNullOrWhiteSpace(access_token)
562
- raise LoginRadius::Error.new, getValidationMessage('access_token')
563
- end
564
- if isNullOrWhiteSpace(album_id)
565
- raise LoginRadius::Error.new, getValidationMessage('album_id')
566
- end
567
-
568
- query_parameters = {}
569
- query_parameters['access_token'] = access_token
570
- query_parameters['albumId'] = album_id
571
-
572
- resource_path = 'api/v2/photo'
573
- get_request(resource_path, query_parameters, nil)
574
- end
575
-
576
- # The Post API is used to get post message data from the user's social account.<br><br><b>Supported Providers:</b> Facebook
577
- #
578
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
579
- #
580
- # @return Response Containing List of Posts Data
581
- # 36.1
582
- def get_posts(access_token)
583
- if isNullOrWhiteSpace(access_token)
584
- raise LoginRadius::Error.new, getValidationMessage('access_token')
585
- end
586
-
587
- query_parameters = {}
588
- query_parameters['access_token'] = access_token
589
-
590
- resource_path = 'api/v2/post'
591
- get_request(resource_path, query_parameters, nil)
592
- end
593
-
594
- # The Status API is used to update the status on the user's wall.<br><br><b>Supported Providers:</b> Facebook, Twitter, LinkedIn
595
- #
596
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
597
- # @param caption - Message displayed below the description(Requires URL, Under 70 Characters).
598
- # @param description - Description of the displayed URL and Image(Requires URL)
599
- # @param imageurl - Image to be displayed in the share(Requires URL).
600
- # @param status - Main body of the Status update.
601
- # @param title - Title of Linked URL
602
- # @param url - URL to be included when clicking on the share.
603
- # @param shorturl - short url
604
- #
605
- # @return Response conatining Definition of Validation and Short URL data
606
- # 37.2
607
- def status_posting(access_token, caption, description, imageurl, status, title, url, shorturl = '0')
608
- if isNullOrWhiteSpace(access_token)
609
- raise LoginRadius::Error.new, getValidationMessage('access_token')
610
- end
611
- if isNullOrWhiteSpace(caption)
612
- raise LoginRadius::Error.new, getValidationMessage('caption')
613
- end
614
- if isNullOrWhiteSpace(description)
615
- raise LoginRadius::Error.new, getValidationMessage('description')
616
- end
617
- if isNullOrWhiteSpace(imageurl)
618
- raise LoginRadius::Error.new, getValidationMessage('imageurl')
619
- end
620
- if isNullOrWhiteSpace(status)
621
- raise LoginRadius::Error.new, getValidationMessage('status')
622
- end
623
- if isNullOrWhiteSpace(title)
624
- raise LoginRadius::Error.new, getValidationMessage('title')
625
- end
626
- if isNullOrWhiteSpace(url)
627
- raise LoginRadius::Error.new, getValidationMessage('url')
628
- end
629
-
630
- query_parameters = {}
631
- query_parameters['access_token'] = access_token
632
- query_parameters['caption'] = caption
633
- query_parameters['description'] = description
634
- query_parameters['imageurl'] = imageurl
635
- query_parameters['status'] = status
636
- query_parameters['title'] = title
637
- query_parameters['url'] = url
638
- unless isNullOrWhiteSpace(shorturl)
639
- query_parameters['shorturl'] = shorturl
640
- end
641
-
642
- resource_path = 'api/v2/status'
643
- post_request(resource_path, query_parameters, nil)
644
- end
645
-
646
- # The Trackable status API works very similar to the Status API but it returns a Post id that you can use to track the stats(shares, likes, comments) for a specific share/post/status update. This API requires setting permissions in your LoginRadius Dashboard.<br><br> The Trackable Status API is used to update the status on the user's wall and return an Post ID value. It is commonly referred to as Permission based sharing or Push notifications.<br><br> POST Input Parameter Format: application/x-www-form-urlencoded
647
- #
648
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
649
- # @param status_model - Model Class containing Definition of payload for Status API
650
- #
651
- # @return Response containing Definition for Complete status data
652
- # 37.6
653
- def trackable_status_posting(access_token, status_model)
654
- if isNullOrWhiteSpace(access_token)
655
- raise LoginRadius::Error.new, getValidationMessage('access_token')
656
- end
657
- if status_model.blank?
658
- raise LoginRadius::Error.new, getValidationMessage('status_model')
659
- end
660
-
661
- query_parameters = {}
662
- query_parameters['access_token'] = access_token
663
-
664
- resource_path = 'api/v2/status/trackable'
665
- post_request(resource_path, query_parameters, status_model)
666
- end
667
-
668
- # The Trackable status API works very similar to the Status API but it returns a Post id that you can use to track the stats(shares, likes, comments) for a specific share/post/status update. This API requires setting permissions in your LoginRadius Dashboard.<br><br> The Trackable Status API is used to update the status on the user's wall and return an Post ID value. It is commonly referred to as Permission based sharing or Push notifications.
669
- #
670
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
671
- # @param caption - Message displayed below the description(Requires URL, Under 70 Characters).
672
- # @param description - Description of the displayed URL and Image(Requires URL)
673
- # @param imageurl - Image to be displayed in the share(Requires URL).
674
- # @param status - Main body of the Status update.
675
- # @param title - Title of Linked URL
676
- # @param url - URL to be included when clicking on the share.
677
- #
678
- # @return Response containing Definition for Complete status data
679
- # 37.7
680
- def get_trackable_status_stats(access_token, caption, description, imageurl, status, title, url)
681
- if isNullOrWhiteSpace(access_token)
682
- raise LoginRadius::Error.new, getValidationMessage('access_token')
683
- end
684
- if isNullOrWhiteSpace(caption)
685
- raise LoginRadius::Error.new, getValidationMessage('caption')
686
- end
687
- if isNullOrWhiteSpace(description)
688
- raise LoginRadius::Error.new, getValidationMessage('description')
689
- end
690
- if isNullOrWhiteSpace(imageurl)
691
- raise LoginRadius::Error.new, getValidationMessage('imageurl')
692
- end
693
- if isNullOrWhiteSpace(status)
694
- raise LoginRadius::Error.new, getValidationMessage('status')
695
- end
696
- if isNullOrWhiteSpace(title)
697
- raise LoginRadius::Error.new, getValidationMessage('title')
698
- end
699
- if isNullOrWhiteSpace(url)
700
- raise LoginRadius::Error.new, getValidationMessage('url')
701
- end
702
-
703
- query_parameters = {}
704
- query_parameters['access_token'] = access_token
705
- query_parameters['caption'] = caption
706
- query_parameters['description'] = description
707
- query_parameters['imageurl'] = imageurl
708
- query_parameters['status'] = status
709
- query_parameters['title'] = title
710
- query_parameters['url'] = url
711
-
712
- resource_path = 'api/v2/status/trackable/js'
713
- get_request(resource_path, query_parameters, nil)
714
- end
715
-
716
- # The Trackable status API works very similar to the Status API but it returns a Post id that you can use to track the stats(shares, likes, comments) for a specific share/post/status update. This API requires setting permissions in your LoginRadius Dashboard.<br><br> This API is used to retrieve a tracked post based on the passed in post ID value. This API requires setting permissions in your LoginRadius Dashboard.<br><br> <b>Note:</b> To utilize this API you need to find the ID for the post you want to track, which might require using Trackable Status Posting API first.
717
- #
718
- # @param post_id - Post ID value
719
- #
720
- # @return Response containing Definition of Complete Status Update data
721
- # 37.8
722
- def trackable_status_fetching(post_id)
723
- if isNullOrWhiteSpace(post_id)
724
- raise LoginRadius::Error.new, getValidationMessage('post_id')
725
- end
726
-
727
- query_parameters = {}
728
- query_parameters['postId'] = post_id
729
- query_parameters['secret'] = @api_secret
730
-
731
- resource_path = 'api/v2/status/trackable'
732
- get_request(resource_path, query_parameters, nil)
733
- end
734
-
735
- # The User Profile API is used to get social profile data from the user's social account after authentication.<br><br><b>Supported Providers:</b> All
736
- #
737
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
738
- # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
739
- #
740
- # @return Response containing Definition for Complete UserProfile data
741
- # 38.1
742
- def get_social_user_profile(access_token, fields = '')
743
- if isNullOrWhiteSpace(access_token)
744
- raise LoginRadius::Error.new, getValidationMessage('access_token')
745
- end
746
-
747
- query_parameters = {}
748
- query_parameters['access_token'] = access_token
749
- unless isNullOrWhiteSpace(fields)
750
- query_parameters['fields'] = fields
751
- end
752
-
753
- resource_path = 'api/v2/userprofile'
754
- get_request(resource_path, query_parameters, nil)
755
- end
756
-
757
- # The User Profile API is used to get the latest updated social profile data from the user's social account after authentication. The social profile will be retrieved via oAuth and OpenID protocols. The data is normalized into LoginRadius' standard data format. This API should be called using the access token retrieved from the refresh access token API.
758
- #
759
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
760
- # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
761
- #
762
- # @return Response containing Definition for Complete UserProfile data
763
- # 38.2
764
- def get_refreshed_social_user_profile(access_token, fields = '')
765
- if isNullOrWhiteSpace(access_token)
766
- raise LoginRadius::Error.new, getValidationMessage('access_token')
767
- end
768
-
769
- query_parameters = {}
770
- query_parameters['access_token'] = access_token
771
- unless isNullOrWhiteSpace(fields)
772
- query_parameters['fields'] = fields
773
- end
774
-
775
- resource_path = 'api/v2/userprofile/refresh'
776
- get_request(resource_path, query_parameters, nil)
777
- end
778
-
779
- # The Video API is used to get video files data from the user's social account.<br><br><b>Supported Providers:</b> Facebook, Google, Live, Vkontakte
780
- #
781
- # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
782
- # @param next_cursor - Cursor value if not all contacts can be retrieved once.
783
- #
784
- # @return Response containing Definition of Video Data with Cursor
785
- # 39.2
786
- def get_videos(access_token, next_cursor)
787
- if isNullOrWhiteSpace(access_token)
788
- raise LoginRadius::Error.new, getValidationMessage('access_token')
789
- end
790
- if isNullOrWhiteSpace(next_cursor)
791
- raise LoginRadius::Error.new, getValidationMessage('next_cursor')
792
- end
793
-
794
- query_parameters = {}
795
- query_parameters['access_token'] = access_token
796
- query_parameters['nextCursor'] = next_cursor
797
-
798
- resource_path = 'api/v2/video'
799
- get_request(resource_path, query_parameters, nil)
800
- end
801
- end
802
- 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
+ # SocialApi module
9
+ class SocialApi
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 translate the Request Token returned during authentication into an Access Token that can be used with other API calls.
29
+ #
30
+ # @param token - Token generated from a successful oauth from social platform
31
+ #
32
+ # @return Response containing Definition of Complete Token data
33
+ # 20.1
34
+ def exchange_access_token(token)
35
+ if isNullOrWhiteSpace(token)
36
+ raise LoginRadius::Error.new, getValidationMessage('token')
37
+ end
38
+
39
+ query_parameters = {}
40
+ query_parameters['secret'] = @api_secret
41
+ query_parameters['token'] = token
42
+
43
+ resource_path = 'api/v2/access_token'
44
+ get_request(resource_path, query_parameters, {})
45
+ end
46
+
47
+ # The Refresh Access Token API is used to refresh the provider access token after authentication. It will be valid for up to 60 days on LoginRadius depending on the provider. In order to use the access token in other APIs, always refresh the token using this API.<br><br><b>Supported Providers :</b> Facebook,Yahoo,Google,Twitter, Linkedin.<br><br> Contact LoginRadius support team to enable this API.
48
+ #
49
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
50
+ # @param expires_in - Allows you to specify a desired expiration time in minutes for the newly issued access token.
51
+ # @param is_web - Is web or not.
52
+ #
53
+ # @return Response containing Definition of Complete Token data
54
+ # 20.2
55
+ def refresh_access_token(access_token, expires_in, is_web = false)
56
+ if isNullOrWhiteSpace(access_token)
57
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
58
+ end
59
+
60
+ query_parameters = {}
61
+ query_parameters['access_token'] = access_token
62
+ query_parameters['secret'] = @api_secret
63
+ unless expires_in == false
64
+ query_parameters['expiresIn'] = expires_in
65
+ end
66
+ unless is_web == false
67
+ query_parameters['isWeb'] = is_web
68
+ end
69
+
70
+ resource_path = 'api/v2/access_token/refresh'
71
+ get_request(resource_path, query_parameters, {})
72
+ end
73
+
74
+ # This API validates access token, if valid then returns a response with its expiry otherwise error.
75
+ #
76
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
77
+ #
78
+ # @return Response containing Definition of Complete Token data
79
+ # 20.9
80
+ def validate_access_token(access_token)
81
+ if isNullOrWhiteSpace(access_token)
82
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
83
+ end
84
+
85
+ query_parameters = {}
86
+ query_parameters['access_token'] = access_token
87
+ query_parameters['key'] = @api_key
88
+ query_parameters['secret'] = @api_secret
89
+
90
+ resource_path = 'api/v2/access_token/validate'
91
+ get_request(resource_path, query_parameters, {})
92
+ end
93
+
94
+ # This api invalidates the active access token or expires an access token validity.
95
+ #
96
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
97
+ #
98
+ # @return Response containing Definition for Complete Validation data
99
+ # 20.10
100
+ def in_validate_access_token(access_token)
101
+ if isNullOrWhiteSpace(access_token)
102
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
103
+ end
104
+
105
+ query_parameters = {}
106
+ query_parameters['access_token'] = access_token
107
+ query_parameters['key'] = @api_key
108
+ query_parameters['secret'] = @api_secret
109
+
110
+ resource_path = 'api/v2/access_token/invalidate'
111
+ get_request(resource_path, query_parameters, {})
112
+ end
113
+
114
+ # This api is use to get all active session by Access Token.
115
+ #
116
+ # @param token - Token generated from a successful oauth from social platform
117
+ #
118
+ # @return Response containing Definition for Complete active sessions
119
+ # 20.11.1
120
+ def get_active_session(token)
121
+ if isNullOrWhiteSpace(token)
122
+ raise LoginRadius::Error.new, getValidationMessage('token')
123
+ end
124
+
125
+ query_parameters = {}
126
+ query_parameters['key'] = @api_key
127
+ query_parameters['secret'] = @api_secret
128
+ query_parameters['token'] = token
129
+
130
+ resource_path = 'api/v2/access_token/activesession'
131
+ get_request(resource_path, query_parameters, {})
132
+ end
133
+
134
+ # This api is used to get all active sessions by AccountID(UID).
135
+ #
136
+ # @param account_id - UID, the unified identifier for each user account
137
+ #
138
+ # @return Response containing Definition for Complete active sessions
139
+ # 20.11.2
140
+ def get_active_session_by_account_id(account_id)
141
+ if isNullOrWhiteSpace(account_id)
142
+ raise LoginRadius::Error.new, getValidationMessage('account_id')
143
+ end
144
+
145
+ query_parameters = {}
146
+ query_parameters['accountId'] = account_id
147
+ query_parameters['key'] = @api_key
148
+ query_parameters['secret'] = @api_secret
149
+
150
+ resource_path = 'api/v2/access_token/activesession'
151
+ get_request(resource_path, query_parameters, {})
152
+ end
153
+
154
+ # This api is used to get all active sessions by ProfileId.
155
+ #
156
+ # @param profile_id - Social Provider Id
157
+ #
158
+ # @return Response containing Definition for Complete active sessions
159
+ # 20.11.3
160
+ def get_active_session_by_profile_id(profile_id)
161
+ if isNullOrWhiteSpace(profile_id)
162
+ raise LoginRadius::Error.new, getValidationMessage('profile_id')
163
+ end
164
+
165
+ query_parameters = {}
166
+ query_parameters['key'] = @api_key
167
+ query_parameters['profileId'] = profile_id
168
+ query_parameters['secret'] = @api_secret
169
+
170
+ resource_path = 'api/v2/access_token/activesession'
171
+ get_request(resource_path, query_parameters, {})
172
+ end
173
+
174
+ # <b>Supported Providers:</b> Facebook, Google, Live, Vkontakte.<br><br> This API returns the photo albums associated with the passed in access tokens Social Profile.
175
+ #
176
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
177
+ #
178
+ # @return Response Containing List of Album Data
179
+ # 22.2.1
180
+ def get_albums(access_token)
181
+ if isNullOrWhiteSpace(access_token)
182
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
183
+ end
184
+
185
+ query_parameters = {}
186
+ query_parameters['access_token'] = access_token
187
+
188
+ resource_path = 'api/v2/album'
189
+ get_request(resource_path, query_parameters, {})
190
+ end
191
+
192
+ # <b>Supported Providers:</b> Facebook, Google, Live, Vkontakte.<br><br> This API returns the photo albums associated with the passed in access tokens Social Profile.
193
+ #
194
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
195
+ # @param next_cursor - Cursor value if not all contacts can be retrieved once.
196
+ #
197
+ # @return Response Model containing Albums with next cursor
198
+ # 22.2.2
199
+ def get_albums_with_cursor(access_token, next_cursor)
200
+ if isNullOrWhiteSpace(access_token)
201
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
202
+ end
203
+ if isNullOrWhiteSpace(next_cursor)
204
+ raise LoginRadius::Error.new, getValidationMessage('next_cursor')
205
+ end
206
+
207
+ query_parameters = {}
208
+ query_parameters['access_token'] = access_token
209
+ query_parameters['nextCursor'] = next_cursor
210
+
211
+ resource_path = 'api/v2/album'
212
+ get_request(resource_path, query_parameters, {})
213
+ end
214
+
215
+ # The Audio API is used to get audio files data from the user's social account.<br><br><b>Supported Providers:</b> Live, Vkontakte
216
+ #
217
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
218
+ #
219
+ # @return Response Containing List of Audio Data
220
+ # 24.2.1
221
+ def get_audios(access_token)
222
+ if isNullOrWhiteSpace(access_token)
223
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
224
+ end
225
+
226
+ query_parameters = {}
227
+ query_parameters['access_token'] = access_token
228
+
229
+ resource_path = 'api/v2/audio'
230
+ get_request(resource_path, query_parameters, {})
231
+ end
232
+
233
+ # The Audio API is used to get audio files data from the user's social account.<br><br><b>Supported Providers:</b> Live, Vkontakte
234
+ #
235
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
236
+ # @param next_cursor - Cursor value if not all contacts can be retrieved once.
237
+ #
238
+ # @return Response Model containing Audio with next cursor
239
+ # 24.2.2
240
+ def get_audios_with_cursor(access_token, next_cursor)
241
+ if isNullOrWhiteSpace(access_token)
242
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
243
+ end
244
+ if isNullOrWhiteSpace(next_cursor)
245
+ raise LoginRadius::Error.new, getValidationMessage('next_cursor')
246
+ end
247
+
248
+ query_parameters = {}
249
+ query_parameters['access_token'] = access_token
250
+ query_parameters['nextCursor'] = next_cursor
251
+
252
+ resource_path = 'api/v2/audio'
253
+ get_request(resource_path, query_parameters, {})
254
+ end
255
+
256
+ # The Check In API is used to get check Ins data from the user's social account.<br><br><b>Supported Providers:</b> Facebook, Foursquare, Vkontakte
257
+ #
258
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
259
+ #
260
+ # @return Response Containing List of CheckIn Data
261
+ # 25.2.1
262
+ def get_check_ins(access_token)
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
+
270
+ resource_path = 'api/v2/checkin'
271
+ get_request(resource_path, query_parameters, {})
272
+ end
273
+
274
+ # The Check In API is used to get check Ins data from the user's social account.<br><br><b>Supported Providers:</b> Facebook, Foursquare, Vkontakte
275
+ #
276
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
277
+ # @param next_cursor - Cursor value if not all contacts can be retrieved once.
278
+ #
279
+ # @return Response Model containing Checkins with next cursor
280
+ # 25.2.2
281
+ def get_check_ins_with_cursor(access_token, next_cursor)
282
+ if isNullOrWhiteSpace(access_token)
283
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
284
+ end
285
+ if isNullOrWhiteSpace(next_cursor)
286
+ raise LoginRadius::Error.new, getValidationMessage('next_cursor')
287
+ end
288
+
289
+ query_parameters = {}
290
+ query_parameters['access_token'] = access_token
291
+ query_parameters['nextCursor'] = next_cursor
292
+
293
+ resource_path = 'api/v2/checkin'
294
+ get_request(resource_path, query_parameters, {})
295
+ end
296
+
297
+ # The Contact API is used to get contacts/friends/connections data from the user's social account.This is one of the APIs that makes up the LoginRadius Friend Invite System. The data will normalized into LoginRadius' standard data format. This API requires setting permissions in your LoginRadius Dashboard. <br><br><b>Note:</b> Facebook restricts access to the list of friends that is returned. When using the Contacts API with Facebook you will only receive friends that have accepted some permissions with your app. <br><br><b>Supported Providers:</b> Facebook, Foursquare, Google, LinkedIn, Live, Twitter, Vkontakte, Yahoo
298
+ #
299
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
300
+ # @param next_cursor - Cursor value if not all contacts can be retrieved once.
301
+ #
302
+ # @return Response containing Definition of Contact Data with Cursor
303
+ # 27.1
304
+ def get_contacts(access_token, next_cursor = '')
305
+ if isNullOrWhiteSpace(access_token)
306
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
307
+ end
308
+
309
+ query_parameters = {}
310
+ query_parameters['access_token'] = access_token
311
+ unless isNullOrWhiteSpace(next_cursor)
312
+ query_parameters['nextCursor'] = next_cursor
313
+ end
314
+
315
+ resource_path = 'api/v2/contact'
316
+ get_request(resource_path, query_parameters, {})
317
+ end
318
+
319
+ # The Event API is used to get the event data from the user's social account.<br><br><b>Supported Providers:</b> Facebook, Live
320
+ #
321
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
322
+ #
323
+ # @return Response Containing List of Events Data
324
+ # 28.2.1
325
+ def get_events(access_token)
326
+ if isNullOrWhiteSpace(access_token)
327
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
328
+ end
329
+
330
+ query_parameters = {}
331
+ query_parameters['access_token'] = access_token
332
+
333
+ resource_path = 'api/v2/event'
334
+ get_request(resource_path, query_parameters, {})
335
+ end
336
+
337
+ # The Event API is used to get the event data from the user's social account.<br><br><b>Supported Providers:</b> Facebook, Live
338
+ #
339
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
340
+ # @param next_cursor - Cursor value if not all contacts can be retrieved once.
341
+ #
342
+ # @return Response Model containing Events with next cursor
343
+ # 28.2.2
344
+ def get_events_with_cursor(access_token, next_cursor)
345
+ if isNullOrWhiteSpace(access_token)
346
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
347
+ end
348
+ if isNullOrWhiteSpace(next_cursor)
349
+ raise LoginRadius::Error.new, getValidationMessage('next_cursor')
350
+ end
351
+
352
+ query_parameters = {}
353
+ query_parameters['access_token'] = access_token
354
+ query_parameters['nextCursor'] = next_cursor
355
+
356
+ resource_path = 'api/v2/event'
357
+ get_request(resource_path, query_parameters, {})
358
+ end
359
+
360
+ # Get the following user list from the user's social account.<br><br><b>Supported Providers:</b> Twitter
361
+ #
362
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
363
+ #
364
+ # @return Response Containing List of Contacts Data
365
+ # 29.2.1
366
+ def get_followings(access_token)
367
+ if isNullOrWhiteSpace(access_token)
368
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
369
+ end
370
+
371
+ query_parameters = {}
372
+ query_parameters['access_token'] = access_token
373
+
374
+ resource_path = 'api/v2/following'
375
+ get_request(resource_path, query_parameters, {})
376
+ end
377
+
378
+ # Get the following user list from the user's social account.<br><br><b>Supported Providers:</b> Twitter
379
+ #
380
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
381
+ # @param next_cursor - Cursor value if not all contacts can be retrieved once.
382
+ #
383
+ # @return Response containing Definition of Contact Data with Cursor
384
+ # 29.2.2
385
+ def get_followings_with_cursor(access_token, next_cursor)
386
+ if isNullOrWhiteSpace(access_token)
387
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
388
+ end
389
+ if isNullOrWhiteSpace(next_cursor)
390
+ raise LoginRadius::Error.new, getValidationMessage('next_cursor')
391
+ end
392
+
393
+ query_parameters = {}
394
+ query_parameters['access_token'] = access_token
395
+ query_parameters['nextCursor'] = next_cursor
396
+
397
+ resource_path = 'api/v2/following'
398
+ get_request(resource_path, query_parameters, {})
399
+ end
400
+
401
+ # The Group API is used to get group data from the user's social account.<br><br><b>Supported Providers:</b> Facebook, Vkontakte
402
+ #
403
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
404
+ #
405
+ # @return Response Containing List of Groups Data
406
+ # 30.2.1
407
+ def get_groups(access_token)
408
+ if isNullOrWhiteSpace(access_token)
409
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
410
+ end
411
+
412
+ query_parameters = {}
413
+ query_parameters['access_token'] = access_token
414
+
415
+ resource_path = 'api/v2/group'
416
+ get_request(resource_path, query_parameters, {})
417
+ end
418
+
419
+ # The Group API is used to get group data from the user's social account.<br><br><b>Supported Providers:</b> Facebook, Vkontakte
420
+ #
421
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
422
+ # @param next_cursor - Cursor value if not all contacts can be retrieved once.
423
+ #
424
+ # @return Response Model containing Groups with next cursor
425
+ # 30.2.2
426
+ def get_groups_with_cursor(access_token, next_cursor)
427
+ if isNullOrWhiteSpace(access_token)
428
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
429
+ end
430
+ if isNullOrWhiteSpace(next_cursor)
431
+ raise LoginRadius::Error.new, getValidationMessage('next_cursor')
432
+ end
433
+
434
+ query_parameters = {}
435
+ query_parameters['access_token'] = access_token
436
+ query_parameters['nextCursor'] = next_cursor
437
+
438
+ resource_path = 'api/v2/group'
439
+ get_request(resource_path, query_parameters, {})
440
+ end
441
+
442
+ # The Like API is used to get likes data from the user's social account.<br><br><b>Supported Providers:</b> Facebook
443
+ #
444
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
445
+ #
446
+ # @return Response Containing List of Likes Data
447
+ # 31.2.1
448
+ def get_likes(access_token)
449
+ if isNullOrWhiteSpace(access_token)
450
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
451
+ end
452
+
453
+ query_parameters = {}
454
+ query_parameters['access_token'] = access_token
455
+
456
+ resource_path = 'api/v2/like'
457
+ get_request(resource_path, query_parameters, {})
458
+ end
459
+
460
+ # The Like API is used to get likes data from the user's social account.<br><br><b>Supported Providers:</b> Facebook
461
+ #
462
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
463
+ # @param next_cursor - Cursor value if not all contacts can be retrieved once.
464
+ #
465
+ # @return Response Model containing Likes with next cursor
466
+ # 31.2.2
467
+ def get_likes_with_cursor(access_token, next_cursor)
468
+ if isNullOrWhiteSpace(access_token)
469
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
470
+ end
471
+ if isNullOrWhiteSpace(next_cursor)
472
+ raise LoginRadius::Error.new, getValidationMessage('next_cursor')
473
+ end
474
+
475
+ query_parameters = {}
476
+ query_parameters['access_token'] = access_token
477
+ query_parameters['nextCursor'] = next_cursor
478
+
479
+ resource_path = 'api/v2/like'
480
+ get_request(resource_path, query_parameters, {})
481
+ end
482
+
483
+ # The Mention API is used to get mentions data from the user's social account.<br><br><b>Supported Providers:</b> Twitter
484
+ #
485
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
486
+ #
487
+ # @return Response Containing List of Status Data
488
+ # 32.1
489
+ def get_mentions(access_token)
490
+ if isNullOrWhiteSpace(access_token)
491
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
492
+ end
493
+
494
+ query_parameters = {}
495
+ query_parameters['access_token'] = access_token
496
+
497
+ resource_path = 'api/v2/mention'
498
+ get_request(resource_path, query_parameters, {})
499
+ end
500
+
501
+ # Post Message API is used to post messages to the user's contacts.<br><br><b>Supported Providers:</b> Twitter, LinkedIn <br><br>The Message API is used to post messages to the user?s contacts. This is one of the APIs that makes up the LoginRadius Friend Invite System. After using the Contact API, you can send messages to the retrieved contacts. This API requires setting permissions in your LoginRadius Dashboard.<br><br>GET & POST Message API work the same way except the API method is different
502
+ #
503
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
504
+ # @param message - Body of your message
505
+ # @param subject - Subject of your message
506
+ # @param to - Recipient's social provider's id
507
+ #
508
+ # @return Response containing Definition for Complete Validation data
509
+ # 33.1
510
+ def post_message(access_token, message, subject, to)
511
+ if isNullOrWhiteSpace(access_token)
512
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
513
+ end
514
+ if isNullOrWhiteSpace(message)
515
+ raise LoginRadius::Error.new, getValidationMessage('message')
516
+ end
517
+ if isNullOrWhiteSpace(subject)
518
+ raise LoginRadius::Error.new, getValidationMessage('subject')
519
+ end
520
+ if isNullOrWhiteSpace(to)
521
+ raise LoginRadius::Error.new, getValidationMessage('to')
522
+ end
523
+
524
+ query_parameters = {}
525
+ query_parameters['access_token'] = access_token
526
+ query_parameters['message'] = message
527
+ query_parameters['subject'] = subject
528
+ query_parameters['to'] = to
529
+
530
+ resource_path = 'api/v2/message'
531
+ post_request(resource_path, query_parameters, {})
532
+ end
533
+
534
+ # The Page API is used to get the page data from the user's social account.<br><br><b>Supported Providers:</b> Facebook, LinkedIn
535
+ #
536
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
537
+ # @param page_name - Name of the page you want to retrieve info from
538
+ #
539
+ # @return Response containing Definition of Complete page data
540
+ # 34.1
541
+ def get_page(access_token, page_name)
542
+ if isNullOrWhiteSpace(access_token)
543
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
544
+ end
545
+ if isNullOrWhiteSpace(page_name)
546
+ raise LoginRadius::Error.new, getValidationMessage('page_name')
547
+ end
548
+
549
+ query_parameters = {}
550
+ query_parameters['access_token'] = access_token
551
+ query_parameters['pageName'] = page_name
552
+
553
+ resource_path = 'api/v2/page'
554
+ get_request(resource_path, query_parameters, {})
555
+ end
556
+
557
+ # The Photo API is used to get photo data from the user's social account.<br><br><b>Supported Providers:</b> Facebook, Foursquare, Google, Live, Vkontakte
558
+ #
559
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
560
+ # @param album_id - The id of the album you want to retrieve info from
561
+ #
562
+ # @return Response Containing List of Photos Data
563
+ # 35.1
564
+ def get_photos(access_token, album_id)
565
+ if isNullOrWhiteSpace(access_token)
566
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
567
+ end
568
+ if isNullOrWhiteSpace(album_id)
569
+ raise LoginRadius::Error.new, getValidationMessage('album_id')
570
+ end
571
+
572
+ query_parameters = {}
573
+ query_parameters['access_token'] = access_token
574
+ query_parameters['albumId'] = album_id
575
+
576
+ resource_path = 'api/v2/photo'
577
+ get_request(resource_path, query_parameters, {})
578
+ end
579
+
580
+ # The Post API is used to get post message data from the user's social account.<br><br><b>Supported Providers:</b> Facebook
581
+ #
582
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
583
+ #
584
+ # @return Response Containing List of Posts Data
585
+ # 36.1
586
+ def get_posts(access_token)
587
+ if isNullOrWhiteSpace(access_token)
588
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
589
+ end
590
+
591
+ query_parameters = {}
592
+ query_parameters['access_token'] = access_token
593
+
594
+ resource_path = 'api/v2/post'
595
+ get_request(resource_path, query_parameters, {})
596
+ end
597
+
598
+ # The Status API is used to update the status on the user's wall.<br><br><b>Supported Providers:</b> Facebook, Twitter, LinkedIn
599
+ #
600
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
601
+ # @param caption - Message displayed below the description(Requires URL, Under 70 Characters).
602
+ # @param description - Description of the displayed URL and Image(Requires URL)
603
+ # @param imageurl - Image to be displayed in the share(Requires URL).
604
+ # @param status - Main body of the Status update.
605
+ # @param title - Title of Linked URL
606
+ # @param url - URL to be included when clicking on the share.
607
+ # @param shorturl - short url
608
+ #
609
+ # @return Response conatining Definition of Validation and Short URL data
610
+ # 37.2
611
+ def status_posting(access_token, caption, description, imageurl, status, title, url, shorturl = '0')
612
+ if isNullOrWhiteSpace(access_token)
613
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
614
+ end
615
+ if isNullOrWhiteSpace(caption)
616
+ raise LoginRadius::Error.new, getValidationMessage('caption')
617
+ end
618
+ if isNullOrWhiteSpace(description)
619
+ raise LoginRadius::Error.new, getValidationMessage('description')
620
+ end
621
+ if isNullOrWhiteSpace(imageurl)
622
+ raise LoginRadius::Error.new, getValidationMessage('imageurl')
623
+ end
624
+ if isNullOrWhiteSpace(status)
625
+ raise LoginRadius::Error.new, getValidationMessage('status')
626
+ end
627
+ if isNullOrWhiteSpace(title)
628
+ raise LoginRadius::Error.new, getValidationMessage('title')
629
+ end
630
+ if isNullOrWhiteSpace(url)
631
+ raise LoginRadius::Error.new, getValidationMessage('url')
632
+ end
633
+
634
+ query_parameters = {}
635
+ query_parameters['access_token'] = access_token
636
+ query_parameters['caption'] = caption
637
+ query_parameters['description'] = description
638
+ query_parameters['imageurl'] = imageurl
639
+ query_parameters['status'] = status
640
+ query_parameters['title'] = title
641
+ query_parameters['url'] = url
642
+ unless isNullOrWhiteSpace(shorturl)
643
+ query_parameters['shorturl'] = shorturl
644
+ end
645
+
646
+ resource_path = 'api/v2/status'
647
+ post_request(resource_path, query_parameters, {})
648
+ end
649
+
650
+ # The Trackable status API works very similar to the Status API but it returns a Post id that you can use to track the stats(shares, likes, comments) for a specific share/post/status update. This API requires setting permissions in your LoginRadius Dashboard.<br><br> The Trackable Status API is used to update the status on the user's wall and return an Post ID value. It is commonly referred to as Permission based sharing or Push notifications.<br><br> POST Input Parameter Format: application/x-www-form-urlencoded
651
+ #
652
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
653
+ # @param status_model - Model Class containing Definition of payload for Status API
654
+ #
655
+ # @return Response containing Definition for Complete status data
656
+ # 37.6
657
+ def trackable_status_posting(access_token, status_model)
658
+ if isNullOrWhiteSpace(access_token)
659
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
660
+ end
661
+ if status_model.blank?
662
+ raise LoginRadius::Error.new, getValidationMessage('status_model')
663
+ end
664
+
665
+ query_parameters = {}
666
+ query_parameters['access_token'] = access_token
667
+
668
+ resource_path = 'api/v2/status/trackable'
669
+ post_request(resource_path, query_parameters, status_model)
670
+ end
671
+
672
+ # The Trackable status API works very similar to the Status API but it returns a Post id that you can use to track the stats(shares, likes, comments) for a specific share/post/status update. This API requires setting permissions in your LoginRadius Dashboard.<br><br> The Trackable Status API is used to update the status on the user's wall and return an Post ID value. It is commonly referred to as Permission based sharing or Push notifications.
673
+ #
674
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
675
+ # @param caption - Message displayed below the description(Requires URL, Under 70 Characters).
676
+ # @param description - Description of the displayed URL and Image(Requires URL)
677
+ # @param imageurl - Image to be displayed in the share(Requires URL).
678
+ # @param status - Main body of the Status update.
679
+ # @param title - Title of Linked URL
680
+ # @param url - URL to be included when clicking on the share.
681
+ #
682
+ # @return Response containing Definition for Complete status data
683
+ # 37.7
684
+ def get_trackable_status_stats(access_token, caption, description, imageurl, status, title, url)
685
+ if isNullOrWhiteSpace(access_token)
686
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
687
+ end
688
+ if isNullOrWhiteSpace(caption)
689
+ raise LoginRadius::Error.new, getValidationMessage('caption')
690
+ end
691
+ if isNullOrWhiteSpace(description)
692
+ raise LoginRadius::Error.new, getValidationMessage('description')
693
+ end
694
+ if isNullOrWhiteSpace(imageurl)
695
+ raise LoginRadius::Error.new, getValidationMessage('imageurl')
696
+ end
697
+ if isNullOrWhiteSpace(status)
698
+ raise LoginRadius::Error.new, getValidationMessage('status')
699
+ end
700
+ if isNullOrWhiteSpace(title)
701
+ raise LoginRadius::Error.new, getValidationMessage('title')
702
+ end
703
+ if isNullOrWhiteSpace(url)
704
+ raise LoginRadius::Error.new, getValidationMessage('url')
705
+ end
706
+
707
+ query_parameters = {}
708
+ query_parameters['access_token'] = access_token
709
+ query_parameters['caption'] = caption
710
+ query_parameters['description'] = description
711
+ query_parameters['imageurl'] = imageurl
712
+ query_parameters['status'] = status
713
+ query_parameters['title'] = title
714
+ query_parameters['url'] = url
715
+
716
+ resource_path = 'api/v2/status/trackable/js'
717
+ get_request(resource_path, query_parameters, {})
718
+ end
719
+
720
+ # The Trackable status API works very similar to the Status API but it returns a Post id that you can use to track the stats(shares, likes, comments) for a specific share/post/status update. This API requires setting permissions in your LoginRadius Dashboard.<br><br> This API is used to retrieve a tracked post based on the passed in post ID value. This API requires setting permissions in your LoginRadius Dashboard.<br><br> <b>Note:</b> To utilize this API you need to find the ID for the post you want to track, which might require using Trackable Status Posting API first.
721
+ #
722
+ # @param post_id - Post ID value
723
+ #
724
+ # @return Response containing Definition of Complete Status Update data
725
+ # 37.8
726
+ def trackable_status_fetching(post_id)
727
+ if isNullOrWhiteSpace(post_id)
728
+ raise LoginRadius::Error.new, getValidationMessage('post_id')
729
+ end
730
+
731
+ query_parameters = {}
732
+ query_parameters['postId'] = post_id
733
+ query_parameters['secret'] = @api_secret
734
+
735
+ resource_path = 'api/v2/status/trackable'
736
+ get_request(resource_path, query_parameters, {})
737
+ end
738
+
739
+ # The User Profile API is used to get the latest updated social profile data from the user's social account after authentication. The social profile will be retrieved via oAuth and OpenID protocols. The data is normalized into LoginRadius' standard data format. This API should be called using the access token retrieved from the refresh access token API.
740
+ #
741
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
742
+ # @param fields - The fields parameter filters the API response so that the response only includes a specific set of fields
743
+ #
744
+ # @return Response containing Definition for Complete UserProfile data
745
+ # 38.2
746
+ def get_refreshed_social_user_profile(access_token, fields = '')
747
+ if isNullOrWhiteSpace(access_token)
748
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
749
+ end
750
+
751
+ query_parameters = {}
752
+ query_parameters['access_token'] = access_token
753
+ unless isNullOrWhiteSpace(fields)
754
+ query_parameters['fields'] = fields
755
+ end
756
+
757
+ resource_path = 'api/v2/userprofile/refresh'
758
+ get_request(resource_path, query_parameters, {})
759
+ end
760
+
761
+ # The Video API is used to get video files data from the user's social account.<br><br><b>Supported Providers:</b> Facebook, Google, Live, Vkontakte
762
+ #
763
+ # @param access_token - Uniquely generated identifier key by LoginRadius that is activated after successful authentication.
764
+ # @param next_cursor - Cursor value if not all contacts can be retrieved once.
765
+ #
766
+ # @return Response containing Definition of Video Data with Cursor
767
+ # 39.2
768
+ def get_videos(access_token, next_cursor)
769
+ if isNullOrWhiteSpace(access_token)
770
+ raise LoginRadius::Error.new, getValidationMessage('access_token')
771
+ end
772
+ if isNullOrWhiteSpace(next_cursor)
773
+ raise LoginRadius::Error.new, getValidationMessage('next_cursor')
774
+ end
775
+
776
+ query_parameters = {}
777
+ query_parameters['access_token'] = access_token
778
+ query_parameters['nextCursor'] = next_cursor
779
+
780
+ resource_path = 'api/v2/video'
781
+ get_request(resource_path, query_parameters, {})
782
+ end
783
+ end
784
+ end