uploadcare-ruby 2.1.2 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/gem-push.yml +20 -0
  3. data/.github/workflows/ruby.yml +52 -0
  4. data/.gitignore +13 -6
  5. data/.rspec +2 -0
  6. data/.rubocop.yml +20 -0
  7. data/.yardopts +4 -0
  8. data/CHANGELOG.md +24 -51
  9. data/DEVELOPMENT.md +18 -0
  10. data/Gemfile +2 -0
  11. data/LICENSE +1 -1
  12. data/README.md +164 -578
  13. data/Rakefile +5 -5
  14. data/bin/console +15 -0
  15. data/bin/setup +8 -0
  16. data/lib/uploadcare.rb +36 -32
  17. data/lib/uploadcare/api/api.rb +25 -0
  18. data/lib/uploadcare/client/file_client.rb +44 -0
  19. data/lib/uploadcare/client/file_list_client.rb +46 -0
  20. data/lib/uploadcare/client/group_client.rb +45 -0
  21. data/lib/uploadcare/client/multipart_upload/chunks_client.rb +46 -0
  22. data/lib/uploadcare/client/multipart_upload_client.rb +62 -0
  23. data/lib/uploadcare/client/project_client.rb +18 -0
  24. data/lib/uploadcare/client/rest_client.rb +73 -0
  25. data/lib/uploadcare/client/rest_group_client.rb +23 -0
  26. data/lib/uploadcare/client/upload_client.rb +35 -0
  27. data/lib/uploadcare/client/uploader_client.rb +93 -0
  28. data/lib/uploadcare/client/webhook_client.rb +43 -0
  29. data/lib/uploadcare/concern/error_handler.rb +54 -0
  30. data/lib/uploadcare/concern/throttle_handler.rb +25 -0
  31. data/lib/uploadcare/concern/upload_error_handler.rb +32 -0
  32. data/lib/uploadcare/entity/decorator/paginator.rb +81 -0
  33. data/lib/uploadcare/entity/entity.rb +18 -0
  34. data/lib/uploadcare/entity/file.rb +81 -0
  35. data/lib/uploadcare/entity/file_list.rb +30 -0
  36. data/lib/uploadcare/entity/group.rb +41 -0
  37. data/lib/uploadcare/entity/group_list.rb +24 -0
  38. data/lib/uploadcare/entity/project.rb +13 -0
  39. data/lib/uploadcare/entity/uploader.rb +73 -0
  40. data/lib/uploadcare/entity/webhook.rb +14 -0
  41. data/lib/uploadcare/exception/request_error.rb +9 -0
  42. data/lib/uploadcare/exception/throttle_error.rb +14 -0
  43. data/lib/uploadcare/param/authentication_header.rb +25 -0
  44. data/lib/uploadcare/param/param.rb +10 -0
  45. data/lib/uploadcare/param/secure_auth_header.rb +37 -0
  46. data/lib/uploadcare/param/simple_auth_header.rb +14 -0
  47. data/lib/uploadcare/param/upload/signature_generator.rb +24 -0
  48. data/lib/uploadcare/param/upload/upload_params_generator.rb +23 -0
  49. data/lib/uploadcare/param/user_agent.rb +21 -0
  50. data/lib/uploadcare/ruby/version.rb +5 -0
  51. data/uploadcare-ruby.gemspec +50 -37
  52. metadata +98 -113
  53. data/.travis.yml +0 -26
  54. data/UPGRADE_NOTES.md +0 -36
  55. data/lib/uploadcare/api.rb +0 -26
  56. data/lib/uploadcare/api/file_api.rb +0 -7
  57. data/lib/uploadcare/api/file_list_api.rb +0 -19
  58. data/lib/uploadcare/api/file_storage_api.rb +0 -34
  59. data/lib/uploadcare/api/group_api.rb +0 -38
  60. data/lib/uploadcare/api/group_list_api.rb +0 -17
  61. data/lib/uploadcare/api/project_api.rb +0 -9
  62. data/lib/uploadcare/api/raw_api.rb +0 -38
  63. data/lib/uploadcare/api/uploading_api.rb +0 -71
  64. data/lib/uploadcare/api/uploading_api/upload_params.rb +0 -72
  65. data/lib/uploadcare/api/validators/file_list_options_validator.rb +0 -73
  66. data/lib/uploadcare/api/validators/group_list_options_validator.rb +0 -49
  67. data/lib/uploadcare/errors/errors.rb +0 -64
  68. data/lib/uploadcare/resources/file.rb +0 -164
  69. data/lib/uploadcare/resources/file_list.rb +0 -14
  70. data/lib/uploadcare/resources/group.rb +0 -115
  71. data/lib/uploadcare/resources/group_list.rb +0 -14
  72. data/lib/uploadcare/resources/project.rb +0 -13
  73. data/lib/uploadcare/resources/resource_list.rb +0 -83
  74. data/lib/uploadcare/rest/auth/auth.rb +0 -31
  75. data/lib/uploadcare/rest/auth/secure.rb +0 -43
  76. data/lib/uploadcare/rest/auth/simple.rb +0 -16
  77. data/lib/uploadcare/rest/connections/api_connection.rb +0 -53
  78. data/lib/uploadcare/rest/connections/upload_connection.rb +0 -22
  79. data/lib/uploadcare/rest/middlewares/auth_middleware.rb +0 -24
  80. data/lib/uploadcare/rest/middlewares/parse_json_middleware.rb +0 -33
  81. data/lib/uploadcare/rest/middlewares/raise_error_middleware.rb +0 -21
  82. data/lib/uploadcare/utils/parser.rb +0 -71
  83. data/lib/uploadcare/utils/user_agent.rb +0 -44
  84. data/lib/uploadcare/version.rb +0 -3
  85. data/spec/api/file_list_api_spec.rb +0 -95
  86. data/spec/api/file_storage_api_spec.rb +0 -88
  87. data/spec/api/group_list_api_spec.rb +0 -59
  88. data/spec/api/raw_api_spec.rb +0 -25
  89. data/spec/api/uploading_api/upload_params_spec.rb +0 -99
  90. data/spec/api/uploading_api_spec.rb +0 -59
  91. data/spec/resources/file_list_spec.rb +0 -25
  92. data/spec/resources/file_spec.rb +0 -223
  93. data/spec/resources/group_list_spec.rb +0 -25
  94. data/spec/resources/group_spec.rb +0 -101
  95. data/spec/resources/operations_spec.rb +0 -59
  96. data/spec/resources/project_spec.rb +0 -21
  97. data/spec/rest/api_connection_spec.rb +0 -68
  98. data/spec/rest/auth/secure_spec.rb +0 -66
  99. data/spec/rest/auth/simple_spec.rb +0 -31
  100. data/spec/rest/errors_spec.rb +0 -75
  101. data/spec/rest/upload_connection_spec.rb +0 -19
  102. data/spec/shared/resource_list.rb +0 -188
  103. data/spec/spec_helper.rb +0 -54
  104. data/spec/uploadcare_spec.rb +0 -43
  105. data/spec/utils/parser_spec.rb +0 -85
  106. data/spec/utils/user_agent_spec.rb +0 -46
  107. data/spec/view.png +0 -0
  108. data/spec/view2.jpg +0 -0
metadata CHANGED
@@ -1,48 +1,45 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uploadcare-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 3.0.3
5
5
  platform: ruby
6
6
  authors:
7
- - "@rastyagaev (Vadim Rastyagaev)"
8
- - "@dimituri (Dimitry Solovyov)"
9
- - "@romanonthego (Roman Dubinin)"
10
- - "@vizvamitra (Dmitrii Krasnov)"
7
+ - Stepan Redka
11
8
  autorequire:
12
- bindir: bin
9
+ bindir: exe
13
10
  cert_chain: []
14
- date: 2018-06-11 00:00:00.000000000 Z
11
+ date: 2021-04-15 00:00:00.000000000 Z
15
12
  dependencies:
16
13
  - !ruby/object:Gem::Dependency
17
- name: faraday
14
+ name: api_struct
18
15
  requirement: !ruby/object:Gem::Requirement
19
16
  requirements:
20
17
  - - "~>"
21
18
  - !ruby/object:Gem::Version
22
- version: '0.8'
19
+ version: 1.0.1
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '0.8'
26
+ version: 1.0.1
30
27
  - !ruby/object:Gem::Dependency
31
- name: faraday_middleware
28
+ name: dry-configurable
32
29
  requirement: !ruby/object:Gem::Requirement
33
30
  requirements:
34
31
  - - "~>"
35
32
  - !ruby/object:Gem::Version
36
- version: '0.9'
33
+ version: 0.9.0
37
34
  type: :runtime
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
38
  - - "~>"
42
39
  - !ruby/object:Gem::Version
43
- version: '0.9'
40
+ version: 0.9.0
44
41
  - !ruby/object:Gem::Dependency
45
- name: multipart-post
42
+ name: parallel
46
43
  requirement: !ruby/object:Gem::Requirement
47
44
  requirements:
48
45
  - - ">="
@@ -56,7 +53,7 @@ dependencies:
56
53
  - !ruby/object:Gem::Version
57
54
  version: '0'
58
55
  - !ruby/object:Gem::Dependency
59
- name: mime-types
56
+ name: retries
60
57
  requirement: !ruby/object:Gem::Requirement
61
58
  requirements:
62
59
  - - ">="
@@ -69,22 +66,50 @@ dependencies:
69
66
  - - ">="
70
67
  - !ruby/object:Gem::Version
71
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: byebug
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '13.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '13.0'
72
97
  - !ruby/object:Gem::Dependency
73
98
  name: rspec
74
99
  requirement: !ruby/object:Gem::Requirement
75
100
  requirements:
76
101
  - - "~>"
77
102
  - !ruby/object:Gem::Version
78
- version: '3.6'
103
+ version: '3.0'
79
104
  type: :development
80
105
  prerelease: false
81
106
  version_requirements: !ruby/object:Gem::Requirement
82
107
  requirements:
83
108
  - - "~>"
84
109
  - !ruby/object:Gem::Version
85
- version: '3.6'
110
+ version: '3.0'
86
111
  - !ruby/object:Gem::Dependency
87
- name: rake
112
+ name: rubocop
88
113
  requirement: !ruby/object:Gem::Requirement
89
114
  requirements:
90
115
  - - ">="
@@ -98,7 +123,7 @@ dependencies:
98
123
  - !ruby/object:Gem::Version
99
124
  version: '0'
100
125
  - !ruby/object:Gem::Dependency
101
- name: pry
126
+ name: vcr
102
127
  requirement: !ruby/object:Gem::Requirement
103
128
  requirements:
104
129
  - - ">="
@@ -112,7 +137,7 @@ dependencies:
112
137
  - !ruby/object:Gem::Version
113
138
  version: '0'
114
139
  - !ruby/object:Gem::Dependency
115
- name: coveralls
140
+ name: webmock
116
141
  requirement: !ruby/object:Gem::Requirement
117
142
  requirements:
118
143
  - - ">="
@@ -125,92 +150,77 @@ dependencies:
125
150
  - - ">="
126
151
  - !ruby/object:Gem::Version
127
152
  version: '0'
128
- description: |2
129
- Ruby wrapper for Uploadcare service API.
130
- Full documentations on APIs can be found
131
- at https://uploadcare.com/documentation/rest/
132
- and https://uploadcare.com/documentation/upload/
153
+ description: Ruby wrapper for uploadcare API
133
154
  email:
134
- - hello@uploadcare.com
155
+ - stepan.redka@railsmuffin.com
135
156
  executables: []
136
157
  extensions: []
137
158
  extra_rdoc_files: []
138
159
  files:
160
+ - ".github/workflows/gem-push.yml"
161
+ - ".github/workflows/ruby.yml"
139
162
  - ".gitignore"
140
163
  - ".rspec"
141
- - ".travis.yml"
164
+ - ".rubocop.yml"
165
+ - ".yardopts"
142
166
  - CHANGELOG.md
167
+ - DEVELOPMENT.md
143
168
  - Gemfile
144
169
  - LICENSE
145
170
  - README.md
146
171
  - Rakefile
147
- - UPGRADE_NOTES.md
172
+ - bin/console
173
+ - bin/setup
148
174
  - lib/uploadcare.rb
149
- - lib/uploadcare/api.rb
150
- - lib/uploadcare/api/file_api.rb
151
- - lib/uploadcare/api/file_list_api.rb
152
- - lib/uploadcare/api/file_storage_api.rb
153
- - lib/uploadcare/api/group_api.rb
154
- - lib/uploadcare/api/group_list_api.rb
155
- - lib/uploadcare/api/project_api.rb
156
- - lib/uploadcare/api/raw_api.rb
157
- - lib/uploadcare/api/uploading_api.rb
158
- - lib/uploadcare/api/uploading_api/upload_params.rb
159
- - lib/uploadcare/api/validators/file_list_options_validator.rb
160
- - lib/uploadcare/api/validators/group_list_options_validator.rb
161
- - lib/uploadcare/errors/errors.rb
162
- - lib/uploadcare/resources/file.rb
163
- - lib/uploadcare/resources/file_list.rb
164
- - lib/uploadcare/resources/group.rb
165
- - lib/uploadcare/resources/group_list.rb
166
- - lib/uploadcare/resources/project.rb
167
- - lib/uploadcare/resources/resource_list.rb
168
- - lib/uploadcare/rest/auth/auth.rb
169
- - lib/uploadcare/rest/auth/secure.rb
170
- - lib/uploadcare/rest/auth/simple.rb
171
- - lib/uploadcare/rest/connections/api_connection.rb
172
- - lib/uploadcare/rest/connections/upload_connection.rb
173
- - lib/uploadcare/rest/middlewares/auth_middleware.rb
174
- - lib/uploadcare/rest/middlewares/parse_json_middleware.rb
175
- - lib/uploadcare/rest/middlewares/raise_error_middleware.rb
176
- - lib/uploadcare/utils/parser.rb
177
- - lib/uploadcare/utils/user_agent.rb
178
- - lib/uploadcare/version.rb
179
- - spec/api/file_list_api_spec.rb
180
- - spec/api/file_storage_api_spec.rb
181
- - spec/api/group_list_api_spec.rb
182
- - spec/api/raw_api_spec.rb
183
- - spec/api/uploading_api/upload_params_spec.rb
184
- - spec/api/uploading_api_spec.rb
185
- - spec/resources/file_list_spec.rb
186
- - spec/resources/file_spec.rb
187
- - spec/resources/group_list_spec.rb
188
- - spec/resources/group_spec.rb
189
- - spec/resources/operations_spec.rb
190
- - spec/resources/project_spec.rb
191
- - spec/rest/api_connection_spec.rb
192
- - spec/rest/auth/secure_spec.rb
193
- - spec/rest/auth/simple_spec.rb
194
- - spec/rest/errors_spec.rb
195
- - spec/rest/upload_connection_spec.rb
196
- - spec/shared/resource_list.rb
197
- - spec/spec_helper.rb
198
- - spec/uploadcare_spec.rb
199
- - spec/utils/parser_spec.rb
200
- - spec/utils/user_agent_spec.rb
201
- - spec/view.png
202
- - spec/view2.jpg
175
+ - lib/uploadcare/api/api.rb
176
+ - lib/uploadcare/client/file_client.rb
177
+ - lib/uploadcare/client/file_list_client.rb
178
+ - lib/uploadcare/client/group_client.rb
179
+ - lib/uploadcare/client/multipart_upload/chunks_client.rb
180
+ - lib/uploadcare/client/multipart_upload_client.rb
181
+ - lib/uploadcare/client/project_client.rb
182
+ - lib/uploadcare/client/rest_client.rb
183
+ - lib/uploadcare/client/rest_group_client.rb
184
+ - lib/uploadcare/client/upload_client.rb
185
+ - lib/uploadcare/client/uploader_client.rb
186
+ - lib/uploadcare/client/webhook_client.rb
187
+ - lib/uploadcare/concern/error_handler.rb
188
+ - lib/uploadcare/concern/throttle_handler.rb
189
+ - lib/uploadcare/concern/upload_error_handler.rb
190
+ - lib/uploadcare/entity/decorator/paginator.rb
191
+ - lib/uploadcare/entity/entity.rb
192
+ - lib/uploadcare/entity/file.rb
193
+ - lib/uploadcare/entity/file_list.rb
194
+ - lib/uploadcare/entity/group.rb
195
+ - lib/uploadcare/entity/group_list.rb
196
+ - lib/uploadcare/entity/project.rb
197
+ - lib/uploadcare/entity/uploader.rb
198
+ - lib/uploadcare/entity/webhook.rb
199
+ - lib/uploadcare/exception/request_error.rb
200
+ - lib/uploadcare/exception/throttle_error.rb
201
+ - lib/uploadcare/param/authentication_header.rb
202
+ - lib/uploadcare/param/param.rb
203
+ - lib/uploadcare/param/secure_auth_header.rb
204
+ - lib/uploadcare/param/simple_auth_header.rb
205
+ - lib/uploadcare/param/upload/signature_generator.rb
206
+ - lib/uploadcare/param/upload/upload_params_generator.rb
207
+ - lib/uploadcare/param/user_agent.rb
208
+ - lib/uploadcare/ruby/version.rb
203
209
  - uploadcare-ruby.gemspec
204
- homepage: https://uploadcare.com/documentation/libs/
210
+ homepage: https://github.com/uploadcare/uploadcare-ruby
205
211
  licenses:
206
212
  - MIT
207
213
  metadata:
208
- github: https://github.com/uploadcare/uploadcare-ruby
209
- issue_tracker: https://github.com/uploadcare/uploadcare-ruby/issues
214
+ allowed_push_host: https://rubygems.org
215
+ homepage_uri: https://github.com/uploadcare/uploadcare-ruby
216
+ source_code_uri: https://github.com/uploadcare/uploadcare-ruby
217
+ changelog_uri: https://github.com/uploadcare/uploadcare-ruby/CHANGELOG.md
210
218
  post_install_message:
211
219
  rdoc_options: []
212
220
  require_paths:
213
221
  - lib
222
+ - lib/uploadcare
223
+ - lib/uploadcare/rest
214
224
  required_ruby_version: !ruby/object:Gem::Requirement
215
225
  requirements:
216
226
  - - ">="
@@ -222,33 +232,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
232
  - !ruby/object:Gem::Version
223
233
  version: '0'
224
234
  requirements: []
225
- rubyforge_project:
226
- rubygems_version: 2.7.7
235
+ rubygems_version: 3.0.1
227
236
  signing_key:
228
237
  specification_version: 4
229
- summary: Ruby gem for Uploadcare
230
- test_files:
231
- - spec/api/file_list_api_spec.rb
232
- - spec/api/file_storage_api_spec.rb
233
- - spec/api/group_list_api_spec.rb
234
- - spec/api/raw_api_spec.rb
235
- - spec/api/uploading_api/upload_params_spec.rb
236
- - spec/api/uploading_api_spec.rb
237
- - spec/resources/file_list_spec.rb
238
- - spec/resources/file_spec.rb
239
- - spec/resources/group_list_spec.rb
240
- - spec/resources/group_spec.rb
241
- - spec/resources/operations_spec.rb
242
- - spec/resources/project_spec.rb
243
- - spec/rest/api_connection_spec.rb
244
- - spec/rest/auth/secure_spec.rb
245
- - spec/rest/auth/simple_spec.rb
246
- - spec/rest/errors_spec.rb
247
- - spec/rest/upload_connection_spec.rb
248
- - spec/shared/resource_list.rb
249
- - spec/spec_helper.rb
250
- - spec/uploadcare_spec.rb
251
- - spec/utils/parser_spec.rb
252
- - spec/utils/user_agent_spec.rb
253
- - spec/view.png
254
- - spec/view2.jpg
238
+ summary: Ruby wrapper for uploadcare API
239
+ test_files: []
data/.travis.yml DELETED
@@ -1,26 +0,0 @@
1
- # currently supported rubies: https://www.ruby-lang.org/en/downloads/branches/
2
-
3
- language: ruby
4
-
5
- rvm:
6
- - 1.9.3
7
- - 2.2
8
- - 2.3
9
- - 2.4
10
- - ruby-head
11
-
12
- jobs:
13
- include:
14
- - stage: style checks
15
- rvm: 2.4
16
- before_install:
17
- - gem install rubocop
18
- script:
19
- - rubocop
20
-
21
- allow_failures:
22
- - stage: style checks
23
- - rvm: ruby-head
24
-
25
- before_install:
26
- - gem update bundler
data/UPGRADE_NOTES.md DELETED
@@ -1,36 +0,0 @@
1
- # Upgrade notes
2
-
3
- ## v1.* -> v2.*
4
-
5
- In 2.* release we've moved to [REST API v0.5][uploadcare-changelog-rest-api-v05] which introduces a new pagination for `/files/` and `/groups/` endpoints, so `Uploadcare::Api::FileList` and `Uploadcare::Api::GroupList` were completely reimplemented.
6
-
7
- Previously, the file/group list API was:
8
-
9
- ```ruby
10
- # creating
11
- list = api.file_list # => #<Uploadcare::Api::FileList page=1 ...>
12
-
13
- # accessing files/groups
14
- list.results # => [#<Uploadcare::Api::File>, ...]
15
-
16
- # pagination
17
- list.next_page # => #<Uploadcare::Api::FileList page=2 ...>
18
- list.previous_page # => #<Uploadcare::Api::FileList page=1 ...>
19
- list.go_to 5 # => #<Uploadcare::Api::FileList page=5 ...>
20
-
21
- # metadata
22
- list.pages # => 15
23
- list.page # => 5
24
- list.total # => 308 (files in a project)
25
- ```
26
-
27
- It **won't work anymore**. For the details on the new file/group lists interface see [readme][readme]
28
-
29
- The core features of the new file/group list API are:
30
-
31
- - transparent pagination via enumerable interface
32
- - loading objects on demand
33
- - ordering, filtering and slicing
34
-
35
- [uploadcare-changelog-rest-api-v05]: https://uploadcare.com/changelog/tag/rest-api#rest-api-version-05
36
- [readme]: https://github.com/uploadcare/uploadcare-ruby#file-lists
@@ -1,26 +0,0 @@
1
- require 'json'
2
- require 'ostruct'
3
- Dir[File.dirname(__FILE__) + '/utils/*.rb'].each {|file| require file }
4
- Dir[File.dirname(__FILE__) + '/errors/*.rb'].each {|file| require file }
5
- Dir[File.dirname(__FILE__) + '/rest/middlewares/*.rb'].each {|file| require file }
6
- Dir[File.dirname(__FILE__) + '/rest/connections/*.rb'].each {|file| require file }
7
- Dir[File.dirname(__FILE__) + '/rest/auth/*.rb'].sort.each {|file| require file }
8
- Dir[File.dirname(__FILE__) + '/api/validators/*.rb'].each {|file| require file }
9
- Dir[File.dirname(__FILE__) + '/api/*.rb'].each {|file| require file }
10
- Dir[File.dirname(__FILE__) + '/resources/*.rb'].each {|file| require file }
11
-
12
-
13
- module Uploadcare
14
- class Api
15
- attr_reader :options
16
-
17
- include Uploadcare::RawApi
18
- include Uploadcare::UploadingApi
19
- include Uploadcare::FileApi
20
- include Uploadcare::ProjectApi
21
- include Uploadcare::FileListApi
22
- include Uploadcare::GroupApi
23
- include Uploadcare::GroupListApi
24
- include Uploadcare::FileStorageApi
25
- end
26
- end
@@ -1,7 +0,0 @@
1
- module Uploadcare
2
- module FileApi
3
- def file uuid_or_cdn_url
4
- file = Uploadcare::Api::File.new self, uuid_or_cdn_url
5
- end
6
- end
7
- end
@@ -1,19 +0,0 @@
1
- module Uploadcare
2
- module FileListApi
3
- # Available options:
4
- #
5
- # limit -- a number of objects retrieved per request. Default: 100
6
- # ordering -- sorting order of files in a list. Default: datetime_uploaded
7
- # from -- a starting point for filtering files.
8
- # stored -- true to include only stored files, false to exclude.
9
- # removed -- true to include only removed files, false to exclude. Default: false
10
- #
11
- # Documentation: http://uploadcare.com/documentation/rest/#file-files
12
- def file_list options={}
13
- Validators::FileListOptionsValidator.new(options).validate
14
-
15
- data = get '/files/', options
16
- Uploadcare::Api::FileList.new self, data, options
17
- end
18
- end
19
- end
@@ -1,34 +0,0 @@
1
- module Uploadcare
2
- module FileStorageApi
3
- MAX_BATCH_SIZE = 100
4
- UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/
5
-
6
- def store_files(objects)
7
- if objects.size > MAX_BATCH_SIZE
8
- raise ArgumentError, "Up to #{MAX_BATCH_SIZE} files are supported per request, #{objects.size} given"
9
- end
10
-
11
- put "/files/storage/", to_uuids(objects)
12
- end
13
-
14
- def delete_files(objects)
15
- if objects.size > MAX_BATCH_SIZE
16
- raise ArgumentError, "Up to #{MAX_BATCH_SIZE} files are supported per request, #{objects.size} given"
17
- end
18
-
19
- delete "/files/storage/", to_uuids(objects)
20
- end
21
-
22
- private
23
-
24
- def to_uuids(objects)
25
- objects.map do |object|
26
- case object
27
- when Uploadcare::Api::File then object.uuid
28
- when UUID_REGEX then object
29
- else raise(ArgumentError, "Unable to convert object to uuid: #{object}")
30
- end
31
- end
32
- end
33
- end
34
- end