Class: Teamlab::Files
- Inherits:
-
Object
- Object
- Teamlab::Files
- Defined in:
- lib/teamlab/modules/files.rb
Instance Method Summary collapse
- #check_conflict(options = {}) ⇒ Object
- #check_conversion_status(fileid) ⇒ Object
- #check_overwrite(set_value = true) ⇒ Object
- #chunked_upload(folder_id, filename, file_size) ⇒ Object
- #clear_recycle_bin ⇒ Object
- #copy_to_folder(folder_id, options = {}) ⇒ Object
- #create_file(folder_id, title) ⇒ Object
- #create_html(folder_id, title, content) ⇒ Object
- #create_html_in_common_docs(title, content) ⇒ Object
- #create_html_in_my_docs(title, content) ⇒ Object
- #create_txt(folder_id, title, content) ⇒ Object
- #create_txt_in_common_docs(title, content) ⇒ Object
-
#create_txt_in_my_docs(title, content) ⇒ Object
region File Creation.
- #delete(options = {}) ⇒ Object
- #delete_file(file_id) ⇒ Object
- #delete_folder(folder_id) ⇒ Object
- #document_server_info ⇒ Object
-
#escape_folder_id(id) ⇒ String
Sometimes folder id require escaping Because for example for folders from connected account will have id like this: “‘ sbox-193828-|New_Folder__474b010d-ad5f-49ff-8b3a-5b2583c1fbcc “` And this need escaping.
- #finish_all ⇒ Object
- #finish_operations(options = {}) ⇒ Object
- #generate_shared_link(file_id, share) ⇒ Object
- #get_common_docs(params = {}) ⇒ Object
- #get_file_history(file_id) ⇒ Object
-
#get_file_info(file_id) ⇒ Object
region Files.
-
#get_file_operations_list ⇒ Object
region File operations.
-
#get_file_sharing(file_id) ⇒ Object
region Sharing.
- #get_folder(folder_id, options = {}) ⇒ Object
- #get_folder_info(folder_id) ⇒ Object
- #get_folder_path(folder_id) ⇒ Object
- #get_folder_sharing(folder_id) ⇒ Object
-
#get_my_docs(params = {}) ⇒ Object
(also: #get_my_files)
region Folders.
- #get_projects_folder(params = {}) ⇒ Object
- #get_shared_docs(params = {}) ⇒ Object
-
#get_third_party ⇒ Object
region Third-Party Integration.
- #get_trash(params = {}) ⇒ Object
-
#initialize(config = nil) ⇒ Files
constructor
A new instance of Files.
- #insert_file(folder_id, file, title: File.basename(file), keep_convert_status: false) ⇒ Object
- #insert_to_common_docs(file, title: File.basename(file), keep_convert_status: false) ⇒ Object
- #insert_to_my_docs(file, title: File.basename(file), keep_convert_status: false, create_new_if_exists: nil) ⇒ Object
- #mark_as_read ⇒ Object
- #move_to_folder(folder_id, options = {}) ⇒ Object (also: #move_files)
- #new_folder(folder_id, title) ⇒ Object
- #remove_third_party_account(provider_id) ⇒ Object
- #removes_sharing_rights(options = {}) ⇒ Object
- #rename_folder(folder_id, title) ⇒ Object
- #save_third_party(options = {}) ⇒ Object
-
#search(query) ⇒ Object
endregion.
- #share_file(file_id, user_id, access_type, options = {}) ⇒ Object
- #share_folder(folder_id, user_id, access_type, options = {}) ⇒ Object
- #start_conversion(file_id, start) ⇒ Object
- #update_file_history(file_id, version, continue_version = false) ⇒ Object
- #update_file_info(file_id, title, last_version) ⇒ Object
- #upload_to_common_docs(file) ⇒ Object
- #upload_to_folder(folder_id, file) ⇒ Object
-
#upload_to_my_docs(file) ⇒ Object
region Uploads.
Constructor Details
Instance Method Details
#check_conflict(options = {}) ⇒ Object
49 50 51 |
# File 'lib/teamlab/modules/files.rb', line 49 def check_conflict( = {}) @request.get(%w[fileops move], ) end |
#check_conversion_status(fileid) ⇒ Object
53 54 55 |
# File 'lib/teamlab/modules/files.rb', line 53 def check_conversion_status(fileid) @request.get(['file', fileid.to_s, 'checkconversion']) end |
#check_overwrite(set_value = true) ⇒ Object
254 255 256 |
# File 'lib/teamlab/modules/files.rb', line 254 def check_overwrite(set_value = true) @request.put(%w[updateifexist], set: set_value) end |
#chunked_upload(folder_id, filename, file_size) ⇒ Object
236 237 238 |
# File 'lib/teamlab/modules/files.rb', line 236 def chunked_upload(folder_id, filename, file_size) @request.post([escape_folder_id(folder_id), 'upload', 'create_session'], fileName: filename, fileSize: file_size) end |
#clear_recycle_bin ⇒ Object
78 79 80 |
# File 'lib/teamlab/modules/files.rb', line 78 def clear_recycle_bin @request.put(%w[fileops emptytrash]) end |
#copy_to_folder(folder_id, options = {}) ⇒ Object
62 63 64 |
# File 'lib/teamlab/modules/files.rb', line 62 def copy_to_folder(folder_id, = {}) @request.put(%w[fileops copy], { destFolderId: escape_folder_id(folder_id) }.merge()) end |
#create_file(folder_id, title) ⇒ Object
37 38 39 |
# File 'lib/teamlab/modules/files.rb', line 37 def create_file(folder_id, title) @request.post([escape_folder_id(folder_id), 'file'], title: title.to_s) end |
#create_html(folder_id, title, content) ⇒ Object
33 34 35 |
# File 'lib/teamlab/modules/files.rb', line 33 def create_html(folder_id, title, content) @request.post([escape_folder_id(folder_id), 'html'], title: title.to_s, content: content.to_s) end |
#create_html_in_common_docs(title, content) ⇒ Object
25 26 27 |
# File 'lib/teamlab/modules/files.rb', line 25 def create_html_in_common_docs(title, content) @request.post(%w[@common html], title: title.to_s, content: content.to_s) end |
#create_html_in_my_docs(title, content) ⇒ Object
17 18 19 |
# File 'lib/teamlab/modules/files.rb', line 17 def create_html_in_my_docs(title, content) @request.post(%w[@my html], title: title.to_s, content: content.to_s) end |
#create_txt(folder_id, title, content) ⇒ Object
29 30 31 |
# File 'lib/teamlab/modules/files.rb', line 29 def create_txt(folder_id, title, content) @request.post([escape_folder_id(folder_id), 'text'], title: title.to_s, content: content.to_s) end |
#create_txt_in_common_docs(title, content) ⇒ Object
21 22 23 |
# File 'lib/teamlab/modules/files.rb', line 21 def create_txt_in_common_docs(title, content) @request.post(%w[@common text], title: title.to_s, content: content.to_s) end |
#create_txt_in_my_docs(title, content) ⇒ Object
region File Creation
13 14 15 |
# File 'lib/teamlab/modules/files.rb', line 13 def create_txt_in_my_docs(title, content) @request.post(%w[@my text], title: title.to_s, content: content.to_s) end |
#delete(options = {}) ⇒ Object
66 67 68 |
# File 'lib/teamlab/modules/files.rb', line 66 def delete( = {}) @request.put(%w[fileops delete], ) end |
#delete_file(file_id) ⇒ Object
110 111 112 |
# File 'lib/teamlab/modules/files.rb', line 110 def delete_file(file_id) @request.delete(['file', file_id.to_s]) end |
#delete_folder(folder_id) ⇒ Object
159 160 161 |
# File 'lib/teamlab/modules/files.rb', line 159 def delete_folder(folder_id) @request.delete(['folder', escape_folder_id(folder_id)]) end |
#document_server_info ⇒ Object
250 251 252 |
# File 'lib/teamlab/modules/files.rb', line 250 def document_server_info @request.get(%w[docservice]) end |
#escape_folder_id(id) ⇒ String
Sometimes folder id require escaping Because for example for folders from connected account will have id like this: “‘ sbox-193828-|New_Folder__474b010d-ad5f-49ff-8b3a-5b2583c1fbcc “` And this need escaping
266 267 268 |
# File 'lib/teamlab/modules/files.rb', line 266 def escape_folder_id(id) CGI.escape(id.to_s) end |
#finish_all ⇒ Object
70 71 72 |
# File 'lib/teamlab/modules/files.rb', line 70 def finish_all @request.put(%w[fileops terminate]) end |
#finish_operations(options = {}) ⇒ Object
82 83 84 |
# File 'lib/teamlab/modules/files.rb', line 82 def finish_operations( = {}) @request.put(%w[fileops bulkdownload], ) end |
#generate_shared_link(file_id, share) ⇒ Object
246 247 248 |
# File 'lib/teamlab/modules/files.rb', line 246 def generate_shared_link(file_id, share) @request.put([file_id.to_s, 'sharedlink'], share: share) end |
#get_common_docs(params = {}) ⇒ Object
131 132 133 |
# File 'lib/teamlab/modules/files.rb', line 131 def get_common_docs(params = {}) @request.get(['@common'], params) end |
#get_file_history(file_id) ⇒ Object
98 99 100 |
# File 'lib/teamlab/modules/files.rb', line 98 def get_file_history(file_id) @request.get(['file', file_id.to_s, 'history']) end |
#get_file_info(file_id) ⇒ Object
region Files
94 95 96 |
# File 'lib/teamlab/modules/files.rb', line 94 def get_file_info(file_id) @request.get(['file', file_id.to_s]) end |
#get_file_operations_list ⇒ Object
region File operations
45 46 47 |
# File 'lib/teamlab/modules/files.rb', line 45 def get_file_operations_list @request.get(%w[fileops]) end |
#get_file_sharing(file_id) ⇒ Object
region Sharing
167 168 169 |
# File 'lib/teamlab/modules/files.rb', line 167 def get_file_sharing(file_id) @request.get(['file', file_id.to_s, 'share']) end |
#get_folder(folder_id, options = {}) ⇒ Object
139 140 141 |
# File 'lib/teamlab/modules/files.rb', line 139 def get_folder(folder_id, = {}) @request.get([escape_folder_id(folder_id)], ) end |
#get_folder_info(folder_id) ⇒ Object
143 144 145 |
# File 'lib/teamlab/modules/files.rb', line 143 def get_folder_info(folder_id) @request.get(['folder', escape_folder_id(folder_id)]) end |
#get_folder_path(folder_id) ⇒ Object
147 148 149 |
# File 'lib/teamlab/modules/files.rb', line 147 def get_folder_path(folder_id) @request.get(['folder', escape_folder_id(folder_id), 'path']) end |
#get_folder_sharing(folder_id) ⇒ Object
171 172 173 |
# File 'lib/teamlab/modules/files.rb', line 171 def get_folder_sharing(folder_id) @request.get(['folder', escape_folder_id(folder_id), 'share']) end |
#get_my_docs(params = {}) ⇒ Object Also known as: get_my_files
region Folders
118 119 120 |
# File 'lib/teamlab/modules/files.rb', line 118 def get_my_docs(params = {}) @request.get(['@my'], params) end |
#get_projects_folder(params = {}) ⇒ Object
135 136 137 |
# File 'lib/teamlab/modules/files.rb', line 135 def get_projects_folder(params = {}) @request.get(['@projects'], params) end |
#get_shared_docs(params = {}) ⇒ Object
123 124 125 |
# File 'lib/teamlab/modules/files.rb', line 123 def get_shared_docs(params = {}) @request.get(['@share'], params) end |
#get_third_party ⇒ Object
region Third-Party Integration
191 192 193 |
# File 'lib/teamlab/modules/files.rb', line 191 def get_third_party @request.get(%w[thirdparty]) end |
#get_trash(params = {}) ⇒ Object
127 128 129 |
# File 'lib/teamlab/modules/files.rb', line 127 def get_trash(params = {}) @request.get(['@trash'], params) end |
#insert_file(folder_id, file, title: File.basename(file), keep_convert_status: false) ⇒ Object
232 233 234 |
# File 'lib/teamlab/modules/files.rb', line 232 def insert_file(folder_id, file, title: File.basename(file), keep_convert_status: false) @request.post([escape_folder_id(folder_id), 'insert'], file: File.new(file), title: title, keepConvertStatus: keep_convert_status) end |
#insert_to_common_docs(file, title: File.basename(file), keep_convert_status: false) ⇒ Object
224 225 226 |
# File 'lib/teamlab/modules/files.rb', line 224 def insert_to_common_docs(file, title: File.basename(file), keep_convert_status: false) @request.post(%w[@common insert], file: File.new(file), title: title, keepConvertStatus: keep_convert_status) end |
#insert_to_my_docs(file, title: File.basename(file), keep_convert_status: false, create_new_if_exists: nil) ⇒ Object
212 213 214 215 216 217 218 |
# File 'lib/teamlab/modules/files.rb', line 212 def insert_to_my_docs(file, title: File.basename(file), keep_convert_status: false, create_new_if_exists: nil) @request.post(%w[@my insert], file: File.new(file), title: title, keepConvertStatus: keep_convert_status, createNewIfExist: create_new_if_exists) end |
#mark_as_read ⇒ Object
74 75 76 |
# File 'lib/teamlab/modules/files.rb', line 74 def mark_as_read @request.put(%w[fileops markasread]) end |
#move_to_folder(folder_id, options = {}) ⇒ Object Also known as: move_files
57 58 59 |
# File 'lib/teamlab/modules/files.rb', line 57 def move_to_folder(folder_id, = {}) @request.put(%w[fileops move], { destFolderId: escape_folder_id(folder_id) }.merge()) end |
#new_folder(folder_id, title) ⇒ Object
151 152 153 |
# File 'lib/teamlab/modules/files.rb', line 151 def new_folder(folder_id, title) @request.post(['folder', escape_folder_id(folder_id)], title: title) end |
#remove_third_party_account(provider_id) ⇒ Object
199 200 201 |
# File 'lib/teamlab/modules/files.rb', line 199 def remove_third_party_account(provider_id) @request.delete(['thirdparty', provider_id.to_s]) end |
#removes_sharing_rights(options = {}) ⇒ Object
183 184 185 |
# File 'lib/teamlab/modules/files.rb', line 183 def removes_sharing_rights( = {}) @request.delete(['share'], ) end |
#rename_folder(folder_id, title) ⇒ Object
155 156 157 |
# File 'lib/teamlab/modules/files.rb', line 155 def rename_folder(folder_id, title) @request.put(['folder', escape_folder_id(folder_id)], title: title) end |
#save_third_party(options = {}) ⇒ Object
195 196 197 |
# File 'lib/teamlab/modules/files.rb', line 195 def save_third_party( = {}) @request.post(%w[thirdparty], ) end |
#search(query) ⇒ Object
endregion
242 243 244 |
# File 'lib/teamlab/modules/files.rb', line 242 def search(query) @request.get(['@search', query.to_s]) end |
#share_file(file_id, user_id, access_type, options = {}) ⇒ Object
175 176 177 |
# File 'lib/teamlab/modules/files.rb', line 175 def share_file(file_id, user_id, access_type, = {}) @request.put(['file', file_id.to_s, 'share'], { share: { shareTo: user_id, Access: access_type } }.merge()) end |
#share_folder(folder_id, user_id, access_type, options = {}) ⇒ Object
179 180 181 |
# File 'lib/teamlab/modules/files.rb', line 179 def share_folder(folder_id, user_id, access_type, = {}) @request.put(['folder', escape_folder_id(folder_id), 'share'], { share: { shareTo: user_id, Access: access_type } }.merge()) end |
#start_conversion(file_id, start) ⇒ Object
86 87 88 |
# File 'lib/teamlab/modules/files.rb', line 86 def start_conversion(file_id, start) @request.put(['file', file_id.to_s, 'checkconversion'], start: start) end |
#update_file_history(file_id, version, continue_version = false) ⇒ Object
102 103 104 |
# File 'lib/teamlab/modules/files.rb', line 102 def update_file_history(file_id, version, continue_version = false) @request.put(['file', file_id.to_s, 'history'], version: version, continueVersion: continue_version) end |
#update_file_info(file_id, title, last_version) ⇒ Object
106 107 108 |
# File 'lib/teamlab/modules/files.rb', line 106 def update_file_info(file_id, title, last_version) @request.put(['file', file_id.to_s], title: title, lastVersion: last_version) end |
#upload_to_common_docs(file) ⇒ Object
220 221 222 |
# File 'lib/teamlab/modules/files.rb', line 220 def upload_to_common_docs(file) @request.post(%w[@common upload], somefile: File.new(file)) end |
#upload_to_folder(folder_id, file) ⇒ Object
228 229 230 |
# File 'lib/teamlab/modules/files.rb', line 228 def upload_to_folder(folder_id, file) @request.post([escape_folder_id(folder_id), 'upload'], somefile: File.new(file)) end |
#upload_to_my_docs(file) ⇒ Object
region Uploads
207 208 209 |
# File 'lib/teamlab/modules/files.rb', line 207 def upload_to_my_docs(file) @request.post(%w[@my upload], somefile: File.new(file)) end |