boxr 0.31.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -6
- data/lib/boxr/client.rb +18 -0
- data/lib/boxr/metadata.rb +19 -0
- data/lib/boxr/search.rb +59 -18
- data/lib/boxr/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 517251718a2a480a9558ec592e3a05fe77a0a176
|
4
|
+
data.tar.gz: bd500f4b3fbcbc8067dba9f177e4ed59dc8fb65e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba654518f7ec93a4635903d5eea630aa35a55614f17dfbac74a41b71cf5d83ec2193b5b1d19fb892e1d80662bb89032533375201d2830127867372152585e14c
|
7
|
+
data.tar.gz: 00bf893d13ca76a97bad47fb23283468fcdfefe416f2443a6ce08257c9d7c8cedc5fab4d85d23896303b451a991d6636074f18418e43d1572305608c05a0630a
|
data/README.md
CHANGED
@@ -172,6 +172,11 @@ file_from_path(path)
|
|
172
172
|
file_from_id(file_id, fields: [])
|
173
173
|
alias :file :file_from_id
|
174
174
|
|
175
|
+
embed_url(file)
|
176
|
+
alias :embed_link :embed_url
|
177
|
+
alias :preview_url :embed_url
|
178
|
+
alias :preview_link :embed_url
|
179
|
+
|
175
180
|
update_file(file, name: nil, description: nil, parent: nil, shared_link: nil, tags: nil, if_match: nil)
|
176
181
|
|
177
182
|
lock_file(file, expires_at: nil, is_download_prevented: false, if_match: nil)
|
@@ -200,9 +205,6 @@ delete_old_version_of_file(file, file_version, if_match: nil)
|
|
200
205
|
|
201
206
|
copy_file(file, parent, name: nil)
|
202
207
|
|
203
|
-
embed_url(file, version: nil, disable_download: nil)
|
204
|
-
alias :preview_url :embed_url
|
205
|
-
|
206
208
|
thumbnail(file, min_height: nil, min_width: nil, max_height: nil, max_width: nil)
|
207
209
|
|
208
210
|
create_shared_link_for_file(file, access: nil, unshared_at: nil, can_download: nil, can_preview: nil)
|
@@ -259,9 +261,12 @@ shared_item(shared_link, shared_link_password: nil)
|
|
259
261
|
```
|
260
262
|
#### [Search](https://developers.box.com/docs/#search)
|
261
263
|
```ruby
|
262
|
-
search(query, scope: nil, file_extensions:
|
263
|
-
|
264
|
-
|
264
|
+
search( query=nil, scope: nil, file_extensions: [],
|
265
|
+
created_at_range_from_date: nil, created_at_range_to_date: nil,
|
266
|
+
updated_at_range_from_date: nil, updated_at_range_to_date: nil,
|
267
|
+
size_range_lower_bound_bytes: nil, size_range_upper_bound_bytes: nil,
|
268
|
+
owner_user_ids: [], ancestor_folder_ids: [], content_types: [], trash_content: nil,
|
269
|
+
mdfilters: nil, type: nil, limit: 30, offset: 0)
|
265
270
|
```
|
266
271
|
#### [Users](https://developers.box.com/docs/#users)
|
267
272
|
```ruby
|
@@ -349,9 +354,15 @@ create_metadata(file, metadata, scope: :global, template: :properties)
|
|
349
354
|
|
350
355
|
metadata(file, scope: :global, template: :properties)
|
351
356
|
|
357
|
+
all_metadata(file)
|
358
|
+
|
352
359
|
update_metadata(file, updates, scope: :global, template: :properties)
|
353
360
|
|
354
361
|
delete_metadata(file, scope: :global, template: :properties)
|
362
|
+
|
363
|
+
enterprise_metadata
|
364
|
+
|
365
|
+
metadata_schema(scope, template_key)
|
355
366
|
```
|
356
367
|
## Contributing
|
357
368
|
|
data/lib/boxr/client.rb
CHANGED
@@ -23,8 +23,10 @@ module Boxr
|
|
23
23
|
TASK_ASSIGNMENTS_URI = "#{API_URI}/task_assignments"
|
24
24
|
SHARED_ITEMS_URI = "#{API_URI}/shared_items"
|
25
25
|
METADATA_URI = "#{API_URI}/files"
|
26
|
+
METADATA_TEMPLATES_URI = "#{API_URI}/metadata_templates"
|
26
27
|
EVENTS_URI = "#{API_URI}/events"
|
27
28
|
|
29
|
+
|
28
30
|
DEFAULT_LIMIT = 100
|
29
31
|
FOLDER_ITEMS_LIMIT = 1000
|
30
32
|
|
@@ -251,6 +253,22 @@ module Boxr
|
|
251
253
|
end
|
252
254
|
end
|
253
255
|
|
256
|
+
def to_comma_separated_string(values)
|
257
|
+
return values if values.is_a?(String) || values.is_a?(Symbol)
|
258
|
+
|
259
|
+
if values.is_a?(Array) && values.length > 0
|
260
|
+
values.join(',')
|
261
|
+
else
|
262
|
+
nil
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
def build_range_string(from, to)
|
267
|
+
range_string = "#{from},#{to}"
|
268
|
+
range_string = nil if range_string == ","
|
269
|
+
range_string
|
270
|
+
end
|
271
|
+
|
254
272
|
def ensure_id(item)
|
255
273
|
return item if item.class == String || item.class == Fixnum || item.nil?
|
256
274
|
return item.id if item.respond_to?(:id)
|
data/lib/boxr/metadata.rb
CHANGED
@@ -15,6 +15,13 @@ module Boxr
|
|
15
15
|
metadata
|
16
16
|
end
|
17
17
|
|
18
|
+
def all_metadata(file)
|
19
|
+
file_id = ensure_id(file)
|
20
|
+
uri = "#{METADATA_URI}/#{file_id}/metadata"
|
21
|
+
all_metadata, response = get(uri)
|
22
|
+
all_metadata
|
23
|
+
end
|
24
|
+
|
18
25
|
def update_metadata(file, updates, scope: :global, template: :properties)
|
19
26
|
file_id = ensure_id(file)
|
20
27
|
uri = "#{METADATA_URI}/#{file_id}/metadata/#{scope}/#{template}"
|
@@ -33,5 +40,17 @@ module Boxr
|
|
33
40
|
result
|
34
41
|
end
|
35
42
|
|
43
|
+
def enterprise_metadata
|
44
|
+
uri = "#{METADATA_TEMPLATES_URI}/enterprise"
|
45
|
+
ent_metadata, response = get(uri)
|
46
|
+
ent_metadata
|
47
|
+
end
|
48
|
+
|
49
|
+
def metadata_schema(scope, template_key)
|
50
|
+
uri = "#{METADATA_TEMPLATES_URI}/#{scope}/#{template_key}/schema"
|
51
|
+
schema, response = get(uri)
|
52
|
+
schema
|
53
|
+
end
|
54
|
+
|
36
55
|
end
|
37
56
|
end
|
data/lib/boxr/search.rb
CHANGED
@@ -1,26 +1,67 @@
|
|
1
1
|
module Boxr
|
2
2
|
class Client
|
3
3
|
|
4
|
-
def search(query, scope: nil, file_extensions:
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
4
|
+
def search( query=nil, scope: nil, file_extensions: [],
|
5
|
+
created_at_range_from_date: nil, created_at_range_to_date: nil,
|
6
|
+
updated_at_range_from_date: nil, updated_at_range_to_date: nil,
|
7
|
+
size_range_lower_bound_bytes: nil, size_range_upper_bound_bytes: nil,
|
8
|
+
owner_user_ids: [], ancestor_folder_ids: [], content_types: [], trash_content: nil,
|
9
|
+
mdfilters: nil, type: nil, limit: 30, offset: 0)
|
10
|
+
|
11
|
+
|
12
|
+
unless mdfilters.nil?
|
13
|
+
unless mdfilters.is_a? String #if a string is passed in assume it is already formatted correctly
|
14
|
+
unless mdfilters.is_a? Array
|
15
|
+
mdfilters = [mdfilters] #if just one mdfilter is specified ensure that it is packaged inside an array
|
16
|
+
end
|
17
|
+
mdfilters = Oj.dump(mdfilters)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
#build range strings
|
22
|
+
created_at_range_string = build_date_range_field(created_at_range_from_date, created_at_range_to_date)
|
23
|
+
updated_at_range_string = build_date_range_field(updated_at_range_from_date, updated_at_range_to_date)
|
24
|
+
size_range_string = build_size_range_field(size_range_lower_bound_bytes, size_range_upper_bound_bytes)
|
25
|
+
|
26
|
+
#build comma separated strings
|
27
|
+
file_extensions_string = to_comma_separated_string(file_extensions)
|
28
|
+
owner_user_ids_string = to_comma_separated_string(owner_user_ids)
|
29
|
+
ancestor_folder_ids_string = to_comma_separated_string(ancestor_folder_ids)
|
30
|
+
content_types_string = to_comma_separated_string(content_types)
|
31
|
+
|
32
|
+
search_query = {}
|
33
|
+
search_query[:query] = query unless query.nil?
|
34
|
+
search_query[:scope] = scope unless scope.nil?
|
35
|
+
search_query[:file_extensions] = file_extensions_string unless file_extensions_string.nil?
|
36
|
+
search_query[:created_at_range] = created_at_range_string unless created_at_range_string.nil?
|
37
|
+
search_query[:updated_at_range] = updated_at_range_string unless updated_at_range_string.nil?
|
38
|
+
search_query[:size_range] = size_range_string unless size_range_string.nil?
|
39
|
+
search_query[:owner_user_ids] = owner_user_ids_string unless owner_user_ids_string.nil?
|
40
|
+
search_query[:ancestor_folder_ids] = ancestor_folder_ids_string unless ancestor_folder_ids_string.nil?
|
41
|
+
search_query[:content_types] = content_types_string unless content_types_string.nil?
|
42
|
+
search_query[:trash_content] = trash_content unless trash_content.nil?
|
43
|
+
search_query[:mdfilters] = mdfilters unless mdfilters.nil?
|
44
|
+
search_query[:type] = type unless type.nil?
|
45
|
+
search_query[:limit] = limit unless limit.nil?
|
46
|
+
search_query[:offset] = offset unless offset.nil?
|
47
|
+
|
48
|
+
results, response = get(SEARCH_URI, query: search_query)
|
22
49
|
results.entries
|
23
50
|
end
|
24
51
|
|
52
|
+
private
|
53
|
+
|
54
|
+
def build_date_range_field(from, to)
|
55
|
+
from_string = from.nil? ? "" : from.to_datetime.rfc3339
|
56
|
+
to_string = to.nil? ? "" : to.to_datetime.rfc3339
|
57
|
+
build_range_string(from_string, to_string)
|
58
|
+
end
|
59
|
+
|
60
|
+
def build_size_range_field(lower, upper)
|
61
|
+
lower_string = lower.nil? ? "" : lower.to_i
|
62
|
+
upper_string = upper.nil? ? "" : upper.to_i
|
63
|
+
build_range_string(lower_string, upper_string)
|
64
|
+
end
|
65
|
+
|
25
66
|
end
|
26
67
|
end
|
data/lib/boxr/version.rb
CHANGED
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.
|
4
|
+
version: 1.0.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-10-
|
11
|
+
date: 2015-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|