boxr 0.9.0 → 0.10.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: 50b4a867d4fc5a6446ae5f142d580c371e7748ae
4
- data.tar.gz: 143e912a0826575b25016119b54690103a9e2a3d
3
+ metadata.gz: 899e4b38f5025cfbd597d3e73efb4779befd1677
4
+ data.tar.gz: 4ce61c545bb2b7c1634b2a4dc7a44ab30a045a94
5
5
  SHA512:
6
- metadata.gz: a9631bd2bd6a8ef95ecacfb9b64d88b94498b59543535195d3a36b03f4e5d5f22b3c4d43210957720c38dca5731456697bedf5f07a85176aabcaa78991113e62
7
- data.tar.gz: bb56e7e644834021a2047ac7605e2d23448a2187fb1f890916433d914b4d1e5a72eea440af4e394bd5b7ed7f89b84c3abba53094c0bffbe524c728c1f77ab7eb
6
+ metadata.gz: c84ac5f3451d2bd13c25e27a6c9dd31ed8d9c5a58b95adfce1207cd819fba7f254ec8183aab5712ba4e01adc32cdfdbdca12b2c1a2199af7061d09ec8acd246d
7
+ data.tar.gz: eea9cbf4af775f0ec27dc851811571ac5b183690148ff6f818ec25772792e31e45cf2e3c3a386a67e7864f3908126214067d6fb275fd9643ca10edc90b15608b
data/README.md CHANGED
@@ -106,9 +106,11 @@ root_folder_items(fields: [], offset: 0, limit: FOLDER_ITEMS_LIMIT)
106
106
 
107
107
  create_folder(name, parent)
108
108
 
109
- update_folder(folder, name: nil, description: nil, parent_id: nil, shared_link: nil,
109
+ update_folder(folder, name: nil, description: nil, parent: nil, shared_link: nil,
110
110
  folder_upload_email_access: nil, owned_by_id: nil, sync_state: nil, tags: nil,
111
111
  can_non_owners_invite: nil, if_match: nil)
112
+
113
+ move_folder(folder, new_parent, name: nil, if_match: nil)
112
114
 
113
115
  delete_folder(folder, recursive: false, if_match: nil)
114
116
 
@@ -124,7 +126,7 @@ trashed_folder(folder, fields: [])
124
126
 
125
127
  delete_trashed_folder(folder)
126
128
 
127
- restore_trashed_folder(folder, name: nil, parent_id: nil)
129
+ restore_trashed_folder(folder, name: nil, parent: nil)
128
130
  ```
129
131
  #### [Files](https://developers.box.com/docs/#files)
130
132
  ```ruby
@@ -133,7 +135,9 @@ file_from_path(path)
133
135
  file_from_id(file_id, fields: [])
134
136
  alias :file :file_from_id
135
137
 
136
- update_file(file, name: nil, description: nil, parent_id: nil, shared_link: nil, tags: nil, if_match: nil)
138
+ update_file(file, name: nil, description: nil, parent: nil, shared_link: nil, tags: nil, if_match: nil)
139
+
140
+ move_file(file, new_parent, name: nil, if_match: nil)
137
141
 
138
142
  download_file(file, version: nil, follow_redirect: true)
139
143
 
@@ -165,7 +169,7 @@ trashed_file(file, fields: [])
165
169
 
166
170
  delete_trashed_file(file)
167
171
 
168
- restore_trashed_file(file, name: nil, parent_id: nil)
172
+ restore_trashed_file(file, name: nil, parent: nil)
169
173
  ```
170
174
  #### [Comments](https://developers.box.com/docs/#comments)
171
175
  ```ruby
@@ -207,12 +207,14 @@ module Boxr
207
207
  end
208
208
 
209
209
  def ensure_id(item)
210
- return item if item.class == String || item.class == Fixnum
210
+ return item if item.class == String || item.class == Fixnum || item.nil?
211
211
  return item.id if item.respond_to?(:id)
212
212
  raise BoxrException.new(boxr_message: "Expecting an id of class String or Fixnum, or object that responds to :id")
213
213
  end
214
214
 
215
- def restore_trashed_item(uri, name, parent_id)
215
+ def restore_trashed_item(uri, name, parent)
216
+ parent_id = ensure_id(parent)
217
+
216
218
  attributes = {}
217
219
  attributes[:name] = name unless name.nil?
218
220
  attributes[:parent] = {id: parent_id} unless parent_id.nil?
@@ -11,14 +11,18 @@ module Boxr
11
11
  @boxr_message = boxr_message
12
12
 
13
13
  if(body)
14
- body_json = Oj.load(body)
15
- if body_json
16
- @type = body_json["type"]
17
- @box_status = body_json["status"]
18
- @code = body_json["code"]
19
- @help_uri = body_json["help_uri"]
20
- @box_message = body_json["message"]
21
- @request_id = body_json["request_id"]
14
+ begin
15
+ body_json = Oj.load(body)
16
+
17
+ if body_json
18
+ @type = body_json["type"]
19
+ @box_status = body_json["status"]
20
+ @code = body_json["code"]
21
+ @help_uri = body_json["help_uri"]
22
+ @box_message = body_json["message"]
23
+ @request_id = body_json["request_id"]
24
+ end
25
+ rescue
22
26
  end
23
27
  end
24
28
  end
@@ -26,8 +26,9 @@ module Boxr
26
26
  end
27
27
  alias :file :file_from_id
28
28
 
29
- def update_file(file, name: nil, description: nil, parent_id: nil, shared_link: nil, tags: nil, if_match: nil)
29
+ def update_file(file, name: nil, description: nil, parent: nil, shared_link: nil, tags: nil, if_match: nil)
30
30
  file_id = ensure_id(file)
31
+ parent_id = ensure_id(parent)
31
32
  uri = "#{FILES_URI}/#{file_id}"
32
33
 
33
34
  attributes = {}
@@ -41,6 +42,10 @@ module Boxr
41
42
  updated_file
42
43
  end
43
44
 
45
+ def move_file(file, new_parent, name: nil, if_match: nil)
46
+ update_file(file, parent: new_parent, name: name, if_match: if_match)
47
+ end
48
+
44
49
  def download_file(file, version: nil, follow_redirect: true)
45
50
  file_id = ensure_id(file)
46
51
  begin
@@ -202,8 +207,10 @@ module Boxr
202
207
  result
203
208
  end
204
209
 
205
- def restore_trashed_file(file, name: nil, parent_id: nil)
210
+ def restore_trashed_file(file, name: nil, parent: nil)
206
211
  file_id = ensure_id(file)
212
+ parent_id = ensure_id(parent)
213
+
207
214
  uri = "#{FILES_URI}/#{file_id}"
208
215
  restore_trashed_item(uri, name, parent_id)
209
216
  end
@@ -47,6 +47,7 @@ module Boxr
47
47
 
48
48
  def create_folder(name, parent)
49
49
  parent_id = ensure_id(parent)
50
+
50
51
  uri = "#{FOLDERS_URI}"
51
52
  attributes = {:name => name, :parent => {:id => parent_id}}
52
53
 
@@ -54,16 +55,17 @@ module Boxr
54
55
  created_folder
55
56
  end
56
57
 
57
- def update_folder(folder, name: nil, description: nil, parent_id: nil, shared_link: nil,
58
+ def update_folder(folder, name: nil, description: nil, parent: nil, shared_link: nil,
58
59
  folder_upload_email_access: nil, owned_by_id: nil, sync_state: nil, tags: nil,
59
60
  can_non_owners_invite: nil, if_match: nil)
60
61
  folder_id = ensure_id(folder)
62
+ parent_id = ensure_id(parent)
61
63
  uri = "#{FOLDERS_URI}/#{folder_id}"
62
64
 
63
65
  attributes = {}
64
66
  attributes[:name] = name unless name.nil?
65
67
  attributes[:description] = description unless description.nil?
66
- attributes[:parent_id] = {id: parent_id} unless parent_id.nil?
68
+ attributes[:parent] = {id: parent_id} unless parent_id.nil?
67
69
  attributes[:shared_link] = shared_link unless shared_link.nil?
68
70
  attributes[:folder_upload_email] = {access: folder_upload_email_access} unless folder_upload_email_access.nil?
69
71
  attributes[:owned_by_id] = {owned_by: owned_by_id} unless owned_by_id.nil?
@@ -75,6 +77,10 @@ module Boxr
75
77
  updated_folder
76
78
  end
77
79
 
80
+ def move_folder(folder, new_parent, name: nil, if_match: nil)
81
+ update_folder(folder, parent: new_parent, name: name, if_match: if_match)
82
+ end
83
+
78
84
  def delete_folder(folder, recursive: false, if_match: nil)
79
85
  folder_id = ensure_id(folder)
80
86
  uri = "#{FOLDERS_URI}/#{folder_id}"
@@ -138,8 +144,10 @@ module Boxr
138
144
  result
139
145
  end
140
146
 
141
- def restore_trashed_folder(folder, name: nil, parent_id: nil)
147
+ def restore_trashed_folder(folder, name: nil, parent: nil)
142
148
  folder_id = ensure_id(folder)
149
+ parent_id = ensure_id(parent)
150
+
143
151
  uri = "#{FOLDERS_URI}/#{folder_id}"
144
152
  restore_trashed_item(uri, name, parent_id)
145
153
  end
@@ -1,3 +1,3 @@
1
1
  module Boxr
2
- VERSION = "0.9.0"
2
+ VERSION = "0.10.0"
3
3
  end
@@ -80,7 +80,7 @@ describe Boxr::Client do
80
80
  expect(updated_folder.description).to eq(SUB_FOLDER_DESCRIPTION)
81
81
 
82
82
  puts "copy folder"
83
- new_folder = BOX_CLIENT.copy_folder(SUB_FOLDER,@test_folder, name: 'copy of sub_folder_1')
83
+ new_folder = BOX_CLIENT.copy_folder(SUB_FOLDER,@test_folder, name: "copy of #{SUB_FOLDER_NAME}")
84
84
  expect(new_folder).to be_a Hashie::Mash
85
85
  SUB_FOLDER_COPY = new_folder
86
86
 
@@ -97,6 +97,12 @@ describe Boxr::Client do
97
97
  updated_folder = BOX_CLIENT.disable_shared_link_for_folder(@test_folder)
98
98
  expect(updated_folder.shared_link).to be_nil
99
99
 
100
+ puts "move folder"
101
+ folder_to_move = BOX_CLIENT.create_folder("Folder to move", @test_folder)
102
+ folder_to_move_into = BOX_CLIENT.create_folder("Folder to move into", @test_folder)
103
+ folder_to_move = BOX_CLIENT.move_folder(folder_to_move, folder_to_move_into)
104
+ expect(folder_to_move.parent.id).to eq(folder_to_move_into.id)
105
+
100
106
  puts "delete folder"
101
107
  result = BOX_CLIENT.delete_folder(SUB_FOLDER_COPY, recursive: true)
102
108
  expect(result).to eq ({})
@@ -187,6 +193,11 @@ describe Boxr::Client do
187
193
  expect(new_file.name).to eq(new_file_name)
188
194
  NEW_FILE = new_file
189
195
 
196
+ puts "move file"
197
+ new_folder = BOX_CLIENT.create_folder(SUB_FOLDER_NAME, @test_folder)
198
+ test_file = BOX_CLIENT.move_file(test_file, new_folder.id)
199
+ expect(test_file.parent.id).to eq(new_folder.id)
200
+
190
201
  puts "delete file"
191
202
  result = BOX_CLIENT.delete_file(NEW_FILE)
192
203
  expect(result).to eq({})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boxr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Burnette