ribose 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -0,0 +1,70 @@
1
+ module Ribose
2
+ class SpaceInvitation < Ribose::Base
3
+ include Ribose::Actions::All
4
+ include Ribose::Actions::Create
5
+ include Ribose::Actions::Update
6
+ include Ribose::Actions::Delete
7
+
8
+ def mass_create
9
+ create_invitations[:invitations]
10
+ end
11
+
12
+ def self.mass_create(space_id, attributes = {})
13
+ new(attributes.merge(space_id: space_id)).mass_create
14
+ end
15
+
16
+ def self.update(invitation_id, attributes = {})
17
+ new(attributes.merge(resource_id: invitation_id)).update
18
+ end
19
+
20
+ def self.accept(invitation_id, attributes = {})
21
+ new(attributes.merge(resource_id: invitation_id, state: 1)).update
22
+ end
23
+
24
+ def self.resend(invitation_id, attributes = {})
25
+ Ribose::Request.post(
26
+ "/invitations/to_new_member/#{invitation_id}/resend", attributes
27
+ )
28
+ end
29
+
30
+ def self.reject(invitation_id, attributes = {})
31
+ new(attributes.merge(resource_id: invitation_id, state: 2)).update
32
+ end
33
+
34
+ def self.cancel(invitation_id, attributes = {})
35
+ new(resource_id: invitation_id, **attributes).delete
36
+ end
37
+
38
+ private
39
+
40
+ def resource
41
+ "to_space"
42
+ end
43
+
44
+ def resource_key
45
+ "invitation"
46
+ end
47
+
48
+ def resources_path
49
+ "invitations/to_space"
50
+ end
51
+
52
+ def extract_local_attributes
53
+ @invitation_id = attributes.delete(:invitation_id)
54
+ end
55
+
56
+ def validate(space_id:, invitee_id:, **attributes)
57
+ attributes.merge(space_id: space_id, invitee_id: invitee_id)
58
+ end
59
+
60
+ def create_invitations
61
+ Ribose::Request.post(
62
+ mass_create_path, custom_option.merge(invitation: attributes)
63
+ )
64
+ end
65
+
66
+ def mass_create_path
67
+ "/spaces/#{attributes[:space_id]}/invitations/to_space/mass_create"
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,15 @@
1
+ module Ribose
2
+ class Stream < Ribose::Base
3
+ include Ribose::Actions::All
4
+
5
+ private
6
+
7
+ def resource
8
+ "stream"
9
+ end
10
+
11
+ def resources
12
+ resource
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,42 @@
1
+ module Ribose
2
+ class User < Ribose::Base
3
+ include Ribose::Actions::Create
4
+
5
+ def create
6
+ create_resource
7
+ end
8
+
9
+ def activate
10
+ Ribose::Request.post(
11
+ "signup.user",
12
+ custom_option.merge(user: attributes, auth_header: false),
13
+ )
14
+ end
15
+
16
+ # Activate a user
17
+ #
18
+ # @param email [String] The registering user email
19
+ # @param password [String] A strong password for login
20
+ # @param otp [String] The OTP received via the email
21
+ # @param attributes [Hash] The other attributes as Hash.
22
+ # @return [Sawyer::Resoruce] The newly activated user
23
+ #
24
+ def self.activate(email:, password:, otp:, **attributes)
25
+ new(attributes.merge(email: email, password: password, otp: otp)).activate
26
+ end
27
+
28
+ private
29
+
30
+ def resource
31
+ "user"
32
+ end
33
+
34
+ def resources_path
35
+ "signup_requests"
36
+ end
37
+
38
+ def validate(email:, **attributes)
39
+ attributes.merge(email: email)
40
+ end
41
+ end
42
+ end
@@ -1,3 +1,3 @@
1
1
  module Ribose
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.2.0".freeze
3
3
  end
@@ -0,0 +1,11 @@
1
+ module Ribose
2
+ class Widget < Ribose::Base
3
+ include Ribose::Actions::All
4
+
5
+ private
6
+
7
+ def resource
8
+ "widget"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,80 @@
1
+ module Ribose
2
+ class Wiki < Ribose::Base
3
+ include Ribose::Actions::All
4
+ include Ribose::Actions::Fetch
5
+ include Ribose::Actions::Create
6
+ include Ribose::Actions::Update
7
+ include Ribose::Actions::Delete
8
+
9
+ # List wiki pages
10
+ #
11
+ # @param space_id [String] The space UUID
12
+ # @param options [Hash] Query parameters
13
+ # @retrun [Array <Sawyer::Resoruce>]
14
+ #
15
+ def self.all(space_id, options = {})
16
+ new(space_id: space_id, **options).all
17
+ end
18
+
19
+ # Fetch a wiki page
20
+ #
21
+ # @param space_id [String] The space UUID
22
+ # @param wiki_id [String] The Wiki UUID
23
+ # @return [Sawyer::Resoruce]
24
+ #
25
+ def self.fetch(space_id, wiki_id, options = {})
26
+ new(space_id: space_id, resource_id: wiki_id, **options).fetch
27
+ end
28
+
29
+ # Create a wiki page
30
+ #
31
+ # @param space_id [String] The space UUID
32
+ # @param attributes [Hash] Wiki page attributes
33
+ # @return [Sawyer::Resoruce] Newly created wiki
34
+ #
35
+ def self.create(space_id, attributes)
36
+ new(space_id: space_id, **attributes).create
37
+ end
38
+
39
+ # Update a wiki page
40
+ #
41
+ # @param space_id [String] The space UUID
42
+ # @param wiki_id [String] The wiki-page UUID
43
+ # @param attributes [Hash] Wiki page attributes
44
+ #
45
+ # @return [Sawyer::Resoruce] Updated wiki page
46
+ #
47
+ def self.update(space_id, wiki_id, attributes)
48
+ new(space_id: space_id, resource_id: wiki_id, **attributes).update
49
+ end
50
+
51
+ # Delete a wiki page
52
+ #
53
+ # @param space_id [String] The space UUID
54
+ # @param wiki_id [String] The wiki-page UUID
55
+ #
56
+ def self.delete(space_id, wiki_id, options = {})
57
+ new(space_id: space_id, resource_id: wiki_id, **options).delete
58
+ end
59
+
60
+ private
61
+
62
+ attr_reader :space_id
63
+
64
+ def resource
65
+ "wiki_page"
66
+ end
67
+
68
+ def extract_local_attributes
69
+ @space_id = attributes.delete(:space_id)
70
+ end
71
+
72
+ def validate(name:, **attributes)
73
+ attributes.merge(name: name)
74
+ end
75
+
76
+ def resources_path
77
+ ["spaces", space_id, "wiki", resources].join("/")
78
+ end
79
+ end
80
+ end
data/ribose.gemspec CHANGED
@@ -20,7 +20,13 @@ Gem::Specification.new do |spec|
20
20
  spec.test_files = `git ls-files -- {spec}/*`.split("\n")
21
21
  spec.required_ruby_version = Gem::Requirement.new(">= 2.1.9")
22
22
 
23
+ spec.add_dependency "sawyer", "~> 0.8.1"
24
+ spec.add_dependency "mime-types", "~> 3.1"
25
+ spec.add_dependency "mechanize", "~> 2.7.5"
26
+
23
27
  spec.add_development_dependency "bundler", "~> 1.14"
24
28
  spec.add_development_dependency "rake", "~> 10.0"
25
29
  spec.add_development_dependency "rspec", "~> 3.0"
30
+ spec.add_development_dependency "pry", "~> 0.10.4"
31
+ spec.add_development_dependency "webmock", "~> 2.0"
26
32
  end
@@ -0,0 +1,188 @@
1
+ {
2
+ "misc": {
3
+ "jabber": {
4
+ "login": "c6fe2f942a69abad4bd7bdc90e58263e",
5
+ "status": "available",
6
+ "status_message": null
7
+ },
8
+ "locale": "en",
9
+ "notification": {
10
+ "notifications_last_received": 1302172,
11
+ "notifications_last_shown": 1302172
12
+ },
13
+ "capps": [
14
+ {
15
+ "id": 107953,
16
+ "app_name": "app/dashboard",
17
+ "enabled": true,
18
+ "name": null,
19
+ "order_id": 0,
20
+ "used_storage": 0,
21
+ "owner_type": "Space",
22
+ "owner_id": "0e8d5c16-1a31-4df9-83d9-eeaa374d5adc",
23
+ "system": true,
24
+ "app_type": "home",
25
+ "space_id": "0e8d5c16-1a31-4df9-83d9-eeaa374d5adc",
26
+ "namespace": "dashboard",
27
+ "show_in_menu?": true,
28
+ "uses_email_notifications?": false,
29
+ "searchable?": true
30
+ },
31
+ {
32
+ "id": 107954,
33
+ "app_name": "app/discussion",
34
+ "enabled": true,
35
+ "name": null,
36
+ "order_id": 1,
37
+ "used_storage": 0,
38
+ "owner_type": "Space",
39
+ "owner_id": "0e8d5c16-1a31-4df9-83d9-eeaa374d5adc",
40
+ "system": false,
41
+ "app_type": "discussion",
42
+ "space_id": "0e8d5c16-1a31-4df9-83d9-eeaa374d5adc",
43
+ "namespace": "discussion",
44
+ "show_in_menu?": true,
45
+ "uses_email_notifications?": true,
46
+ "searchable?": true
47
+ },
48
+ {
49
+ "id": 107955,
50
+ "app_name": "app/file",
51
+ "enabled": true,
52
+ "name": null,
53
+ "order_id": 2,
54
+ "used_storage": 0,
55
+ "owner_type": "Space",
56
+ "owner_id": "0e8d5c16-1a31-4df9-83d9-eeaa374d5adc",
57
+ "system": false,
58
+ "app_type": "file",
59
+ "space_id": "0e8d5c16-1a31-4df9-83d9-eeaa374d5adc",
60
+ "namespace": "file",
61
+ "show_in_menu?": true,
62
+ "uses_email_notifications?": true,
63
+ "searchable?": true
64
+ },
65
+ {
66
+ "id": 107956,
67
+ "app_name": "app/member",
68
+ "enabled": true,
69
+ "name": null,
70
+ "order_id": 3,
71
+ "used_storage": 0,
72
+ "owner_type": "Space",
73
+ "owner_id": "0e8d5c16-1a31-4df9-83d9-eeaa374d5adc",
74
+ "system": true,
75
+ "app_type": "people",
76
+ "space_id": "0e8d5c16-1a31-4df9-83d9-eeaa374d5adc",
77
+ "namespace": "people",
78
+ "show_in_menu?": true,
79
+ "uses_email_notifications?": true,
80
+ "searchable?": false
81
+ },
82
+ {
83
+ "id": 107957,
84
+ "app_name": "app/calendar",
85
+ "enabled": true,
86
+ "name": null,
87
+ "order_id": 4,
88
+ "used_storage": 0,
89
+ "owner_type": "Space",
90
+ "owner_id": "0e8d5c16-1a31-4df9-83d9-eeaa374d5adc",
91
+ "system": true,
92
+ "app_type": "calendar",
93
+ "space_id": "0e8d5c16-1a31-4df9-83d9-eeaa374d5adc",
94
+ "namespace": "calendar",
95
+ "show_in_menu?": true,
96
+ "uses_email_notifications?": true,
97
+ "searchable?": true
98
+ },
99
+ {
100
+ "id": 107958,
101
+ "app_name": "app/wiki",
102
+ "enabled": true,
103
+ "name": null,
104
+ "order_id": 5,
105
+ "used_storage": 0,
106
+ "owner_type": "Space",
107
+ "owner_id": "0e8d5c16-1a31-4df9-83d9-eeaa374d5adc",
108
+ "system": false,
109
+ "app_type": "wiki",
110
+ "space_id": "0e8d5c16-1a31-4df9-83d9-eeaa374d5adc",
111
+ "namespace": "wiki",
112
+ "show_in_menu?": true,
113
+ "uses_email_notifications?": true,
114
+ "searchable?": true
115
+ },
116
+ {
117
+ "id": 107959,
118
+ "app_name": "app/poll",
119
+ "enabled": true,
120
+ "name": null,
121
+ "order_id": 6,
122
+ "used_storage": 0,
123
+ "owner_type": "Space",
124
+ "owner_id": "0e8d5c16-1a31-4df9-83d9-eeaa374d5adc",
125
+ "system": false,
126
+ "app_type": "poll",
127
+ "space_id": "0e8d5c16-1a31-4df9-83d9-eeaa374d5adc",
128
+ "namespace": "poll",
129
+ "show_in_menu?": true,
130
+ "uses_email_notifications?": true,
131
+ "searchable?": true
132
+ }
133
+ ],
134
+ "status_message": null,
135
+ "number_of_connection": 1
136
+ },
137
+ "user": {
138
+ "id": "63116bd1-c08d-4a4d-8332-fcdaecb13e34",
139
+ "login": "john.doe",
140
+ "email": "john.doe@gmail.com",
141
+ "created_at": "2017-07-27T07:18:16.000+00:00",
142
+ "activity_points": {
143
+ "level": 0,
144
+ "total": 0,
145
+ "last7days": 0,
146
+ "last30days": 0,
147
+ "points_till_next_level": 35,
148
+ "points_for_current_level": 34
149
+ },
150
+ "mutual_users": [
151
+ "e674a27a-4bfe-5cb3-96a1-09a891db8422"
152
+ ],
153
+ "visible_spaces": [
154
+ {
155
+ "id": "0e8d5c16-1a31-4df9-83d9-eeaa374d5adc",
156
+ "name": "Work",
157
+ "visibility": "invisible",
158
+ "members_count": 1
159
+ }
160
+ ],
161
+ "connection_id": null,
162
+ "from_ribose?": false,
163
+ "name": "John Doe",
164
+ "connected_users": [
165
+ {
166
+ "id": "e674a27a-4bfe-5cb3-96a1-09a891db8422",
167
+ "name": "Team Ribose",
168
+ "mutual_spaces": []
169
+ }
170
+ ],
171
+ "badge_states": [
172
+ {
173
+ "badge_id": 2,
174
+ "state": "unlocked",
175
+ "rank": null,
176
+ "unlocked_at": "2017-07-27T07:18:17.000+00:00"
177
+ }
178
+ ],
179
+ "profile": {
180
+ "id": 9632,
181
+ "first_name": "John",
182
+ "last_name": "Doe",
183
+ "user_id": "63116bd1-c08d-4a4d-8332-fcdaecb13e34",
184
+ "fields": {},
185
+ "name": "John Doe"
186
+ }
187
+ }
188
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "app_relation": {
3
+ "id": 123456789,
4
+ "app_name": "app/home",
5
+ "enabled": true,
6
+ "name": null,
7
+ "order_id": 0,
8
+ "used_storage": 0,
9
+ "owner_type": "User",
10
+ "owner_id": "63116bd1-c08d-4a4d-8332-fcdaecb13e34",
11
+ "system": true,
12
+ "app_type": "home",
13
+ "space_id": null,
14
+ "namespace": "home",
15
+ "show_in_menu?": true,
16
+ "uses_email_notifications?": false,
17
+ "searchable?": true
18
+ }
19
+ }