boxr 1.3.0 → 1.4.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: c454c797a01d524a1d291f614b6cbc325cd3b752
4
- data.tar.gz: 706e102052b88ddbb8f2728bfc259a2352d6da08
3
+ metadata.gz: 070f7c0d6b0a19d622880a61080cc53f8f648545
4
+ data.tar.gz: ab51a80c8118f7bdf048db7285cf04deaf9772ac
5
5
  SHA512:
6
- metadata.gz: ea87475ea281d5fa10a3d48bc8fec22dceec7bd2fe13f8e3e4166a230393c6925bd0b9b342ab99e15b5a7cceb2d7778a3601bf06aae7bb959dd52bd87393dc6d
7
- data.tar.gz: f31f1792ab1e85af9f091d5fedbbbc1ba03ce31092abdc98300275e82e9d680f3f6c18fc7593f089a6994b2313e46d812d7005a297e9905697fca78fe5e445f4
6
+ metadata.gz: 07cf929137f8b6bbb9877b4643861a6ab430fbf957f575fe06a3f9b18b57b81317f3c9b1bfeffbef97fcb9292a30daca50c5da0b06d3740acecaa036fb1aae1a
7
+ data.tar.gz: ee5d20a7c16d3e629e9d6522b268b4749b44a337a66e8a708f2512c05d5be73b9cc88ab1d752cd006bc70c8bcc38aba085b73e11b7dd6f8dc81a49181bf8592c
data/README.md CHANGED
@@ -163,7 +163,7 @@ delete_folder(folder, recursive: false, if_match: nil)
163
163
 
164
164
  copy_folder(folder, dest_folder, name: nil)
165
165
 
166
- create_shared_link_for_folder(folder, access: nil, unshared_at: nil, can_download: nil, can_preview: nil)
166
+ create_shared_link_for_folder(folder, access: nil, unshared_at: nil, can_download: nil, can_preview: nil, password: nil)
167
167
 
168
168
  disable_shared_link_for_folder(folder)
169
169
 
@@ -217,7 +217,7 @@ copy_file(file, parent, name: nil)
217
217
 
218
218
  thumbnail(file, min_height: nil, min_width: nil, max_height: nil, max_width: nil)
219
219
 
220
- create_shared_link_for_file(file, access: nil, unshared_at: nil, can_download: nil, can_preview: nil)
220
+ create_shared_link_for_file(file, access: nil, unshared_at: nil, can_download: nil, can_preview: nil, password: nil)
221
221
 
222
222
  disable_shared_link_for_file(file)
223
223
 
@@ -271,7 +271,13 @@ module Boxr
271
271
  end
272
272
 
273
273
  def ensure_id(item)
274
- return item if item.class == String || item.class == Fixnum || item.nil?
274
+ # Ruby 2.4 unified Fixnum and Bignum into Integer. This tests for Ruby 2.4
275
+ if 1.class == Integer
276
+ return item if item.class == String || item.class == Integer || item.nil?
277
+ else
278
+ return item if item.class == String || item.class == Fixnum || item.class == Bignum || item.nil?
279
+ end
280
+
275
281
  return item.id if item.respond_to?(:id)
276
282
  raise BoxrError.new(boxr_message: "Expecting an id of class String or Fixnum, or object that responds to :id")
277
283
  end
@@ -287,9 +293,10 @@ module Boxr
287
293
  restored_item
288
294
  end
289
295
 
290
- def create_shared_link(uri, item_id, access, unshared_at, can_download, can_preview)
296
+ def create_shared_link(uri, item_id, access, unshared_at, can_download, can_preview, password)
291
297
  attributes = {shared_link: {access: access}}
292
298
  attributes[:shared_link][:unshared_at] = unshared_at.to_datetime.rfc3339 unless unshared_at.nil?
299
+ attributes[:shared_link][:password] = password unless password.nil?
293
300
  attributes[:shared_link][:permissions] = {} unless can_download.nil? && can_preview.nil?
294
301
  attributes[:shared_link][:permissions][:can_download] = can_download unless can_download.nil?
295
302
  attributes[:shared_link][:permissions][:can_preview] = can_preview unless can_preview.nil?
@@ -211,10 +211,10 @@ module Boxr
211
211
  thumbnail
212
212
  end
213
213
 
214
- def create_shared_link_for_file(file, access: nil, unshared_at: nil, can_download: nil, can_preview: nil)
214
+ def create_shared_link_for_file(file, access: nil, unshared_at: nil, can_download: nil, can_preview: nil, password: nil)
215
215
  file_id = ensure_id(file)
216
216
  uri = "#{FILES_URI}/#{file_id}"
217
- create_shared_link(uri, file_id, access, unshared_at, can_download, can_preview)
217
+ create_shared_link(uri, file_id, access, unshared_at, can_download, can_preview, password)
218
218
  end
219
219
 
220
220
  def disable_shared_link_for_file(file)
@@ -103,10 +103,10 @@ module Boxr
103
103
  new_folder
104
104
  end
105
105
 
106
- def create_shared_link_for_folder(folder, access: nil, unshared_at: nil, can_download: nil, can_preview: nil)
106
+ def create_shared_link_for_folder(folder, access: nil, unshared_at: nil, can_download: nil, can_preview: nil, password: nil)
107
107
  folder_id = ensure_id(folder)
108
108
  uri = "#{FOLDERS_URI}/#{folder_id}"
109
- create_shared_link(uri, folder_id, access, unshared_at, can_download, can_preview)
109
+ create_shared_link(uri, folder_id, access, unshared_at, can_download, can_preview, password)
110
110
  end
111
111
 
112
112
  def disable_shared_link_for_folder(folder)
@@ -1,3 +1,3 @@
1
1
  module Boxr
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -92,6 +92,10 @@ describe Boxr::Client do
92
92
  puts "create shared link for folder"
93
93
  updated_folder = BOX_CLIENT.create_shared_link_for_folder(@test_folder, access: :open)
94
94
  expect(updated_folder.shared_link.access).to eq("open")
95
+
96
+ puts "create password-protected shared link for folder"
97
+ updated_folder = BOX_CLIENT.create_shared_link_for_folder(@test_folder, password: 'password')
98
+ expect(updated_folder.shared_link.is_password_enabled).to eq(true)
95
99
  shared_link = updated_folder.shared_link.url
96
100
 
97
101
  puts "inspect shared link"
@@ -213,6 +217,10 @@ describe Boxr::Client do
213
217
  updated_file = BOX_CLIENT.create_shared_link_for_file(test_file, access: :open)
214
218
  expect(updated_file.shared_link.access).to eq("open")
215
219
 
220
+ puts "create password-protected shared link for file"
221
+ updated_file = BOX_CLIENT.create_shared_link_for_file(test_file, password: 'password')
222
+ expect(updated_file.shared_link.is_password_enabled).to eq(true)
223
+
216
224
  puts "disable shared link for file"
217
225
  updated_file = BOX_CLIENT.disable_shared_link_for_file(test_file)
218
226
  expect(updated_file.shared_link).to be_nil
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: 1.3.0
4
+ version: 1.4.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: 2017-02-21 00:00:00.000000000 Z
11
+ date: 2017-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler