boxr 0.28.0 → 0.29.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 +4 -4
- data/README.md +3 -0
- data/lib/boxr.rb +11 -0
- data/lib/boxr/auth.rb +1 -1
- data/lib/boxr/client.rb +7 -4
- data/lib/boxr/events.rb +3 -3
- data/lib/boxr/files.rb +23 -10
- data/lib/boxr/search.rb +1 -1
- data/lib/boxr/tasks.rb +1 -1
- data/lib/boxr/version.rb +1 -1
- data/spec/boxr_spec.rb +2 -2
- 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: 0665e63cc6208e2b553601a6a1748b3ab7e0b4b6
|
4
|
+
data.tar.gz: 2161c7d7914825edf273d40c1e576851bb766199
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed18bbde850f3662f24feb12b3e8243e73d2af181893a80076c006197eb949b7daba26a0919b3492dbcda4358993b24d4468a20d8c39aaab7e3de284ce1e6acf
|
7
|
+
data.tar.gz: 2d590a62dc56694c53a5c24b5d59e32ced3ed081173968763c73c700f517e25f0273481a5d66731c2abf7617d5dafb1e37659cbd51f703917752c823bbba07db
|
data/README.md
CHANGED
@@ -190,6 +190,9 @@ delete_old_version_of_file(file, file_version, if_match: nil)
|
|
190
190
|
|
191
191
|
copy_file(file, parent, name: nil)
|
192
192
|
|
193
|
+
embed_url(file, version: nil, disable_download: nil)
|
194
|
+
alias :preview_url :embed_url
|
195
|
+
|
193
196
|
thumbnail(file, min_height: nil, min_width: nil, max_height: nil, max_width: nil)
|
194
197
|
|
195
198
|
create_shared_link_for_file(file, access: nil, unshared_at: nil, can_download: nil, can_preview: nil)
|
data/lib/boxr.rb
CHANGED
@@ -36,6 +36,16 @@ module Enumerable
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
class BoxrMash < Hashie::Mash
|
40
|
+
def entries
|
41
|
+
self["entries"]
|
42
|
+
end
|
43
|
+
|
44
|
+
def size
|
45
|
+
self["size"]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
39
49
|
module Boxr
|
40
50
|
Oj.default_options = {:mode => :compat }
|
41
51
|
|
@@ -49,6 +59,7 @@ module Boxr
|
|
49
59
|
BOX_CLIENT.send_timeout = 3600 #one hour; needed for lengthy uploads
|
50
60
|
BOX_CLIENT.agent_name = "Boxr/#{Boxr::VERSION}"
|
51
61
|
BOX_CLIENT.transparent_gzip_decompression = true
|
62
|
+
#BOX_CLIENT.ssl_config.add_trust_ca("/Users/cburnette/code/ssh-keys/dev_root_ca.pem")
|
52
63
|
|
53
64
|
def self.turn_on_debugging(device=STDOUT)
|
54
65
|
BOX_CLIENT.debug_dev = device
|
data/lib/boxr/auth.rb
CHANGED
data/lib/boxr/client.rb
CHANGED
@@ -4,6 +4,9 @@ module Boxr
|
|
4
4
|
|
5
5
|
attr_reader :access_token, :refresh_token, :client_id, :client_secret, :identifier, :as_user_id
|
6
6
|
|
7
|
+
#API_URI = "https://wcheng.inside-box.net/api/2.0"
|
8
|
+
#UPLOAD_URI = "https://upload.wcheng.inside-box.net/api/2.0"
|
9
|
+
|
7
10
|
API_URI = "https://api.box.com/2.0"
|
8
11
|
UPLOAD_URI = "https://upload.box.com/api/2.0"
|
9
12
|
FILES_URI = "#{API_URI}/files"
|
@@ -124,7 +127,7 @@ module Boxr
|
|
124
127
|
end
|
125
128
|
end until offset - total_count >= 0
|
126
129
|
|
127
|
-
entries.flatten.map{|i|
|
130
|
+
entries.flatten.map{|i| BoxrMash.new(i)}
|
128
131
|
end
|
129
132
|
|
130
133
|
def post(uri, body, query: nil, success_codes: [201], process_body: true, content_md5: nil, content_type: nil, if_match: nil)
|
@@ -211,10 +214,10 @@ module Boxr
|
|
211
214
|
@token_refresh_listener.call(@access_token, @refresh_token, @identifier) if @token_refresh_listener
|
212
215
|
else
|
213
216
|
if @as_user_id
|
214
|
-
new_token = Boxr::get_user_token(@as_user_id, private_key: @jwt_private_key, private_key_password: @jwt_private_key_password, client_id: @client_id)
|
217
|
+
new_token = Boxr::get_user_token(@as_user_id, private_key: @jwt_private_key, private_key_password: @jwt_private_key_password, client_id: @client_id, client_secret: @client_secret)
|
215
218
|
@access_token = new_token.access_token
|
216
219
|
else
|
217
|
-
new_token = Boxr::get_enterprise_token(private_key: @jwt_private_key, private_key_password: @jwt_private_key_password, enterprise_id: @enterprise_id, client_id: @client_id)
|
220
|
+
new_token = Boxr::get_enterprise_token(private_key: @jwt_private_key, private_key_password: @jwt_private_key_password, enterprise_id: @enterprise_id, client_id: @client_id, client_secret: @client_secret)
|
218
221
|
@access_token = new_token.access_token
|
219
222
|
end
|
220
223
|
end
|
@@ -232,7 +235,7 @@ module Boxr
|
|
232
235
|
|
233
236
|
def processed_response(res)
|
234
237
|
body_json = Oj.load(res.body)
|
235
|
-
return
|
238
|
+
return BoxrMash.new(body_json), res
|
236
239
|
end
|
237
240
|
|
238
241
|
def build_fields_query(fields, all_fields_query)
|
data/lib/boxr/events.rb
CHANGED
@@ -5,7 +5,7 @@ module Boxr
|
|
5
5
|
query = {stream_position: stream_position, stream_type: stream_type, limit: limit}
|
6
6
|
|
7
7
|
events, response = get(EVENTS_URI, query: query)
|
8
|
-
|
8
|
+
BoxrMash.new({events: events.entries, chunk_size: events.chunk_size, next_stream_position: events.next_stream_position})
|
9
9
|
end
|
10
10
|
|
11
11
|
def enterprise_events(created_after: nil, created_before: nil, stream_position: 0, event_type: nil, limit: 500)
|
@@ -17,7 +17,7 @@ module Boxr
|
|
17
17
|
|
18
18
|
break if event_response.events.empty?
|
19
19
|
end
|
20
|
-
|
20
|
+
BoxrMash.new({events: events, next_stream_position: stream_position})
|
21
21
|
end
|
22
22
|
|
23
23
|
def enterprise_events_stream(initial_stream_position, event_type: nil, limit: 500, refresh_period: 300)
|
@@ -42,7 +42,7 @@ module Boxr
|
|
42
42
|
query['created_before'] = created_before.to_datetime.rfc3339 unless created_before.nil?
|
43
43
|
|
44
44
|
events, response = get(EVENTS_URI, query: query)
|
45
|
-
|
45
|
+
BoxrMash.new({events: events.entries, chunk_size: events.chunk_size, next_stream_position: events.next_stream_position})
|
46
46
|
end
|
47
47
|
|
48
48
|
end
|
data/lib/boxr/files.rb
CHANGED
@@ -116,14 +116,7 @@ module Boxr
|
|
116
116
|
file_info, response = post(FILES_UPLOAD_URI, body, process_body: false, content_md5: content_md5)
|
117
117
|
end
|
118
118
|
|
119
|
-
file_info
|
120
|
-
end
|
121
|
-
|
122
|
-
def delete_file(file, if_match: nil)
|
123
|
-
file_id = ensure_id(file)
|
124
|
-
uri = "#{FILES_URI}/#{file_id}"
|
125
|
-
result, response = delete(uri, if_match: if_match)
|
126
|
-
result
|
119
|
+
file_info.entries[0]
|
127
120
|
end
|
128
121
|
|
129
122
|
def upload_new_version_of_file(path_to_file, file, content_modified_at: nil, send_content_md5: true,
|
@@ -142,14 +135,14 @@ module Boxr
|
|
142
135
|
file_info, response = post(uri, attributes, process_body: false, content_md5: content_md5, if_match: if_match)
|
143
136
|
end
|
144
137
|
|
145
|
-
file_info
|
138
|
+
file_info.entries[0]
|
146
139
|
end
|
147
140
|
|
148
141
|
def versions_of_file(file)
|
149
142
|
file_id = ensure_id(file)
|
150
143
|
uri = "#{FILES_URI}/#{file_id}/versions"
|
151
144
|
versions, response = get(uri)
|
152
|
-
versions
|
145
|
+
versions.entries
|
153
146
|
end
|
154
147
|
|
155
148
|
def promote_old_version_of_file(file, file_version)
|
@@ -162,6 +155,13 @@ module Boxr
|
|
162
155
|
new_version
|
163
156
|
end
|
164
157
|
|
158
|
+
def delete_file(file, if_match: nil)
|
159
|
+
file_id = ensure_id(file)
|
160
|
+
uri = "#{FILES_URI}/#{file_id}"
|
161
|
+
result, response = delete(uri, if_match: if_match)
|
162
|
+
result
|
163
|
+
end
|
164
|
+
|
165
165
|
def delete_old_version_of_file(file, file_version, if_match: nil)
|
166
166
|
file_id = ensure_id(file)
|
167
167
|
file_version_id = ensure_id(file_version)
|
@@ -182,6 +182,19 @@ module Boxr
|
|
182
182
|
new_file
|
183
183
|
end
|
184
184
|
|
185
|
+
def embed_url(file, version: nil, disable_download: nil)
|
186
|
+
file_id = ensure_id(file)
|
187
|
+
uri = "#{FILES_URI}/#{file_id}/embed_url"
|
188
|
+
|
189
|
+
query = {}
|
190
|
+
query[:version] = version unless version.nil?
|
191
|
+
query[:disable_download] = disable_download unless disable_download.nil?
|
192
|
+
|
193
|
+
result, response = get(uri, query: query)
|
194
|
+
result.url
|
195
|
+
end
|
196
|
+
alias :preview_url :embed_url
|
197
|
+
|
185
198
|
def thumbnail(file, min_height: nil, min_width: nil, max_height: nil, max_width: nil)
|
186
199
|
file_id = ensure_id(file)
|
187
200
|
uri = "#{FILES_URI}/#{file_id}/thumbnail.png"
|
data/lib/boxr/search.rb
CHANGED
data/lib/boxr/tasks.rb
CHANGED
data/lib/boxr/version.rb
CHANGED
data/spec/boxr_spec.rb
CHANGED
@@ -75,7 +75,7 @@ describe Boxr::Client do
|
|
75
75
|
|
76
76
|
puts "create new folder"
|
77
77
|
new_folder = BOX_CLIENT.create_folder(SUB_FOLDER_NAME, @test_folder)
|
78
|
-
expect(new_folder).to be_a
|
78
|
+
expect(new_folder).to be_a BoxrMash
|
79
79
|
SUB_FOLDER = new_folder
|
80
80
|
|
81
81
|
puts "update folder"
|
@@ -84,7 +84,7 @@ describe Boxr::Client do
|
|
84
84
|
|
85
85
|
puts "copy folder"
|
86
86
|
new_folder = BOX_CLIENT.copy_folder(SUB_FOLDER,@test_folder, name: "copy of #{SUB_FOLDER_NAME}")
|
87
|
-
expect(new_folder).to be_a
|
87
|
+
expect(new_folder).to be_a BoxrMash
|
88
88
|
SUB_FOLDER_COPY = new_folder
|
89
89
|
|
90
90
|
puts "create shared link for folder"
|
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: 0.29.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-08-
|
11
|
+
date: 2015-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|