boxr 0.28.0 → 0.29.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b15e90705ae77e54c7e29b60d798f78fb2f43df2
4
- data.tar.gz: 88b53548306c6f9aecc6521f3392fe16bcfb3ce8
3
+ metadata.gz: 0665e63cc6208e2b553601a6a1748b3ab7e0b4b6
4
+ data.tar.gz: 2161c7d7914825edf273d40c1e576851bb766199
5
5
  SHA512:
6
- metadata.gz: 3bb9d947f065884e1647534bab48dd7a1127d3262e55f339982fef9d4eaef930fc1f57c85436543ddbc76a63528fcf989a2ae7f350188381b6ce3b93f355a383
7
- data.tar.gz: a2eb5cbc5cefb115f3f5db3b39ea7654391f4a6beb3e193b5dc3a92cf5b74728bb9e51e85a3b86e93cd904e4418be8ac63203445b2547cefce563039330d8740
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)
@@ -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
@@ -81,7 +81,7 @@ module Boxr
81
81
 
82
82
  if(res.status==200)
83
83
  body_json = Oj.load(res.body)
84
- return Hashie::Mash.new(body_json)
84
+ return BoxrMash.new(body_json)
85
85
  else
86
86
  raise BoxrError.new(status: res.status, body: res.body, header: res.header)
87
87
  end
@@ -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| Hashie::Mash.new(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 Hashie::Mash.new(body_json), res
238
+ return BoxrMash.new(body_json), res
236
239
  end
237
240
 
238
241
  def build_fields_query(fields, all_fields_query)
@@ -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
- Hashie::Mash.new({events: events["entries"], chunk_size: events["chunk_size"], next_stream_position: events["next_stream_position"]})
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
- Hashie::Mash.new({events: events, next_stream_position: stream_position})
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
- Hashie::Mash.new({events: events["entries"], chunk_size: events["chunk_size"], next_stream_position: events["next_stream_position"]})
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
@@ -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["entries"][0]
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["entries"][0]
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["entries"]
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"
@@ -19,7 +19,7 @@ module Boxr
19
19
  query[:offset] = offset unless offset.nil?
20
20
 
21
21
  results, response = get(SEARCH_URI, query: query)
22
- results["entries"]
22
+ results.entries
23
23
  end
24
24
 
25
25
  end
@@ -7,7 +7,7 @@ module Boxr
7
7
  query = build_fields_query(fields, TASK_FIELDS_QUERY)
8
8
 
9
9
  tasks, response = get(uri, query: query)
10
- tasks["entries"]
10
+ tasks.entries
11
11
  end
12
12
 
13
13
  def create_task(file, action: :review, message: nil, due_at: nil)
@@ -1,3 +1,3 @@
1
1
  module Boxr
2
- VERSION = "0.28.0"
2
+ VERSION = "0.29.0"
3
3
  end
@@ -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 Hashie::Mash
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 Hashie::Mash
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.28.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-05 00:00:00.000000000 Z
11
+ date: 2015-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler