imgwire 0.3.0 → 0.3.2
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.
- checksums.yaml +4 -4
- data/CODEGEN_VERSION +1 -1
- data/README.md +11 -0
- data/generated/lib/imgwire-generated/api/images_api.rb +66 -0
- data/generated/lib/imgwire-generated/models/upload_via_url_create_schema.rb +381 -0
- data/generated/lib/imgwire-generated.rb +1 -0
- data/lib/imgwire/resources/images_resource.rb +25 -0
- data/lib/imgwire/url_transformations.rb +23 -1
- data/lib/imgwire/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cd3ca88b1ea564edd82e1ab17f6c2f3f8f416e0abcda94bdb0487c32037798ba
|
|
4
|
+
data.tar.gz: d0445e8d5bfa097bd244738ab709c810dbea33e027aee1097a5657566a618f17
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 60028a30e19f7a121a71e807e3a2702605da1d018a535fdb924c621870213cb2330df805233f1f1a11cabbb44e5dea7fa09385390eb9c3573a33b6eacf314cd2
|
|
7
|
+
data.tar.gz: d383ab6be490ef82fe783ea25667724fef42c15d47f0fa904766f70916f86867cbcd675673da49ad37f477eb192a6e599d94af2918f7934e4b8df1e9a4ea630b
|
data/CODEGEN_VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
57998c6d1fd50ddee463591b6b88ee751b6cc37b79ab4ce6e38af84d28cfddc3
|
data/README.md
CHANGED
|
@@ -89,6 +89,17 @@ image = client.images.upload(
|
|
|
89
89
|
)
|
|
90
90
|
```
|
|
91
91
|
|
|
92
|
+
To upload from a publicly reachable source URL without streaming bytes through
|
|
93
|
+
your Ruby process:
|
|
94
|
+
|
|
95
|
+
```ruby
|
|
96
|
+
image = client.images.upload_via_url(
|
|
97
|
+
url: "https://example.com/file.jpg",
|
|
98
|
+
file_name: "file.jpg",
|
|
99
|
+
mime_type: "image/jpeg"
|
|
100
|
+
)
|
|
101
|
+
```
|
|
102
|
+
|
|
92
103
|
### Pagination
|
|
93
104
|
|
|
94
105
|
```ruby
|
|
@@ -530,5 +530,71 @@ module ImgwireGenerated
|
|
|
530
530
|
end
|
|
531
531
|
return data, status_code, headers
|
|
532
532
|
end
|
|
533
|
+
|
|
534
|
+
# Upload Image Via URL
|
|
535
|
+
# @param upload_via_url_create_schema [UploadViaUrlCreateSchema]
|
|
536
|
+
# @param [Hash] opts the optional parameters
|
|
537
|
+
# @return [ImageSchema]
|
|
538
|
+
def images_upload_via_url(upload_via_url_create_schema, opts = {})
|
|
539
|
+
data, _status_code, _headers = images_upload_via_url_with_http_info(upload_via_url_create_schema, opts)
|
|
540
|
+
data
|
|
541
|
+
end
|
|
542
|
+
|
|
543
|
+
# Upload Image Via URL
|
|
544
|
+
# @param upload_via_url_create_schema [UploadViaUrlCreateSchema]
|
|
545
|
+
# @param [Hash] opts the optional parameters
|
|
546
|
+
# @return [Array<(ImageSchema, Integer, Hash)>] ImageSchema data, response status code and response headers
|
|
547
|
+
def images_upload_via_url_with_http_info(upload_via_url_create_schema, opts = {})
|
|
548
|
+
if @api_client.config.debugging
|
|
549
|
+
@api_client.config.logger.debug 'Calling API: ImagesApi.images_upload_via_url ...'
|
|
550
|
+
end
|
|
551
|
+
# verify the required parameter 'upload_via_url_create_schema' is set
|
|
552
|
+
if @api_client.config.client_side_validation && upload_via_url_create_schema.nil?
|
|
553
|
+
fail ArgumentError, "Missing the required parameter 'upload_via_url_create_schema' when calling ImagesApi.images_upload_via_url"
|
|
554
|
+
end
|
|
555
|
+
# resource path
|
|
556
|
+
local_var_path = '/api/v1/images/upload_via_url'
|
|
557
|
+
|
|
558
|
+
# query parameters
|
|
559
|
+
query_params = opts[:query_params] || {}
|
|
560
|
+
|
|
561
|
+
# header parameters
|
|
562
|
+
header_params = opts[:header_params] || {}
|
|
563
|
+
# HTTP header 'Accept' (if needed)
|
|
564
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
|
|
565
|
+
# HTTP header 'Content-Type'
|
|
566
|
+
content_type = @api_client.select_header_content_type(['application/json'])
|
|
567
|
+
if !content_type.nil?
|
|
568
|
+
header_params['Content-Type'] = content_type
|
|
569
|
+
end
|
|
570
|
+
|
|
571
|
+
# form parameters
|
|
572
|
+
form_params = opts[:form_params] || {}
|
|
573
|
+
|
|
574
|
+
# http body (model)
|
|
575
|
+
post_body = opts[:debug_body] || @api_client.object_to_http_body(upload_via_url_create_schema)
|
|
576
|
+
|
|
577
|
+
# return_type
|
|
578
|
+
return_type = opts[:debug_return_type] || 'ImageSchema'
|
|
579
|
+
|
|
580
|
+
# auth_names
|
|
581
|
+
auth_names = opts[:debug_auth_names] || []
|
|
582
|
+
|
|
583
|
+
new_options = opts.merge(
|
|
584
|
+
:operation => :"ImagesApi.images_upload_via_url",
|
|
585
|
+
:header_params => header_params,
|
|
586
|
+
:query_params => query_params,
|
|
587
|
+
:form_params => form_params,
|
|
588
|
+
:body => post_body,
|
|
589
|
+
:auth_names => auth_names,
|
|
590
|
+
:return_type => return_type
|
|
591
|
+
)
|
|
592
|
+
|
|
593
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
|
594
|
+
if @api_client.config.debugging
|
|
595
|
+
@api_client.config.logger.debug "API called: ImagesApi#images_upload_via_url\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
|
596
|
+
end
|
|
597
|
+
return data, status_code, headers
|
|
598
|
+
end
|
|
533
599
|
end
|
|
534
600
|
end
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#imgwire.dev Backend API development
|
|
3
|
+
|
|
4
|
+
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 0.1.0
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.14.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module ImgwireGenerated
|
|
17
|
+
class UploadViaUrlCreateSchema
|
|
18
|
+
attr_accessor :custom_metadata
|
|
19
|
+
|
|
20
|
+
attr_accessor :file_name
|
|
21
|
+
|
|
22
|
+
attr_accessor :idempotency_key
|
|
23
|
+
|
|
24
|
+
attr_accessor :mime_type
|
|
25
|
+
|
|
26
|
+
attr_accessor :purpose
|
|
27
|
+
|
|
28
|
+
attr_accessor :url
|
|
29
|
+
|
|
30
|
+
class EnumAttributeValidator
|
|
31
|
+
attr_reader :datatype
|
|
32
|
+
attr_reader :allowable_values
|
|
33
|
+
|
|
34
|
+
def initialize(datatype, allowable_values)
|
|
35
|
+
@allowable_values = allowable_values.map do |value|
|
|
36
|
+
case datatype.to_s
|
|
37
|
+
when /Integer/i
|
|
38
|
+
value.to_i
|
|
39
|
+
when /Float/i
|
|
40
|
+
value.to_f
|
|
41
|
+
else
|
|
42
|
+
value
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def valid?(value)
|
|
48
|
+
!value || allowable_values.include?(value)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
53
|
+
def self.attribute_map
|
|
54
|
+
{
|
|
55
|
+
:'custom_metadata' => :'custom_metadata',
|
|
56
|
+
:'file_name' => :'file_name',
|
|
57
|
+
:'idempotency_key' => :'idempotency_key',
|
|
58
|
+
:'mime_type' => :'mime_type',
|
|
59
|
+
:'purpose' => :'purpose',
|
|
60
|
+
:'url' => :'url'
|
|
61
|
+
}
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Returns attribute mapping this model knows about
|
|
65
|
+
def self.acceptable_attribute_map
|
|
66
|
+
attribute_map
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# Returns all the JSON keys this model knows about
|
|
70
|
+
def self.acceptable_attributes
|
|
71
|
+
acceptable_attribute_map.values
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
# Attribute type mapping.
|
|
75
|
+
def self.openapi_types
|
|
76
|
+
{
|
|
77
|
+
:'custom_metadata' => :'Hash<String, CustomMetadataValue>',
|
|
78
|
+
:'file_name' => :'String',
|
|
79
|
+
:'idempotency_key' => :'String',
|
|
80
|
+
:'mime_type' => :'SupportedMimeType',
|
|
81
|
+
:'purpose' => :'String',
|
|
82
|
+
:'url' => :'String'
|
|
83
|
+
}
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# List of attributes with nullable: true
|
|
87
|
+
def self.openapi_nullable
|
|
88
|
+
Set.new([
|
|
89
|
+
:'file_name',
|
|
90
|
+
:'idempotency_key',
|
|
91
|
+
:'purpose',
|
|
92
|
+
])
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Initializes the object
|
|
96
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
97
|
+
def initialize(attributes = {})
|
|
98
|
+
if (!attributes.is_a?(Hash))
|
|
99
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `ImgwireGenerated::UploadViaUrlCreateSchema` initialize method"
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
103
|
+
acceptable_attribute_map = self.class.acceptable_attribute_map
|
|
104
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
105
|
+
if (!acceptable_attribute_map.key?(k.to_sym))
|
|
106
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `ImgwireGenerated::UploadViaUrlCreateSchema`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
|
|
107
|
+
end
|
|
108
|
+
h[k.to_sym] = v
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if attributes.key?(:'custom_metadata')
|
|
112
|
+
if (value = attributes[:'custom_metadata']).is_a?(Hash)
|
|
113
|
+
self.custom_metadata = value
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
if attributes.key?(:'file_name')
|
|
118
|
+
self.file_name = attributes[:'file_name']
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
if attributes.key?(:'idempotency_key')
|
|
122
|
+
self.idempotency_key = attributes[:'idempotency_key']
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
if attributes.key?(:'mime_type')
|
|
126
|
+
self.mime_type = attributes[:'mime_type']
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
if attributes.key?(:'purpose')
|
|
130
|
+
self.purpose = attributes[:'purpose']
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
if attributes.key?(:'url')
|
|
134
|
+
self.url = attributes[:'url']
|
|
135
|
+
else
|
|
136
|
+
self.url = nil
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
141
|
+
# @return Array for valid properties with the reasons
|
|
142
|
+
def list_invalid_properties
|
|
143
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
144
|
+
invalid_properties = Array.new
|
|
145
|
+
if !@file_name.nil? && @file_name.to_s.length < 1
|
|
146
|
+
invalid_properties.push('invalid value for "file_name", the character length must be greater than or equal to 1.')
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
if !@idempotency_key.nil? && @idempotency_key.to_s.length > 255
|
|
150
|
+
invalid_properties.push('invalid value for "idempotency_key", the character length must be smaller than or equal to 255.')
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
if !@idempotency_key.nil? && @idempotency_key.to_s.length < 1
|
|
154
|
+
invalid_properties.push('invalid value for "idempotency_key", the character length must be greater than or equal to 1.')
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
if !@purpose.nil? && @purpose.to_s.length > 255
|
|
158
|
+
invalid_properties.push('invalid value for "purpose", the character length must be smaller than or equal to 255.')
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
if !@purpose.nil? && @purpose.to_s.length < 1
|
|
162
|
+
invalid_properties.push('invalid value for "purpose", the character length must be greater than or equal to 1.')
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
if @url.nil?
|
|
166
|
+
invalid_properties.push('invalid value for "url", url cannot be nil.')
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
if @url.to_s.length < 1
|
|
170
|
+
invalid_properties.push('invalid value for "url", the character length must be greater than or equal to 1.')
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
invalid_properties
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
# Check to see if the all the properties in the model are valid
|
|
177
|
+
# @return true if the model is valid
|
|
178
|
+
def valid?
|
|
179
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
180
|
+
return false if !@file_name.nil? && @file_name.to_s.length < 1
|
|
181
|
+
return false if !@idempotency_key.nil? && @idempotency_key.to_s.length > 255
|
|
182
|
+
return false if !@idempotency_key.nil? && @idempotency_key.to_s.length < 1
|
|
183
|
+
return false if !@purpose.nil? && @purpose.to_s.length > 255
|
|
184
|
+
return false if !@purpose.nil? && @purpose.to_s.length < 1
|
|
185
|
+
return false if @url.nil?
|
|
186
|
+
return false if @url.to_s.length < 1
|
|
187
|
+
true
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# Custom attribute writer method with validation
|
|
191
|
+
# @param [Object] file_name Value to be assigned
|
|
192
|
+
def file_name=(file_name)
|
|
193
|
+
if !file_name.nil? && file_name.to_s.length < 1
|
|
194
|
+
fail ArgumentError, 'invalid value for "file_name", the character length must be greater than or equal to 1.'
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
@file_name = file_name
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
# Custom attribute writer method with validation
|
|
201
|
+
# @param [Object] idempotency_key Value to be assigned
|
|
202
|
+
def idempotency_key=(idempotency_key)
|
|
203
|
+
if !idempotency_key.nil? && idempotency_key.to_s.length > 255
|
|
204
|
+
fail ArgumentError, 'invalid value for "idempotency_key", the character length must be smaller than or equal to 255.'
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
if !idempotency_key.nil? && idempotency_key.to_s.length < 1
|
|
208
|
+
fail ArgumentError, 'invalid value for "idempotency_key", the character length must be greater than or equal to 1.'
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
@idempotency_key = idempotency_key
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
# Custom attribute writer method with validation
|
|
215
|
+
# @param [Object] purpose Value to be assigned
|
|
216
|
+
def purpose=(purpose)
|
|
217
|
+
if !purpose.nil? && purpose.to_s.length > 255
|
|
218
|
+
fail ArgumentError, 'invalid value for "purpose", the character length must be smaller than or equal to 255.'
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
if !purpose.nil? && purpose.to_s.length < 1
|
|
222
|
+
fail ArgumentError, 'invalid value for "purpose", the character length must be greater than or equal to 1.'
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
@purpose = purpose
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
# Custom attribute writer method with validation
|
|
229
|
+
# @param [Object] url Value to be assigned
|
|
230
|
+
def url=(url)
|
|
231
|
+
if url.nil?
|
|
232
|
+
fail ArgumentError, 'url cannot be nil'
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
if url.to_s.length < 1
|
|
236
|
+
fail ArgumentError, 'invalid value for "url", the character length must be greater than or equal to 1.'
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
@url = url
|
|
240
|
+
end
|
|
241
|
+
|
|
242
|
+
# Checks equality by comparing each attribute.
|
|
243
|
+
# @param [Object] Object to be compared
|
|
244
|
+
def ==(o)
|
|
245
|
+
return true if self.equal?(o)
|
|
246
|
+
self.class == o.class &&
|
|
247
|
+
custom_metadata == o.custom_metadata &&
|
|
248
|
+
file_name == o.file_name &&
|
|
249
|
+
idempotency_key == o.idempotency_key &&
|
|
250
|
+
mime_type == o.mime_type &&
|
|
251
|
+
purpose == o.purpose &&
|
|
252
|
+
url == o.url
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
# @see the `==` method
|
|
256
|
+
# @param [Object] Object to be compared
|
|
257
|
+
def eql?(o)
|
|
258
|
+
self == o
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
# Calculates hash code according to all attributes.
|
|
262
|
+
# @return [Integer] Hash code
|
|
263
|
+
def hash
|
|
264
|
+
[custom_metadata, file_name, idempotency_key, mime_type, purpose, url].hash
|
|
265
|
+
end
|
|
266
|
+
|
|
267
|
+
# Builds the object from hash
|
|
268
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
269
|
+
# @return [Object] Returns the model itself
|
|
270
|
+
def self.build_from_hash(attributes)
|
|
271
|
+
return nil unless attributes.is_a?(Hash)
|
|
272
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
273
|
+
transformed_hash = {}
|
|
274
|
+
openapi_types.each_pair do |key, type|
|
|
275
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
276
|
+
transformed_hash["#{key}"] = nil
|
|
277
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
278
|
+
# check to ensure the input is an array given that the attribute
|
|
279
|
+
# is documented as an array but the input is not
|
|
280
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
281
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
282
|
+
end
|
|
283
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
284
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
285
|
+
end
|
|
286
|
+
end
|
|
287
|
+
new(transformed_hash)
|
|
288
|
+
end
|
|
289
|
+
|
|
290
|
+
# Deserializes the data based on type
|
|
291
|
+
# @param string type Data type
|
|
292
|
+
# @param string value Value to be deserialized
|
|
293
|
+
# @return [Object] Deserialized data
|
|
294
|
+
def self._deserialize(type, value)
|
|
295
|
+
case type.to_sym
|
|
296
|
+
when :Time
|
|
297
|
+
Time.parse(value)
|
|
298
|
+
when :Date
|
|
299
|
+
Date.parse(value)
|
|
300
|
+
when :String
|
|
301
|
+
value.to_s
|
|
302
|
+
when :Integer
|
|
303
|
+
value.to_i
|
|
304
|
+
when :Float
|
|
305
|
+
value.to_f
|
|
306
|
+
when :Boolean
|
|
307
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
308
|
+
true
|
|
309
|
+
else
|
|
310
|
+
false
|
|
311
|
+
end
|
|
312
|
+
when :Object
|
|
313
|
+
# generic object (usually a Hash), return directly
|
|
314
|
+
value
|
|
315
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
316
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
317
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
318
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
319
|
+
k_type = Regexp.last_match[:k_type]
|
|
320
|
+
v_type = Regexp.last_match[:v_type]
|
|
321
|
+
{}.tap do |hash|
|
|
322
|
+
value.each do |k, v|
|
|
323
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
324
|
+
end
|
|
325
|
+
end
|
|
326
|
+
else # model
|
|
327
|
+
# models (e.g. Pet) or oneOf
|
|
328
|
+
klass = ImgwireGenerated.const_get(type)
|
|
329
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
330
|
+
end
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
# Returns the string representation of the object
|
|
334
|
+
# @return [String] String presentation of the object
|
|
335
|
+
def to_s
|
|
336
|
+
to_hash.to_s
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
340
|
+
# @return [Hash] Returns the object in the form of hash
|
|
341
|
+
def to_body
|
|
342
|
+
to_hash
|
|
343
|
+
end
|
|
344
|
+
|
|
345
|
+
# Returns the object in the form of hash
|
|
346
|
+
# @return [Hash] Returns the object in the form of hash
|
|
347
|
+
def to_hash
|
|
348
|
+
hash = {}
|
|
349
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
350
|
+
value = self.send(attr)
|
|
351
|
+
if value.nil?
|
|
352
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
353
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
hash[param] = _to_hash(value)
|
|
357
|
+
end
|
|
358
|
+
hash
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
# Outputs non-array value in the form of hash
|
|
362
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
363
|
+
# @param [Object] value Any valid value
|
|
364
|
+
# @return [Hash] Returns the value in the form of hash
|
|
365
|
+
def _to_hash(value)
|
|
366
|
+
if value.is_a?(Array)
|
|
367
|
+
value.compact.map { |v| _to_hash(v) }
|
|
368
|
+
elsif value.is_a?(Hash)
|
|
369
|
+
{}.tap do |hash|
|
|
370
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
371
|
+
end
|
|
372
|
+
elsif value.respond_to? :to_hash
|
|
373
|
+
value.to_hash
|
|
374
|
+
else
|
|
375
|
+
value
|
|
376
|
+
end
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
end
|
|
@@ -46,6 +46,7 @@ require 'imgwire-generated/models/supported_mime_type'
|
|
|
46
46
|
require 'imgwire-generated/models/transfer_bytes_dataset_point_schema'
|
|
47
47
|
require 'imgwire-generated/models/transformations_dataset_point_schema'
|
|
48
48
|
require 'imgwire-generated/models/upload_token_create_response_schema'
|
|
49
|
+
require 'imgwire-generated/models/upload_via_url_create_schema'
|
|
49
50
|
require 'imgwire-generated/models/uploads_dataset_point_schema'
|
|
50
51
|
require 'imgwire-generated/models/validation_error'
|
|
51
52
|
|
|
@@ -62,6 +62,31 @@ module Imgwire
|
|
|
62
62
|
@api.images_retrieve_bulk_download_job(image_download_job_id)
|
|
63
63
|
end
|
|
64
64
|
|
|
65
|
+
def upload_via_url(
|
|
66
|
+
url:,
|
|
67
|
+
file_name: nil,
|
|
68
|
+
mime_type: nil,
|
|
69
|
+
custom_metadata: nil,
|
|
70
|
+
idempotency_key: nil,
|
|
71
|
+
purpose: nil
|
|
72
|
+
)
|
|
73
|
+
Image.wrap(
|
|
74
|
+
@api.images_upload_via_url(
|
|
75
|
+
coerce_model(
|
|
76
|
+
ImgwireGenerated::UploadViaUrlCreateSchema,
|
|
77
|
+
{
|
|
78
|
+
custom_metadata: custom_metadata,
|
|
79
|
+
file_name: file_name,
|
|
80
|
+
idempotency_key: idempotency_key,
|
|
81
|
+
mime_type: mime_type,
|
|
82
|
+
purpose: purpose,
|
|
83
|
+
url: url
|
|
84
|
+
}
|
|
85
|
+
)
|
|
86
|
+
)
|
|
87
|
+
)
|
|
88
|
+
end
|
|
89
|
+
|
|
65
90
|
def upload(
|
|
66
91
|
file:,
|
|
67
92
|
file_name: nil,
|
|
@@ -13,6 +13,7 @@ module Imgwire
|
|
|
13
13
|
'background_alpha' => %w[bga background_alpha],
|
|
14
14
|
'blur' => %w[bl blur],
|
|
15
15
|
'brightness' => %w[br brightness],
|
|
16
|
+
'chroma_subsampling' => %w[chroma_subsampling],
|
|
16
17
|
'color_profile' => %w[cp icc color_profile],
|
|
17
18
|
'colorize' => %w[col colorize],
|
|
18
19
|
'contrast' => %w[co contrast],
|
|
@@ -38,6 +39,7 @@ module Imgwire
|
|
|
38
39
|
'normalize' => %w[norm normalise normalize],
|
|
39
40
|
'padding' => %w[pd padding],
|
|
40
41
|
'pixelate' => %w[pix pixelate],
|
|
42
|
+
'progressive' => %w[progressive],
|
|
41
43
|
'quality' => %w[q quality],
|
|
42
44
|
'resizing_algorithm' => %w[ra resizing_algorithm],
|
|
43
45
|
'resizing_type' => %w[resizing_type],
|
|
@@ -58,6 +60,7 @@ module Imgwire
|
|
|
58
60
|
}.freeze
|
|
59
61
|
|
|
60
62
|
COLOR_PROFILES = %w[srgb rgb16 cmyk keep preserve].freeze
|
|
63
|
+
CHROMA_SUBSAMPLING_VALUES = %w[4:2:0 4:4:4 auto].freeze
|
|
61
64
|
FORMATS = %w[auto jpg jpeg png webp avif gif tiff].freeze
|
|
62
65
|
FLIP_VALUES = %w[vertical horizontal both].freeze
|
|
63
66
|
RESIZING_ALGORITHMS = %w[nearest cubic mitchell lanczos2 lanczos3].freeze
|
|
@@ -122,6 +125,8 @@ module Imgwire
|
|
|
122
125
|
normalize_true_or_number(value, min: 0.3, max: 100)
|
|
123
126
|
when 'brightness', 'lightness', 'saturation'
|
|
124
127
|
normalize_number(value, min: 0.01, max: 10)
|
|
128
|
+
when 'chroma_subsampling'
|
|
129
|
+
normalize_enum(value, CHROMA_SUBSAMPLING_VALUES)
|
|
125
130
|
when 'color_profile'
|
|
126
131
|
normalize_enum(value, COLOR_PROFILES)
|
|
127
132
|
when 'contrast'
|
|
@@ -162,8 +167,10 @@ module Imgwire
|
|
|
162
167
|
normalize_padding(value)
|
|
163
168
|
when 'pixelate'
|
|
164
169
|
normalize_integer(value, min: 2, max: 256)
|
|
170
|
+
when 'progressive'
|
|
171
|
+
normalize_boolean_or_auto(value)
|
|
165
172
|
when 'quality'
|
|
166
|
-
|
|
173
|
+
normalize_quality(value)
|
|
167
174
|
when 'resizing_algorithm'
|
|
168
175
|
normalize_enum(value, RESIZING_ALGORITHMS)
|
|
169
176
|
when 'resizing_type'
|
|
@@ -501,6 +508,12 @@ module Imgwire
|
|
|
501
508
|
contiguous_segments([top, right, bottom, left], []) || compact_json
|
|
502
509
|
end
|
|
503
510
|
|
|
511
|
+
def normalize_quality(value)
|
|
512
|
+
return 'auto' if normalize_string(value) == 'auto'
|
|
513
|
+
|
|
514
|
+
normalize_integer(value, min: 1, max: 100)
|
|
515
|
+
end
|
|
516
|
+
|
|
504
517
|
def normalize_rotate(value)
|
|
505
518
|
return normalize_json_string(value) if json_object_string?(value)
|
|
506
519
|
|
|
@@ -721,6 +734,15 @@ module Imgwire
|
|
|
721
734
|
parse_boolean(value) == true ? 'true' : nil
|
|
722
735
|
end
|
|
723
736
|
|
|
737
|
+
def normalize_boolean_or_auto(value)
|
|
738
|
+
return 'auto' if normalize_string(value) == 'auto'
|
|
739
|
+
|
|
740
|
+
boolean = parse_boolean(value)
|
|
741
|
+
return 'true' if boolean == true
|
|
742
|
+
|
|
743
|
+
'false' if boolean == false
|
|
744
|
+
end
|
|
745
|
+
|
|
724
746
|
def parse_boolean(value)
|
|
725
747
|
return true if value == true
|
|
726
748
|
return false if value == false
|
data/lib/imgwire/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: imgwire
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Blackhawk Software, LLC
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-05-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: typhoeus
|
|
@@ -129,6 +129,7 @@ files:
|
|
|
129
129
|
- generated/lib/imgwire-generated/models/transfer_bytes_dataset_point_schema.rb
|
|
130
130
|
- generated/lib/imgwire-generated/models/transformations_dataset_point_schema.rb
|
|
131
131
|
- generated/lib/imgwire-generated/models/upload_token_create_response_schema.rb
|
|
132
|
+
- generated/lib/imgwire-generated/models/upload_via_url_create_schema.rb
|
|
132
133
|
- generated/lib/imgwire-generated/models/uploads_dataset_point_schema.rb
|
|
133
134
|
- generated/lib/imgwire-generated/models/validation_error.rb
|
|
134
135
|
- generated/lib/imgwire-generated/version.rb
|