files.com 1.0.92

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTORS +4 -0
  3. data/Gemfile +12 -0
  4. data/Gemfile.lock +82 -0
  5. data/LICENSE +21 -0
  6. data/README.md +119 -0
  7. data/Rakefile +12 -0
  8. data/SECURITY.md +24 -0
  9. data/_VERSION +1 -0
  10. data/bin/files +8 -0
  11. data/bin/files-console +16 -0
  12. data/docs/account_line_item.md +41 -0
  13. data/docs/action.md +37 -0
  14. data/docs/api_key.md +202 -0
  15. data/docs/app.md +59 -0
  16. data/docs/as2_key.md +133 -0
  17. data/docs/auto.md +11 -0
  18. data/docs/automation.md +190 -0
  19. data/docs/behavior.md +208 -0
  20. data/docs/bundle.md +252 -0
  21. data/docs/bundle_download.md +35 -0
  22. data/docs/clickwrap.md +143 -0
  23. data/docs/dns_record.md +35 -0
  24. data/docs/errors.md +17 -0
  25. data/docs/file.md +204 -0
  26. data/docs/file_action.md +126 -0
  27. data/docs/file_comment.md +116 -0
  28. data/docs/file_comment_reaction.md +62 -0
  29. data/docs/file_part_upload.md +37 -0
  30. data/docs/file_utils.md +4 -0
  31. data/docs/folder.md +90 -0
  32. data/docs/group.md +153 -0
  33. data/docs/group_user.md +124 -0
  34. data/docs/history.md +171 -0
  35. data/docs/history_export.md +174 -0
  36. data/docs/image.md +13 -0
  37. data/docs/invoice.md +72 -0
  38. data/docs/invoice_line_item.md +27 -0
  39. data/docs/ip_address.md +55 -0
  40. data/docs/lock.md +98 -0
  41. data/docs/message.md +147 -0
  42. data/docs/message_comment.md +132 -0
  43. data/docs/message_comment_reaction.md +94 -0
  44. data/docs/message_reaction.md +94 -0
  45. data/docs/notification.md +177 -0
  46. data/docs/payment.md +72 -0
  47. data/docs/payment_line_item.md +19 -0
  48. data/docs/permission.md +95 -0
  49. data/docs/preview.md +19 -0
  50. data/docs/project.md +121 -0
  51. data/docs/public_ip_address.md +13 -0
  52. data/docs/public_key.md +133 -0
  53. data/docs/remote_server.md +356 -0
  54. data/docs/request.md +100 -0
  55. data/docs/session.md +78 -0
  56. data/docs/site.md +448 -0
  57. data/docs/sso_strategy.md +114 -0
  58. data/docs/status.md +21 -0
  59. data/docs/style.md +93 -0
  60. data/docs/usage_daily_snapshot.md +45 -0
  61. data/docs/usage_snapshot.md +53 -0
  62. data/docs/user.md +535 -0
  63. data/docs/user_cipher_use.md +41 -0
  64. data/docs/user_request.md +93 -0
  65. data/files.com.gemspec +22 -0
  66. data/lib/files.com.rb +184 -0
  67. data/lib/files.com/api.rb +38 -0
  68. data/lib/files.com/api_client.rb +340 -0
  69. data/lib/files.com/errors.rb +41 -0
  70. data/lib/files.com/list.rb +95 -0
  71. data/lib/files.com/models/account_line_item.rb +82 -0
  72. data/lib/files.com/models/action.rb +77 -0
  73. data/lib/files.com/models/api_key.rb +270 -0
  74. data/lib/files.com/models/app.rb +106 -0
  75. data/lib/files.com/models/as2_key.rb +179 -0
  76. data/lib/files.com/models/auto.rb +17 -0
  77. data/lib/files.com/models/automation.rb +304 -0
  78. data/lib/files.com/models/behavior.rb +266 -0
  79. data/lib/files.com/models/bundle.rb +371 -0
  80. data/lib/files.com/models/bundle_download.rb +49 -0
  81. data/lib/files.com/models/clickwrap.rb +197 -0
  82. data/lib/files.com/models/dir.rb +3 -0
  83. data/lib/files.com/models/dns_record.rb +51 -0
  84. data/lib/files.com/models/errors.rb +22 -0
  85. data/lib/files.com/models/file.rb +968 -0
  86. data/lib/files.com/models/file_action.rb +126 -0
  87. data/lib/files.com/models/file_comment.rb +146 -0
  88. data/lib/files.com/models/file_comment_reaction.rb +100 -0
  89. data/lib/files.com/models/file_part_upload.rb +82 -0
  90. data/lib/files.com/models/file_utils.rb +118 -0
  91. data/lib/files.com/models/folder.rb +357 -0
  92. data/lib/files.com/models/group.rb +208 -0
  93. data/lib/files.com/models/group_user.rb +171 -0
  94. data/lib/files.com/models/history.rb +228 -0
  95. data/lib/files.com/models/history_export.rb +353 -0
  96. data/lib/files.com/models/image.rb +22 -0
  97. data/lib/files.com/models/invoice.rb +117 -0
  98. data/lib/files.com/models/invoice_line_item.rb +57 -0
  99. data/lib/files.com/models/ip_address.rb +66 -0
  100. data/lib/files.com/models/lock.rb +173 -0
  101. data/lib/files.com/models/message.rb +201 -0
  102. data/lib/files.com/models/message_comment.rb +165 -0
  103. data/lib/files.com/models/message_comment_reaction.rb +128 -0
  104. data/lib/files.com/models/message_reaction.rb +128 -0
  105. data/lib/files.com/models/notification.rb +263 -0
  106. data/lib/files.com/models/payment.rb +117 -0
  107. data/lib/files.com/models/payment_line_item.rb +37 -0
  108. data/lib/files.com/models/permission.rb +172 -0
  109. data/lib/files.com/models/preview.rb +37 -0
  110. data/lib/files.com/models/project.rb +140 -0
  111. data/lib/files.com/models/public_ip_address.rb +22 -0
  112. data/lib/files.com/models/public_key.rb +179 -0
  113. data/lib/files.com/models/remote_server.rb +680 -0
  114. data/lib/files.com/models/request.rb +179 -0
  115. data/lib/files.com/models/session.rb +247 -0
  116. data/lib/files.com/models/site.rb +733 -0
  117. data/lib/files.com/models/sso_strategy.rb +227 -0
  118. data/lib/files.com/models/status.rb +37 -0
  119. data/lib/files.com/models/style.rb +131 -0
  120. data/lib/files.com/models/usage_daily_snapshot.rb +66 -0
  121. data/lib/files.com/models/usage_snapshot.rb +96 -0
  122. data/lib/files.com/models/user.rb +876 -0
  123. data/lib/files.com/models/user_cipher_use.rb +63 -0
  124. data/lib/files.com/models/user_request.rb +127 -0
  125. data/lib/files.com/response.rb +25 -0
  126. data/lib/files.com/sizable_io.rb +32 -0
  127. data/lib/files.com/system_profiler.rb +56 -0
  128. data/lib/files.com/util.rb +106 -0
  129. data/lib/files.com/version.rb +5 -0
  130. data/spec/list_spec.rb +214 -0
  131. data/spec/models/file_spec.rb +68 -0
  132. data/spec/models/folder_spec.rb +40 -0
  133. data/spec/spec_helper.rb +36 -0
  134. data/test.sh +8 -0
  135. data/test/test.rb +75 -0
  136. metadata +235 -0
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Files
4
+ class BundleDownload
5
+ attr_reader :options, :attributes
6
+
7
+ def initialize(attributes = {}, options = {})
8
+ @attributes = attributes || {}
9
+ @options = options || {}
10
+ end
11
+
12
+ # string - Download method (file or full_zip)
13
+ def download_method
14
+ @attributes[:download_method]
15
+ end
16
+
17
+ # string - Download path This must be slash-delimited, but it must neither start nor end with a slash. Maximum of 5000 characters.
18
+ def path
19
+ @attributes[:path]
20
+ end
21
+
22
+ # date-time - Download date/time
23
+ def created_at
24
+ @attributes[:created_at]
25
+ end
26
+
27
+ # Parameters:
28
+ # page - int64 - Current page number.
29
+ # per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
30
+ # action - string - Deprecated: If set to `count` returns a count of matching records rather than the records themselves.
31
+ # bundle_registration_id (required) - int64 - BundleRegistration ID
32
+ def self.list(params = {}, options = {})
33
+ raise InvalidParameterError.new("Bad parameter: page must be an Integer") if params.dig(:page) and !params.dig(:page).is_a?(Integer)
34
+ raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params.dig(:per_page) and !params.dig(:per_page).is_a?(Integer)
35
+ raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
36
+ raise InvalidParameterError.new("Bad parameter: bundle_registration_id must be an Integer") if params.dig(:bundle_registration_id) and !params.dig(:bundle_registration_id).is_a?(Integer)
37
+ raise MissingParameterError.new("Parameter missing: bundle_registration_id") unless params.dig(:bundle_registration_id)
38
+
39
+ response, options = Api.send_request("/bundle_downloads", :get, params, options)
40
+ response.data.map do |entity_data|
41
+ BundleDownload.new(entity_data, options)
42
+ end
43
+ end
44
+
45
+ def self.all(params = {}, options = {})
46
+ list(params, options)
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,197 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Files
4
+ class Clickwrap
5
+ attr_reader :options, :attributes
6
+
7
+ def initialize(attributes = {}, options = {})
8
+ @attributes = attributes || {}
9
+ @options = options || {}
10
+ end
11
+
12
+ # string - Name of the Clickwrap agreement (used when selecting from multiple Clickwrap agreements.)
13
+ def name
14
+ @attributes[:name]
15
+ end
16
+
17
+ def name=(value)
18
+ @attributes[:name] = value
19
+ end
20
+
21
+ # string - Body text of Clickwrap (supports Markdown formatting).
22
+ def body
23
+ @attributes[:body]
24
+ end
25
+
26
+ def body=(value)
27
+ @attributes[:body] = value
28
+ end
29
+
30
+ # string - Use this Clickwrap for User Registrations? Note: This only applies to User Registrations where the User is invited to your Files.com site using an E-Mail invitation process where they then set their own password.
31
+ def use_with_users
32
+ @attributes[:use_with_users]
33
+ end
34
+
35
+ def use_with_users=(value)
36
+ @attributes[:use_with_users] = value
37
+ end
38
+
39
+ # string - Use this Clickwrap for Bundles?
40
+ def use_with_bundles
41
+ @attributes[:use_with_bundles]
42
+ end
43
+
44
+ def use_with_bundles=(value)
45
+ @attributes[:use_with_bundles] = value
46
+ end
47
+
48
+ # string - Use this Clickwrap for Inboxes?
49
+ def use_with_inboxes
50
+ @attributes[:use_with_inboxes]
51
+ end
52
+
53
+ def use_with_inboxes=(value)
54
+ @attributes[:use_with_inboxes] = value
55
+ end
56
+
57
+ # int64 - Clickwrap ID.
58
+ def id
59
+ @attributes[:id]
60
+ end
61
+
62
+ def id=(value)
63
+ @attributes[:id] = value
64
+ end
65
+
66
+ # Parameters:
67
+ # name - string - Name of the Clickwrap agreement (used when selecting from multiple Clickwrap agreements.)
68
+ # body - string - Body text of Clickwrap (supports Markdown formatting).
69
+ # use_with_bundles - string - Use this Clickwrap for Bundles?
70
+ # use_with_inboxes - string - Use this Clickwrap for Inboxes?
71
+ # use_with_users - string - Use this Clickwrap for User Registrations? Note: This only applies to User Registrations where the User is invited to your Files.com site using an E-Mail invitation process where they then set their own password.
72
+ def update(params = {})
73
+ params ||= {}
74
+ params[:id] = @attributes[:id]
75
+ raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
76
+ raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
77
+ raise InvalidParameterError.new("Bad parameter: name must be an String") if params.dig(:name) and !params.dig(:name).is_a?(String)
78
+ raise InvalidParameterError.new("Bad parameter: body must be an String") if params.dig(:body) and !params.dig(:body).is_a?(String)
79
+ raise InvalidParameterError.new("Bad parameter: use_with_bundles must be an String") if params.dig(:use_with_bundles) and !params.dig(:use_with_bundles).is_a?(String)
80
+ raise InvalidParameterError.new("Bad parameter: use_with_inboxes must be an String") if params.dig(:use_with_inboxes) and !params.dig(:use_with_inboxes).is_a?(String)
81
+ raise InvalidParameterError.new("Bad parameter: use_with_users must be an String") if params.dig(:use_with_users) and !params.dig(:use_with_users).is_a?(String)
82
+ raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)
83
+
84
+ Api.send_request("/clickwraps/#{@attributes[:id]}", :patch, params, @options)
85
+ end
86
+
87
+ def delete(params = {})
88
+ params ||= {}
89
+ params[:id] = @attributes[:id]
90
+ raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
91
+ raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
92
+ raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)
93
+
94
+ Api.send_request("/clickwraps/#{@attributes[:id]}", :delete, params, @options)
95
+ end
96
+
97
+ def destroy(params = {})
98
+ delete(params)
99
+ end
100
+
101
+ def save
102
+ if @attributes[:id]
103
+ update(@attributes)
104
+ else
105
+ new_obj = Clickwrap.create(@attributes, @options)
106
+ @attributes = new_obj.attributes
107
+ end
108
+ end
109
+
110
+ # Parameters:
111
+ # page - int64 - Current page number.
112
+ # per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
113
+ # action - string - Deprecated: If set to `count` returns a count of matching records rather than the records themselves.
114
+ def self.list(params = {}, options = {})
115
+ raise InvalidParameterError.new("Bad parameter: page must be an Integer") if params.dig(:page) and !params.dig(:page).is_a?(Integer)
116
+ raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params.dig(:per_page) and !params.dig(:per_page).is_a?(Integer)
117
+ raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
118
+
119
+ response, options = Api.send_request("/clickwraps", :get, params, options)
120
+ response.data.map do |entity_data|
121
+ Clickwrap.new(entity_data, options)
122
+ end
123
+ end
124
+
125
+ def self.all(params = {}, options = {})
126
+ list(params, options)
127
+ end
128
+
129
+ # Parameters:
130
+ # id (required) - int64 - Clickwrap ID.
131
+ def self.find(id, params = {}, options = {})
132
+ params ||= {}
133
+ params[:id] = id
134
+ raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
135
+ raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)
136
+
137
+ response, options = Api.send_request("/clickwraps/#{params[:id]}", :get, params, options)
138
+ Clickwrap.new(response.data, options)
139
+ end
140
+
141
+ def self.get(id, params = {}, options = {})
142
+ find(id, params, options)
143
+ end
144
+
145
+ # Parameters:
146
+ # name - string - Name of the Clickwrap agreement (used when selecting from multiple Clickwrap agreements.)
147
+ # body - string - Body text of Clickwrap (supports Markdown formatting).
148
+ # use_with_bundles - string - Use this Clickwrap for Bundles?
149
+ # use_with_inboxes - string - Use this Clickwrap for Inboxes?
150
+ # use_with_users - string - Use this Clickwrap for User Registrations? Note: This only applies to User Registrations where the User is invited to your Files.com site using an E-Mail invitation process where they then set their own password.
151
+ def self.create(params = {}, options = {})
152
+ raise InvalidParameterError.new("Bad parameter: name must be an String") if params.dig(:name) and !params.dig(:name).is_a?(String)
153
+ raise InvalidParameterError.new("Bad parameter: body must be an String") if params.dig(:body) and !params.dig(:body).is_a?(String)
154
+ raise InvalidParameterError.new("Bad parameter: use_with_bundles must be an String") if params.dig(:use_with_bundles) and !params.dig(:use_with_bundles).is_a?(String)
155
+ raise InvalidParameterError.new("Bad parameter: use_with_inboxes must be an String") if params.dig(:use_with_inboxes) and !params.dig(:use_with_inboxes).is_a?(String)
156
+ raise InvalidParameterError.new("Bad parameter: use_with_users must be an String") if params.dig(:use_with_users) and !params.dig(:use_with_users).is_a?(String)
157
+
158
+ response, options = Api.send_request("/clickwraps", :post, params, options)
159
+ Clickwrap.new(response.data, options)
160
+ end
161
+
162
+ # Parameters:
163
+ # name - string - Name of the Clickwrap agreement (used when selecting from multiple Clickwrap agreements.)
164
+ # body - string - Body text of Clickwrap (supports Markdown formatting).
165
+ # use_with_bundles - string - Use this Clickwrap for Bundles?
166
+ # use_with_inboxes - string - Use this Clickwrap for Inboxes?
167
+ # use_with_users - string - Use this Clickwrap for User Registrations? Note: This only applies to User Registrations where the User is invited to your Files.com site using an E-Mail invitation process where they then set their own password.
168
+ def self.update(id, params = {}, options = {})
169
+ params ||= {}
170
+ params[:id] = id
171
+ raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
172
+ raise InvalidParameterError.new("Bad parameter: name must be an String") if params.dig(:name) and !params.dig(:name).is_a?(String)
173
+ raise InvalidParameterError.new("Bad parameter: body must be an String") if params.dig(:body) and !params.dig(:body).is_a?(String)
174
+ raise InvalidParameterError.new("Bad parameter: use_with_bundles must be an String") if params.dig(:use_with_bundles) and !params.dig(:use_with_bundles).is_a?(String)
175
+ raise InvalidParameterError.new("Bad parameter: use_with_inboxes must be an String") if params.dig(:use_with_inboxes) and !params.dig(:use_with_inboxes).is_a?(String)
176
+ raise InvalidParameterError.new("Bad parameter: use_with_users must be an String") if params.dig(:use_with_users) and !params.dig(:use_with_users).is_a?(String)
177
+ raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)
178
+
179
+ response, options = Api.send_request("/clickwraps/#{params[:id]}", :patch, params, options)
180
+ Clickwrap.new(response.data, options)
181
+ end
182
+
183
+ def self.delete(id, params = {}, options = {})
184
+ params ||= {}
185
+ params[:id] = id
186
+ raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer)
187
+ raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id)
188
+
189
+ response, _options = Api.send_request("/clickwraps/#{params[:id]}", :delete, params, options)
190
+ response.data
191
+ end
192
+
193
+ def self.destroy(id, params = {}, options = {})
194
+ delete(id, params, options)
195
+ end
196
+ end
197
+ end
@@ -0,0 +1,3 @@
1
+ module Files
2
+ Dir = Folder
3
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Files
4
+ class DnsRecord
5
+ attr_reader :options, :attributes
6
+
7
+ def initialize(attributes = {}, options = {})
8
+ @attributes = attributes || {}
9
+ @options = options || {}
10
+ end
11
+
12
+ # string - Unique label for DNS record; used by Zapier and other integrations.
13
+ def id
14
+ @attributes[:id]
15
+ end
16
+
17
+ # string - DNS record domain name
18
+ def domain
19
+ @attributes[:domain]
20
+ end
21
+
22
+ # string - DNS record type
23
+ def rrtype
24
+ @attributes[:rrtype]
25
+ end
26
+
27
+ # string - DNS record value
28
+ def value
29
+ @attributes[:value]
30
+ end
31
+
32
+ # Parameters:
33
+ # page - int64 - Current page number.
34
+ # per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
35
+ # action - string - Deprecated: If set to `count` returns a count of matching records rather than the records themselves.
36
+ def self.list(params = {}, options = {})
37
+ raise InvalidParameterError.new("Bad parameter: page must be an Integer") if params.dig(:page) and !params.dig(:page).is_a?(Integer)
38
+ raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params.dig(:per_page) and !params.dig(:per_page).is_a?(Integer)
39
+ raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
40
+
41
+ response, options = Api.send_request("/dns_records", :get, params, options)
42
+ response.data.map do |entity_data|
43
+ DnsRecord.new(entity_data, options)
44
+ end
45
+ end
46
+
47
+ def self.all(params = {}, options = {})
48
+ list(params, options)
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Files
4
+ class Errors
5
+ attr_reader :options, :attributes
6
+
7
+ def initialize(attributes = {}, options = {})
8
+ @attributes = attributes || {}
9
+ @options = options || {}
10
+ end
11
+
12
+ # array - A list of fields where errors occur
13
+ def fields
14
+ @attributes[:fields]
15
+ end
16
+
17
+ # array - A list of error messages
18
+ def messages
19
+ @attributes[:messages]
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,968 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Files
4
+ class File
5
+ attr_reader :options, :attributes
6
+ attr_reader :mode
7
+
8
+ def self.binread(name, *args)
9
+ new(name).read(*args)
10
+ end
11
+
12
+ def self.binwrite(name, *args)
13
+ new(name).write(*args)
14
+ end
15
+
16
+ def self.chmod(*_args)
17
+ raise NotImplementedError
18
+ end
19
+
20
+ def self.chown(*_args)
21
+ raise NotImplementedError
22
+ end
23
+
24
+ def self.client(options = {})
25
+ options[:client] || ApiClient.active_client
26
+ end
27
+
28
+ def self.copy(old_path, new_path)
29
+ FileAction.copy(old_path, destination: new_path)
30
+ end
31
+
32
+ def self.copy_stream(*_args)
33
+ raise NotImplementedError
34
+ end
35
+
36
+ def self.directory?(path, options = {})
37
+ find(path, {}, options).type == "directory"
38
+ end
39
+
40
+ def self.download_file(path, local_path = nil)
41
+ local_path ||= File.basename(path)
42
+ new(path).download_file(local_path)
43
+ end
44
+
45
+ def self.exist?(path, options = {})
46
+ find(path, {}, options)
47
+ true
48
+ rescue Error => e
49
+ if e.code == 404
50
+ false
51
+ else
52
+ raise e
53
+ end
54
+ end
55
+
56
+ def self.exists?(path, options = {})
57
+ exist?(path, options)
58
+ end
59
+
60
+ def self.find(path, params = {}, options = {})
61
+ params[:action] = "stat"
62
+ download(path, params, options)
63
+ end
64
+
65
+ def self.for_fd(*_args)
66
+ raise NotImplementedError
67
+ end
68
+
69
+ def self.foreach(name, *args, &block)
70
+ new(name).each(*args, &block)
71
+ end
72
+
73
+ def self.get(path, params = {}, options = {})
74
+ find(path, params, options)
75
+ end
76
+
77
+ def self.identical?(path1, path2)
78
+ new(path1).crc32 == new(path2).crc32
79
+ end
80
+
81
+ def self.lstat(path)
82
+ new(path).stat
83
+ end
84
+
85
+ def self.move(old_path, new_path)
86
+ FileAction.move(old_path, destination: new_path)
87
+ end
88
+
89
+ def self.mtime(path)
90
+ new(path).mtime
91
+ end
92
+
93
+ def self.open(path, mode = "r", options = {}, &block)
94
+ file = new(path, mode, options)
95
+ if block
96
+ yield file
97
+ file.close
98
+ end
99
+ file
100
+ end
101
+
102
+ def self.owned?(_path)
103
+ raise NotImplementedError
104
+ end
105
+
106
+ def self.pipe(*_args)
107
+ raise NotImplementedError
108
+ end
109
+
110
+ def self.popen(*_args)
111
+ raise NotImplementedError
112
+ end
113
+
114
+ def self.read(name, *args)
115
+ new(name).read(*args)
116
+ end
117
+
118
+ def self.readable?(path)
119
+ new(path).stat.permissions.include?("read")
120
+ end
121
+
122
+ def self.readlines(name, *args)
123
+ new(name).readlines(*args)
124
+ end
125
+
126
+ def self.rename(old_path, new_path)
127
+ FileAction.move(old_path, destination: new_path)
128
+ end
129
+
130
+ def self.select(*_args)
131
+ raise NotImplementedError
132
+ end
133
+
134
+ def self.stat(path)
135
+ new(path).stat
136
+ end
137
+
138
+ def self.sysopen(*_args)
139
+ raise NotImplementedError
140
+ end
141
+
142
+ def self.try_convert(*_args)
143
+ raise NotImplementedError
144
+ end
145
+
146
+ def self.unlink(*paths)
147
+ paths.map { |p| delete(p) }
148
+ end
149
+
150
+ def self.upload_chunks(io, path, options, upload = nil, etags = [])
151
+ etags ||= []
152
+ bytes_written = 0
153
+ loop do
154
+ begin_upload = FileAction.begin_upload(path, { ref: upload&.ref, part: (upload&.part_number || 0) + 1 }, options)
155
+ upload = begin_upload.is_a?(Enumerable) ? begin_upload.first : begin_upload
156
+ buf = io.read(upload.partsize) || ""
157
+ bytes_written += buf.length
158
+ method = upload.http_method.downcase.to_sym
159
+ response = client(options).remote_request(method, upload.upload_uri, { "Content-Length": buf.length.to_s }, buf)
160
+ etags << { etag: response.headers["ETag"], part: upload.part_number }
161
+ return upload, etags, bytes_written if io.eof?
162
+ end
163
+ end
164
+
165
+ def self.upload_file(path, destination = nil, options = {})
166
+ local_file = ::File.open(path, 'r')
167
+ destination ||= File.basename(path)
168
+ upload, etags = upload_chunks(local_file, destination, options)
169
+
170
+ params = {
171
+ action: "end",
172
+ etags: etags,
173
+ provided_mtime: local_file.mtime.to_s,
174
+ ref: upload.ref,
175
+ size: local_file.size
176
+ }
177
+
178
+ create(destination, params, options)
179
+ ensure
180
+ local_file.close
181
+ end
182
+
183
+ def self.write(*_args)
184
+ raise NotImplementedError
185
+ end
186
+
187
+ def self.zero?(path)
188
+ new(path).empty?
189
+ end
190
+
191
+ def initialize(*args)
192
+ @attributes = (args[0].is_a?(Hash) && args[0]) || {}
193
+ @options = (args[1].is_a?(Hash) && args[1])
194
+ @options ||= (args[2].is_a?(Hash) && args[2]) || {}
195
+ @attributes[:path] = args[0] if args[0].is_a?(String)
196
+ @mode = args[1] || 'r' if args[1].is_a?(String)
197
+ @write_io = StringIO.new
198
+ @bytes_written = 0
199
+ end
200
+
201
+ def advise(*_args); end
202
+
203
+ def atime
204
+ mtime
205
+ end
206
+
207
+ def autoclose=(*_args); end
208
+
209
+ def autoclose?(*_args); end
210
+
211
+ def binmode
212
+ binmode?
213
+ end
214
+
215
+ def binmode?
216
+ true
217
+ end
218
+
219
+ def birthtime
220
+ raise NotImplementedError
221
+ end
222
+
223
+ def bytes
224
+ read_io.bytes
225
+ end
226
+
227
+ def chars
228
+ read_io.chars
229
+ end
230
+
231
+ def chmod(*_args)
232
+ raise NotImplementedError
233
+ end
234
+
235
+ def chown(*_args)
236
+ raise NotImplementedError
237
+ end
238
+
239
+ def client
240
+ options[:client] || ApiClient.active_client
241
+ end
242
+
243
+ def close
244
+ flush
245
+
246
+ if @upload
247
+ end_options = {
248
+ "action": "end",
249
+ "etags": @etags,
250
+ "provided_mtime": Time.now.to_s,
251
+ "ref": @upload.ref,
252
+ "size": @bytes_written
253
+ }
254
+
255
+ file = File.create(path, end_options, @options)
256
+ @attributes = file.attributes
257
+ @upload = nil
258
+ end
259
+ @write_io.close
260
+ end
261
+
262
+ def close_on_exec?(*args)
263
+ @write_io.close_on_exec? *args
264
+ end
265
+
266
+ def close_on_exec=(*args)
267
+ @write_io.close_on_exec = *args
268
+ end
269
+
270
+ def close_read(*args)
271
+ @write_io.close_read *args
272
+ end
273
+
274
+ def close_write(*args)
275
+ @write_io.close_write *args
276
+ end
277
+
278
+ def closed?(*args)
279
+ @write_io.closed? *args
280
+ end
281
+
282
+ def codepoints(*args, &block)
283
+ @write_io.codepoints *args, &block
284
+ end
285
+
286
+ def copy(destination)
287
+ File.copy(path, destination)
288
+ end
289
+
290
+ def ctime(*_args)
291
+ mtime
292
+ end
293
+
294
+ def download_uri_with_load
295
+ return download_uri if download_uri
296
+
297
+ file = File.download(path, {}, @options)
298
+ @attributes = file.attributes
299
+ download_uri
300
+ end
301
+
302
+ def download_file(output_file)
303
+ ::File.open(output_file, 'wb') do |file|
304
+ download_content(file)
305
+ end
306
+ end
307
+
308
+ def download_content(io)
309
+ Files::ApiClient.download_client.stream_download(download_uri_with_load, io)
310
+ end
311
+
312
+ def each(*args, &block)
313
+ read_io.each *args, &block
314
+ end
315
+
316
+ def each_byte(*args, &block)
317
+ read_io.each_byte *args, &block
318
+ end
319
+
320
+ def each_char(*args, &block)
321
+ read_io.each_char *args, &block
322
+ end
323
+
324
+ def each_codepoint(*args, &block)
325
+ read_io.each_codepoint *args, &block
326
+ end
327
+
328
+ def each_line(*args, &block)
329
+ each(*args, &block)
330
+ end
331
+
332
+ def empty?
333
+ size == 0
334
+ end
335
+
336
+ def eof
337
+ eof?
338
+ end
339
+
340
+ def eof?
341
+ @write_io.eof?
342
+ end
343
+
344
+ def external_encoding(*args)
345
+ internal_encoding *args
346
+ end
347
+
348
+ def fcntl(*_args)
349
+ raise NotImplementedError
350
+ end
351
+
352
+ def fdatasync(*_args)
353
+ flush
354
+ end
355
+
356
+ def fileno(*_args)
357
+ id
358
+ end
359
+
360
+ def flock(*_args)
361
+ raise NotImplementedError
362
+ end
363
+
364
+ def flush(*_args)
365
+ if mode.include? "w"
366
+ @write_io.rewind if @write_io.is_a?(StringIO)
367
+
368
+ @upload, @etags, bytes_written = File.upload_chunks(@write_io, path, options, @upload, @etags)
369
+ @bytes_written += bytes_written
370
+ elsif mode.include? "a"
371
+ raise NotImplementedError
372
+ end
373
+ end
374
+
375
+ def fsync(*args)
376
+ flush *args
377
+ end
378
+
379
+ def getbyte(*args)
380
+ read_io.getbyte *args
381
+ end
382
+
383
+ def getc(*args)
384
+ read_io.getc *args
385
+ end
386
+
387
+ def gets(*args)
388
+ read_io.gets *args
389
+ end
390
+
391
+ def read_io
392
+ @read_io ||= begin
393
+ r, w = SizableIO.pipe
394
+ Thread.new do
395
+ download_content(w)
396
+ ensure
397
+ w.close
398
+ end
399
+ r
400
+ end
401
+ end
402
+
403
+ def internal_encoding(*_args)
404
+ "".encoding
405
+ end
406
+
407
+ def ioctl(*_args)
408
+ raise NotImplementedError
409
+ end
410
+
411
+ def isatty(*_args)
412
+ false
413
+ end
414
+
415
+ def lineno(*_args)
416
+ @lineno ||= 0
417
+ end
418
+
419
+ attr_writer :lineno
420
+
421
+ def lines(*args, &block)
422
+ each_line *args, &block
423
+ end
424
+
425
+ def lstat(*_args)
426
+ stats
427
+ end
428
+
429
+ def move(destination)
430
+ File.move(path, destination)
431
+ end
432
+
433
+ def mv(destination)
434
+ File.move(path, destination)
435
+ end
436
+
437
+ def pid(*_args)
438
+ Process.pid
439
+ end
440
+
441
+ def pos
442
+ @pos ||= 0
443
+ end
444
+
445
+ attr_writer :pos
446
+
447
+ def pread(*args)
448
+ read_io.pread *args
449
+ end
450
+
451
+ def print(*args)
452
+ @write_io.print *args
453
+ end
454
+
455
+ def printf(*args)
456
+ @write_io.printf *args
457
+ end
458
+
459
+ def putc(*args)
460
+ @write_io.putc *args
461
+ end
462
+
463
+ def puts(*args)
464
+ @write_io.puts *args
465
+ end
466
+
467
+ def pwrite(*args)
468
+ @write_io.pwrite *args
469
+ end
470
+
471
+ def read(*args)
472
+ read_io.read *args
473
+ end
474
+
475
+ def read_nonblock(*args)
476
+ read_io.read_nonblock *args
477
+ end
478
+
479
+ def readbyte(*args)
480
+ read_io.readbyte *args
481
+ end
482
+
483
+ def readchar(*args)
484
+ read_io.readchar *args
485
+ end
486
+
487
+ def readline(*args)
488
+ read_io.readline *args
489
+ end
490
+
491
+ def readlines(*args)
492
+ io.readlines(*args)
493
+ end
494
+
495
+ def readpartial(*args)
496
+ read_io.readpartial *args
497
+ end
498
+
499
+ def rename(destination)
500
+ File.rename(path, destination)
501
+ end
502
+
503
+ def reopen(*_args)
504
+ raise NotImplementedError
505
+ end
506
+
507
+ def rewind
508
+ @pos = 0
509
+ end
510
+
511
+ def seek(pos)
512
+ @pos = pos
513
+ end
514
+
515
+ def set_encoding(*_args) # rubocop:disable Naming/AccessorMethodName
516
+ raise NotImplementedError
517
+ end
518
+
519
+ def stat(*_args)
520
+ stats
521
+ end
522
+
523
+ def sync
524
+ @sync ||= false
525
+ end
526
+
527
+ attr_writer :sync
528
+
529
+ def sysread(*args)
530
+ read *args
531
+ end
532
+
533
+ def sysseek(*args)
534
+ seek *args
535
+ end
536
+
537
+ def syswrite(*_args)
538
+ raise NotImplementedError
539
+ end
540
+
541
+ def tell
542
+ pos
543
+ end
544
+
545
+ def to_i(*_args)
546
+ fileno
547
+ end
548
+
549
+ def to_io(*_args)
550
+ @write_io
551
+ end
552
+
553
+ def to_path(*_args)
554
+ path
555
+ end
556
+
557
+ def truncate(*_args)
558
+ raise NotImplementedError
559
+ end
560
+
561
+ def tty?(*_args)
562
+ false
563
+ end
564
+
565
+ def ungetbyte(*_args)
566
+ raise NotImplementedError
567
+ end
568
+
569
+ def ungetc(*_args)
570
+ raise NotImplementedError
571
+ end
572
+
573
+ def upload_file(local_file)
574
+ File.upload_file(local_file.path)
575
+ end
576
+
577
+ def write(*args)
578
+ @mode ||= 'w'
579
+ if args[0].respond_to?(:read)
580
+ flush if @write_io.size > 0 # rubocop:disable Style/ZeroLengthPredicate
581
+ @write_io = args[0]
582
+ else
583
+ @write_io.write *args
584
+ end
585
+ end
586
+
587
+ def write_nonblock(*args)
588
+ @write_io.write_nonblock *args
589
+ end
590
+
591
+ # int64 - File/Folder ID
592
+ def id
593
+ @attributes[:id]
594
+ end
595
+
596
+ def id=(value)
597
+ @attributes[:id] = value
598
+ end
599
+
600
+ # string - File/Folder path This must be slash-delimited, but it must neither start nor end with a slash. Maximum of 5000 characters.
601
+ def path
602
+ @attributes[:path]
603
+ end
604
+
605
+ def path=(value)
606
+ @attributes[:path] = value
607
+ end
608
+
609
+ # string - File/Folder display name
610
+ def display_name
611
+ @attributes[:display_name]
612
+ end
613
+
614
+ def display_name=(value)
615
+ @attributes[:display_name] = value
616
+ end
617
+
618
+ # string - Type: `directory` or `file`.
619
+ def type
620
+ @attributes[:type]
621
+ end
622
+
623
+ def type=(value)
624
+ @attributes[:type] = value
625
+ end
626
+
627
+ # int64 - File/Folder size
628
+ def size
629
+ @attributes[:size]
630
+ end
631
+
632
+ def size=(value)
633
+ @attributes[:size] = value
634
+ end
635
+
636
+ # date-time - File last modified date/time, according to the server. This is the timestamp of the last Files.com operation of the file, regardless of what modified timestamp was sent.
637
+ def mtime
638
+ @attributes[:mtime]
639
+ end
640
+
641
+ def mtime=(value)
642
+ @attributes[:mtime] = value
643
+ end
644
+
645
+ # date-time - File last modified date/time, according to the client who set it. Files.com allows desktop, FTP, SFTP, and WebDAV clients to set modified at times. This allows Desktop<->Cloud syncing to preserve modified at times.
646
+ def provided_mtime
647
+ @attributes[:provided_mtime]
648
+ end
649
+
650
+ def provided_mtime=(value)
651
+ @attributes[:provided_mtime] = value
652
+ end
653
+
654
+ # string - File CRC32 checksum. This is sometimes delayed, so if you get a blank response, wait and try again.
655
+ def crc32
656
+ @attributes[:crc32]
657
+ end
658
+
659
+ def crc32=(value)
660
+ @attributes[:crc32] = value
661
+ end
662
+
663
+ # string - File MD5 checksum. This is sometimes delayed, so if you get a blank response, wait and try again.
664
+ def md5
665
+ @attributes[:md5]
666
+ end
667
+
668
+ def md5=(value)
669
+ @attributes[:md5] = value
670
+ end
671
+
672
+ # string - MIME Type. This is determined by the filename extension and is not stored separately internally.
673
+ def mime_type
674
+ @attributes[:mime_type]
675
+ end
676
+
677
+ def mime_type=(value)
678
+ @attributes[:mime_type] = value
679
+ end
680
+
681
+ # string - Region location
682
+ def region
683
+ @attributes[:region]
684
+ end
685
+
686
+ def region=(value)
687
+ @attributes[:region] = value
688
+ end
689
+
690
+ # string - A short string representing the current user's permissions. Can be `r`,`w`,`p`, or any combination
691
+ def permissions
692
+ @attributes[:permissions]
693
+ end
694
+
695
+ def permissions=(value)
696
+ @attributes[:permissions] = value
697
+ end
698
+
699
+ # boolean - Are subfolders locked and unable to be modified?
700
+ def subfolders_locked?
701
+ @attributes[:subfolders_locked?]
702
+ end
703
+
704
+ def subfolders_locked=(value)
705
+ @attributes[:subfolders_locked?] = value
706
+ end
707
+
708
+ # string - Link to download file. Provided only in response to a download request.
709
+ def download_uri
710
+ @attributes[:download_uri]
711
+ end
712
+
713
+ def download_uri=(value)
714
+ @attributes[:download_uri] = value
715
+ end
716
+
717
+ # string - Bookmark/priority color of file/folder
718
+ def priority_color
719
+ @attributes[:priority_color]
720
+ end
721
+
722
+ def priority_color=(value)
723
+ @attributes[:priority_color] = value
724
+ end
725
+
726
+ # int64 - File preview ID
727
+ def preview_id
728
+ @attributes[:preview_id]
729
+ end
730
+
731
+ def preview_id=(value)
732
+ @attributes[:preview_id] = value
733
+ end
734
+
735
+ # File preview
736
+ def preview
737
+ @attributes[:preview]
738
+ end
739
+
740
+ def preview=(value)
741
+ @attributes[:preview] = value
742
+ end
743
+
744
+ # string - The action to perform. Can be `append`, `attachment`, `end`, `upload`, `put`, or may not exist
745
+ def action
746
+ @attributes[:action]
747
+ end
748
+
749
+ def action=(value)
750
+ @attributes[:action] = value
751
+ end
752
+
753
+ # int64 - Length of file.
754
+ def length
755
+ @attributes[:length]
756
+ end
757
+
758
+ def length=(value)
759
+ @attributes[:length] = value
760
+ end
761
+
762
+ # boolean - Create parent directories if they do not exist?
763
+ def mkdir_parents
764
+ @attributes[:mkdir_parents]
765
+ end
766
+
767
+ def mkdir_parents=(value)
768
+ @attributes[:mkdir_parents] = value
769
+ end
770
+
771
+ # int64 - Part if uploading a part.
772
+ def part
773
+ @attributes[:part]
774
+ end
775
+
776
+ def part=(value)
777
+ @attributes[:part] = value
778
+ end
779
+
780
+ # int64 - How many parts to fetch?
781
+ def parts
782
+ @attributes[:parts]
783
+ end
784
+
785
+ def parts=(value)
786
+ @attributes[:parts] = value
787
+ end
788
+
789
+ # string -
790
+ def ref
791
+ @attributes[:ref]
792
+ end
793
+
794
+ def ref=(value)
795
+ @attributes[:ref] = value
796
+ end
797
+
798
+ # int64 - File byte offset to restart from.
799
+ def restart
800
+ @attributes[:restart]
801
+ end
802
+
803
+ def restart=(value)
804
+ @attributes[:restart] = value
805
+ end
806
+
807
+ # string - If copying folder, copy just the structure?
808
+ def structure
809
+ @attributes[:structure]
810
+ end
811
+
812
+ def structure=(value)
813
+ @attributes[:structure] = value
814
+ end
815
+
816
+ # boolean - Allow file rename instead of overwrite?
817
+ def with_rename
818
+ @attributes[:with_rename]
819
+ end
820
+
821
+ def with_rename=(value)
822
+ @attributes[:with_rename] = value
823
+ end
824
+
825
+ # Download file
826
+ #
827
+ # Parameters:
828
+ # action - string - Can be blank, `redirect` or `stat`. If set to `stat`, we will return file information but without a download URL, and without logging a download. If set to `redirect` we will serve a 302 redirect directly to the file. This is used for integrations with Zapier, and is not recommended for most integrations.
829
+ # preview_size - string - Request a preview size. Can be `small` (default), `large`, `xlarge`, or `pdf`.
830
+ # with_previews - boolean - Include file preview information?
831
+ # with_priority_color - boolean - Include file priority color information?
832
+ def download(params = {})
833
+ params ||= {}
834
+ params[:path] = @attributes[:path]
835
+ raise MissingParameterError.new("Current object doesn't have a path") unless @attributes[:path]
836
+ raise InvalidParameterError.new("Bad parameter: path must be an String") if params.dig(:path) and !params.dig(:path).is_a?(String)
837
+ raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
838
+ raise InvalidParameterError.new("Bad parameter: preview_size must be an String") if params.dig(:preview_size) and !params.dig(:preview_size).is_a?(String)
839
+ raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path)
840
+
841
+ Api.send_request("/files/#{@attributes[:path]}", :get, params, @options)
842
+ end
843
+
844
+ # Parameters:
845
+ # provided_mtime - string - Modified time of file.
846
+ # priority_color - string - Priority/Bookmark color of file.
847
+ def update(params = {})
848
+ params ||= {}
849
+ params[:path] = @attributes[:path]
850
+ raise MissingParameterError.new("Current object doesn't have a path") unless @attributes[:path]
851
+ raise InvalidParameterError.new("Bad parameter: path must be an String") if params.dig(:path) and !params.dig(:path).is_a?(String)
852
+ raise InvalidParameterError.new("Bad parameter: provided_mtime must be an String") if params.dig(:provided_mtime) and !params.dig(:provided_mtime).is_a?(String)
853
+ raise InvalidParameterError.new("Bad parameter: priority_color must be an String") if params.dig(:priority_color) and !params.dig(:priority_color).is_a?(String)
854
+ raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path)
855
+
856
+ Api.send_request("/files/#{@attributes[:path]}", :patch, params, @options)
857
+ end
858
+
859
+ # Parameters:
860
+ # recursive - boolean - If true, will recursively delete folers. Otherwise, will error on non-empty folders. For legacy reasons, this parameter may also be provided as the HTTP header `Depth: Infinity`
861
+ def delete(params = {})
862
+ params ||= {}
863
+ params[:path] = @attributes[:path]
864
+ raise MissingParameterError.new("Current object doesn't have a path") unless @attributes[:path]
865
+ raise InvalidParameterError.new("Bad parameter: path must be an String") if params.dig(:path) and !params.dig(:path).is_a?(String)
866
+ raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path)
867
+
868
+ Api.send_request("/files/#{@attributes[:path]}", :delete, params, @options)
869
+ end
870
+
871
+ def destroy(params = {})
872
+ delete(params)
873
+ end
874
+
875
+ def save
876
+ if @attributes[:path]
877
+ update(@attributes)
878
+ else
879
+ new_obj = File.create(@attributes, @options)
880
+ @attributes = new_obj.attributes
881
+ end
882
+ end
883
+
884
+ # Download file
885
+ #
886
+ # Parameters:
887
+ # action - string - Can be blank, `redirect` or `stat`. If set to `stat`, we will return file information but without a download URL, and without logging a download. If set to `redirect` we will serve a 302 redirect directly to the file. This is used for integrations with Zapier, and is not recommended for most integrations.
888
+ # preview_size - string - Request a preview size. Can be `small` (default), `large`, `xlarge`, or `pdf`.
889
+ # with_previews - boolean - Include file preview information?
890
+ # with_priority_color - boolean - Include file priority color information?
891
+ def self.download(path, params = {}, options = {})
892
+ params ||= {}
893
+ params[:path] = path
894
+ raise InvalidParameterError.new("Bad parameter: path must be an String") if params.dig(:path) and !params.dig(:path).is_a?(String)
895
+ raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
896
+ raise InvalidParameterError.new("Bad parameter: preview_size must be an String") if params.dig(:preview_size) and !params.dig(:preview_size).is_a?(String)
897
+ raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path)
898
+
899
+ response, options = Api.send_request("/files/#{params[:path]}", :get, params, options)
900
+ File.new(response.data, options)
901
+ end
902
+
903
+ # Parameters:
904
+ # path (required) - string - Path to operate on.
905
+ # action - string - The action to perform. Can be `append`, `attachment`, `end`, `upload`, `put`, or may not exist
906
+ # etags[etag] (required) - array(string) - etag identifier.
907
+ # etags[part] (required) - array(int64) - Part number.
908
+ # length - int64 - Length of file.
909
+ # mkdir_parents - boolean - Create parent directories if they do not exist?
910
+ # part - int64 - Part if uploading a part.
911
+ # parts - int64 - How many parts to fetch?
912
+ # provided_mtime - string - User provided modification time.
913
+ # ref - string -
914
+ # restart - int64 - File byte offset to restart from.
915
+ # size - int64 - Size of file.
916
+ # structure - string - If copying folder, copy just the structure?
917
+ # with_rename - boolean - Allow file rename instead of overwrite?
918
+ def self.create(path, params = {}, options = {})
919
+ params ||= {}
920
+ params[:path] = path
921
+ raise InvalidParameterError.new("Bad parameter: path must be an String") if params.dig(:path) and !params.dig(:path).is_a?(String)
922
+ raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String)
923
+ raise InvalidParameterError.new("Bad parameter: length must be an Integer") if params.dig(:length) and !params.dig(:length).is_a?(Integer)
924
+ raise InvalidParameterError.new("Bad parameter: part must be an Integer") if params.dig(:part) and !params.dig(:part).is_a?(Integer)
925
+ raise InvalidParameterError.new("Bad parameter: parts must be an Integer") if params.dig(:parts) and !params.dig(:parts).is_a?(Integer)
926
+ raise InvalidParameterError.new("Bad parameter: provided_mtime must be an String") if params.dig(:provided_mtime) and !params.dig(:provided_mtime).is_a?(String)
927
+ raise InvalidParameterError.new("Bad parameter: ref must be an String") if params.dig(:ref) and !params.dig(:ref).is_a?(String)
928
+ raise InvalidParameterError.new("Bad parameter: restart must be an Integer") if params.dig(:restart) and !params.dig(:restart).is_a?(Integer)
929
+ raise InvalidParameterError.new("Bad parameter: size must be an Integer") if params.dig(:size) and !params.dig(:size).is_a?(Integer)
930
+ raise InvalidParameterError.new("Bad parameter: structure must be an String") if params.dig(:structure) and !params.dig(:structure).is_a?(String)
931
+ raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path)
932
+
933
+ response, options = Api.send_request("/files/#{params[:path]}", :post, params, options)
934
+ File.new(response.data, options)
935
+ end
936
+
937
+ # Parameters:
938
+ # provided_mtime - string - Modified time of file.
939
+ # priority_color - string - Priority/Bookmark color of file.
940
+ def self.update(path, params = {}, options = {})
941
+ params ||= {}
942
+ params[:path] = path
943
+ raise InvalidParameterError.new("Bad parameter: path must be an String") if params.dig(:path) and !params.dig(:path).is_a?(String)
944
+ raise InvalidParameterError.new("Bad parameter: provided_mtime must be an String") if params.dig(:provided_mtime) and !params.dig(:provided_mtime).is_a?(String)
945
+ raise InvalidParameterError.new("Bad parameter: priority_color must be an String") if params.dig(:priority_color) and !params.dig(:priority_color).is_a?(String)
946
+ raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path)
947
+
948
+ response, options = Api.send_request("/files/#{params[:path]}", :patch, params, options)
949
+ File.new(response.data, options)
950
+ end
951
+
952
+ # Parameters:
953
+ # recursive - boolean - If true, will recursively delete folers. Otherwise, will error on non-empty folders. For legacy reasons, this parameter may also be provided as the HTTP header `Depth: Infinity`
954
+ def self.delete(path, params = {}, options = {})
955
+ params ||= {}
956
+ params[:path] = path
957
+ raise InvalidParameterError.new("Bad parameter: path must be an String") if params.dig(:path) and !params.dig(:path).is_a?(String)
958
+ raise MissingParameterError.new("Parameter missing: path") unless params.dig(:path)
959
+
960
+ response, _options = Api.send_request("/files/#{params[:path]}", :delete, params, options)
961
+ response.data
962
+ end
963
+
964
+ def self.destroy(path, params = {}, options = {})
965
+ delete(path, params, options)
966
+ end
967
+ end
968
+ end