boxr 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env.example +6 -3
- data/Rakefile +0 -2
- data/examples/enterprise_events.rb +8 -8
- data/examples/oauth.rb +27 -0
- data/examples/user_events.rb +12 -12
- data/lib/boxr.rb +12 -11
- data/lib/boxr/auth.rb +46 -0
- data/lib/boxr/client.rb +255 -214
- data/lib/boxr/collaborations.rb +56 -56
- data/lib/boxr/comments.rb +38 -38
- data/lib/boxr/events.rb +16 -16
- data/lib/boxr/exceptions.rb +35 -35
- data/lib/boxr/files.rb +209 -209
- data/lib/boxr/folders.rb +117 -117
- data/lib/boxr/groups.rb +61 -61
- data/lib/boxr/metadata.rb +22 -22
- data/lib/boxr/search.rb +20 -20
- data/lib/boxr/shared_items.rb +8 -8
- data/lib/boxr/tasks.rb +83 -83
- data/lib/boxr/users.rb +80 -82
- data/lib/boxr/version.rb +1 -1
- data/spec/boxr_spec.rb +441 -441
- metadata +5 -4
- data/lib/tasks/oauth.rake +0 -22
data/lib/boxr/shared_items.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
module Boxr
|
2
|
-
|
2
|
+
class Client
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
def shared_item(shared_link, shared_link_password: nil)
|
5
|
+
box_api_header = "shared_link=#{shared_link}"
|
6
|
+
box_api_header += "&shared_link_password=#{shared_link_password}" unless shared_link_password.nil?
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
file_or_folder, response = get(SHARED_ITEMS_URI, box_api_header: box_api_header)
|
9
|
+
file_or_folder
|
10
|
+
end
|
11
11
|
|
12
|
-
|
12
|
+
end
|
13
13
|
end
|
data/lib/boxr/tasks.rb
CHANGED
@@ -1,85 +1,85 @@
|
|
1
1
|
module Boxr
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
2
|
+
class Client
|
3
|
+
|
4
|
+
def file_tasks(file_id, fields: [])
|
5
|
+
uri = "#{FILES_URI}/#{file_id}/tasks"
|
6
|
+
query = build_fields_query(fields, TASK_FIELDS_QUERY)
|
7
|
+
|
8
|
+
tasks, response = get uri, query: query
|
9
|
+
tasks["entries"]
|
10
|
+
end
|
11
|
+
|
12
|
+
def create_task(file_id, action: :review, message: nil, due_at: nil)
|
13
|
+
attributes = {item: {type: :file, id: file_id}}
|
14
|
+
attributes[:action] = action unless action.nil?
|
15
|
+
attributes[:message] = message unless message.nil?
|
16
|
+
attributes[:due_at] = due_at.to_datetime.rfc3339 unless due_at.nil?
|
17
|
+
|
18
|
+
new_task, response = post TASKS_URI, attributes
|
19
|
+
new_task
|
20
|
+
end
|
21
|
+
|
22
|
+
def task(task_id)
|
23
|
+
uri = "#{TASKS_URI}/#{task_id}"
|
24
|
+
task, response = get uri
|
25
|
+
task
|
26
|
+
end
|
27
|
+
|
28
|
+
def update_task(task_id, action: :review, message: nil, due_at: nil)
|
29
|
+
uri = "#{TASKS_URI}/#{task_id}"
|
30
|
+
attributes = {}
|
31
|
+
attributes[:action] = action unless action.nil?
|
32
|
+
attributes[:message] = message unless message.nil?
|
33
|
+
attributes[:due_at] = due_at.to_datetime.rfc3339 unless due_at.nil?
|
34
|
+
|
35
|
+
task, response = put uri, attributes
|
36
|
+
task
|
37
|
+
end
|
38
|
+
|
39
|
+
def delete_task(task_id)
|
40
|
+
uri = "#{TASKS_URI}/#{task_id}"
|
41
|
+
result, response = delete uri
|
42
|
+
result
|
43
|
+
end
|
44
|
+
|
45
|
+
def task_assignments(task_id)
|
46
|
+
uri = "#{TASKS_URI}/#{task_id}/assignments"
|
47
|
+
assignments, response = get uri
|
48
|
+
assignments['entries']
|
49
|
+
end
|
50
|
+
|
51
|
+
def create_task_assignment(task_id, assign_to_id: nil, assign_to_login: nil)
|
52
|
+
attributes = {task: {type: :task, id: "#{task_id}"}}
|
53
|
+
|
54
|
+
attributes[:assign_to] = {}
|
55
|
+
attributes[:assign_to][:login] = assign_to_login unless assign_to_login.nil?
|
56
|
+
attributes[:assign_to][:id] = assign_to_id unless assign_to_id.nil?
|
57
|
+
|
58
|
+
new_task_assignment, response = post TASK_ASSIGNMENTS_URI, attributes
|
59
|
+
new_task_assignment
|
60
|
+
end
|
61
|
+
|
62
|
+
def task_assignment(task_id)
|
63
|
+
uri = "#{TASK_ASSIGNMENTS_URI}/#{task_id}"
|
64
|
+
task_assignment, response = get uri
|
65
|
+
task_assignment
|
66
|
+
end
|
67
|
+
|
68
|
+
def delete_task_assignment(task_id)
|
69
|
+
uri = "#{TASK_ASSIGNMENTS_URI}/#{task_id}"
|
70
|
+
result, response = delete uri
|
71
|
+
result
|
72
|
+
end
|
73
|
+
|
74
|
+
def update_task_assignment(task_id, message: nil, resolution_state: nil)
|
75
|
+
uri = "#{TASK_ASSIGNMENTS_URI}/#{task_id}"
|
76
|
+
attributes = {}
|
77
|
+
attributes[:message] = message unless message.nil?
|
78
|
+
attributes[:resolution_state] = resolution_state unless resolution_state.nil?
|
79
|
+
|
80
|
+
updated_task, response = put uri, attributes
|
81
|
+
updated_task
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
85
|
end
|
data/lib/boxr/users.rb
CHANGED
@@ -1,96 +1,94 @@
|
|
1
1
|
module Boxr
|
2
|
-
|
2
|
+
class Client
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
def current_user(fields: [])
|
5
|
+
uri = "#{USERS_URI}/me"
|
6
|
+
query = build_fields_query(fields, USER_FIELDS_QUERY)
|
7
|
+
user, response = get(uri, query: query)
|
8
|
+
user
|
9
|
+
end
|
10
10
|
|
11
|
-
|
12
|
-
current_user(fields: fields)
|
13
|
-
end
|
11
|
+
alias :me :current_user
|
14
12
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
13
|
+
def user(user_id, fields: [])
|
14
|
+
uri = "#{USERS_URI}/#{user_id}"
|
15
|
+
query = build_fields_query(fields, USER_FIELDS_QUERY)
|
16
|
+
user, response = get(uri, query: query)
|
17
|
+
user
|
18
|
+
end
|
21
19
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
20
|
+
def all_users(filter_term: nil, fields: [])
|
21
|
+
uri = USERS_URI
|
22
|
+
query = build_fields_query(fields, USER_FIELDS_QUERY)
|
23
|
+
query[:filter_term] = filter_term unless filter_term.nil?
|
24
|
+
users = get_with_pagination(uri, query: query)
|
25
|
+
end
|
28
26
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
def create_user(login, name, role: nil, language: nil, is_sync_enabled: nil, job_title: nil,
|
28
|
+
phone: nil, address: nil, space_amount: nil, tracking_codes: nil,
|
29
|
+
can_see_managed_users: nil, is_external_collab_restricted: nil, status: nil, timezone: nil,
|
30
|
+
is_exempt_from_device_limits: nil, is_exempt_from_login_verification: nil)
|
33
31
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
32
|
+
uri = USERS_URI
|
33
|
+
attributes = {login: login, name: name}
|
34
|
+
attributes[:role] = role unless role.nil?
|
35
|
+
attributes[:language] = language unless language.nil?
|
36
|
+
attributes[:is_sync_enabled] = is_sync_enabled unless is_sync_enabled.nil?
|
37
|
+
attributes[:job_title] = job_title unless job_title.nil?
|
38
|
+
attributes[:phone] = phone unless phone.nil?
|
39
|
+
attributes[:address] = address unless address.nil?
|
40
|
+
attributes[:space_amount] = space_amount unless space_amount.nil?
|
41
|
+
attributes[:tracking_codes] = tracking_codes unless tracking_codes.nil?
|
42
|
+
attributes[:can_see_managed_users] = can_see_managed_users unless can_see_managed_users.nil?
|
43
|
+
attributes[:is_external_collab_restricted] = is_external_collab_restricted unless is_external_collab_restricted.nil?
|
44
|
+
attributes[:status] = status unless status.nil?
|
45
|
+
attributes[:timezone] = timezone unless timezone.nil?
|
46
|
+
attributes[:is_exempt_from_device_limits] = is_exempt_from_device_limits unless is_exempt_from_device_limits.nil?
|
47
|
+
attributes[:is_exempt_from_login_verification] = is_exempt_from_login_verification unless is_exempt_from_login_verification.nil?
|
50
48
|
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
new_user, response = post(uri, attributes)
|
50
|
+
new_user
|
51
|
+
end
|
54
52
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
53
|
+
def update_user(user_id, notify: nil, enterprise: true, name: nil, role: nil, language: nil, is_sync_enabled: nil,
|
54
|
+
job_title: nil, phone: nil, address: nil, space_amount: nil, tracking_codes: nil,
|
55
|
+
can_see_managed_users: nil, status: nil, timezone: nil, is_exempt_from_device_limits: nil,
|
56
|
+
is_exempt_from_login_verification: nil, is_exempt_from_reset_required: nil, is_external_collab_restricted: nil)
|
59
57
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
58
|
+
uri = "#{USERS_URI}/#{user_id}"
|
59
|
+
query = {notify: notify} unless notify.nil?
|
60
|
+
|
61
|
+
attributes = {}
|
62
|
+
attributes[:enterprise] = nil if enterprise.nil? #this is a special condition where setting this to nil means to roll this user out of the enterprise
|
63
|
+
attributes[:name] = name unless name.nil?
|
64
|
+
attributes[:role] = role unless role.nil?
|
65
|
+
attributes[:language] = language unless language.nil?
|
66
|
+
attributes[:is_sync_enabled] = is_sync_enabled unless is_sync_enabled.nil?
|
67
|
+
attributes[:job_title] = job_title unless job_title.nil?
|
68
|
+
attributes[:phone] = phone unless phone.nil?
|
69
|
+
attributes[:address] = address unless address.nil?
|
70
|
+
attributes[:space_amount] = space_amount unless space_amount.nil?
|
71
|
+
attributes[:tracking_codes] = tracking_codes unless tracking_codes.nil?
|
72
|
+
attributes[:can_see_managed_users] = can_see_managed_users unless can_see_managed_users.nil?
|
73
|
+
attributes[:status] = status unless status.nil?
|
74
|
+
attributes[:timezone] = timezone unless timezone.nil?
|
75
|
+
attributes[:is_exempt_from_device_limits] = is_exempt_from_device_limits unless is_exempt_from_device_limits.nil?
|
76
|
+
attributes[:is_exempt_from_login_verification] = is_exempt_from_login_verification unless is_exempt_from_login_verification.nil?
|
77
|
+
attributes[:is_exempt_from_reset_required] = is_exempt_from_reset_required unless is_exempt_from_reset_required.nil?
|
78
|
+
attributes[:is_external_collab_restricted] = is_external_collab_restricted unless is_external_collab_restricted.nil?
|
81
79
|
|
82
|
-
|
83
|
-
|
84
|
-
|
80
|
+
updated_user, response = put(uri, attributes, query: query)
|
81
|
+
updated_user
|
82
|
+
end
|
85
83
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
84
|
+
def delete_user(user_id, notify: nil, force: nil)
|
85
|
+
uri = "#{USERS_URI}/#{user_id}"
|
86
|
+
query = {}
|
87
|
+
query[:notify] = notify unless notify.nil?
|
88
|
+
query[:force] = force unless force.nil?
|
89
|
+
result, response = delete(uri, query: query)
|
90
|
+
result
|
91
|
+
end
|
94
92
|
|
95
|
-
|
93
|
+
end
|
96
94
|
end
|
data/lib/boxr/version.rb
CHANGED
data/spec/boxr_spec.rb
CHANGED
@@ -2,446 +2,446 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Boxr::Client do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
5
|
+
#PLEASE NOTE
|
6
|
+
#This test is intentionally NOT a series of unit tests. The goal is to smoke test the entire code base
|
7
|
+
#against an actual Box account, making real calls to the Box API. The Box API is subject to frequent
|
8
|
+
#changes and it is not sufficient to mock responses as those responses will change over time. Successfully
|
9
|
+
#running this test suite shows that the code base works with the current Box API. The main premise here
|
10
|
+
#is that an exception will be thrown if anything unexpected happens.
|
11
|
+
|
12
|
+
#REQUIRED BOX SETTINGS
|
13
|
+
# 1. The developer token used must have admin or co-admin priviledges
|
14
|
+
# 2. Enterprise settings must allow Admin and Co-admins to permanently delete content in Trash
|
15
|
+
|
16
|
+
#follow the directions in .env.example to set up your BOX_DEVELOPER_TOKEN
|
17
|
+
#keep in mind it is only valid for 60 minutes
|
18
|
+
BOX_CLIENT = Boxr::Client.new(ENV['BOX_DEVELOPER_TOKEN'])
|
19
|
+
|
20
|
+
#uncomment this line to see the HTTP request and response debug info in the rspec output
|
21
|
+
#Boxr::Client.turn_on_debugging
|
22
|
+
|
23
|
+
BOX_SERVER_SLEEP = 5
|
24
|
+
TEST_FOLDER_NAME = 'Boxr Test'
|
25
|
+
SUB_FOLDER_NAME = 'sub_folder_1'
|
26
|
+
SUB_FOLDER_DESCRIPTION = 'This was created by the Boxr test suite'
|
27
|
+
TEST_FILE_NAME = 'test file.txt'
|
28
|
+
DOWNLOADED_TEST_FILE_NAME = 'downloaded test file.txt'
|
29
|
+
COMMENT_MESSAGE = 'this is a comment'
|
30
|
+
REPLY_MESSAGE = 'this is a comment reply'
|
31
|
+
CHANGED_COMMENT_MESSAGE = 'this comment has been changed'
|
32
|
+
TEST_USER_LOGIN = "test-boxr-user@example.com"
|
33
|
+
TEST_USER_NAME = "Test Boxr User"
|
34
|
+
TEST_GROUP_NAME= "Test Boxr Group"
|
35
|
+
TEST_TASK_MESSAGE = "Please review"
|
36
|
+
|
37
|
+
before(:each) do
|
38
|
+
puts "-----> Resetting Box Environment"
|
39
|
+
sleep BOX_SERVER_SLEEP
|
40
|
+
root_folders = BOX_CLIENT.folder_items(Boxr::ROOT).folders
|
41
|
+
test_folder = root_folders.find{|f| f.name == TEST_FOLDER_NAME}
|
42
|
+
if(test_folder)
|
43
|
+
BOX_CLIENT.delete_folder(test_folder.id, recursive: true)
|
44
|
+
end
|
45
|
+
new_folder = BOX_CLIENT.create_folder(TEST_FOLDER_NAME, Boxr::ROOT)
|
46
|
+
@test_folder_id = new_folder.id
|
47
|
+
|
48
|
+
all_users = BOX_CLIENT.all_users
|
49
|
+
test_user = all_users.find{|u| u.login == TEST_USER_LOGIN}
|
50
|
+
if(test_user)
|
51
|
+
BOX_CLIENT.delete_user(test_user.id, force: true)
|
52
|
+
end
|
53
|
+
sleep BOX_SERVER_SLEEP
|
54
|
+
test_user = BOX_CLIENT.create_user(TEST_USER_LOGIN, TEST_USER_NAME)
|
55
|
+
@test_user_id = test_user.id
|
56
|
+
|
57
|
+
all_groups = BOX_CLIENT.groups
|
58
|
+
test_group = all_groups.find{|g| g.name == TEST_GROUP_NAME}
|
59
|
+
if(test_group)
|
60
|
+
BOX_CLIENT.delete_group(test_group.id)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'invokes folder operations' do
|
65
|
+
puts "get folder id using path"
|
66
|
+
folder_id = BOX_CLIENT.folder_id(TEST_FOLDER_NAME)
|
67
|
+
expect(folder_id).to eq(@test_folder_id)
|
68
|
+
|
69
|
+
puts "get folder info"
|
70
|
+
folder = BOX_CLIENT.folder(@test_folder_id)
|
71
|
+
expect(folder.id).to eq(@test_folder_id)
|
72
|
+
|
73
|
+
puts "create new folder"
|
74
|
+
new_folder = BOX_CLIENT.create_folder(SUB_FOLDER_NAME, @test_folder_id)
|
75
|
+
expect(new_folder).to be_a Hashie::Mash
|
76
|
+
SUB_FOLDER_ID = new_folder.id
|
77
|
+
|
78
|
+
puts "update folder"
|
79
|
+
updated_folder = BOX_CLIENT.update_folder(SUB_FOLDER_ID, description: SUB_FOLDER_DESCRIPTION)
|
80
|
+
expect(updated_folder.description).to eq(SUB_FOLDER_DESCRIPTION)
|
81
|
+
|
82
|
+
puts "copy folder"
|
83
|
+
new_folder = BOX_CLIENT.copy_folder(SUB_FOLDER_ID,@test_folder_id, name: 'copy of sub_folder_1')
|
84
|
+
expect(new_folder).to be_a Hashie::Mash
|
85
|
+
SUB_FOLDER_COPY_ID = new_folder.id
|
86
|
+
|
87
|
+
puts "create shared link for folder"
|
88
|
+
updated_folder = BOX_CLIENT.create_shared_link_for_folder(@test_folder_id, access: :open)
|
89
|
+
expect(updated_folder.shared_link.access).to eq("open")
|
90
|
+
shared_link = updated_folder.shared_link.url
|
91
|
+
|
92
|
+
puts "inspect shared link"
|
93
|
+
shared_item = BOX_CLIENT.shared_item(shared_link)
|
94
|
+
expect(shared_item.id).to eq(@test_folder_id)
|
95
|
+
|
96
|
+
puts "disable shared link for folder"
|
97
|
+
updated_folder = BOX_CLIENT.disable_shared_link_for_folder(@test_folder_id)
|
98
|
+
expect(updated_folder.shared_link).to be_nil
|
99
|
+
|
100
|
+
puts "delete folder"
|
101
|
+
result = BOX_CLIENT.delete_folder(SUB_FOLDER_COPY_ID, recursive: true)
|
102
|
+
expect(result).to eq ({})
|
103
|
+
|
104
|
+
puts "inspect the trash"
|
105
|
+
trash = BOX_CLIENT.trash()
|
106
|
+
expect(trash).to be_a Array
|
107
|
+
|
108
|
+
puts "inspect trashed folder"
|
109
|
+
trashed_folder = BOX_CLIENT.trashed_folder(SUB_FOLDER_COPY_ID)
|
110
|
+
expect(trashed_folder.item_status).to eq("trashed")
|
111
|
+
|
112
|
+
puts "restore trashed folder"
|
113
|
+
restored_folder = BOX_CLIENT.restore_trashed_folder(SUB_FOLDER_COPY_ID)
|
114
|
+
expect(restored_folder.item_status).to eq("active")
|
115
|
+
|
116
|
+
puts "trash and permanently delete folder"
|
117
|
+
BOX_CLIENT.delete_folder(SUB_FOLDER_COPY_ID, recursive: true)
|
118
|
+
result = BOX_CLIENT.delete_trashed_folder(SUB_FOLDER_COPY_ID)
|
119
|
+
expect(result).to eq({})
|
120
|
+
end
|
121
|
+
|
122
|
+
it "invokes file operations" do
|
123
|
+
puts "upload a file"
|
124
|
+
new_file = BOX_CLIENT.upload_file("./spec/test_files/#{TEST_FILE_NAME}", @test_folder_id)
|
125
|
+
expect(new_file.name).to eq(TEST_FILE_NAME)
|
126
|
+
test_file_id = new_file.id
|
127
|
+
|
128
|
+
puts "get file id using path"
|
129
|
+
file_id = BOX_CLIENT.file_id("/#{TEST_FOLDER_NAME}/#{TEST_FILE_NAME}")
|
130
|
+
expect(file_id).to eq(test_file_id)
|
131
|
+
|
132
|
+
puts "get file download url"
|
133
|
+
download_url = BOX_CLIENT.download_url(test_file_id)
|
134
|
+
expect(download_url).to start_with("https://")
|
135
|
+
|
136
|
+
puts "get file info"
|
137
|
+
file_info = BOX_CLIENT.file(test_file_id)
|
138
|
+
expect(file_info.id).to eq(test_file_id)
|
139
|
+
|
140
|
+
puts "update file"
|
141
|
+
new_description = 'this file is used to test Boxr'
|
142
|
+
updated_file_info = BOX_CLIENT.update_file(test_file_id, description: new_description)
|
143
|
+
expect(updated_file_info.description).to eq(new_description)
|
144
|
+
|
145
|
+
puts "download file"
|
146
|
+
file = BOX_CLIENT.download_file(test_file_id)
|
147
|
+
f = open("./spec/test_files/#{DOWNLOADED_TEST_FILE_NAME}", 'w+')
|
148
|
+
f.write(file)
|
149
|
+
f.close
|
150
|
+
expect(FileUtils.identical?("./spec/test_files/#{TEST_FILE_NAME}","./spec/test_files/#{DOWNLOADED_TEST_FILE_NAME}")).to eq(true)
|
151
|
+
File.delete("./spec/test_files/#{DOWNLOADED_TEST_FILE_NAME}")
|
152
|
+
|
153
|
+
puts "upload new version of file"
|
154
|
+
new_version = BOX_CLIENT.upload_new_version_of_file("./spec/test_files/#{TEST_FILE_NAME}", test_file_id)
|
155
|
+
expect(new_version.id).to eq(test_file_id)
|
156
|
+
|
157
|
+
puts "inspect versions of file"
|
158
|
+
versions = BOX_CLIENT.versions_of_file(test_file_id)
|
159
|
+
expect(versions.count).to eq(1) #the reason this is 1 instead of 2 is that Box considers 'versions' to be a versions other than 'current'
|
160
|
+
v1_id = versions.first.id
|
161
|
+
|
162
|
+
puts "promote old version of file"
|
163
|
+
newer_version = BOX_CLIENT.promote_old_version_of_file(test_file_id, v1_id)
|
164
|
+
versions = BOX_CLIENT.versions_of_file(test_file_id)
|
165
|
+
expect(versions.count).to eq(2)
|
166
|
+
|
167
|
+
puts "delete old version of file"
|
168
|
+
result = BOX_CLIENT.delete_old_version_of_file(test_file_id,v1_id)
|
169
|
+
versions = BOX_CLIENT.versions_of_file(test_file_id)
|
170
|
+
expect(versions.count).to eq(2) #this is still 2 because with Box you can restore a trashed old version
|
171
|
+
|
172
|
+
puts "get file thumbnail"
|
173
|
+
thumb = BOX_CLIENT.thumbnail(test_file_id)
|
174
|
+
expect(thumb).not_to be_nil
|
175
|
+
|
176
|
+
puts "create shared link for file"
|
177
|
+
updated_file = BOX_CLIENT.create_shared_link_for_file(test_file_id, access: :open)
|
178
|
+
expect(updated_file.shared_link.access).to eq("open")
|
179
|
+
|
180
|
+
puts "disable shared link for file"
|
181
|
+
updated_file = BOX_CLIENT.disable_shared_link_for_file(test_file_id)
|
182
|
+
expect(updated_file.shared_link).to be_nil
|
183
|
+
|
184
|
+
puts "copy file"
|
185
|
+
new_file_name = "copy of #{TEST_FILE_NAME}"
|
186
|
+
new_file = BOX_CLIENT.copy_file(test_file_id, @test_folder_id, name: new_file_name)
|
187
|
+
expect(new_file.name).to eq(new_file_name)
|
188
|
+
NEW_FILE_ID = new_file.id
|
189
|
+
|
190
|
+
puts "delete file"
|
191
|
+
result = BOX_CLIENT.delete_file(NEW_FILE_ID)
|
192
|
+
expect(result).to eq({})
|
193
|
+
|
194
|
+
puts "get trashed file info"
|
195
|
+
trashed_file = BOX_CLIENT.trashed_file(NEW_FILE_ID)
|
196
|
+
expect(trashed_file.item_status).to eq("trashed")
|
197
|
+
|
198
|
+
puts "restore trashed file"
|
199
|
+
restored_file = BOX_CLIENT.restore_trashed_file(NEW_FILE_ID)
|
200
|
+
expect(restored_file.item_status).to eq("active")
|
201
|
+
|
202
|
+
puts "trash and permanently delete file"
|
203
|
+
BOX_CLIENT.delete_file(NEW_FILE_ID)
|
204
|
+
result = BOX_CLIENT.delete_trashed_file(NEW_FILE_ID)
|
205
|
+
expect(result).to eq({})
|
206
|
+
end
|
207
|
+
|
208
|
+
it "invokes user operations" do
|
209
|
+
puts "inspect current user"
|
210
|
+
user = BOX_CLIENT.current_user
|
211
|
+
expect(user.status).to eq('active')
|
212
|
+
user = BOX_CLIENT.me(fields: [:role])
|
213
|
+
expect(user.role).to_not be_nil
|
214
|
+
|
215
|
+
puts "inspect a user"
|
216
|
+
user = BOX_CLIENT.user(@test_user_id)
|
217
|
+
expect(user.id).to eq(@test_user_id)
|
218
|
+
|
219
|
+
puts "inspect all users"
|
220
|
+
all_users = BOX_CLIENT.all_users()
|
221
|
+
test_user = all_users.find{|u| u.id == @test_user_id}
|
222
|
+
expect(test_user).to_not be_nil
|
223
|
+
|
224
|
+
puts "update user"
|
225
|
+
new_name = "Chuck Nevitt"
|
226
|
+
user = BOX_CLIENT.update_user(@test_user_id, name: new_name)
|
227
|
+
expect(user.name).to eq(new_name)
|
228
|
+
|
229
|
+
#create user is tested in the before method
|
230
|
+
|
231
|
+
puts "delete user"
|
232
|
+
result = BOX_CLIENT.delete_user(@test_user_id, force: true)
|
233
|
+
expect(result).to eq({})
|
234
|
+
end
|
235
|
+
|
236
|
+
it "invokes group operations" do
|
237
|
+
puts "create group"
|
238
|
+
group = BOX_CLIENT.create_group(TEST_GROUP_NAME)
|
239
|
+
expect(group.name).to eq(TEST_GROUP_NAME)
|
240
|
+
test_group_id = group.id
|
241
|
+
|
242
|
+
puts "inspect groups"
|
243
|
+
groups = BOX_CLIENT.groups
|
244
|
+
test_group = groups.find{|g| g.name == TEST_GROUP_NAME}
|
245
|
+
expect(test_group).to_not be_nil
|
246
|
+
|
247
|
+
puts "update group"
|
248
|
+
new_name = "Test Boxr Group Renamed"
|
249
|
+
group = BOX_CLIENT.update_group(test_group_id, new_name)
|
250
|
+
expect(group.name).to eq(new_name)
|
251
|
+
group = BOX_CLIENT.rename_group(test_group_id,TEST_GROUP_NAME)
|
252
|
+
expect(group.name).to eq(TEST_GROUP_NAME)
|
253
|
+
|
254
|
+
puts "add user to group"
|
255
|
+
group_membership = BOX_CLIENT.add_user_to_group(@test_user_id, test_group_id)
|
256
|
+
expect(group_membership.user.id).to eq(@test_user_id)
|
257
|
+
expect(group_membership.group.id).to eq(test_group_id)
|
258
|
+
membership_id = group_membership.id
|
259
|
+
|
260
|
+
puts "inspect group membership"
|
261
|
+
group_membership = BOX_CLIENT.group_membership(membership_id)
|
262
|
+
expect(group_membership.id).to eq(membership_id)
|
263
|
+
|
264
|
+
puts "inspect group memberships"
|
265
|
+
group_memberships = BOX_CLIENT.group_memberships(test_group_id)
|
266
|
+
expect(group_memberships.count).to eq(1)
|
267
|
+
expect(group_memberships.first.id).to eq(membership_id)
|
268
|
+
|
269
|
+
puts "inspect group memberships for a user"
|
270
|
+
group_memberships = BOX_CLIENT.group_memberships_for_user(@test_user_id)
|
271
|
+
expect(group_memberships.count).to eq(1)
|
272
|
+
expect(group_memberships.first.id).to eq(membership_id)
|
273
|
+
|
274
|
+
puts "inspect group memberships for me"
|
275
|
+
#this is whatever user your developer token is tied to
|
276
|
+
group_memberships = BOX_CLIENT.group_memberships_for_me
|
277
|
+
expect(group_memberships).to be_a(Array)
|
278
|
+
|
279
|
+
puts "update group membership"
|
280
|
+
group_membership = BOX_CLIENT.update_group_membership(membership_id, :admin)
|
281
|
+
expect(group_membership.role).to eq("admin")
|
282
|
+
|
283
|
+
puts "delete group membership"
|
284
|
+
result = BOX_CLIENT.delete_group_membership(membership_id)
|
285
|
+
expect(result).to eq({})
|
286
|
+
group_memberships = BOX_CLIENT.group_memberships_for_user(@test_user_id)
|
287
|
+
expect(group_memberships.count).to eq(0)
|
288
|
+
|
289
|
+
puts "inspect group collaborations"
|
290
|
+
group_collaboration = BOX_CLIENT.add_collaboration(@test_folder_id, {id: test_group_id, type: :group}, :editor)
|
291
|
+
expect(group_collaboration.accessible_by.id).to eq(test_group_id)
|
292
|
+
|
293
|
+
puts "delete group"
|
294
|
+
response = BOX_CLIENT.delete_group(test_group_id)
|
295
|
+
expect(response).to eq({})
|
296
|
+
end
|
297
|
+
|
298
|
+
it "invokes comment operations" do
|
299
|
+
new_file = BOX_CLIENT.upload_file("./spec/test_files/#{TEST_FILE_NAME}", @test_folder_id)
|
300
|
+
test_file_id = new_file.id
|
301
|
+
|
302
|
+
puts "add comment to file"
|
303
|
+
comment = BOX_CLIENT.add_comment_to_file(test_file_id, message: COMMENT_MESSAGE)
|
304
|
+
expect(comment.message).to eq(COMMENT_MESSAGE)
|
305
|
+
COMMENT_ID = comment.id
|
306
|
+
|
307
|
+
puts "reply to comment"
|
308
|
+
reply = BOX_CLIENT.reply_to_comment(COMMENT_ID, message: REPLY_MESSAGE)
|
309
|
+
expect(reply.message).to eq(REPLY_MESSAGE)
|
310
|
+
|
311
|
+
puts "get file comments"
|
312
|
+
comments = BOX_CLIENT.file_comments(test_file_id)
|
313
|
+
expect(comments.count).to eq(2)
|
314
|
+
|
315
|
+
puts "update a comment"
|
316
|
+
comment = BOX_CLIENT.change_comment(COMMENT_ID, CHANGED_COMMENT_MESSAGE)
|
317
|
+
expect(comment.message).to eq(CHANGED_COMMENT_MESSAGE)
|
318
|
+
|
319
|
+
puts "get comment info"
|
320
|
+
comment = BOX_CLIENT.comment(COMMENT_ID)
|
321
|
+
expect(comment.id).to eq(COMMENT_ID)
|
322
|
+
|
323
|
+
puts "delete comment"
|
324
|
+
result = BOX_CLIENT.delete_comment(COMMENT_ID)
|
325
|
+
expect(result).to eq({})
|
326
|
+
end
|
327
|
+
|
328
|
+
it "invokes collaborations operations" do
|
329
|
+
puts "add collaboration"
|
330
|
+
collaboration = BOX_CLIENT.add_collaboration(@test_folder_id, {id: @test_user_id, type: :user}, :editor)
|
331
|
+
expect(collaboration.accessible_by.id).to eq(@test_user_id)
|
332
|
+
collaboration_id = collaboration.id
|
333
|
+
|
334
|
+
puts "inspect collaboration"
|
335
|
+
collaboration = BOX_CLIENT.collaboration(collaboration_id)
|
336
|
+
expect(collaboration.id).to eq(collaboration_id)
|
337
|
+
|
338
|
+
puts "edit collaboration"
|
339
|
+
collaboration = BOX_CLIENT.edit_collaboration(collaboration_id, role: "viewer uploader")
|
340
|
+
expect(collaboration.role).to eq("viewer uploader")
|
341
|
+
|
342
|
+
puts "inspect folder collaborations"
|
343
|
+
collaborations = BOX_CLIENT.folder_collaborations(@test_folder_id)
|
344
|
+
expect(collaborations.count).to eq(1)
|
345
|
+
expect(collaborations[0].id).to eq(collaboration_id)
|
346
|
+
|
347
|
+
puts "remove collaboration"
|
348
|
+
result = BOX_CLIENT.remove_collaboration(collaboration_id)
|
349
|
+
expect(result).to eq({})
|
350
|
+
collaborations = BOX_CLIENT.folder_collaborations(@test_folder_id)
|
351
|
+
expect(collaborations.count).to eq(0)
|
352
|
+
|
353
|
+
puts "inspect pending collaborations"
|
354
|
+
pending_collaborations = BOX_CLIENT.pending_collaborations
|
355
|
+
expect(pending_collaborations).to eq([])
|
356
|
+
end
|
357
|
+
|
358
|
+
it "invokes task operations" do
|
359
|
+
new_file = BOX_CLIENT.upload_file("./spec/test_files/#{TEST_FILE_NAME}", @test_folder_id)
|
360
|
+
test_file_id = new_file.id
|
361
|
+
collaboration = BOX_CLIENT.add_collaboration(@test_folder_id, {id: @test_user_id, type: :user}, :editor)
|
362
|
+
|
363
|
+
puts "create task"
|
364
|
+
new_task = BOX_CLIENT.create_task(test_file_id, message: TEST_TASK_MESSAGE)
|
365
|
+
expect(new_task.message).to eq(TEST_TASK_MESSAGE)
|
366
|
+
TEST_TASK_ID = new_task.id
|
367
|
+
|
368
|
+
puts "inspect file tasks"
|
369
|
+
tasks = BOX_CLIENT.file_tasks(test_file_id)
|
370
|
+
expect(tasks.first.id).to eq(TEST_TASK_ID)
|
371
|
+
|
372
|
+
puts "inspect task"
|
373
|
+
task = BOX_CLIENT.task(TEST_TASK_ID)
|
374
|
+
expect(task.id).to eq(TEST_TASK_ID)
|
375
|
+
|
376
|
+
puts "update task"
|
377
|
+
NEW_TASK_MESSAGE = "new task message"
|
378
|
+
updated_task = BOX_CLIENT.update_task(TEST_TASK_ID, message: NEW_TASK_MESSAGE)
|
379
|
+
expect(updated_task.message).to eq(NEW_TASK_MESSAGE)
|
380
|
+
|
381
|
+
puts "create task assignment"
|
382
|
+
task_assignment = BOX_CLIENT.create_task_assignment(TEST_TASK_ID, assign_to_id: @test_user_id)
|
383
|
+
expect(task_assignment.assigned_to.id).to eq(@test_user_id)
|
384
|
+
task_assignment_id = task_assignment.id
|
385
|
+
|
386
|
+
puts "inspect task assignment"
|
387
|
+
task_assignment = BOX_CLIENT.task_assignment(task_assignment_id)
|
388
|
+
expect(task_assignment.id).to eq(task_assignment_id)
|
389
|
+
|
390
|
+
puts "inspect task assignments"
|
391
|
+
task_assignments = BOX_CLIENT.task_assignments(TEST_TASK_ID)
|
392
|
+
expect(task_assignments.count).to eq(1)
|
393
|
+
expect(task_assignments[0].id).to eq(task_assignment_id)
|
394
|
+
|
395
|
+
#TODO: can't do this test yet because the test user needs to confirm their email address before you can do this
|
396
|
+
puts "update task assignment"
|
397
|
+
expect {
|
398
|
+
box_client_as_test_user = Boxr::Client.new(ENV['BOX_DEVELOPER_TOKEN'], as_user_id: @test_user_id)
|
399
|
+
new_message = "Updated task message"
|
400
|
+
task_assignment = box_client_as_test_user.update_task_assignment(TEST_TASK_ID, resolution_state: :completed)
|
401
|
+
expect(task_assignment.resolution_state).to eq('completed')
|
402
|
+
}.to raise_error
|
403
|
+
|
404
|
+
puts "delete task assignment"
|
405
|
+
result = BOX_CLIENT.delete_task_assignment(task_assignment_id)
|
406
|
+
expect(result).to eq({})
|
407
|
+
|
408
|
+
puts "delete task"
|
409
|
+
result = BOX_CLIENT.delete_task(TEST_TASK_ID)
|
410
|
+
expect(result).to eq({})
|
411
|
+
end
|
412
|
+
|
413
|
+
it "invokes metadata operations" do
|
414
|
+
new_file = BOX_CLIENT.upload_file("./spec/test_files/#{TEST_FILE_NAME}", @test_folder_id)
|
415
|
+
test_file_id = new_file.id
|
416
|
+
|
417
|
+
puts "create metadata"
|
418
|
+
meta = {"a" => "hello", "b" => "world"}
|
419
|
+
metadata = BOX_CLIENT.create_metadata(test_file_id, meta)
|
420
|
+
expect(metadata.a).to eq("hello")
|
421
|
+
|
422
|
+
puts "update metadata"
|
423
|
+
metadata = BOX_CLIENT.update_metadata(test_file_id, [{op: :replace, path: "/b", value: "there"}])
|
424
|
+
expect(metadata.b).to eq("there")
|
425
|
+
|
426
|
+
puts "get metadata"
|
427
|
+
metadata = BOX_CLIENT.metadata(test_file_id)
|
428
|
+
expect(metadata.a).to eq("hello")
|
429
|
+
|
430
|
+
puts "delete metadata"
|
431
|
+
result = BOX_CLIENT.delete_metadata(test_file_id)
|
432
|
+
expect(result).to eq({})
|
433
|
+
end
|
434
|
+
|
435
|
+
it "invokes search operations" do
|
436
|
+
#the issue with this test is that Box can take between 5-10 minutes to index any content uploaded; this is just a smoke test
|
437
|
+
#so we are searching for something that should return zero results
|
438
|
+
puts "perform search"
|
439
|
+
results = BOX_CLIENT.search("sdlfjuwnsljsdfuqpoiqweouyvnnadsfkjhiuweruywerbjvhvkjlnasoifyukhenlwdflnsdvoiuawfydfjh")
|
440
|
+
expect(results).to eq([])
|
441
|
+
end
|
442
|
+
|
443
|
+
it "invokes a Boxr exception" do
|
444
|
+
expect { BOX_CLIENT.folder(1)}.to raise_error
|
445
|
+
end
|
446
446
|
|
447
447
|
end
|