ribose 0.3.0 → 0.3.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2e0b15b878e195c9733369b05fd950d9bf77f079
4
- data.tar.gz: 7255d85171187ea37f9ff8bd1ffdf900daaf1808
2
+ SHA256:
3
+ metadata.gz: b7c4b6c53a6c8d7f9a5648e1aa4cb0bf8e37ffa9cac3d9d1fecd5c6fbbc1c81a
4
+ data.tar.gz: 3a8eaac73e14e834ce155b3e2ca1c4ac1593d0925ad26dc61085c0a570f0883e
5
5
  SHA512:
6
- metadata.gz: 60ca909d98a6b7ff1d640a95deaabf730f375dcea7fec4a8e8d7f71fba9e00918c7be49f118ef039ebaf50eb7fab3bc4a2535e5c5c1cf187826429e9b7a91303
7
- data.tar.gz: 231660d478721f30381564b376478de330ff47c116ea5932f99a6429cf6dd907812ffa71b1fa441a646f228f6d5c72d9060ce9eff8e465350ef937a5d5523a13
6
+ metadata.gz: 1fe42b371ab20c599bc152089f439aebd1ad02c5e04dccdef71b64e5b353b3c88984dfe2d4b088ebe5d75e27d54d6ebc433dae3ebadfc5531abe9167a21c79c4
7
+ data.tar.gz: a6dd3241989f1499e3ee48710f8118eeafc886f4716cf3e59ef75a128eec2ae057073d7a5f39f23749744da25aa334b927afbdcabfd1991c50572a557f7b872f
data/README.md CHANGED
@@ -231,6 +231,12 @@ Ribose::SpaceFile.all(space_id, options)
231
231
  Ribose::SpaceFile.fetch(space_id, file_id, options = {})
232
232
  ```
233
233
 
234
+ #### Fetch a file icon
235
+
236
+ ```ruby
237
+ Ribose::SpaceFile.fetch_icon(space_id, file_id, options = {})
238
+ ```
239
+
234
240
  #### Create a file upload
235
241
 
236
242
  ```ruby
@@ -249,6 +255,16 @@ Ribose::SpaceFile.update(space_id, file_id, new_file_attributes = {})
249
255
  Ribose::SpaceFile.delete(space_id, file_id)
250
256
  ```
251
257
 
258
+ ### File Version
259
+
260
+ #### Fetch file version
261
+
262
+ ```ruby
263
+ Ribose::FileVersion.fetch(
264
+ space_id: space_id, file_id: file_id, version_id: version_id
265
+ )
266
+ ```
267
+
252
268
  ### Conversations
253
269
 
254
270
  #### Listing Space Conversations
@@ -283,6 +299,12 @@ Ribose::Conversation.update(space_id, conversation_id, new_attributes_hash)
283
299
  Ribose::Conversation.destroy(space_id: "space_id", conversation_id: "12345")
284
300
  ```
285
301
 
302
+ #### Mark a conversation as favorite
303
+
304
+ ```ruby
305
+ Ribose::Conversation.mark_as_favorite(space_id, conversation_id)
306
+ ```
307
+
286
308
  ### Message
287
309
 
288
310
  #### List Conversation Messages
@@ -556,6 +578,53 @@ Ribose::Calendar.create(
556
578
  Ribose::Calendar.delete(calendar_id)
557
579
  ```
558
580
 
581
+ ### Event
582
+
583
+ #### List calendar events
584
+
585
+ ```ruby
586
+ Ribose::Event.all(calendar_id)
587
+ ```
588
+
589
+ #### Fetch a calendar event
590
+
591
+ ```ruby
592
+ Ribose::Event.fetch(calendar_id, event_id)
593
+ ```
594
+
595
+ #### Create a calendar event
596
+
597
+ ```ruby
598
+ Ribose::Event.create(
599
+ calendar_id,
600
+ name: "Sample Event",
601
+ date_start: "04/04/2018",
602
+ time_start: "4:30pm",
603
+ date_finish: "04/04/2018",
604
+ time_finish: "5:30pm",
605
+ recurring_type: "not_repeat",
606
+ until: "never",
607
+ repeat_every: "1",
608
+ where: "Skype",
609
+ description: "Sample event",
610
+ all_day: false,
611
+ )
612
+ ```
613
+
614
+ #### Update a calendar event
615
+
616
+ ```ruby
617
+ Ribose::Event.update(
618
+ calendar_id, event_id, new_attributes_hash, options_params
619
+ )
620
+ ```
621
+
622
+ #### Delete a calendar event
623
+
624
+ ```ruby
625
+ Ribose::Event.delete(calendar_id, event_id)
626
+ ```
627
+
559
628
  ### User
560
629
 
561
630
  #### Create a signup request
@@ -610,6 +679,14 @@ Ribose::Wiki.update(
610
679
  Ribose::Wiki.delete(space_id, wiki_id)
611
680
  ```
612
681
 
682
+ ### Space categories
683
+
684
+ #### List space categories
685
+
686
+ ```ruby
687
+ Ribose::SpaceCategory.all
688
+ ```
689
+
613
690
  ## Development
614
691
 
615
692
  We are following Sandi Metz's Rules for this gem, you can read the
@@ -6,7 +6,8 @@ module Ribose
6
6
  extend Ribose::Actions::Base
7
7
 
8
8
  def create
9
- create_resource[resource]
9
+ response = create_resource
10
+ response[resource] || response
10
11
  end
11
12
 
12
13
  private
@@ -9,7 +9,8 @@ module Ribose
9
9
  #
10
10
  # @return [Sawyer::Resource] Update resource response
11
11
  def update
12
- update_resource[resource]
12
+ response = update_resource
13
+ response[resource] || response
13
14
  end
14
15
 
15
16
  private
@@ -14,14 +14,14 @@ module Ribose
14
14
  # @params length [Integer] How many days to fetch
15
15
  # @return [Sawyer::Resource] The calendar events
16
16
  #
17
- def self.fetch(calendar_ids, start: Date.today, length: 7)
17
+ def self.fetch(calendar_ids, start: Date.today, length: 7, **others)
18
18
  query = {
19
19
  length: length,
20
20
  cal_ids: Ribose.encode_ids(calendar_ids),
21
21
  start: start.to_time.to_i / (60 * 60 * 24),
22
22
  }
23
23
 
24
- super(nil, query: query)
24
+ super(nil, query: others.merge(query))
25
25
  end
26
26
 
27
27
  private
@@ -62,6 +62,24 @@ module Ribose
62
62
  new(space_id: space_id, conversation_id: conversation_id, **opts).delete
63
63
  end
64
64
 
65
+ def mark_as_favorite
66
+ response = Ribose::Request.put(
67
+ "#{resource_path}/mark_as_favorite",
68
+ resource_key.to_sym => { is_favorite: true },
69
+ )
70
+
71
+ response[resource]
72
+ end
73
+
74
+ # Mark a conversation a favorite
75
+ #
76
+ # @param space_id [String] The Space UUID
77
+ # @param conversation_id [String] Conversation UUID
78
+ #
79
+ def self.mark_as_favorite(space_id, conversation_id)
80
+ new(space_id: space_id, conversation_id: conversation_id).mark_as_favorite
81
+ end
82
+
65
83
  private
66
84
 
67
85
  attr_reader :space_id, :conversation_id
@@ -0,0 +1,86 @@
1
+ module Ribose
2
+ class Event < Ribose::Base
3
+ include Ribose::Actions::Fetch
4
+ include Ribose::Actions::Create
5
+ include Ribose::Actions::Update
6
+ include Ribose::Actions::Delete
7
+
8
+ # List calendar events
9
+ #
10
+ # @params calendar_id [Integer] Calendar Ids
11
+ # @params options [Hash] The options parameters
12
+ # @return [Sawyer::Resource] Calendar Events
13
+ #
14
+ def self.all(calendar_id, options = {})
15
+ Ribose::Calendar.fetch(calendar_id, options)
16
+ end
17
+
18
+ # Fetch a calendar event
19
+ #
20
+ # @params calendar_id - The calendar ID
21
+ # @params event_id - The calendar event ID
22
+ # @return [Sawyer::Resource] Event details
23
+ #
24
+ def self.fetch(calendar_id, event_id, options = {})
25
+ new(options.merge(calendar_id: calendar_id, resource_id: event_id)).fetch
26
+ end
27
+
28
+ # Create a calendar event
29
+ #
30
+ # @params calendar_id - The calendar Id
31
+ # @attributes [Hash] - New Event attributes
32
+ # @return [Sawyer::Resource] The new event
33
+ #
34
+ def self.create(calendar_id, attrs, options = {})
35
+ new(options.merge(calendar_id: calendar_id, **attrs)).create["events"]
36
+ end
37
+
38
+ # Update a calendar event
39
+ #
40
+ # @params calendar_id [Integer] The calendar Id
41
+ # @params event_id [Integer] The calendar event Id
42
+ # @params attributes [Hash] New attributes for event
43
+ # @params options [Hash] The additional query params
44
+ #
45
+ def self.update(calendar_id, event_id, attributes, options = {})
46
+ new(options.merge(
47
+ calendar_id: calendar_id, resource_id: event_id, **attributes,
48
+ )).update["events"]
49
+ end
50
+
51
+ # Delete a calendar event
52
+ #
53
+ # @params calendar_id The calendar Id
54
+ # @params event_id The calendar event Id
55
+ # @params options [Hash] The query params
56
+ #
57
+ def self.delete(calendar_id, event_id, options = {})
58
+ new(options.merge(calendar_id: calendar_id, resource_id: event_id)).delete
59
+ end
60
+
61
+ private
62
+
63
+ attr_reader :calendar_id
64
+
65
+ def resource
66
+ "event"
67
+ end
68
+
69
+ def validate(date_start:, date_finish:, time_start:, time_finish:, **others)
70
+ others.merge(
71
+ date_start: date_start,
72
+ time_start: time_start,
73
+ date_finish: date_finish,
74
+ time_finish: time_finish,
75
+ )
76
+ end
77
+
78
+ def extract_local_attributes
79
+ @calendar_id = attributes.delete(:calendar_id)
80
+ end
81
+
82
+ def resources_path
83
+ "calendar/calendar/#{calendar_id}/event"
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,42 @@
1
+ module Ribose
2
+ class FileVersion < Ribose::Base
3
+ include Ribose::Actions::Fetch
4
+
5
+ # Fetch file version
6
+ #
7
+ # @params :space_id [UUID] The space Id
8
+ # @params :file_id [UUID] The space file Id
9
+ # @params :version_id [UUID] The file version Id
10
+ # @returns [Sawyer::Resource] The file version
11
+ #
12
+ def self.fetch(space_id:, file_id:, version_id:, **options)
13
+ new(
14
+ file_id: file_id,
15
+ space_id: space_id,
16
+ resource_id: version_id,
17
+ **options,
18
+ ).fetch
19
+ end
20
+
21
+ private
22
+
23
+ attr_reader :file_id, :space_id
24
+
25
+ def resource
26
+ nil
27
+ end
28
+
29
+ def extract_local_attributes
30
+ @file_id = attributes.delete(:file_id)
31
+ @space_id = attributes.delete(:space_id)
32
+ end
33
+
34
+ def resource_path
35
+ [files_path, file_id, "versions", resource_id].join("/")
36
+ end
37
+
38
+ def files_path
39
+ ["spaces", space_id, "file", "files"].join("/")
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,15 @@
1
+ module Ribose
2
+ class SpaceCategory < Ribose::Base
3
+ include Ribose::Actions::All
4
+
5
+ private
6
+
7
+ def resources
8
+ nil
9
+ end
10
+
11
+ def resources_path
12
+ "space_categories"
13
+ end
14
+ end
15
+ end
@@ -66,6 +66,20 @@ module Ribose
66
66
  new(space_id: space_id, resource_id: file_id, **options).delete
67
67
  end
68
68
 
69
+ def fetch_icon
70
+ Ribose::Request.get([resource_path, "icon"].join("/"))
71
+ end
72
+
73
+ # Fetch a space file icon
74
+ #
75
+ # @param space_id [String] The Space UUID
76
+ # @param file_id [String] The space file ID
77
+ # @return [Sawyer::Resource]
78
+ #
79
+ def self.fetch_icon(space_id, file_id, options = {})
80
+ new(space_id: space_id, resource_id: file_id, **options).fetch_icon
81
+ end
82
+
69
83
  private
70
84
 
71
85
  attr_reader :space_id
@@ -1,3 +1,3 @@
1
1
  module Ribose
2
- VERSION = "0.3.0".freeze
2
+ VERSION = "0.3.1".freeze
3
3
  end
data/lib/ribose.rb CHANGED
@@ -28,6 +28,9 @@ require "ribose/session"
28
28
  require "ribose/profile"
29
29
  require "ribose/wiki"
30
30
  require "ribose/member_role"
31
+ require "ribose/event"
32
+ require "ribose/space_category"
33
+ require "ribose/file_version"
31
34
 
32
35
  module Ribose
33
36
  def self.root
@@ -0,0 +1,48 @@
1
+ {
2
+ "filter": {
3
+ "enabled": [
4
+ 123456789
5
+ ],
6
+ "userSetting": [0]
7
+ },
8
+ "cal_info": [
9
+ {
10
+ "id": 123456789,
11
+ "owner_type": "User",
12
+ "name": "johndoe",
13
+ "owner_id": "2970d105-5ccc-4a8c",
14
+ "owner_name": "Personal",
15
+ "display_name": "johndoe (Personal)",
16
+ "can_manage": true,
17
+ "can_create_event": true
18
+ }
19
+ ],
20
+ "spaces_permission": {
21
+ "268b0407-c3a3-4aad-8693-fdba789f7f0d": false,
22
+ "457e8438-1c6f-423f-8bf2-77b9d5102fb0": true,
23
+ "52e47e18-9a9d-4663-94c5-abcb18fa783a": true,
24
+ "a45387e2-a573-48ba-8df0-f1424d8a8ec9": false,
25
+ "a7f7b94e-a007-4457-868f-5af319706ad5": false
26
+ },
27
+ "event": {
28
+ "id": 456789,
29
+ "name": "Sample event",
30
+ "description": "",
31
+ "where": "",
32
+ "all_day": true,
33
+ "recurring_type": "not_repeat",
34
+ "my_note": null,
35
+ "old_head_id": null,
36
+ "calendar_id": 123456789,
37
+ "created_by": "2970d105-5ccc-4a8c-b0c4-ec32d539a00a",
38
+ "utc_start": "2018-03-13T12:00:00.000Z",
39
+ "utc_finish": "2018-03-13T13:00:00.000Z",
40
+ "utc_old_start": null,
41
+ "utc_old_finish": null,
42
+ "can_save": true,
43
+ "can_delete": true,
44
+ "timestamp": 1520690119
45
+ },
46
+ "head_event": null,
47
+ "recurring": []
48
+ }
@@ -7,7 +7,7 @@
7
7
  "name": "Trips to the Mars!",
8
8
  "tag_list": [],
9
9
  "published": false,
10
- "is_favorite": false,
10
+ "is_favorite": true,
11
11
  "is_read": true,
12
12
  "allow_publish": false,
13
13
  "number_of_messages": 1,
@@ -0,0 +1,21 @@
1
+ {
2
+ "events": {
3
+ "id": 789012345,
4
+ "name": "Sample Event",
5
+ "description": "Sample event",
6
+ "where": "Skype",
7
+ "all_day": false,
8
+ "recurring_type": "not_repeat",
9
+ "my_note": null,
10
+ "old_head_id": null,
11
+ "calendar_id": 18987,
12
+ "created_by": "2970d105-5ccc",
13
+ "utc_start": "2018-04-04T18:00:00.000Z",
14
+ "utc_finish": "2018-04-04T18:30:00.000Z",
15
+ "utc_old_start": null,
16
+ "utc_old_finish": null,
17
+ "can_save": true,
18
+ "can_delete": true,
19
+ "timestamp": 1521387260
20
+ }
21
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "events": [
3
+ {
4
+ "id": 345678901,
5
+ "name": "Sample event",
6
+ "description": "",
7
+ "where": "",
8
+ "all_day": true,
9
+ "recurring_type": "not_repeat",
10
+ "my_note": "",
11
+ "old_head_id": null,
12
+ "calendar_id": 123456789,
13
+ "created_by": "bdc6aced-f7d0-465d-9d8b",
14
+ "utc_start": "2017-11-07T12:00:00.000Z",
15
+ "utc_finish": "2017-11-07T13:00:00.000Z",
16
+ "utc_old_start": null,
17
+ "utc_old_finish": null,
18
+ "can_save": true,
19
+ "can_delete": true,
20
+ "timestamp": 1508401619
21
+ }
22
+ ]
23
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "version": 1,
3
+ "name": "sample.png",
4
+ "description": "",
5
+ "created_at": "2017-11-30T09:12:03.000+00:00",
6
+ "updated_at": "2017-11-30T09:12:05.000+00:00",
7
+ "position": 1,
8
+ "current_version_id": 789012,
9
+ "icon_path": "/spaces/456789/file/files/11570/versions/13235?type=usual",
10
+ "content_size": 81421,
11
+ "author": "John Doe",
12
+ "content_type": "image/png",
13
+ "file_info_id": 11570
14
+ }
@@ -0,0 +1,150 @@
1
+ [
2
+ {
3
+ "id": 1,
4
+ "name": "animals"
5
+ },
6
+ {
7
+ "id": 2,
8
+ "name": "architecture"
9
+ },
10
+ {
11
+ "id": 3,
12
+ "name": "art"
13
+ },
14
+ {
15
+ "id": 4,
16
+ "name": "business"
17
+ },
18
+ {
19
+ "id": 5,
20
+ "name": "cars_and_motorcycles"
21
+ },
22
+ {
23
+ "id": 6,
24
+ "name": "common_interest"
25
+ },
26
+ {
27
+ "id": 7,
28
+ "name": "diy_and_crafts"
29
+ },
30
+ {
31
+ "id": 8,
32
+ "name": "design"
33
+ },
34
+ {
35
+ "id": 9,
36
+ "name": "education"
37
+ },
38
+ {
39
+ "id": 10,
40
+ "name": "entertainment"
41
+ },
42
+ {
43
+ "id": 11,
44
+ "name": "fashion"
45
+ },
46
+ {
47
+ "id": 12,
48
+ "name": "film_music_books"
49
+ },
50
+ {
51
+ "id": 13,
52
+ "name": "food_and_drink"
53
+ },
54
+ {
55
+ "id": 14,
56
+ "name": "gardening"
57
+ },
58
+ {
59
+ "id": 15,
60
+ "name": "geek"
61
+ },
62
+ {
63
+ "id": 16,
64
+ "name": "geography"
65
+ },
66
+ {
67
+ "id": 17,
68
+ "name": "groups_and_organizations"
69
+ },
70
+ {
71
+ "id": 18,
72
+ "name": "hair_and_beauty"
73
+ },
74
+ {
75
+ "id": 19,
76
+ "name": "health_and_fitness"
77
+ },
78
+ {
79
+ "id": 20,
80
+ "name": "history"
81
+ },
82
+ {
83
+ "id": 21,
84
+ "name": "holidays_and_events"
85
+ },
86
+ {
87
+ "id": 22,
88
+ "name": "home_decor"
89
+ },
90
+ {
91
+ "id": 23,
92
+ "name": "humor"
93
+ },
94
+ {
95
+ "id": 24,
96
+ "name": "illustrations_and_posters"
97
+ },
98
+ {
99
+ "id": 25,
100
+ "name": "kids"
101
+ },
102
+ {
103
+ "id": 26,
104
+ "name": "mens_fashion"
105
+ },
106
+ {
107
+ "id": 27,
108
+ "name": "outdoors"
109
+ },
110
+ {
111
+ "id": 28,
112
+ "name": "philosophy"
113
+ },
114
+ {
115
+ "id": 29,
116
+ "name": "photography"
117
+ },
118
+ {
119
+ "id": 30,
120
+ "name": "products"
121
+ },
122
+ {
123
+ "id": 31,
124
+ "name": "religion_and_spirituality"
125
+ },
126
+ {
127
+ "id": 32,
128
+ "name": "science_and_nature"
129
+ },
130
+ {
131
+ "id": 33,
132
+ "name": "sports"
133
+ },
134
+ {
135
+ "id": 34,
136
+ "name": "technology"
137
+ },
138
+ {
139
+ "id": 35,
140
+ "name": "travel"
141
+ },
142
+ {
143
+ "id": 36,
144
+ "name": "weddings"
145
+ },
146
+ {
147
+ "id": 37,
148
+ "name": "others"
149
+ }
150
+ ]
@@ -0,0 +1,4 @@
1
+ {
2
+ "icon_processed": true,
3
+ "icon_path": "/spaces/files/icon_path?type=usual"
4
+ }
@@ -59,6 +59,20 @@ RSpec.describe Ribose::Conversation do
59
59
  end
60
60
  end
61
61
 
62
+ describe ".mark_as_favorite" do
63
+ it "marks a conversation as favorite" do
64
+ space_id = 123_456_789
65
+ conversation_id = 456_789
66
+ stub_ribose_space_conversation_mafav_api(space_id, conversation_id)
67
+
68
+ conversation = Ribose::Conversation.mark_as_favorite(
69
+ space_id, conversation_id
70
+ )
71
+
72
+ expect(conversation.is_favorite).to eq(true)
73
+ end
74
+ end
75
+
62
76
  describe ".destroy" do
63
77
  it "remvoes a conversation from a space" do
64
78
  space_id = 123456789
@@ -0,0 +1,85 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Ribose::Event do
4
+ describe ".all" do
5
+ it "retrieves the list of events" do
6
+ calendar_id = 123
7
+ stub_ribose_calendar_events_api(calendar_id)
8
+
9
+ calendar_events = Ribose::Event.all(calendar_id).events
10
+
11
+ expect(calendar_events.first.id).not_to be_nil
12
+ expect(calendar_events.first.calendar_id).to eq(123)
13
+ expect(calendar_events.first.name).to eq("Sample event")
14
+ end
15
+ end
16
+
17
+ describe ".fetch" do
18
+ it "retrives the details for an event" do
19
+ event_id = 456_789
20
+ calendar_id = 123_456_789
21
+
22
+ stub_ribose_event_fetch_api(calendar_id, event_id)
23
+ event = Ribose::Event.fetch(calendar_id, event_id)
24
+
25
+ expect(event.id).to eq(event_id)
26
+ expect(event.name).to eq("Sample event")
27
+ expect(event.calendar_id).to eq(calendar_id)
28
+ end
29
+ end
30
+
31
+ describe ".create" do
32
+ it "creates a new event" do
33
+ calendar_id = 123_456_789
34
+
35
+ stub_ribose_event_create_api(calendar_id, event_attributes)
36
+ event = Ribose::Event.create(calendar_id, event_attributes)
37
+
38
+ expect(event.id).not_to be_nil
39
+ expect(event.name).to eq(event_attributes[:name])
40
+ expect(event.description).to eq(event_attributes[:description])
41
+ end
42
+ end
43
+
44
+ describe ".update" do
45
+ it "updates an existing event" do
46
+ event_id = 345_678_901
47
+ calendar_id = 123_456_789
48
+
49
+ stub_ribose_event_update_api(calendar_id, event_id, event_attributes)
50
+ event = Ribose::Event.update(calendar_id, event_id, event_attributes)
51
+
52
+ expect(event.first.id).not_to be_nil
53
+ expect(event.first.name).to eq("Sample event")
54
+ end
55
+ end
56
+
57
+ describe ".delete" do
58
+ it "removes a calendar event" do
59
+ event_id = 456_789
60
+ calendar_id = 123_456_789
61
+ stub_ribose_event_delete_api(calendar_id, event_id)
62
+
63
+ expect do
64
+ Ribose::Event.delete(calendar_id, event_id)
65
+ end.not_to raise_error
66
+ end
67
+ end
68
+
69
+ def event_attributes
70
+ @event_attributes ||= {
71
+ name: "Sample Event",
72
+ recurring_type: "not_repeat",
73
+ until: "never",
74
+ repeat_every: "1",
75
+ where: "Skype",
76
+ description: "Sample event",
77
+ all_day: false,
78
+
79
+ date_start: "04/04/2018",
80
+ time_start: "4:30pm",
81
+ date_finish: "04/04/2018",
82
+ time_finish: "5:30pm",
83
+ }
84
+ end
85
+ end
@@ -0,0 +1,20 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Ribose::FileVersion do
4
+ describe ".fetch" do
5
+ it "retrieves the details of a file version" do
6
+ file_id = 123_456
7
+ space_id = 456_789
8
+ version_id = 789_012
9
+
10
+ stub_ribose_file_version_fetch_api(space_id, file_id, version_id)
11
+ file_version = Ribose::FileVersion.fetch(
12
+ space_id: space_id, file_id: file_id, version_id: version_id,
13
+ )
14
+
15
+ expect(file_version.version).to eq(1)
16
+ expect(file_version.author).to eq("John Doe")
17
+ expect(file_version.current_version_id).to eq(789012)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,13 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Ribose::SpaceCategory do
4
+ describe ".all" do
5
+ it "retrieves the list of space categories" do
6
+ stub_ribose_space_categories_api
7
+ categories = Ribose::SpaceCategory.all
8
+
9
+ expect(categories.first.id).not_to be_nil
10
+ expect(categories.first.name).to eq("animals")
11
+ end
12
+ end
13
+ end
@@ -67,6 +67,19 @@ RSpec.describe Ribose::SpaceFile do
67
67
  end
68
68
  end
69
69
 
70
+ describe ".fetch_icon" do
71
+ it "retrives the details for a file icon" do
72
+ file_id = 456_789_012
73
+ space_id = 123_456_789
74
+
75
+ stub_ribose_space_file_fetch_icon_api(space_id, file_id)
76
+ icon = Ribose::SpaceFile.fetch_icon(space_id, file_id)
77
+
78
+ expect(icon.icon_processed).to be_truthy
79
+ expect(icon.icon_path).to eq("/spaces/files/icon_path?type=usual")
80
+ end
81
+ end
82
+
70
83
  def file_attributes
71
84
  {
72
85
  file: sample_fixture_file,
@@ -127,6 +127,40 @@ module Ribose
127
127
  )
128
128
  end
129
129
 
130
+ def stub_ribose_event_fetch_api(calender_id, event_id)
131
+ stub_api_response(
132
+ :get,
133
+ "calendar/calendar/#{calender_id}/event/#{event_id}",
134
+ filename: "calendar_event",
135
+ )
136
+ end
137
+
138
+ def stub_ribose_event_create_api(calender_id, event_attributes)
139
+ stub_api_response(
140
+ :post,
141
+ "calendar/calendar/#{calender_id}/event",
142
+ data: { event: event_attributes },
143
+ filename: "event_created",
144
+ )
145
+ end
146
+
147
+ def stub_ribose_event_update_api(calender_id, event_id, attributes)
148
+ stub_api_response(
149
+ :put,
150
+ "calendar/calendar/#{calender_id}/event/#{event_id}",
151
+ data: { event: attributes },
152
+ filename: "event_updated",
153
+ )
154
+ end
155
+
156
+ def stub_ribose_event_delete_api(calender_id, event_id)
157
+ stub_api_response(
158
+ :delete,
159
+ "calendar/calendar/#{calender_id}/event/#{event_id}",
160
+ filename: "empty",
161
+ )
162
+ end
163
+
130
164
  def stub_ribose_app_user_create_api(attributes)
131
165
  stub_api_response(
132
166
  :post,
@@ -159,6 +193,11 @@ module Ribose
159
193
  stub_api_response(:get, file_endppoint, filename: "space_file")
160
194
  end
161
195
 
196
+ def stub_ribose_space_file_fetch_icon_api(space_id, file_id)
197
+ path = ["spaces", space_id, "file", "files", file_id, "icon"].join("/")
198
+ stub_api_response(:get, path, filename: "space_file_icon")
199
+ end
200
+
162
201
  def stub_ribose_space_file_update_api(space_id, file_id, attributes)
163
202
  stub_api_response(
164
203
  :put,
@@ -173,6 +212,14 @@ module Ribose
173
212
  stub_api_response(:delete, file_endppoint, filename: "empty")
174
213
  end
175
214
 
215
+ def stub_ribose_file_version_fetch_api(sid, fid, vid)
216
+ stub_api_response(
217
+ :get,
218
+ ["spaces", sid, "file/files", fid, "versions", vid].join("/"),
219
+ filename: "file_version",
220
+ )
221
+ end
222
+
176
223
  def stub_ribose_space_conversation_list(space_id)
177
224
  stub_api_response(
178
225
  :get, conversations_path(space_id), filename: "conversations"
@@ -207,6 +254,14 @@ module Ribose
207
254
  )
208
255
  end
209
256
 
257
+ def stub_ribose_space_conversation_mafav_api(sid, cid)
258
+ stub_api_response(
259
+ :put,
260
+ [conversations_path(sid), cid, "mark_as_favorite"].join("/"),
261
+ filename: "conversation",
262
+ )
263
+ end
264
+
210
265
  def stub_ribose_space_conversation_remove(space_id, conversation_id)
211
266
  path = [conversations_path(space_id), conversation_id].join("/")
212
267
  stub_api_response(:delete, path, filename: "empty", status: 200)
@@ -433,6 +488,12 @@ module Ribose
433
488
  )
434
489
  end
435
490
 
491
+ def stub_ribose_space_categories_api
492
+ stub_api_response(
493
+ :get, "space_categories", filename: "space_categories"
494
+ )
495
+ end
496
+
436
497
  private
437
498
 
438
499
  def ribose_endpoint(endpoint)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ribose
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-10 00:00:00.000000000 Z
11
+ date: 2018-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: id_pack
@@ -176,8 +176,10 @@ files:
176
176
  - lib/ribose/connection_invitation.rb
177
177
  - lib/ribose/conversation.rb
178
178
  - lib/ribose/error.rb
179
+ - lib/ribose/event.rb
179
180
  - lib/ribose/feed.rb
180
181
  - lib/ribose/file_uploader.rb
182
+ - lib/ribose/file_version.rb
181
183
  - lib/ribose/join_space_request.rb
182
184
  - lib/ribose/leaderboard.rb
183
185
  - lib/ribose/member.rb
@@ -191,6 +193,7 @@ files:
191
193
  - lib/ribose/session.rb
192
194
  - lib/ribose/setting.rb
193
195
  - lib/ribose/space.rb
196
+ - lib/ribose/space_category.rb
194
197
  - lib/ribose/space_file.rb
195
198
  - lib/ribose/space_invitation.rb
196
199
  - lib/ribose/stream.rb
@@ -203,6 +206,7 @@ files:
203
206
  - spec/fixtures/app_relation.json
204
207
  - spec/fixtures/app_relations.json
205
208
  - spec/fixtures/calendar.json
209
+ - spec/fixtures/calendar_event.json
206
210
  - spec/fixtures/calendar_events.json
207
211
  - spec/fixtures/calendars.json
208
212
  - spec/fixtures/connection_invitation.json
@@ -215,9 +219,12 @@ files:
215
219
  - spec/fixtures/conversation_created.json
216
220
  - spec/fixtures/conversations.json
217
221
  - spec/fixtures/empty.json
222
+ - spec/fixtures/event_created.json
223
+ - spec/fixtures/event_updated.json
218
224
  - spec/fixtures/feeds.json
219
225
  - spec/fixtures/file_upload_prepared.json
220
226
  - spec/fixtures/file_uploaded.json
227
+ - spec/fixtures/file_version.json
221
228
  - spec/fixtures/general_information.json
222
229
  - spec/fixtures/join_space_request.json
223
230
  - spec/fixtures/join_space_request_created.json
@@ -235,8 +242,10 @@ files:
235
242
  - spec/fixtures/setting.json
236
243
  - spec/fixtures/settings.json
237
244
  - spec/fixtures/space.json
245
+ - spec/fixtures/space_categories.json
238
246
  - spec/fixtures/space_created.json
239
247
  - spec/fixtures/space_file.json
248
+ - spec/fixtures/space_file_icon.json
240
249
  - spec/fixtures/space_files.json
241
250
  - spec/fixtures/space_invitation.json
242
251
  - spec/fixtures/space_invitation_updated.json
@@ -261,8 +270,10 @@ files:
261
270
  - spec/ribose/connection_spec.rb
262
271
  - spec/ribose/conversation_spec.rb
263
272
  - spec/ribose/error_spec.rb
273
+ - spec/ribose/event_spec.rb
264
274
  - spec/ribose/feed_spec.rb
265
275
  - spec/ribose/file_uploader_spec.rb
276
+ - spec/ribose/file_version_spec.rb
266
277
  - spec/ribose/join_space_request_spec.rb
267
278
  - spec/ribose/leaderboard_spec.rb
268
279
  - spec/ribose/member_role_spec.rb
@@ -273,6 +284,7 @@ files:
273
284
  - spec/ribose/resource_helper_spec.rb
274
285
  - spec/ribose/session_spec.rb
275
286
  - spec/ribose/setting_spec.rb
287
+ - spec/ribose/space_category_spec.rb
276
288
  - spec/ribose/space_file_spec.rb
277
289
  - spec/ribose/space_invitation_spec.rb
278
290
  - spec/ribose/space_spec.rb
@@ -303,7 +315,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
303
315
  version: '0'
304
316
  requirements: []
305
317
  rubyforge_project:
306
- rubygems_version: 2.6.14
318
+ rubygems_version: 2.7.7
307
319
  signing_key:
308
320
  specification_version: 4
309
321
  summary: The Ruby interface for Ribose API