boxrubylib 0.0.1
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.
- data/History.txt +4 -0
- data/License.txt +621 -0
- data/Manifest.txt +14 -0
- data/PostInstall.txt +3 -0
- data/README.rdoc +37 -0
- data/Rakefile +26 -0
- data/lib/boxrubylib/boxclientlib.rb +1036 -0
- data/lib/boxrubylib/restclientlib.rb +284 -0
- data/lib/boxrubylib.rb +8 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/test/test_boxrubylib.rb +11 -0
- data/test/test_helper.rb +3 -0
- metadata +83 -0
@@ -0,0 +1,1036 @@
|
|
1
|
+
#= boxclientlib.rb
|
2
|
+
#Author:: Tomohiko Ariki, Makoto Kobayashi
|
3
|
+
#CopyRights:: Canon Software Inc.
|
4
|
+
#Created date:: 2009/06/10
|
5
|
+
#Version:: 1.0.0
|
6
|
+
#
|
7
|
+
#This file contains Box.net service class.
|
8
|
+
|
9
|
+
require "boxrubylib/restclientlib"
|
10
|
+
|
11
|
+
module BoxClientLib
|
12
|
+
#Box.net client class.
|
13
|
+
#
|
14
|
+
#class valiable:
|
15
|
+
# @@server - Box.net URL ("www.box.net").
|
16
|
+
# @@upload - Upload URL ("upload.box.net").
|
17
|
+
# @@apiPath - Box.net rest api path ("/api/1.0/rest").
|
18
|
+
# @@header - HTTP header to get/post method.
|
19
|
+
#
|
20
|
+
#attributes:
|
21
|
+
# userStorageInfo - User's Box.net storage information.
|
22
|
+
class BoxRestClient < RestClientLib::RestClient
|
23
|
+
@@server = "www.box.net"
|
24
|
+
@@port = 80
|
25
|
+
@@sslPort = 443
|
26
|
+
@@upload = "upload.box.net"
|
27
|
+
@@apiPath = "/api/1.0/rest"
|
28
|
+
@@header = {
|
29
|
+
"User-Agent" => "boxclientlib/0.0.1\r\n"
|
30
|
+
}
|
31
|
+
attr_accessor :apiKey, :userStorageInfo
|
32
|
+
|
33
|
+
# Constructor.
|
34
|
+
#
|
35
|
+
# If you want to use your Box.net api key, you can set it after initializing.
|
36
|
+
def initialize
|
37
|
+
super
|
38
|
+
@apiKey = "3kaxmeu3cj0fvm6is2smxgsqhnxa6ajy"
|
39
|
+
end
|
40
|
+
|
41
|
+
# Request ticket to receive auth token.
|
42
|
+
#
|
43
|
+
# [Return value]
|
44
|
+
# Ticket(string value).
|
45
|
+
def getTicket
|
46
|
+
params = {
|
47
|
+
"action" => "get_ticket",
|
48
|
+
"api_key" => @apiKey
|
49
|
+
}
|
50
|
+
doc = getRequest(@@server, @useSSL == false ? @@port : @@sslPort, @@apiPath, params, @@header)
|
51
|
+
checkError(doc, "get_ticket_ok")
|
52
|
+
|
53
|
+
return doc.elements["/response/ticket"].text
|
54
|
+
end
|
55
|
+
|
56
|
+
# Get auth token to call Box.net API.
|
57
|
+
# [ticket]
|
58
|
+
# Ticket to get auth token.
|
59
|
+
#
|
60
|
+
# [Return value]
|
61
|
+
# Auth token. (And it will be set instance value - @userStorageInfo.)
|
62
|
+
def getAuthToken(ticket)
|
63
|
+
params = {
|
64
|
+
"action" => "get_auth_token",
|
65
|
+
"api_key" => @apiKey,
|
66
|
+
"ticket" => ticket
|
67
|
+
}
|
68
|
+
doc = getRequest(@@server, @useSSL == false ? @@port : @@sslPort, @@apiPath, params, @@header)
|
69
|
+
checkError(doc, "get_auth_token_ok")
|
70
|
+
@userStorageInfo = UserStorageInfo.new(doc.elements['/response/user'])
|
71
|
+
return @userStorageInfo.authToken = doc.elements['/response/auth_token'].text
|
72
|
+
end
|
73
|
+
|
74
|
+
# Logout.
|
75
|
+
#
|
76
|
+
# [Return value]
|
77
|
+
# True, if success.
|
78
|
+
def logout
|
79
|
+
params = {
|
80
|
+
"action" => "logout",
|
81
|
+
"api_key" => @apiKey,
|
82
|
+
"auth_token" => @userStorageInfo == nil ? "" : @userStorageInfo.authToken
|
83
|
+
}
|
84
|
+
doc = getRequest(@@server, @useSSL == false ? @@port : @@sslPort, @@apiPath, params, @@header)
|
85
|
+
return checkError(doc, "logout_ok")
|
86
|
+
end
|
87
|
+
|
88
|
+
# Regist new user.
|
89
|
+
#
|
90
|
+
# [login]
|
91
|
+
# Login user name to regist.
|
92
|
+
# [password]
|
93
|
+
# Password for new user to regist.
|
94
|
+
#
|
95
|
+
# [Return value]
|
96
|
+
# True, if success.
|
97
|
+
def registerNewUser(login, password)
|
98
|
+
params = {
|
99
|
+
"action" => "register_new_user",
|
100
|
+
"api_key" => @apiKey,
|
101
|
+
"login" => login,
|
102
|
+
"password" => password
|
103
|
+
}
|
104
|
+
doc = getRequest(@@server, @useSSL == false ? @@port : @@sslPort, @@apiPath, params, @@header)
|
105
|
+
return checkError(doc, "successful_register")
|
106
|
+
end
|
107
|
+
|
108
|
+
# This method is used to verify whether a user email is available, or already in use.
|
109
|
+
#
|
110
|
+
# [userName]
|
111
|
+
# The login username of the user for which you would like to verify registration.
|
112
|
+
#
|
113
|
+
# [Return value]
|
114
|
+
# True, if success.
|
115
|
+
def verifyRegistrationEmail(login)
|
116
|
+
params = {
|
117
|
+
"action" => "verify_registration_email",
|
118
|
+
"api_key" => @apiKey,
|
119
|
+
"login" => login
|
120
|
+
}
|
121
|
+
doc = getRequest(@@server, @useSSL == false ? @@port : @@sslPort, @@apiPath, params, @@header)
|
122
|
+
return checkError(doc, "successful_register")
|
123
|
+
end
|
124
|
+
|
125
|
+
# Update user's storage information.
|
126
|
+
#
|
127
|
+
# [Return value]
|
128
|
+
# True, if success. (And it will be set instance value - @userStorageInfo.)
|
129
|
+
def updateUserStorageInfo
|
130
|
+
params = {
|
131
|
+
"action" => "get_account_info",
|
132
|
+
"api_key" => @apiKey,
|
133
|
+
"auth_token" => @userStorageInfo.authToken
|
134
|
+
}
|
135
|
+
doc = getRequest(@@server, @useSSL == false ? @@port : @@sslPort, @@apiPath, params, @@header)
|
136
|
+
checkError(doc, "get_account_info_ok")
|
137
|
+
@userStorageInfo.loginName = doc.elements['/response/user/login'].text
|
138
|
+
@userStorageInfo.email = doc.elements['/response/user/email'].text
|
139
|
+
@userStorageInfo.accessId = doc.elements['/response/user/access_id'].text
|
140
|
+
@userStorageInfo.userId = doc.elements['/response/user/user_id'].text
|
141
|
+
@userStorageInfo.spaceAmount = doc.elements['/response/user/space_amount'].text
|
142
|
+
@userStorageInfo.spaceUsed = doc.elements['/response/user/space_used'].text
|
143
|
+
|
144
|
+
return true
|
145
|
+
end
|
146
|
+
|
147
|
+
# File & Folder Operations
|
148
|
+
|
149
|
+
# Get folder info from root folder.
|
150
|
+
#
|
151
|
+
# [options]
|
152
|
+
# Array of to get folder info option parameter(s).you can set follows value(s).
|
153
|
+
# "onelevel" - Get one level of folder info.
|
154
|
+
# "nofiles" - Get folder info without file info.
|
155
|
+
# "simple" - Get simple info only(thumbnails, shared status, tags, and other attributes are left out).
|
156
|
+
#
|
157
|
+
# [Return value]
|
158
|
+
# Root folder information.
|
159
|
+
def getRootFolderInfo(options)
|
160
|
+
return getFolderInfo(0, options)
|
161
|
+
end
|
162
|
+
|
163
|
+
# Get target folder info.
|
164
|
+
# [folderId]
|
165
|
+
# Folder ID to get folder info.
|
166
|
+
# [options]
|
167
|
+
# Array of to get folder info option parameter(s).you can set follows value(s).
|
168
|
+
# "onelevel" - Get one level of folder info.
|
169
|
+
# "nofiles" - Get folder info without file info.
|
170
|
+
# "simple" - Get simple info only(thumbnails, shared status, tags, and other attributes are left out).
|
171
|
+
# [Return value]
|
172
|
+
# Target folder information.
|
173
|
+
def getFolderInfo(folderId, options)
|
174
|
+
options = Array.new if (options.nil?)
|
175
|
+
options.push("nozip") if (options.index("nozip").nil?)
|
176
|
+
params = {
|
177
|
+
"action" => "get_account_tree",
|
178
|
+
"api_key" => @apiKey,
|
179
|
+
"auth_token" => @userStorageInfo.authToken,
|
180
|
+
"folder_id" => folderId,
|
181
|
+
"params[]" => options
|
182
|
+
}
|
183
|
+
doc = getRequest(@@server, @useSSL == false ? @@port : @@sslPort, @@apiPath, params, @@header)
|
184
|
+
checkError(doc, "listing_ok")
|
185
|
+
|
186
|
+
return FolderInfo.new(doc.elements['/response/tree/folder'])
|
187
|
+
end
|
188
|
+
|
189
|
+
# Create folder.
|
190
|
+
#
|
191
|
+
# [parentId]
|
192
|
+
# Parent folder ID.
|
193
|
+
# [name]
|
194
|
+
# Folder name it will be created.
|
195
|
+
# [share]
|
196
|
+
# 1 - share, 0 - not share.
|
197
|
+
#
|
198
|
+
# [Return value]
|
199
|
+
# Created folder information.
|
200
|
+
def createFolder(parentId, name, share)
|
201
|
+
params = {
|
202
|
+
"action" => "create_folder",
|
203
|
+
"api_key" => @apiKey,
|
204
|
+
"auth_token" => @userStorageInfo.authToken,
|
205
|
+
"parent_id" => parentId,
|
206
|
+
"name" => name,
|
207
|
+
"share" => share
|
208
|
+
}
|
209
|
+
doc = getRequest(@@server, @useSSL == false ? @@port : @@sslPort, @@apiPath, params, @@header)
|
210
|
+
checkError(doc, "create_ok")
|
211
|
+
|
212
|
+
return CreatedFolderInfo.new(doc.elements['/response/folder'])
|
213
|
+
end
|
214
|
+
|
215
|
+
# Move file or folder.
|
216
|
+
#
|
217
|
+
# [target]
|
218
|
+
# The type of item to be moved. Can be 'file' or 'folder'.
|
219
|
+
# [targetId]
|
220
|
+
# The id of the item you wish to move.
|
221
|
+
# [destinationId]
|
222
|
+
# The folder_id of the folder to which you will move the item.
|
223
|
+
#
|
224
|
+
# [Return value]
|
225
|
+
# True, if success.
|
226
|
+
def move(target, targetId, destinationId)
|
227
|
+
params = {
|
228
|
+
"action" => "move",
|
229
|
+
"api_key" => @apiKey,
|
230
|
+
"auth_token" => @userStorageInfo.authToken,
|
231
|
+
"target" => target,
|
232
|
+
"target_id" => targetId,
|
233
|
+
"destination_id" => destinationId
|
234
|
+
}
|
235
|
+
doc = getRequest(@@server, @useSSL == false ? @@port : @@sslPort, @@apiPath, params, @@header)
|
236
|
+
return checkError(doc, "s_move_node")
|
237
|
+
end
|
238
|
+
|
239
|
+
# Rename file or folder.
|
240
|
+
#
|
241
|
+
# [target]
|
242
|
+
# The type of item to be renamed. Can be 'file' or 'folder'.
|
243
|
+
# [targetId]
|
244
|
+
# The id of the item you wish to rename.
|
245
|
+
# [newName]
|
246
|
+
# The new name to be applied to the item.
|
247
|
+
#
|
248
|
+
# [Return value]
|
249
|
+
# True, if success.
|
250
|
+
def rename(target, targetId, newName)
|
251
|
+
params = {
|
252
|
+
"action" => "rename",
|
253
|
+
"api_key" => @apiKey,
|
254
|
+
"auth_token" => @userStorageInfo.authToken,
|
255
|
+
"target" => target,
|
256
|
+
"target_id" => targetId,
|
257
|
+
"new_name" => newName
|
258
|
+
}
|
259
|
+
doc = getRequest(@@server, @useSSL == false ? @@port : @@sslPort, @@apiPath, params, @@header)
|
260
|
+
return checkError(doc, "s_rename_node")
|
261
|
+
end
|
262
|
+
|
263
|
+
# Delete file or folder.
|
264
|
+
#
|
265
|
+
# [target]
|
266
|
+
# The type of item to be deleted. Can be 'file' or 'folder'.
|
267
|
+
# [targetId]
|
268
|
+
# The id of the item you wish to delete.
|
269
|
+
#
|
270
|
+
# [Return value]
|
271
|
+
# True, if success.
|
272
|
+
def delete(target, targetId)
|
273
|
+
params = {
|
274
|
+
"action" => "delete",
|
275
|
+
"api_key" => @apiKey,
|
276
|
+
"auth_token" => @userStorageInfo.authToken,
|
277
|
+
"target" => target,
|
278
|
+
"target_id" => targetId,
|
279
|
+
}
|
280
|
+
doc = getRequest(@@server, @useSSL == false ? @@port : @@sslPort, @@apiPath, params, @@header)
|
281
|
+
return checkError(doc, "s_delete_node")
|
282
|
+
end
|
283
|
+
|
284
|
+
# Get the file information.
|
285
|
+
#
|
286
|
+
# [fileId]
|
287
|
+
# The id of the file for with you want to obtain more information.
|
288
|
+
#
|
289
|
+
# [Return value]
|
290
|
+
# File information.
|
291
|
+
def getFileInfo(fileId)
|
292
|
+
params = {
|
293
|
+
"action" => "get_file_info",
|
294
|
+
"api_key" => @apiKey,
|
295
|
+
"auth_token" => @userStorageInfo.authToken,
|
296
|
+
"fild_id" => fileId
|
297
|
+
}
|
298
|
+
doc = getRequest(@@server, @useSSL == false ? @@port : @@sslPort, @@apiPath, params, @@header)
|
299
|
+
checkError(doc, "s_get_file_info")
|
300
|
+
|
301
|
+
return FileInfo.new(doc.elements['/response/info'])
|
302
|
+
end
|
303
|
+
|
304
|
+
# Set description file or folder.
|
305
|
+
#
|
306
|
+
# [target]
|
307
|
+
# The type of item to set description. Can be 'file' or 'folder'.
|
308
|
+
# [targetId]
|
309
|
+
# The id of the item you wish to set description.
|
310
|
+
# [description]
|
311
|
+
# File or folder description.
|
312
|
+
#
|
313
|
+
# [Return value]
|
314
|
+
# True, if success.
|
315
|
+
def setDescription(target, targetId, description)
|
316
|
+
params = {
|
317
|
+
"action" => "set_description",
|
318
|
+
"api_key" => @apiKey,
|
319
|
+
"auth_token" => @userStorageInfo.authToken,
|
320
|
+
"target" => target,
|
321
|
+
"target_id" => targetId,
|
322
|
+
"description" => description
|
323
|
+
}
|
324
|
+
doc = getRequest(@@server, @useSSL == false ? @@port : @@sslPort, @@apiPath, params)
|
325
|
+
return checkError(doc, "s_set_desctiption")
|
326
|
+
end
|
327
|
+
|
328
|
+
# Upload file (If same file name is already exist target folder, it will be overwritten).
|
329
|
+
#
|
330
|
+
# [fileName]
|
331
|
+
# Name of the upload file.
|
332
|
+
# [data]
|
333
|
+
# File contents.
|
334
|
+
# [targetId]
|
335
|
+
# Folder ID to upload.
|
336
|
+
# [shareValue]
|
337
|
+
# 1 - share, 0 - not share.
|
338
|
+
# [message]
|
339
|
+
# An message to be included in a notification email, if the file will be shared with others.
|
340
|
+
# [emails]
|
341
|
+
# email addresses to notify him or her about file uploaded.if you want to send 2 or more
|
342
|
+
# email address, you set to "emails" parameter to Array type.
|
343
|
+
#
|
344
|
+
# [Return value]
|
345
|
+
# Uploaded file information.
|
346
|
+
def fileUpload(fileName, data, targetId, shareValue, message, emails)
|
347
|
+
params = setUploadParameter(shareValue, message, emails)
|
348
|
+
uri = "/api/1.0/upload/#{@userStorageInfo.authToken}/#{targetId}"
|
349
|
+
doc = postRequest(@@upload, @useSSL == false ? @@port : @@sslPort, uri, fileName, data, params, @@header)
|
350
|
+
checkError(doc, "upload_ok")
|
351
|
+
|
352
|
+
return UploadedFileInfo.new(doc.elements['/response/files/file'])
|
353
|
+
end
|
354
|
+
|
355
|
+
# Upload file (Over write particular file).
|
356
|
+
#
|
357
|
+
# [fileName]
|
358
|
+
# Name of the upload file.
|
359
|
+
# [data]
|
360
|
+
# File contents.
|
361
|
+
# [targetId]
|
362
|
+
# File ID to overwrite.
|
363
|
+
# [shareValue]
|
364
|
+
# 1 - share, 0 - not share.
|
365
|
+
# [message]
|
366
|
+
# An message to be included in a notification email, if the file will be shared with others.
|
367
|
+
# [emails]
|
368
|
+
# email addresses to notify him or her about file uploaded.if you want to send 2 or more
|
369
|
+
# email address, you set to "emails" parameter to Array type.
|
370
|
+
#
|
371
|
+
# [Return value]
|
372
|
+
# Uploaded file information.
|
373
|
+
def fileOverWrite(fileName, data, targetId, shareValue, message, emails)
|
374
|
+
params = setUploadParameter(shareValue, message, emails)
|
375
|
+
uri = "/api/1.0/overwrite/#{@userStorageInfo.authToken}/#{targetId}"
|
376
|
+
doc = postRequest(@@upload, @useSSL == false ? @@port : @@sslPort, uri, fileName, data, params, @@header)
|
377
|
+
checkError(doc, "upload_ok")
|
378
|
+
|
379
|
+
return UploadedFileInfo.new(doc.elements['/response/files/file'])
|
380
|
+
end
|
381
|
+
|
382
|
+
# Upload file (uploaded file's name will be "Copy of original-file-name").
|
383
|
+
#
|
384
|
+
# [fileName]
|
385
|
+
# Name of the upload file.
|
386
|
+
# [data]
|
387
|
+
# File contents.
|
388
|
+
# [targetId]
|
389
|
+
# File ID to origin.
|
390
|
+
# [shareValue]
|
391
|
+
# 1 - share, 0 - not share.
|
392
|
+
# [message]
|
393
|
+
# An message to be included in a notification email, if the file will be shared with others.
|
394
|
+
# [emails]
|
395
|
+
# email addresses to notify him or her about file uploaded.if you want to send 2 or more
|
396
|
+
# email address, you set to "emails" parameter to Array type.
|
397
|
+
#
|
398
|
+
# [Return value]
|
399
|
+
# Uploaded file information.
|
400
|
+
def fileNewCopy(fileName, data, targetId, shareValue, message, emails)
|
401
|
+
params = setUploadParameter(shareValue, message, emails)
|
402
|
+
uri = "/api/1.0/new_copy/#{@userStorageInfo.authToken}/#{targetId}"
|
403
|
+
doc = postRequest(@@upload, @useSSL == false ? @@port : @@sslPort, uri, fileName, data, params, @@header)
|
404
|
+
checkError(doc, "upload_ok")
|
405
|
+
|
406
|
+
return UploadedFileInfo.new(doc.elements['/response/files/file'])
|
407
|
+
end
|
408
|
+
|
409
|
+
# Download file.
|
410
|
+
#
|
411
|
+
# [targetId]
|
412
|
+
# Download file ID.
|
413
|
+
#
|
414
|
+
# [Return value]
|
415
|
+
# File data.
|
416
|
+
def fileDownload(targetId)
|
417
|
+
uri = "/api/1.0/download/#{@userStorageInfo.authToken}/#{targetId}"
|
418
|
+
|
419
|
+
return httpGetRequest(@@server, @useSSL == false ? @@port : @@sslPort, uri, @@header)
|
420
|
+
end
|
421
|
+
|
422
|
+
# Sharing
|
423
|
+
|
424
|
+
# Make a file or folder shareable.
|
425
|
+
#
|
426
|
+
# [target]
|
427
|
+
# The type of item to share. Can be 'file' or 'folder'.
|
428
|
+
# [targetId]
|
429
|
+
# The id of the item you wish to share.
|
430
|
+
# [password]
|
431
|
+
# New password to be applied to the shared item.
|
432
|
+
# [message]
|
433
|
+
# An message to be included in a notification email.
|
434
|
+
# [emails]
|
435
|
+
# An array of emails for which to notify users about the newly shared file or folder.
|
436
|
+
#
|
437
|
+
# [Return value]
|
438
|
+
# Public name.
|
439
|
+
def publicShare(target, targetId, password, message, emails)
|
440
|
+
params = {
|
441
|
+
"action" => "public_share",
|
442
|
+
"api_key" => @apiKey,
|
443
|
+
"auth_token" => @userStorageInfo.authToken,
|
444
|
+
"target" => target,
|
445
|
+
"target_id" => targetId,
|
446
|
+
"password" => password,
|
447
|
+
"message" => message,
|
448
|
+
"emails[]" => emails
|
449
|
+
}
|
450
|
+
doc = getRequest(@@server, @useSSL == false ? @@port : @@sslPort, @@apiPath, params, @@header)
|
451
|
+
checkError(doc, "share_ok")
|
452
|
+
|
453
|
+
return doc.elements["/response/public_name"].text
|
454
|
+
end
|
455
|
+
|
456
|
+
# Unshare a public folder or file.
|
457
|
+
#
|
458
|
+
# [target]
|
459
|
+
# The type of item to set description. Can be 'file' or 'folder'.
|
460
|
+
# [targetId]
|
461
|
+
# The id of the item you wish to unshare.
|
462
|
+
#
|
463
|
+
# [Return value]
|
464
|
+
# True, if success.
|
465
|
+
def publicUnshare(target, targetId)
|
466
|
+
params = {
|
467
|
+
"action" => "public_unshare",
|
468
|
+
"api_key" => @apiKey,
|
469
|
+
"auth_token" => @userStorageInfo.authToken,
|
470
|
+
"target" => target,
|
471
|
+
"target_id" => targetId
|
472
|
+
}
|
473
|
+
doc = getRequest(@@server, @useSSL == false ? @@port : @@sslPort, @@apiPath, params, @@header)
|
474
|
+
return checkError(doc, "unshare_ok")
|
475
|
+
end
|
476
|
+
|
477
|
+
# Share a private folder or file.
|
478
|
+
#
|
479
|
+
# [target]
|
480
|
+
# The type of item to set description. Can be 'file' or 'folder'.
|
481
|
+
# [targetId]
|
482
|
+
# The id of the item you wish to private share.
|
483
|
+
# [message]
|
484
|
+
# An message to be included in a notification email.
|
485
|
+
# [emails]
|
486
|
+
# An array of emails for which to share (and notify) users about the newly shared file or folder.
|
487
|
+
# [notify]
|
488
|
+
# 1 - notification email will be sent to users, 0 - not notification.
|
489
|
+
#
|
490
|
+
# [Return value]
|
491
|
+
# True, if success.
|
492
|
+
def privateShare(target, targetId, message, emails, notify)
|
493
|
+
params = {
|
494
|
+
"action" => "private_share",
|
495
|
+
"api_key" => @apiKey,
|
496
|
+
"auth_token" => @userStorageInfo.authToken,
|
497
|
+
"target" => target,
|
498
|
+
"target_id" => targetId,
|
499
|
+
"message" => message,
|
500
|
+
"emails[]" => emails,
|
501
|
+
"notify" => notify == 0 ? "false" : "true"
|
502
|
+
}
|
503
|
+
doc = getRequest(@@server, @useSSL == false ? @@port : @@sslPort, @@apiPath, params, @@header)
|
504
|
+
return checkError(doc, "private_share_ok")
|
505
|
+
end
|
506
|
+
|
507
|
+
# Request new friends to be added to the user's friend list.
|
508
|
+
#
|
509
|
+
# [message]
|
510
|
+
# An message to be included in a notification email.
|
511
|
+
# [emails]
|
512
|
+
# An array of emails for which to notify users to be added user's friend list.
|
513
|
+
# [options]
|
514
|
+
# Array of option parameter. See below - parameter values.
|
515
|
+
# "box_auto_subscribe" - Subscribe to the public boxes of invited users.
|
516
|
+
# "no_email" - Do not send emails to the invited users.
|
517
|
+
#
|
518
|
+
# [Return value]
|
519
|
+
# True, if success.
|
520
|
+
def requestFriends(messsage, emails, options)
|
521
|
+
params = {
|
522
|
+
"action" => "request_friends",
|
523
|
+
"api_key" => @apiKey,
|
524
|
+
"auth_token" => @userStorageInfo.authToken,
|
525
|
+
"message" => message,
|
526
|
+
"emails[]" => emails,
|
527
|
+
"params[]" => options
|
528
|
+
}
|
529
|
+
doc = getRequest(@@server, @useSSL == false ? @@port : @@sslPort, @@apiPath, params, @@header)
|
530
|
+
return checkError(doc, "s_request_friends")
|
531
|
+
end
|
532
|
+
|
533
|
+
# Retrieve user's friend list.
|
534
|
+
#
|
535
|
+
# [Return value]
|
536
|
+
# Friend list.
|
537
|
+
def getFriends
|
538
|
+
params = {
|
539
|
+
"action" => "get_friends",
|
540
|
+
"api_key" => @apiKey,
|
541
|
+
"auth_token" => @userStorageInfo.authToken,
|
542
|
+
"params[]" => "nozip"
|
543
|
+
}
|
544
|
+
doc = getRequest(@@server, @useSSL == false ? @@port : @@sslPort, @@apiPath, params, @@header)
|
545
|
+
checkError(doc, "s_get_friends")
|
546
|
+
friendList = Array.new
|
547
|
+
doc.elements.each('/response/friends/friend') do |friendElement|
|
548
|
+
friendList.push(TagInfo.new(friendElment))
|
549
|
+
end
|
550
|
+
|
551
|
+
return friendList
|
552
|
+
end
|
553
|
+
|
554
|
+
# Add to user's storage from publicly shared by another.
|
555
|
+
#
|
556
|
+
# [target]
|
557
|
+
# The type of item to set description. Can be 'file' or 'folder'.
|
558
|
+
# [fileId]
|
559
|
+
# The id of the file you wish to add user's storage. If you will pass a value to publicName, you must pass this parameter - nil.
|
560
|
+
# [publicName]
|
561
|
+
# The unique public name of the shared file that you wish to add to user's storage. If you will pass a value to fileId, you must pass this parameter - nil.
|
562
|
+
# [folderId]
|
563
|
+
# The folder ID of the folder to which you will add user to user's storage.
|
564
|
+
# [tags]
|
565
|
+
# A List of tags to apply to the file when copied into the user's own folder.
|
566
|
+
#
|
567
|
+
# [Return value]
|
568
|
+
# True, if success.
|
569
|
+
def addToMyStorage(target, fileId, publicName, folderId, tags)
|
570
|
+
params = {
|
571
|
+
"action" => "add_to_mybox",
|
572
|
+
"api_key" => @apiKey,
|
573
|
+
"auth_token" => @userStorageInfo.authToken,
|
574
|
+
"file_id" => fileId,
|
575
|
+
"target" => target,
|
576
|
+
"public_name" => publicName,
|
577
|
+
"folder_id" => folderId,
|
578
|
+
"tags" => tags
|
579
|
+
}
|
580
|
+
doc = getRequest(@@server, @useSSL == false ? @@port : @@sslPort, @@apiPath, params, @@header)
|
581
|
+
return checkError(doc, "addtomybox_ok")
|
582
|
+
end
|
583
|
+
|
584
|
+
# Tags
|
585
|
+
|
586
|
+
# Add to a tag or tags to a designated file or folder.
|
587
|
+
#
|
588
|
+
# [target]
|
589
|
+
# The type of item to add to tag(s). Can be 'file' or 'folder'.
|
590
|
+
# [targetId]
|
591
|
+
# The id of the item you wish to add to tag(s).
|
592
|
+
# [tags]
|
593
|
+
# A List of tags to apply to the file when copied into the user's own file or folder.
|
594
|
+
#
|
595
|
+
# [Return value]
|
596
|
+
# True, if success.
|
597
|
+
def addToTag(target, targetId, tags)
|
598
|
+
params = {
|
599
|
+
"action" => "add_to_tag",
|
600
|
+
"api_key" => @apiKey,
|
601
|
+
"auth_token" => @userStorageInfo.authToken,
|
602
|
+
"target" => target,
|
603
|
+
"target_id" => targetId,
|
604
|
+
"tags" => tags
|
605
|
+
}
|
606
|
+
doc = getRequest(@@server, @useSSL == false ? @@port : @@sslPort, @@apiPath, params, @@header)
|
607
|
+
return checkError(doc, "addtotag_ok")
|
608
|
+
end
|
609
|
+
|
610
|
+
#This method returns all the tags in a user's account.
|
611
|
+
#
|
612
|
+
# [Return value]
|
613
|
+
# Tag info list.
|
614
|
+
def exportTag
|
615
|
+
params = {
|
616
|
+
"action" => "export_tags",
|
617
|
+
"api_key" => @apiKey,
|
618
|
+
"auth_token" => @userStorageInfo.authToken
|
619
|
+
}
|
620
|
+
doc = getRequest(@@server, @useSSL == false ? @@port : @@sslPort, @@apiPath, params, @@header)
|
621
|
+
checkError(doc, "export_tags_ok")
|
622
|
+
tagList = Array.new
|
623
|
+
doc.elements.each('/response/tags/tag') do |tagElement|
|
624
|
+
tagList.push(TagInfo.new(tagElment))
|
625
|
+
end
|
626
|
+
return tagList
|
627
|
+
end
|
628
|
+
|
629
|
+
# Login to Box.net.
|
630
|
+
#
|
631
|
+
# [loginName]
|
632
|
+
# Login email address.
|
633
|
+
# [password]
|
634
|
+
# Login password.
|
635
|
+
#
|
636
|
+
# [Return value]
|
637
|
+
# Auth token - if success login. nil - if not success login.
|
638
|
+
def login(loginName, password)
|
639
|
+
sslFlag = @useSSL
|
640
|
+
ticket = getTicket()
|
641
|
+
params = {
|
642
|
+
"dologin" => 1,
|
643
|
+
"__login" => 1,
|
644
|
+
"login" => loginName,
|
645
|
+
"password" => password
|
646
|
+
}
|
647
|
+
@useSSL = true
|
648
|
+
uri = "/api/1.0/auth/#{ticket}"
|
649
|
+
begin
|
650
|
+
body = postRequest(@@server, @@sslPort, uri, nil, nil, params, @@header)
|
651
|
+
ensure
|
652
|
+
@useSSL = sslFlag
|
653
|
+
end
|
654
|
+
return getAuthToken(ticket) if body
|
655
|
+
return nil
|
656
|
+
end
|
657
|
+
|
658
|
+
private
|
659
|
+
def checkError(doc, success)
|
660
|
+
status = doc.elements['/response/status'].text
|
661
|
+
unless status == success
|
662
|
+
raise BoxServiceError.new(status)
|
663
|
+
end
|
664
|
+
return true
|
665
|
+
end
|
666
|
+
|
667
|
+
def setUploadParameter(shareValue, message, emails)
|
668
|
+
params = {
|
669
|
+
"share" => shareValue
|
670
|
+
}
|
671
|
+
params["message"] = message if (message != nil)
|
672
|
+
params["emails[]"] = emails if (emails != nil)
|
673
|
+
return params
|
674
|
+
end
|
675
|
+
end
|
676
|
+
|
677
|
+
#Box.net service exception class.
|
678
|
+
#
|
679
|
+
#attributes:
|
680
|
+
# errStatus - Error status.
|
681
|
+
class BoxServiceError < StandardError
|
682
|
+
attr_reader :errStatus
|
683
|
+
|
684
|
+
# Constructor.
|
685
|
+
#
|
686
|
+
# [errStatus]
|
687
|
+
# Error status.
|
688
|
+
def initialize(errStatus)
|
689
|
+
@errStatus = errStatus
|
690
|
+
end
|
691
|
+
|
692
|
+
# Error status to string.
|
693
|
+
#
|
694
|
+
# [Return value]
|
695
|
+
# Error status string.
|
696
|
+
def to_s
|
697
|
+
"Box.net Service Error: #{@errStatus}"
|
698
|
+
end
|
699
|
+
end
|
700
|
+
|
701
|
+
#Logined user's storage information class.
|
702
|
+
#
|
703
|
+
#attributes:
|
704
|
+
# authToken - Auth token. It's necessary to call Box.net api.
|
705
|
+
# loginName - Logined user name.
|
706
|
+
# email - Logined user's email address.
|
707
|
+
# accessId - Access id.
|
708
|
+
# userId - Logined user's id.
|
709
|
+
# spaceAmount - The storage's free space.
|
710
|
+
# spaceUsed - The storage's used space.
|
711
|
+
class UserStorageInfo
|
712
|
+
attr_accessor :authToken, :loginName, :email, :accessId, :userId, :spaceAmount,
|
713
|
+
:spaceUsed
|
714
|
+
|
715
|
+
# Constructor.
|
716
|
+
#
|
717
|
+
def initialize(userStorageElement)
|
718
|
+
@authToken = nil
|
719
|
+
createUserStorageInfo(userStorageElement) if (userStorageElement != nil)
|
720
|
+
end
|
721
|
+
|
722
|
+
private
|
723
|
+
def createUserStorageInfo(userStorageElement)
|
724
|
+
@loginName = userStorageElement.elements['login'].text
|
725
|
+
@email = userStorageElement.elements['email'].text
|
726
|
+
@accessId = userStorageElement.elements['access_id'].text
|
727
|
+
@userId = userStorageElement.elements['user_id'].text.to_i
|
728
|
+
@spaceAmount = userStorageElement.elements['space_amount'].text.to_i
|
729
|
+
@spaceUsed = userStorageElement.elements['space_used'].text.to_i
|
730
|
+
end
|
731
|
+
end
|
732
|
+
|
733
|
+
#Tag information class.
|
734
|
+
#
|
735
|
+
#attributes:
|
736
|
+
# tagId - Tag id.
|
737
|
+
# description - Tag's description.
|
738
|
+
class TagInfo
|
739
|
+
attr_accessor :tagId, :description
|
740
|
+
|
741
|
+
# Constructor.
|
742
|
+
#
|
743
|
+
def initialize(tagElement)
|
744
|
+
createTagInfo(tagElement)
|
745
|
+
end
|
746
|
+
|
747
|
+
private
|
748
|
+
def createTagInfo(tagElement)
|
749
|
+
@tagId = tagElement.attributes['id'].to_i
|
750
|
+
@description = tagElement.text
|
751
|
+
end
|
752
|
+
end
|
753
|
+
|
754
|
+
#Folder information class.
|
755
|
+
#
|
756
|
+
#attributes:
|
757
|
+
# userId - Logined user's id.
|
758
|
+
# folderId - The folder id.
|
759
|
+
# folderName - The folder name.
|
760
|
+
# description - The folder's description.
|
761
|
+
# createDate - The folder's created date.
|
762
|
+
# updateDate - The folder's update date.
|
763
|
+
# totalFileSize - Total size of the folder's files.
|
764
|
+
# shared - Shared flag(0 = unshare, 1 = share).
|
765
|
+
# sharedLinkName - The folder's shared(public) name.
|
766
|
+
# permissions - The folder's permissions.
|
767
|
+
# fileList - Files list.
|
768
|
+
# childFolderList - Child folder list.
|
769
|
+
# numOfTags - Number of tags folder has.
|
770
|
+
# tagList - Tag list.
|
771
|
+
class FolderInfo
|
772
|
+
attr_accessor :userId, :folderId, :folderName, :description, :createDate, :updateDate,
|
773
|
+
:totalFolderSize, :shared, :sharedLinkName, :permissions, :fileList,
|
774
|
+
:childFolderList, :numOfTags, :tagList;
|
775
|
+
|
776
|
+
# Constructor.
|
777
|
+
#
|
778
|
+
def initialize(folderElement)
|
779
|
+
createFolderInfo(folderElement) if (folderElement != nil)
|
780
|
+
end
|
781
|
+
|
782
|
+
private
|
783
|
+
def createFolderInfo(folderElement)
|
784
|
+
@userId = folderElement.attributes['user_id'].to_i;
|
785
|
+
@folderId = folderElement.attributes['id'].to_i;
|
786
|
+
@folderName = folderElement.attributes['name'];
|
787
|
+
@description = folderElement.attributes['description'];
|
788
|
+
@createDate = folderElement.attributes['created'].to_i;
|
789
|
+
@updateDate = folderElement.attributes['updated'].to_i;
|
790
|
+
@totalFolderSize = folderElement.attributes['size'].to_i;
|
791
|
+
@shared = folderElement.attributes['shared'].to_i;
|
792
|
+
@sharedLinkName = folderElement.attributes['shared_link'];
|
793
|
+
@permissions = folderElement.attributes['permissions'];
|
794
|
+
|
795
|
+
if (folderElement.elements['files'] != nil)
|
796
|
+
@fileList = Array.new
|
797
|
+
folderElement.elements.each('files/file') do |fileElement|
|
798
|
+
@fileList.push(FileInFolderInfo.new(fileElement))
|
799
|
+
end
|
800
|
+
else
|
801
|
+
@fileList = nil
|
802
|
+
end
|
803
|
+
|
804
|
+
if (folderElement.elements['folders'] != nil)
|
805
|
+
@childFolderList = Array.new
|
806
|
+
folderElement.elements.each('folders/folder') do |childFolderElement|
|
807
|
+
@childFolderList.push(FolderInfo.new(childFolderElement))
|
808
|
+
end
|
809
|
+
else
|
810
|
+
@childFolderList = nil
|
811
|
+
end
|
812
|
+
|
813
|
+
if (folderElement.elements['tags'] != nil)
|
814
|
+
@tagList = Array.new
|
815
|
+
folderElement.elements.each('/tags/tag') do |tagElement|
|
816
|
+
@tagList.push(BoxNetClientLib::TagInfo.new(tagElement))
|
817
|
+
end
|
818
|
+
end
|
819
|
+
end
|
820
|
+
end
|
821
|
+
|
822
|
+
#File information class in the Folder.
|
823
|
+
#
|
824
|
+
# userId - Logined user's id.
|
825
|
+
# fileId - File id.
|
826
|
+
# fileName - File name.
|
827
|
+
# description - File description.
|
828
|
+
# sha1 - File's hash value.
|
829
|
+
# createDate - File create date.
|
830
|
+
# updateDate - File update date.
|
831
|
+
# size - File size.
|
832
|
+
# shared - Share flag(0 = unshare, 1 = share).
|
833
|
+
# sharedLinkName - The file's shared(public) name.
|
834
|
+
# thumbNail - The file's thumbnail URI.
|
835
|
+
# smallThumbNail - The file's small thumbnail URI.
|
836
|
+
# largeThumbNail - The file's large thumbnail URI.
|
837
|
+
# largerThumbNail - The file's larger thumbail URI.
|
838
|
+
# previewThumbNail - The file's preview thumbnail URI.
|
839
|
+
# permissions - Permissions.
|
840
|
+
# numOfTags - Number of tags the file has.
|
841
|
+
# tagList - Tag list.
|
842
|
+
class FileInFolderInfo
|
843
|
+
attr_accessor :userId, :fileId, :fileName, :description, :sha1, :createDate,
|
844
|
+
:updateDate, :size, :shared, :sharedLinkName, :thumbNail, :smallThumbNail,
|
845
|
+
:largeThumbNail, :largerThumbNail, :previewThumbNail, :permissions,
|
846
|
+
:tagList;
|
847
|
+
|
848
|
+
# Constructor.
|
849
|
+
#
|
850
|
+
def initialize(fileElement)
|
851
|
+
createFileInfoByAttributes(fileElement) if (fileElement != nil)
|
852
|
+
end
|
853
|
+
|
854
|
+
private
|
855
|
+
def createFileInfoByAttributes(fileElement)
|
856
|
+
@userId = fileElement.attributes['user_id'].to_i;
|
857
|
+
@fileId = fileElement.attributes['id'].to_i;
|
858
|
+
@fileName = fileElement.attributes['file_name'];
|
859
|
+
@description = fileElement.attributes['description'];
|
860
|
+
@sha1 = fileElement.attributes['sha1'];
|
861
|
+
@createDate = fileElement.attributes['created'].to_i;
|
862
|
+
@updateDate = fileElement.attributes['updated'].to_i;
|
863
|
+
@size = fileElement.attributes['size'].to_i;
|
864
|
+
@shared = fileElement.attributes['shared'].to_i;
|
865
|
+
@sharedLinkName = fileElement.attributes['shared_link'];
|
866
|
+
@thumbNail = fileElement.attributes['thumbnail'];
|
867
|
+
@smallThumbNail = fileElement.attributes['small_thumbnail'];
|
868
|
+
@largeThumbNail = fileElement.attributes['large_thumbnail'];
|
869
|
+
@largerThumbNail = fileElement.attributes['larger_thumbnail'];
|
870
|
+
@previewThumbNail = fileElement.attributes['preview_thumbnail'];
|
871
|
+
@permissions = fileElement.attributes['permissions'];
|
872
|
+
|
873
|
+
if (fileElement.elements['tags'] != nil)
|
874
|
+
@tagList = Array.new
|
875
|
+
fileElement.elements.each('/tags/tag') do |tagElement|
|
876
|
+
@tagList.push(TagInfo.new(tagElement))
|
877
|
+
end
|
878
|
+
end
|
879
|
+
end
|
880
|
+
end
|
881
|
+
|
882
|
+
#File information class.
|
883
|
+
#
|
884
|
+
# userId - Logined user's id.
|
885
|
+
# fileId - File id.
|
886
|
+
# fileName - File name.
|
887
|
+
# parentFolderId - Parent folder id.
|
888
|
+
# description - File description.
|
889
|
+
# sha1 - File's hash value.
|
890
|
+
# createDate - File create date.
|
891
|
+
# updateDate - File update date.
|
892
|
+
# size - File size.
|
893
|
+
# shared - Share flag(0 = unshare, 1 = share).
|
894
|
+
# sharedLinkName - The file's shared(public) name.
|
895
|
+
class FileInfo
|
896
|
+
attr_accessor :userId, :fileId, :fileName, :parentFolderId, :description, :sha1, :createDate,
|
897
|
+
:updateDate, :size, :shared, :sharedLinkName;
|
898
|
+
|
899
|
+
# Constructor.
|
900
|
+
#
|
901
|
+
def initialize(fileElement)
|
902
|
+
createFileInfo(fileElement) if (fileElement != nil)
|
903
|
+
end
|
904
|
+
|
905
|
+
private
|
906
|
+
def createFileInfo(fileElement)
|
907
|
+
@fileId = fileElement.elements['file_id'].text.to_i;
|
908
|
+
@fileName = fileElement.elements['file_name'].text;
|
909
|
+
@parentFolderId = fileElement.elements['folder_id'].text.to_i;
|
910
|
+
@description = fileElement.elements['description'].text;
|
911
|
+
@sha1 = fileElement.elements['sha1'].text;
|
912
|
+
@createDate = fileElement.elements['created'].text.to_i;
|
913
|
+
@updateDate = fileElement.elements['updated'].text.to_i;
|
914
|
+
@size = fileElement.elements['size'].text.to_i;
|
915
|
+
@shared = fileElement.elements['shared'].text.to_i;
|
916
|
+
@sharedLinkName = fileElement.elements['shared_name'].text;
|
917
|
+
end
|
918
|
+
end
|
919
|
+
|
920
|
+
#Created folder information class.
|
921
|
+
#
|
922
|
+
#attributes:
|
923
|
+
# userId - Logined user's id.
|
924
|
+
# folderId - The folder id.
|
925
|
+
# folderName - The folder name.
|
926
|
+
# folderPath - The folder's path.
|
927
|
+
# shared - Shared flag(0 = unshare, 1 = share).
|
928
|
+
# sharedLinkName - The folder's shared(public) name.
|
929
|
+
# parentFolderId - Parent folder id.
|
930
|
+
# password - Password to open the folder.
|
931
|
+
class CreatedFolderInfo
|
932
|
+
attr_accessor :userId, :folderId, :folderName, :folderPath, :shared, :sharedLinkName,
|
933
|
+
:parentFolderId, :password;
|
934
|
+
|
935
|
+
# Constructor.
|
936
|
+
#
|
937
|
+
def initialize(folderElement)
|
938
|
+
createCreatedFolderInfo(folderElement) if (folderElement != nil)
|
939
|
+
end
|
940
|
+
|
941
|
+
private
|
942
|
+
def createCreatedFolderInfo(folderElement)
|
943
|
+
@userId = folderElement.elements['user_id'].text.to_i;
|
944
|
+
@folderId = folderElement.elements['folder_id'].text.to_i;
|
945
|
+
@folderName = folderElement.elements['folder_name'].text;
|
946
|
+
@folderPath = folderElement.elements['path'].text;
|
947
|
+
@shared = folderElement.elements['shared'].text.to_i;
|
948
|
+
@sharedLinkName = folderElement.elements['public_name'].text;
|
949
|
+
@parentFolderId = folderElement.elements['parent_folder_id'].text.to_i;
|
950
|
+
@password = folderElement.elements['password'].text;
|
951
|
+
end
|
952
|
+
end
|
953
|
+
|
954
|
+
#Friend information class.
|
955
|
+
#
|
956
|
+
#attributes:
|
957
|
+
# friendName - The friend's name.
|
958
|
+
# email - The friend's email address.
|
959
|
+
# accepted - Allow or deny to access the friend's box.
|
960
|
+
# avatarURL - The friend's avatar URL.
|
961
|
+
# boxList - Box list.
|
962
|
+
class FriendInfo
|
963
|
+
attr_accessor :friendName, :email, :accepted, :avatarURL, :boxList;
|
964
|
+
|
965
|
+
# Constructor.
|
966
|
+
#
|
967
|
+
def initialize(friendElement)
|
968
|
+
createFriendInfo(friendElement) if (friendElement != nil)
|
969
|
+
end
|
970
|
+
|
971
|
+
private
|
972
|
+
def createFriendInfo(friendElement)
|
973
|
+
@friendName = friendElement.elements['name'].text;
|
974
|
+
@email = friendElement.elements['email'].text;
|
975
|
+
@accepted = friendElement.elements['accepted'].text;
|
976
|
+
@avatarURL = friendElement.elements['avatar_url'].text;
|
977
|
+
@boxList = Array.new
|
978
|
+
fileElement.elements.each('/boxes/box') do |boxElement|
|
979
|
+
@boxList.push(BoxInfo.new(boxElement))
|
980
|
+
end
|
981
|
+
end
|
982
|
+
end
|
983
|
+
|
984
|
+
#Box information class.
|
985
|
+
#
|
986
|
+
#attributes:
|
987
|
+
# boxId - The box id.
|
988
|
+
# URL - The box URL.
|
989
|
+
class BoxInfo
|
990
|
+
attr_accessor :boxId, :URL;
|
991
|
+
|
992
|
+
# Constructor.
|
993
|
+
#
|
994
|
+
def initialize(boxElement)
|
995
|
+
createBoxList(boxElement) if (boxElement != nil)
|
996
|
+
end
|
997
|
+
|
998
|
+
private
|
999
|
+
def createBoxList(boxElement)
|
1000
|
+
@boxId = boxElement.elements['id'];
|
1001
|
+
@URL = boxElement.elements['url'];
|
1002
|
+
end
|
1003
|
+
end
|
1004
|
+
#Uploaded file information class.
|
1005
|
+
#
|
1006
|
+
#attributes:
|
1007
|
+
# fileName - The uploaded file name.
|
1008
|
+
# fileId - The uploaded file id.
|
1009
|
+
# parentFolderId - The uploaded file's parent folder id.
|
1010
|
+
# publicName - The uploaded file's public name.
|
1011
|
+
# status - "upload_ok":File upload is success.
|
1012
|
+
# others :File upload occues something error(ex. filesize_limit_exceeded).
|
1013
|
+
class UploadedFileInfo
|
1014
|
+
attr_accessor :fileName, :fileId, :parentFolderId, :shared, :publicName, :status;
|
1015
|
+
|
1016
|
+
# Constructor.
|
1017
|
+
#
|
1018
|
+
def initialize(fileElement)
|
1019
|
+
createUploadedFileInfo(fileElement) if (fileElement != nil)
|
1020
|
+
end
|
1021
|
+
|
1022
|
+
private
|
1023
|
+
def createUploadedFileInfo(fileElement)
|
1024
|
+
@fileName = fileElement.attributes['file_name']
|
1025
|
+
if (fileElement.attributes['error'] != nil)
|
1026
|
+
@status = fileElement.attributes['error']
|
1027
|
+
else
|
1028
|
+
@status = "upload_ok"
|
1029
|
+
@fileId = fileElement.attributes['id']
|
1030
|
+
@parentFolderId = fileElement.attributes['folder_id']
|
1031
|
+
@shared = fileElement.attributes['shared']
|
1032
|
+
@publicName = fileElement.attributes['public_name']
|
1033
|
+
end
|
1034
|
+
end
|
1035
|
+
end
|
1036
|
+
end
|