onlyoffice_api 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f8c8455b783aef58695e2f11ac059804435a6be117b76b453cdebd0a996e41a
4
- data.tar.gz: 46cf0de4e5b2a8a8ad1215c7f86f50d182b5b4bcc1f364054c50015a0b522123
3
+ metadata.gz: c892bbb1d17d3dc5973b02ff35819d2ac24c25562128e34a511b85f2a853b765
4
+ data.tar.gz: 3370a41ebc3b2b591836eaf2b4cc5d49fa4f5bd05665016a07e7fad2a20d654c
5
5
  SHA512:
6
- metadata.gz: d88170f761bb8384014573a865dc1e5d2614054bf8e7f4e032f36b043160763ad2d6226cf4151cd145a7b8cfc42a1313fd6a7670e8fa532298cad3c49c32ac00
7
- data.tar.gz: ffa186f53c8b0077ca1af6e04495c6a83992a02f02cc861a8a6f26335fc4f022f2a1ecc3a9555a2a5a0ea5537dd6fd710dbeebfa96d92ebf3e3e1281f0a5f6c9
6
+ metadata.gz: 27bd8ba09090aaa9220498757d732dcc37037d34fc4cb42eb14a82995dbbf93eee528535f0a8750f27ac019d3df1650827423fe18de4054e13579d16c64a31ba
7
+ data.tar.gz: 9ff12209da0b8d4316470f1f71653ce2d31574d2359c1d21e05ece096fd3345f4606e07373a909ac8abffaab49a4f62c2b4b92eaf2194adcb94e5966fe606099
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'cgi'
4
+
3
5
  module Teamlab
4
6
  class Files
5
7
  def initialize(config = nil)
@@ -25,15 +27,15 @@ module Teamlab
25
27
  end
26
28
 
27
29
  def create_txt(folder_id, title, content)
28
- @request.post([folder_id.to_s, 'text'], title: title.to_s, content: content.to_s)
30
+ @request.post([escape_folder_id(folder_id), 'text'], title: title.to_s, content: content.to_s)
29
31
  end
30
32
 
31
33
  def create_html(folder_id, title, content)
32
- @request.post([folder_id.to_s, 'html'], title: title.to_s, content: content.to_s)
34
+ @request.post([escape_folder_id(folder_id), 'html'], title: title.to_s, content: content.to_s)
33
35
  end
34
36
 
35
37
  def create_file(folder_id, title)
36
- @request.post([folder_id.to_s, 'file'], title: title.to_s)
38
+ @request.post([escape_folder_id(folder_id), 'file'], title: title.to_s)
37
39
  end
38
40
 
39
41
  # endregion
@@ -52,13 +54,13 @@ module Teamlab
52
54
  @request.get(['file', fileid.to_s, 'checkconversion'])
53
55
  end
54
56
 
55
- def move_to_folder(dest_folder_id, options = {})
56
- @request.put(%w[fileops move], { destFolderId: dest_folder_id }.merge(options))
57
+ def move_to_folder(folder_id, options = {})
58
+ @request.put(%w[fileops move], { destFolderId: escape_folder_id(folder_id) }.merge(options))
57
59
  end
58
60
  alias move_files move_to_folder
59
61
 
60
- def copy_to_folder(dest_folder_id, options = {})
61
- @request.put(%w[fileops copy], { destFolderId: dest_folder_id }.merge(options))
62
+ def copy_to_folder(folder_id, options = {})
63
+ @request.put(%w[fileops copy], { destFolderId: escape_folder_id(folder_id) }.merge(options))
62
64
  end
63
65
 
64
66
  def delete(options = {})
@@ -135,27 +137,27 @@ module Teamlab
135
137
  end
136
138
 
137
139
  def get_folder(folder_id, options = {})
138
- @request.get([folder_id.to_s], options)
140
+ @request.get([escape_folder_id(folder_id)], options)
139
141
  end
140
142
 
141
143
  def get_folder_info(folder_id)
142
- @request.get(['folder', folder_id.to_s])
144
+ @request.get(['folder', escape_folder_id(folder_id)])
143
145
  end
144
146
 
145
147
  def get_folder_path(folder_id)
146
- @request.get(['folder', folder_id.to_s, 'path'])
148
+ @request.get(['folder', escape_folder_id(folder_id), 'path'])
147
149
  end
148
150
 
149
151
  def new_folder(folder_id, title)
150
- @request.post(['folder', folder_id.to_s], title: title)
152
+ @request.post(['folder', escape_folder_id(folder_id)], title: title)
151
153
  end
152
154
 
153
155
  def rename_folder(folder_id, title)
154
- @request.put(['folder', folder_id.to_s], title: title)
156
+ @request.put(['folder', escape_folder_id(folder_id)], title: title)
155
157
  end
156
158
 
157
159
  def delete_folder(folder_id)
158
- @request.delete(['folder', folder_id.to_s])
160
+ @request.delete(['folder', escape_folder_id(folder_id)])
159
161
  end
160
162
 
161
163
  # endregion
@@ -167,7 +169,7 @@ module Teamlab
167
169
  end
168
170
 
169
171
  def get_folder_sharing(folder_id)
170
- @request.get(['folder', folder_id.to_s, 'share'])
172
+ @request.get(['folder', escape_folder_id(folder_id), 'share'])
171
173
  end
172
174
 
173
175
  def share_file(file_id, user_id, access_type, options = {})
@@ -175,7 +177,7 @@ module Teamlab
175
177
  end
176
178
 
177
179
  def share_folder(folder_id, user_id, access_type, options = {})
178
- @request.put(['folder', folder_id.to_s, 'share'], { share: { shareTo: user_id, Access: access_type } }.merge(options))
180
+ @request.put(['folder', escape_folder_id(folder_id), 'share'], { share: { shareTo: user_id, Access: access_type } }.merge(options))
179
181
  end
180
182
 
181
183
  def removes_sharing_rights(options = {})
@@ -224,15 +226,15 @@ module Teamlab
224
226
  end
225
227
 
226
228
  def upload_to_folder(folder_id, file)
227
- @request.post([folder_id.to_s, 'upload'], somefile: File.new(file))
229
+ @request.post([escape_folder_id(folder_id), 'upload'], somefile: File.new(file))
228
230
  end
229
231
 
230
232
  def insert_file(folder_id, file, title: File.basename(file), keep_convert_status: false)
231
- @request.post([folder_id.to_s, 'insert'], file: File.new(file), title: title, keepConvertStatus: keep_convert_status)
233
+ @request.post([escape_folder_id(folder_id), 'insert'], file: File.new(file), title: title, keepConvertStatus: keep_convert_status)
232
234
  end
233
235
 
234
236
  def chunked_upload(folder_id, filename, file_size)
235
- @request.post([folder_id.to_s, 'upload', 'create_session'], fileName: filename, fileSize: file_size)
237
+ @request.post([escape_folder_id(folder_id), 'upload', 'create_session'], fileName: filename, fileSize: file_size)
236
238
  end
237
239
 
238
240
  # endregion
@@ -252,5 +254,17 @@ module Teamlab
252
254
  def check_overwrite(set_value = true)
253
255
  @request.put(%w[updateifexist], set: set_value)
254
256
  end
257
+
258
+ # Sometimes folder id require escaping
259
+ # Because for example for folders from connected account will have id like this:
260
+ # ```
261
+ # sbox-193828-|New_Folder__474b010d-ad5f-49ff-8b3a-5b2583c1fbcc
262
+ # ```
263
+ # And this need escaping
264
+ # @param [Integer, String] id to escape
265
+ # @return [String] result after escape
266
+ def escape_folder_id(id)
267
+ CGI.escape(id.to_s)
268
+ end
255
269
  end
256
270
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Teamlab
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onlyoffice_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ONLYOFFICE
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2022-02-04 00:00:00.000000000 Z
14
+ date: 2022-02-22 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: httparty
@@ -280,7 +280,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
280
280
  - !ruby/object:Gem::Version
281
281
  version: '0'
282
282
  requirements: []
283
- rubygems_version: 3.3.4
283
+ rubygems_version: 3.3.7
284
284
  signing_key:
285
285
  specification_version: 4
286
286
  summary: Ruby gem for OnlyOffice. Formerly known as `teamlab`.