boxr 0.5.0 → 0.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 44f0efa6c33c1ad7a0126cddc1cef3a883782be0
4
- data.tar.gz: e2c3bd4cb8400ab48106db786a798bb81ed91638
3
+ metadata.gz: f372e70fa452b62c0c46bb5e8d4e7bb3d43d7f6c
4
+ data.tar.gz: 9b314c9dcf61db5c92d721ac8d2fbe7f1c2f40d2
5
5
  SHA512:
6
- metadata.gz: 94f78c8a5af9b80583cf4ec615170201a72a3c5ff0f8d371209ca759249362ed9e6dd0d8a17ac5e95fe37c2ba761b3d5fd79e736ba3a5268b2b649941afb9e8c
7
- data.tar.gz: a795b2fb4e8ab3e66c5a31177fd40bcb49fc15079cb6774bb9993f8592feade6603bdc84fe97062f72994ad4e645c742666f946d58809b12680dc2f10151069b
6
+ metadata.gz: c6f21f76dec7a9b6a7b56a39b3eb6416296ce966c260d918420635809f4b83c605f43e2bd3952107e15cd7fea6905fa65c3ce192c1035d19600c588b58f2531c
7
+ data.tar.gz: d8c96b6cc61d2f9ecc05ac49e58b583fd3988d2be293b13290b679d42973774b6343f184ba4a78e655eb2118919cb9c6f4b3dab70cefadb95fe6423d53138236
data/README.md CHANGED
@@ -89,7 +89,7 @@ puts "Shared Link: #{file.shared_link.url}"
89
89
  ```
90
90
 
91
91
  ### Methods
92
- #### Folders
92
+ #### [Folders](https://developers.box.com/docs/#folders)
93
93
  ```ruby
94
94
  folder_from_path(path)
95
95
 
@@ -121,7 +121,7 @@ delete_trashed_folder(folder)
121
121
 
122
122
  restore_trashed_folder(folder, name: nil, parent_id: nil)
123
123
  ```
124
- #### Files
124
+ #### [Files](https://developers.box.com/docs/#files)
125
125
  ```ruby
126
126
  file_from_path(path)
127
127
 
@@ -161,7 +161,7 @@ delete_trashed_file(file)
161
161
 
162
162
  restore_trashed_file(file, name: nil, parent_id: nil)
163
163
  ```
164
- #### Comments
164
+ #### [Comments](https://developers.box.com/docs/#comments)
165
165
  ```ruby
166
166
  file_comments(file, fields: [], offset: 0, limit: DEFAULT_LIMIT)
167
167
 
@@ -175,7 +175,7 @@ comment(comment_id, fields: [])
175
175
 
176
176
  delete_comment(comment)
177
177
  ```
178
- #### Collaborations
178
+ #### [Collaborations](https://developers.box.com/docs/#collaborations)
179
179
  ```ruby
180
180
  folder_collaborations(folder)
181
181
 
@@ -189,23 +189,23 @@ collaboration(collaboration_id, fields: [], status: nil)
189
189
 
190
190
  pending_collaborations()
191
191
  ```
192
- #### Events
192
+ #### [Events](https://developers.box.com/docs/#events)
193
193
  ```ruby
194
194
  user_events(stream_position: 0, stream_type: :all, limit: 100)
195
195
 
196
196
  enterprise_events(stream_position: 0, limit: 100, event_type: nil, created_after: nil, created_before: nil)
197
197
  ```
198
- #### Shared Items
198
+ #### [Shared Items](https://developers.box.com/docs/#shared-items)
199
199
  ```ruby
200
200
  shared_item(shared_link, shared_link_password: nil)
201
201
  ```
202
- #### Search
202
+ #### [Search](https://developers.box.com/docs/#search)
203
203
  ```ruby
204
204
  search(query, scope: nil, file_extensions: nil, created_at_range: nil, updated_at_range: nil, size_range: nil,
205
205
  owner_user_ids: nil, ancestor_folder_ids: nil, content_types: nil, type: nil,
206
206
  limit: 30, offset: 0)
207
207
  ```
208
- #### Users
208
+ #### [Users](https://developers.box.com/docs/#users)
209
209
  ```ruby
210
210
  current_user(fields: [])
211
211
 
@@ -228,7 +228,7 @@ update_user(user, notify: nil, enterprise: true, name: nil, role: nil, language:
228
228
 
229
229
  delete_user(user, notify: nil, force: nil)
230
230
  ```
231
- #### Groups
231
+ #### [Groups](https://developers.box.com/docs/#groups)
232
232
  ```ruby
233
233
  groups(fields: [], offset: 0, limit: DEFAULT_LIMIT)
234
234
 
@@ -256,7 +256,7 @@ delete_group_membership(membership)
256
256
 
257
257
  group_collaborations(group, offset: 0, limit: DEFAULT_LIMIT)
258
258
  ```
259
- #### Tasks
259
+ #### [Tasks](https://developers.box.com/docs/#tasks)
260
260
  ```ruby
261
261
  file_tasks(file, fields: [])
262
262
 
@@ -278,7 +278,16 @@ delete_task_assignment(task)
278
278
 
279
279
  update_task_assignment(task, message: nil, resolution_state: nil)
280
280
  ```
281
-
281
+ #### [Metadata](https://developers.box.com/metadata-api/#crud)
282
+ ```ruby
283
+ create_metadata(file, metadata, type: :properties)
284
+
285
+ metadata(file, type: :properties)
286
+
287
+ update_metadata(file, updates, type: :properties)
288
+
289
+ delete_metadata(file, type: :properties)
290
+ ```
282
291
  ## Contributing
283
292
 
284
293
  1. Fork it ( https://github.com/cburnette/boxr/fork )
@@ -12,6 +12,7 @@ require 'boxr/comments'
12
12
  require 'boxr/users'
13
13
  require 'boxr/groups'
14
14
  require 'boxr/collaborations'
15
+ require 'boxr/collections'
15
16
  require 'boxr/search'
16
17
  require 'boxr/tasks'
17
18
  require 'boxr/metadata'
@@ -13,6 +13,7 @@ module Boxr
13
13
  GROUPS_URI = "#{API_URI}/groups"
14
14
  GROUP_MEMBERSHIPS_URI = "#{API_URI}/group_memberships"
15
15
  COLLABORATIONS_URI = "#{API_URI}/collaborations"
16
+ COLLECTIONS_URI = "#{API_URI}/collections"
16
17
  COMMENTS_URI = "#{API_URI}/comments"
17
18
  SEARCH_URI = "#{API_URI}/search"
18
19
  TASKS_URI = "#{API_URI}/tasks"
@@ -59,11 +60,13 @@ module Boxr
59
60
  def self.turn_on_debugging(device=STDOUT)
60
61
  BOX_CLIENT.debug_dev = device
61
62
  BOX_CLIENT.transparent_gzip_decompression = false
63
+ nil
62
64
  end
63
65
 
64
66
  def self.turn_off_debugging
65
67
  BOX_CLIENT.debug_dev = nil
66
68
  BOX_CLIENT.transparent_gzip_decompression = true
69
+ nil
67
70
  end
68
71
 
69
72
  def initialize(access_token, refresh_token: nil, box_client_id: ENV['BOX_CLIENT_ID'], box_client_secret: ENV['BOX_CLIENT_SECRET'],
@@ -98,7 +101,7 @@ module Boxr
98
101
  end
99
102
  end
100
103
 
101
- def get_with_pagination(uri, query: {}, offset: 0, limit: DEFAULT_LIMIT)
104
+ def get_all_with_pagination(uri, query: {}, offset: 0, limit: DEFAULT_LIMIT)
102
105
  entries = []
103
106
 
104
107
  begin
@@ -0,0 +1,16 @@
1
+ module Boxr
2
+ class Client
3
+
4
+ def collections
5
+ collections = get_all_with_pagination(COLLECTIONS_URI, offset: 0, limit: DEFAULT_LIMIT)
6
+ end
7
+
8
+ def collection_items(collection, fields: [])
9
+ collection_id = ensure_id(collection)
10
+ uri = "#{COLLECTIONS_URI}/#{collection_id}/items"
11
+ query = build_fields_query(fields, FOLDER_AND_FILE_FIELDS_QUERY)
12
+ items = get_all_with_pagination(uri, query: query, offset: 0, limit: DEFAULT_LIMIT)
13
+ end
14
+
15
+ end
16
+ end
@@ -1,12 +1,12 @@
1
1
  module Boxr
2
2
  class Client
3
3
 
4
- def file_comments(file, fields: [], offset: 0, limit: DEFAULT_LIMIT)
4
+ def file_comments(file, fields: [])
5
5
  file_id = ensure_id(file)
6
6
  uri = "#{FILES_URI}/#{file_id}/comments"
7
7
  query = build_fields_query(fields, COMMENT_FIELDS_QUERY)
8
8
 
9
- comments = get_with_pagination(uri, query: query, offset: offset, limit: limit)
9
+ comments = get_all_with_pagination(uri, query: query, offset: 0, limit: DEFAULT_LIMIT)
10
10
  end
11
11
 
12
12
  def add_comment_to_file(file, message: nil, tagged_message: nil)
@@ -16,15 +16,22 @@ module Boxr
16
16
  end
17
17
  end
18
18
 
19
- def folder_items(folder, fields: [], offset: 0, limit: FOLDER_ITEMS_LIMIT)
19
+ def folder_items(folder, fields: [], offset: nil, limit: nil)
20
20
  folder_id = ensure_id(folder)
21
21
  query = build_fields_query(fields, FOLDER_AND_FILE_FIELDS_QUERY)
22
22
  uri = "#{FOLDERS_URI}/#{folder_id}/items"
23
23
 
24
- items = get_with_pagination(uri, query: query, offset: offset, limit: limit)
24
+ if offset.nil? || limit.nil?
25
+ items = get_all_with_pagination(uri, query: query, offset: 0, limit: FOLDER_ITEMS_LIMIT)
26
+ else
27
+ query[:offset] = offset
28
+ query[:limit] = limit
29
+ items, response = get(uri, query: query)
30
+ items['entries']
31
+ end
25
32
  end
26
33
 
27
- def root_folder_items(fields: [], offset: 0, limit: FOLDER_ITEMS_LIMIT)
34
+ def root_folder_items(fields: [], offset: nil, limit: nil)
28
35
  folder_items(Boxr::ROOT, fields: fields, offset: offset, limit: limit)
29
36
  end
30
37
 
@@ -100,11 +107,18 @@ module Boxr
100
107
  disable_shared_link(uri, folder_id)
101
108
  end
102
109
 
103
- def trash(fields: [], offset: 0, limit: FOLDER_ITEMS_LIMIT)
110
+ def trash(fields: [], offset: nil, limit: nil)
104
111
  uri = "#{FOLDERS_URI}/trash/items"
105
112
  query = build_fields_query(fields, FOLDER_AND_FILE_FIELDS_QUERY)
106
113
 
107
- items = get_with_pagination(uri, query: query, offset: offset, limit: limit)
114
+ if offset.nil? || limit.nil?
115
+ items = get_all_with_pagination(uri, query: query, offset: 0, limit: FOLDER_ITEMS_LIMIT)
116
+ else
117
+ query[:offset] = offset
118
+ query[:limit] = limit
119
+ items, response = get(uri, query: query)
120
+ items['entries']
121
+ end
108
122
  end
109
123
 
110
124
  def trashed_folder(folder, fields: [])
@@ -1,9 +1,9 @@
1
1
  module Boxr
2
2
  class Client
3
3
 
4
- def groups(fields: [], offset: 0, limit: DEFAULT_LIMIT)
4
+ def groups(fields: [])
5
5
  query = build_fields_query(fields, GROUP_FIELDS_QUERY)
6
- groups = get_with_pagination(GROUPS_URI, query: query, offset: offset, limit: limit)
6
+ groups = get_all_with_pagination(GROUPS_URI, query: query, offset: 0, limit: DEFAULT_LIMIT)
7
7
  end
8
8
 
9
9
  def create_group(name)
@@ -30,21 +30,21 @@ module Boxr
30
30
  result
31
31
  end
32
32
 
33
- def group_memberships(group, offset: 0, limit: DEFAULT_LIMIT)
33
+ def group_memberships(group)
34
34
  group_id = ensure_id(group)
35
35
  uri = "#{GROUPS_URI}/#{group_id}/memberships"
36
- memberships = get_with_pagination(uri, offset: offset, limit: limit)
36
+ memberships = get_all_with_pagination(uri, offset: 0, limit: DEFAULT_LIMIT)
37
37
  end
38
38
 
39
- def group_memberships_for_user(user, offset: 0, limit: DEFAULT_LIMIT)
39
+ def group_memberships_for_user(user)
40
40
  user_id = ensure_id(user)
41
41
  uri = "#{USERS_URI}/#{user_id}/memberships"
42
- memberships = get_with_pagination(uri, offset: offset, limit: limit)
42
+ memberships = get_all_with_pagination(uri, offset: 0, limit: DEFAULT_LIMIT)
43
43
  end
44
44
 
45
- def group_memberships_for_me(offset: 0, limit: DEFAULT_LIMIT)
45
+ def group_memberships_for_me
46
46
  uri = "#{USERS_URI}/me/memberships"
47
- memberships = get_with_pagination(uri, offset: offset, limit: limit)
47
+ memberships = get_all_with_pagination(uri, offset: 0, limit: DEFAULT_LIMIT)
48
48
  end
49
49
 
50
50
  def group_membership(membership_id)
@@ -79,10 +79,10 @@ module Boxr
79
79
  result
80
80
  end
81
81
 
82
- def group_collaborations(group, offset: 0, limit: DEFAULT_LIMIT)
82
+ def group_collaborations(group)
83
83
  group_id = ensure_id(group)
84
84
  uri = "#{GROUPS_URI}/#{group_id}/collaborations"
85
- collaborations = get_with_pagination(uri, offset: offset, limit: limit)
85
+ collaborations = get_all_with_pagination(uri, offset: 0, limit: DEFAULT_LIMIT)
86
86
  end
87
87
 
88
88
  end
@@ -18,11 +18,19 @@ module Boxr
18
18
  user
19
19
  end
20
20
 
21
- def all_users(filter_term: nil, fields: [], offset: 0, limit: DEFAULT_LIMIT)
21
+ def all_users(filter_term: nil, fields: [], offset: nil, limit: nil)
22
22
  uri = USERS_URI
23
23
  query = build_fields_query(fields, USER_FIELDS_QUERY)
24
24
  query[:filter_term] = filter_term unless filter_term.nil?
25
- users = get_with_pagination(uri, query: query, offset: offset, limit: limit)
25
+
26
+ if offset.nil? || limit.nil?
27
+ users = get_all_with_pagination(uri, query: query, offset: 0, limit: DEFAULT_LIMIT)
28
+ else
29
+ query[:offset] = offset
30
+ query[:limit] = limit
31
+ users, response = get(uri, query: query)
32
+ users['entries']
33
+ end
26
34
  end
27
35
 
28
36
  def create_user(login, name, role: nil, language: nil, is_sync_enabled: nil, job_title: nil,
@@ -1,3 +1,3 @@
1
1
  module Boxr
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boxr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Burnette
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-16 00:00:00.000000000 Z
11
+ date: 2015-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -171,6 +171,7 @@ files:
171
171
  - lib/boxr/auth.rb
172
172
  - lib/boxr/client.rb
173
173
  - lib/boxr/collaborations.rb
174
+ - lib/boxr/collections.rb
174
175
  - lib/boxr/comments.rb
175
176
  - lib/boxr/events.rb
176
177
  - lib/boxr/exceptions.rb