ribose 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +539 -970
  4. data/.sample.pryrc +4 -0
  5. data/CHANGELOG.md +5 -0
  6. data/README.md +539 -3
  7. data/bin/console +2 -5
  8. data/lib/ribose.rb +31 -1
  9. data/lib/ribose/actions.rb +10 -0
  10. data/lib/ribose/actions/all.rb +43 -0
  11. data/lib/ribose/actions/base.rb +11 -0
  12. data/lib/ribose/actions/create.rb +44 -0
  13. data/lib/ribose/actions/delete.rb +32 -0
  14. data/lib/ribose/actions/fetch.rb +44 -0
  15. data/lib/ribose/actions/update.rb +35 -0
  16. data/lib/ribose/app_data.rb +15 -0
  17. data/lib/ribose/app_relation.rb +12 -0
  18. data/lib/ribose/base.rb +48 -0
  19. data/lib/ribose/calendar.rb +22 -0
  20. data/lib/ribose/client.rb +31 -0
  21. data/lib/ribose/config.rb +21 -0
  22. data/lib/ribose/configuration.rb +25 -0
  23. data/lib/ribose/connection.rb +39 -0
  24. data/lib/ribose/connection_invitation.rb +51 -0
  25. data/lib/ribose/conversation.rb +87 -0
  26. data/lib/ribose/error.rb +30 -0
  27. data/lib/ribose/feed.rb +11 -0
  28. data/lib/ribose/file_uploader.rb +93 -0
  29. data/lib/ribose/join_space_request.rb +41 -0
  30. data/lib/ribose/leaderboard.rb +19 -0
  31. data/lib/ribose/member.rb +34 -0
  32. data/lib/ribose/message.rb +94 -0
  33. data/lib/ribose/profile.rb +56 -0
  34. data/lib/ribose/request.rb +122 -0
  35. data/lib/ribose/resource_helper.rb +81 -0
  36. data/lib/ribose/response/raise_error.rb +15 -0
  37. data/lib/ribose/rspec.rb +19 -0
  38. data/lib/ribose/session.rb +48 -0
  39. data/lib/ribose/setting.rb +16 -0
  40. data/lib/ribose/space.rb +30 -0
  41. data/lib/ribose/space_file.rb +49 -0
  42. data/lib/ribose/space_invitation.rb +70 -0
  43. data/lib/ribose/stream.rb +15 -0
  44. data/lib/ribose/user.rb +42 -0
  45. data/lib/ribose/version.rb +1 -1
  46. data/lib/ribose/widget.rb +11 -0
  47. data/lib/ribose/wiki.rb +80 -0
  48. data/ribose.gemspec +6 -0
  49. data/spec/fixtures/app_data.json +188 -0
  50. data/spec/fixtures/app_relation.json +19 -0
  51. data/spec/fixtures/app_relations.json +89 -0
  52. data/spec/fixtures/calendar.json +12 -0
  53. data/spec/fixtures/calendars.json +34 -0
  54. data/spec/fixtures/connection_invitation.json +26 -0
  55. data/spec/fixtures/connection_invitation_accepted.json +26 -0
  56. data/spec/fixtures/connection_invitations.json +28 -0
  57. data/spec/fixtures/connection_invitations_created.json +37 -0
  58. data/spec/fixtures/connection_suggestion.json +22 -0
  59. data/spec/fixtures/connections.json +28 -0
  60. data/spec/fixtures/conversation.json +26 -0
  61. data/spec/fixtures/conversation_created.json +31 -0
  62. data/spec/fixtures/conversations.json +34 -0
  63. data/spec/fixtures/empty.json +1 -0
  64. data/spec/fixtures/feeds.json +84 -0
  65. data/spec/fixtures/file_upload_prepared.json +17 -0
  66. data/spec/fixtures/file_uploaded.json +38 -0
  67. data/spec/fixtures/general_information.json +16 -0
  68. data/spec/fixtures/join_space_request_created.json +26 -0
  69. data/spec/fixtures/join_space_request_updated.json +25 -0
  70. data/spec/fixtures/join_space_requests.json +34 -0
  71. data/spec/fixtures/leaderboard.json +21 -0
  72. data/spec/fixtures/login.html +323 -0
  73. data/spec/fixtures/members.json +20 -0
  74. data/spec/fixtures/message.json +22 -0
  75. data/spec/fixtures/messages.json +24 -0
  76. data/spec/fixtures/ping.json +3 -0
  77. data/spec/fixtures/profile.json +10 -0
  78. data/spec/fixtures/sample.png +0 -0
  79. data/spec/fixtures/setting.json +16 -0
  80. data/spec/fixtures/settings.json +18 -0
  81. data/spec/fixtures/space.json +59 -0
  82. data/spec/fixtures/space_created.json +59 -0
  83. data/spec/fixtures/space_file.json +58 -0
  84. data/spec/fixtures/space_invitation.json +32 -0
  85. data/spec/fixtures/space_invitation_updated.json +35 -0
  86. data/spec/fixtures/space_invitations.json +34 -0
  87. data/spec/fixtures/space_mass_invitations.json +46 -0
  88. data/spec/fixtures/spaces.json +61 -0
  89. data/spec/fixtures/stream.json +176 -0
  90. data/spec/fixtures/user_activated.json +6 -0
  91. data/spec/fixtures/widgets.json +50 -0
  92. data/spec/fixtures/wiki.json +79 -0
  93. data/spec/fixtures/wikis.json +197 -0
  94. data/spec/ribose/actions/create_spec.rb +40 -0
  95. data/spec/ribose/actions/delete_spec.rb +24 -0
  96. data/spec/ribose/actions/fetch_spec.rb +32 -0
  97. data/spec/ribose/actions/update_spec.rb +36 -0
  98. data/spec/ribose/app_data_spec.rb +15 -0
  99. data/spec/ribose/app_relation_spec.rb +27 -0
  100. data/spec/ribose/calendar_spec.rb +50 -0
  101. data/spec/ribose/client_spec.rb +48 -0
  102. data/spec/ribose/config_spec.rb +41 -0
  103. data/spec/ribose/connection_invitation_spec.rb +79 -0
  104. data/spec/ribose/connection_spec.rb +26 -0
  105. data/spec/ribose/conversation_spec.rb +84 -0
  106. data/spec/ribose/error_spec.rb +67 -0
  107. data/spec/ribose/feed_spec.rb +14 -0
  108. data/spec/ribose/file_uploader_spec.rb +30 -0
  109. data/spec/ribose/join_space_request_spec.rb +70 -0
  110. data/spec/ribose/leaderboard_spec.rb +13 -0
  111. data/spec/ribose/member_spec.rb +16 -0
  112. data/spec/ribose/message_spec.rb +69 -0
  113. data/spec/ribose/profile_spec.rb +40 -0
  114. data/spec/ribose/request_spec.rb +66 -0
  115. data/spec/ribose/resource_helper_spec.rb +58 -0
  116. data/spec/ribose/session_spec.rb +46 -0
  117. data/spec/ribose/setting_spec.rb +40 -0
  118. data/spec/ribose/space_file_spec.rb +41 -0
  119. data/spec/ribose/space_invitation_spec.rb +117 -0
  120. data/spec/ribose/space_spec.rb +70 -0
  121. data/spec/ribose/stream_spec.rb +14 -0
  122. data/spec/ribose/user_spec.rb +48 -0
  123. data/spec/ribose/widget_spec.rb +14 -0
  124. data/spec/ribose/wiki_spec.rb +67 -0
  125. data/spec/spec_helper.rb +11 -0
  126. data/spec/support/fake_ribose_api.rb +431 -0
  127. data/spec/support/file_upload_stub.rb +76 -0
  128. metadata +190 -3
  129. data/spec/ribose_spec.rb +0 -4
data/.sample.pryrc ADDED
@@ -0,0 +1,4 @@
1
+ Ribose.configure do |config|
2
+ config.api_token = "your_secret_api_token"
3
+ config.user_email = "the_email_you_used_for_ribose"
4
+ end
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## 0.2.0 (2017-11-30)
2
+
3
+ Features:
4
+
5
+ - Initial functional release.
data/README.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # Ribose
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ribose`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ [![Build
4
+ Status](https://travis-ci.org/riboseinc/ribose-ruby.svg?branch=master)](https://travis-ci.org/riboseinc/ribose-ruby)
5
+ [![Code
6
+ Climate](https://codeclimate.com/github/riboseinc/ribose-ruby/badges/gpa.svg)](https://codeclimate.com/github/riboseinc/ribose-ruby)
7
+ [![Gem Version](https://badge.fury.io/rb/ribose.svg)](https://badge.fury.io/rb/ribose)
4
8
 
5
- TODO: Delete this and the text above, and describe your gem
9
+ The Ruby Interface to the Ribose API.
6
10
 
7
11
  ## Installation
8
12
 
@@ -24,9 +28,541 @@ Or install it yourself as:
24
28
  $ gem install ribose
25
29
  ```
26
30
 
31
+ ## Configure
32
+
33
+ We need to setup Ribose API configuration before we can perform any request
34
+ throughout this client, and to request an API Key please contact Ribose Inc.
35
+ Once you have your API key then you can configure it by adding an initializer
36
+ with the following code
37
+
38
+ ```ruby
39
+ Ribose.configure do |config|
40
+ config.api_token = "SECRET_API_TOKEN"
41
+ config.user_email = "your-email@example.com"
42
+
43
+ # There are also some default configurations, normally you do not need to
44
+ # change those unless you have some very specific use case scenario.
45
+ #
46
+ # config.debug_mode = false
47
+ # config.api_host = "www.ribose.com"
48
+ end
49
+ ```
50
+
51
+ Or
52
+
53
+ ```ruby
54
+ Ribose.configuration.api_token = "SECRET_API_TOKEN"
55
+ Ribose.configuration.user_email = "your-email@example.com"
56
+ ```
57
+
27
58
  ## Usage
28
59
 
29
- TODO: Write usage instructions here
60
+ ### App Data
61
+
62
+ Ribose API provides an easier way to retrieve the list of App data, and to
63
+ retrieve the list of app data we can use the `AppData.all` interface.
64
+
65
+ ```ruby
66
+ Ribose::AppData.all
67
+ ```
68
+
69
+ ### App Relation
70
+
71
+ #### List app relations
72
+
73
+ To retrieve the list of app relations we can use the `AppRelation.all` interface
74
+
75
+ ```ruby
76
+ Ribose::AppRelation.all
77
+ ```
78
+
79
+ #### Fetch an app relation
80
+
81
+ To retrieve the details for a specific app relation, we can use the following
82
+ interface
83
+
84
+ ```ruby
85
+ Ribose::AppRelation.fetch(app_relation_id)
86
+ ```
87
+
88
+ ### Profile
89
+
90
+ #### Fetch user profile
91
+
92
+ ```ruby
93
+ Ribose::Profile.fetch
94
+ ```
95
+
96
+ #### Update user profile
97
+
98
+ ```ruby
99
+ Ribose::Profile.update(first_name: "John", last_name: "Doe")
100
+ ```
101
+
102
+ #### Set user login
103
+
104
+ ```ruby
105
+ Ribose::Profile.set_login(login_name)
106
+ ```
107
+
108
+ ### Settings
109
+
110
+ #### List user's settings
111
+
112
+ To list user's settings we can use the `Setting.all` interface, and it will
113
+ return all of the user's settings.
114
+
115
+ ```ruby
116
+ Ribose::Setting.all
117
+ ```
118
+
119
+ #### Fetch a setting
120
+
121
+ To fetch the details for any specific settings we can use the `Setting.fetch`
122
+ interface and it will return the details for that setting.
123
+
124
+ ```ruby
125
+ Ribose::Setting.fetch(setting_id)
126
+ ```
127
+
128
+ #### Update a setting
129
+
130
+ ```ruby
131
+ Ribose::Setting.update(setting_id, **new_updated_attributes_hash)
132
+ ```
133
+
134
+ ### Spaces
135
+
136
+ #### List user's spaces
137
+
138
+ To list user's spaces we can use the `Space.all` interface, and it will retrieve
139
+ all of the spaces for the currently configured user.
140
+
141
+ ```ruby
142
+ Ribose::Space.all
143
+ ```
144
+
145
+ #### Fetch a user space
146
+
147
+ To retrieve the details for a space we can use the `Space.fetch(space_id)`.
148
+
149
+ ```ruby
150
+ Ribose::Space.fetch(space_id)
151
+ ```
152
+
153
+ #### Create a user space
154
+
155
+ To create a new user space we can use
156
+
157
+ ```ruby
158
+ Ribose::Space.create(
159
+ access: "private",
160
+ space_category_id: 12,
161
+ name: "The amazing Ribose Space",
162
+ description: "Description about your space"
163
+ )
164
+ ```
165
+
166
+ #### Update a user space
167
+
168
+ ```ruby
169
+ Ribose::Space.update("space_uuid", name: "New updated name", **other_attributes)
170
+ ```
171
+
172
+ #### Remove a user space
173
+
174
+ To remove an existing space and we can use the following interface
175
+
176
+ ```ruby
177
+ Ribose::Space.remove(space_uuid, confirmation: true)
178
+ ```
179
+
180
+ ### Members
181
+
182
+ The members endpoint are space specific, to retrieve the member details under
183
+ any specific space we can use this interface.
184
+
185
+ ### List of Members
186
+
187
+ To retrieve the list of members, we can use the following interface.
188
+
189
+ ```ruby
190
+ Ribose::Member.all(space_id, options)
191
+ ```
192
+
193
+ ### Files
194
+
195
+ #### List of Files
196
+
197
+ To retrieves the files for any specific space we can use the following interface
198
+
199
+ ```ruby
200
+ Ribose::SpaceFile.all(space_id, options)
201
+ ```
202
+
203
+ ### Create a file upload
204
+
205
+ ```ruby
206
+ Ribose::SpaceFile.create(space_id, file: "The complete file path", **attributes)
207
+ ```
208
+
209
+ ### Conversations
210
+
211
+ #### Listing Space Conversations
212
+
213
+ ```ruby
214
+ Ribose::Conversation.all(space_id, options = {})
215
+ ```
216
+
217
+ #### Retrieve a conversation details
218
+
219
+ ```ruby
220
+ Ribose::Conversation.fetch(space_id, conversation_id)
221
+ ```
222
+
223
+ #### Create A New Conversation
224
+
225
+ ```ruby
226
+ Ribose::Conversation.create(
227
+ space_id, name: "Sample conversation", tag_list: "sample, conversation"
228
+ )
229
+ ```
230
+
231
+ #### Update a conversation
232
+
233
+ ```ruby
234
+ Ribose::Conversation.update(space_id, conversation_id, new_attributes_hash)
235
+ ```
236
+
237
+ #### Remove A Conversation
238
+
239
+ ```ruby
240
+ Ribose::Conversation.destroy(space_id: "space_id", conversation_id: "12345")
241
+ ```
242
+
243
+ ### Message
244
+
245
+ #### List Conversation Messages
246
+
247
+ ```ruby
248
+ Ribose::Message.all(space_id: space_uuid, conversation_id: conversation_uuid)
249
+ ```
250
+
251
+ #### Create a new message
252
+
253
+ ```ruby
254
+ Ribose::Message.create(
255
+ space_id: space_uuid,
256
+ conversation_id: conversation_uuid,
257
+ contents: "Provide your message body here",
258
+ )
259
+ ```
260
+
261
+ #### Update an existing message
262
+
263
+ ```ruby
264
+ Ribose::Message.update(
265
+ space_id: space_uuid,
266
+ message_id: message_uuid,
267
+ conversation_id: conversation_uuid,
268
+ contents: "The new content for message",
269
+ )
270
+ ```
271
+
272
+ #### Remove a message
273
+
274
+ ```ruby
275
+ Ribose::Message.remove(
276
+ space_id: space_uuid,
277
+ message_id: message_uuid,
278
+ conversation_id: conversation_uuid,
279
+ )
280
+ ```
281
+
282
+ ### Feeds
283
+
284
+ #### List user feeds
285
+
286
+ To retrieve the list of user feeds, we can use the `Feed.all` interface
287
+
288
+ ```ruby
289
+ Ribose::Feed.all
290
+ ```
291
+
292
+ ### Widgets
293
+
294
+ #### List widgets
295
+
296
+ To retrieve the list of widgets we can use the `Widget.all` interface
297
+
298
+ ```ruby
299
+ Ribose::Widget.all
300
+ ```
301
+
302
+ ### Stream
303
+
304
+ #### List of stream notifications
305
+
306
+ To retrieve the list of notifications we can use the `Stream.all` interface
307
+
308
+ ```ruby
309
+ Ribose::Stream.all
310
+ ```
311
+
312
+ ### Leaderboard
313
+
314
+ #### Retrieve the current leadership board
315
+
316
+ To retrieve the current leadership board, we can use the `Leaderboard.all`
317
+ interface and it will return the details.
318
+
319
+ ```ruby
320
+ Ribose::Leaderboard.all
321
+ ```
322
+
323
+ ### Connections
324
+
325
+ ### List of connections
326
+
327
+ To retrieve the list of connections, we can use the `Connection.all` interface
328
+ and it will return the connection as `Sawyer::Resource`.
329
+
330
+ ```ruby
331
+ Ribose::Connection.all
332
+ ```
333
+
334
+ #### Connection suggestions
335
+
336
+ To retrieve the list of connection suggestions we can use the following
337
+ interface and it will retrieve the suggested users.
338
+
339
+ ```ruby
340
+ Ribose::Connection.suggestions
341
+ ```
342
+
343
+ ### Invitations
344
+
345
+ #### List connection invitations
346
+
347
+ ```ruby
348
+ Ribose::ConnectionInvitation.all
349
+ ```
350
+
351
+ #### List space invitations
352
+
353
+ ```ruby
354
+ Ribose::SpaceInvitation.all
355
+ ```
356
+
357
+ #### Fetch a connection invitation
358
+
359
+ ```ruby
360
+ Ribose::ConnectionInvitation.fetch(invitation_id)
361
+ ```
362
+
363
+ #### Create mass connection invitations
364
+
365
+ ```ruby
366
+ Ribose::ConnectionInvitation.create(
367
+ emails: ["email-one@example.com", "email-two@example.com"],
368
+ body: "This contains the details message about the invitation",
369
+ )
370
+ ```
371
+
372
+ #### Accept a connection invitation
373
+
374
+ ```ruby
375
+ Ribose::ConnectionInvitation.accept(invitation_id)
376
+ ```
377
+
378
+ #### Reject a connection invitation
379
+
380
+ ```ruby
381
+ Ribose::ConnectionInvitation.reject(invitation_id)
382
+ ```
383
+
384
+ #### Cancel a connection invitation
385
+
386
+ ```ruby
387
+ Ribose::ConnectionInvitation.cancel(invitation_id)
388
+ ```
389
+
390
+ #### Invite user to a space
391
+
392
+ ```ruby
393
+ Ribose::SpaceInvitation.create(
394
+ state: "0",
395
+ space_id: "123_456_789",
396
+ invitee_id: "456_789_012",
397
+ type: "Invitation::ToSpace",
398
+ body: "Please join to this amazing space",
399
+ )
400
+ ```
401
+
402
+ #### Create space invitation - Mass
403
+
404
+ ```ruby
405
+ Ribose::SpaceInvitation.mass_create(
406
+ space_id,
407
+ emails: ["email-one@example.com"],
408
+ role_ids: ["role-for-email-address-in-sequance"],
409
+ body: "The complete message body for the invitation",
410
+ )
411
+ ```
412
+
413
+ #### Update a space invitation
414
+
415
+ ```ruby
416
+ Ribose::SpaceInvitation.update(invitation_id, new_attributes_hash)
417
+ ```
418
+
419
+ #### Accept a space invitation
420
+
421
+ ```ruby
422
+ Ribose::SpaceInvitation.accept(invitation_id)
423
+ ```
424
+
425
+ #### Resend a space invitation
426
+
427
+ ```ruby
428
+ Ribose::SpaceInvitation.resend(invitation_id)
429
+ ```
430
+
431
+ #### Reject a space invitation
432
+
433
+ ```ruby
434
+ Ribose::SpaceInvitation.reject(invitation_id)
435
+ ```
436
+
437
+ #### Cancel a space invitation
438
+
439
+ ```ruby
440
+ Ribose::SpaceInvitation.cancel(invitation_id)
441
+ ```
442
+
443
+ ### Join Space Request
444
+
445
+ #### List join space requests
446
+
447
+ ```ruby
448
+ Ribose::JoinSpaceRequest.all
449
+ ```
450
+
451
+ #### Create a join space request
452
+
453
+ ```ruby
454
+ Ribose::JoinSpaceRequest.create(
455
+ state: 0,
456
+ space_id: 123_456_789,
457
+ type: "Invitation::JoinSpaceRequest",
458
+ body: "Hi, I would like to join to your space",
459
+ )
460
+ ```
461
+
462
+ #### Accept a join space request
463
+
464
+ ```ruby
465
+ Ribose::JoinSpaceRequest.accept(invitation_id)
466
+ ```
467
+
468
+ #### Reject a join space requests
469
+
470
+ ```ruby
471
+ Ribose::JoinSpaceRequest.reject(invitation_id)
472
+ ```
473
+
474
+ #### Update an join space requests
475
+
476
+ ```ruby
477
+ Ribose::JoinSpaceRequest.update(invitation_id, new_attributes_hash)
478
+ ```
479
+
480
+ ### Calendar
481
+
482
+ #### List user calendars
483
+
484
+ To retrieve the list of user calendar, we can use the `Calendar.all` and it will
485
+ fetch the calendar details for the currently configured user.
486
+
487
+ ```ruby
488
+ Ribose::Calendar.all
489
+ ```
490
+
491
+ #### Fetch a calendar
492
+
493
+ ```ruby
494
+ Ribose::Calendar.fetch(calendar_id)
495
+ ```
496
+
497
+ #### Create a calendar
498
+
499
+ ```ruby
500
+ Ribose::Calendar.create(
501
+ owner_type: "User",
502
+ owner_id: "The Owner UUID",
503
+ name: "The name for the calendar",
504
+ )
505
+ ```
506
+
507
+ #### Delete a calendar
508
+
509
+ ```ruby
510
+ Ribose::Calendar.delete(calendar_id)
511
+ ```
512
+
513
+ ### User
514
+
515
+ #### Create a signup request
516
+
517
+ ```ruby
518
+ Ribose::User.create(email: "user@example.com", **other_attributes)
519
+ ```
520
+
521
+ #### Activate a signup request
522
+
523
+ ```ruby
524
+ Ribose::User.activate(
525
+ email: "user@example.com",
526
+ password: "ASecureUserPassword",
527
+ otp: "OTP Recived via the Email",
528
+ )
529
+ ```
530
+
531
+ ### Wikis
532
+
533
+ #### List wiki pages
534
+
535
+ ```ruby
536
+ Ribose::Wiki.all(space_id, options = {})
537
+ ```
538
+
539
+ #### Fetch a wiki page
540
+
541
+ ```ruby
542
+ Ribose::Wiki.fetch(space_id, wiki_id, options = {})
543
+ ```
544
+
545
+ #### Create a wiki page
546
+
547
+ ```ruby
548
+ Ribose::Wiki.create(
549
+ space_id, name: "Wiki Name", tag_list: "sample", **other_attributes_hash
550
+ )
551
+ ```
552
+
553
+ ### Update a wiki page
554
+
555
+ ```ruby
556
+ Ribose::Wiki.update(
557
+ space_id, wiki_id, **updated_attributes_hash
558
+ )
559
+ ```
560
+
561
+ ### Remove a wiki page
562
+
563
+ ```ruby
564
+ Ribose::Wiki.delete(space_id, wiki_id)
565
+ ```
30
566
 
31
567
  ## Development
32
568