Class: TemplateFox::CreateImageRequest

Inherits:
ApiModelBase show all
Defined in:
lib/templatefox/models/create_image_request.rb

Overview

Request model for image generation

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ CreateImageRequest

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/templatefox/models/create_image_request.rb', line 136

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `TemplateFox::CreateImageRequest` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  acceptable_attribute_map = self.class.acceptable_attribute_map
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!acceptable_attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `TemplateFox::CreateImageRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'template_id')
    self.template_id = attributes[:'template_id']
  else
    self.template_id = nil
  end

  if attributes.key?(:'modifications')
    if (value = attributes[:'modifications']).is_a?(Array)
      self.modifications = value
    end
  end

  if attributes.key?(:'data')
    if (value = attributes[:'data']).is_a?(Hash)
      self.data = value
    end
  end

  if attributes.key?(:'format')
    self.format = attributes[:'format']
  end

  if attributes.key?(:'width')
    self.width = attributes[:'width']
  end

  if attributes.key?(:'quality')
    self.quality = attributes[:'quality']
  else
    self.quality = 85
  end

  if attributes.key?(:'export_type')
    self.export_type = attributes[:'export_type']
  end

  if attributes.key?(:'expiration')
    self.expiration = attributes[:'expiration']
  else
    self.expiration = 86400
  end

  if attributes.key?(:'filename')
    self.filename = attributes[:'filename']
  end

  if attributes.key?(:'store_s3')
    self.store_s3 = attributes[:'store_s3']
  else
    self.store_s3 = false
  end

  if attributes.key?(:'s3_filepath')
    self.s3_filepath = attributes[:'s3_filepath']
  end

  if attributes.key?(:'s3_bucket')
    self.s3_bucket = attributes[:'s3_bucket']
  end

  if attributes.key?(:'version')
    self.version = attributes[:'version']
  end
end

Instance Attribute Details

#dataObject

Optional key-value data merged into {{ }} template variables. For most image templates, prefer modifications instead.



25
26
27
# File 'lib/templatefox/models/create_image_request.rb', line 25

def data
  @data
end

#expirationObject

URL expiration in seconds. Min: 60 (1 min), Max: 604800 (7 days). Only applies to url export type.



39
40
41
# File 'lib/templatefox/models/create_image_request.rb', line 39

def expiration
  @expiration
end

#export_typeObject

Export format: url uploads to CDN and returns URL, binary returns raw image bytes



36
37
38
# File 'lib/templatefox/models/create_image_request.rb', line 36

def export_type
  @export_type
end

#filenameObject

Returns the value of attribute filename.



41
42
43
# File 'lib/templatefox/models/create_image_request.rb', line 41

def filename
  @filename
end

#formatObject

Output image format: png (default), jpeg or webp.



28
29
30
# File 'lib/templatefox/models/create_image_request.rb', line 28

def format
  @format
end

#modificationsObject

Returns the value of attribute modifications.



22
23
24
# File 'lib/templatefox/models/create_image_request.rb', line 22

def modifications
  @modifications
end

#qualityObject

Compression quality for jpeg/webp (1-100). Ignored for png.



33
34
35
# File 'lib/templatefox/models/create_image_request.rb', line 33

def quality
  @quality
end

#s3_bucketObject

Returns the value of attribute s3_bucket.



48
49
50
# File 'lib/templatefox/models/create_image_request.rb', line 48

def s3_bucket
  @s3_bucket
end

#s3_filepathObject

Returns the value of attribute s3_filepath.



46
47
48
# File 'lib/templatefox/models/create_image_request.rb', line 46

def s3_filepath
  @s3_filepath
end

#store_s3Object

Upload to your configured S3 bucket instead of CDN



44
45
46
# File 'lib/templatefox/models/create_image_request.rb', line 44

def store_s3
  @store_s3
end

#template_idObject

Template short ID (12 characters)



20
21
22
# File 'lib/templatefox/models/create_image_request.rb', line 20

def template_id
  @template_id
end

#versionObject

Returns the value of attribute version.



50
51
52
# File 'lib/templatefox/models/create_image_request.rb', line 50

def version
  @version
end

#widthObject

Returns the value of attribute width.



30
31
32
# File 'lib/templatefox/models/create_image_request.rb', line 30

def width
  @width
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



94
95
96
# File 'lib/templatefox/models/create_image_request.rb', line 94

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



99
100
101
# File 'lib/templatefox/models/create_image_request.rb', line 99

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/templatefox/models/create_image_request.rb', line 75

def self.attribute_map
  {
    :'template_id' => :'template_id',
    :'modifications' => :'modifications',
    :'data' => :'data',
    :'format' => :'format',
    :'width' => :'width',
    :'quality' => :'quality',
    :'export_type' => :'export_type',
    :'expiration' => :'expiration',
    :'filename' => :'filename',
    :'store_s3' => :'store_s3',
    :'s3_filepath' => :'s3_filepath',
    :'s3_bucket' => :'s3_bucket',
    :'version' => :'version'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
# File 'lib/templatefox/models/create_image_request.rb', line 495

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_nullableObject

List of attributes with nullable: true



123
124
125
126
127
128
129
130
131
132
# File 'lib/templatefox/models/create_image_request.rb', line 123

def self.openapi_nullable
  Set.new([
    :'modifications',
    :'width',
    :'filename',
    :'s3_filepath',
    :'s3_bucket',
    :'version'
  ])
end

.openapi_typesObject

Attribute type mapping.



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/templatefox/models/create_image_request.rb', line 104

def self.openapi_types
  {
    :'template_id' => :'String',
    :'modifications' => :'Array<Modification>',
    :'data' => :'Hash<String, Object>',
    :'format' => :'ImageFormat',
    :'width' => :'Integer',
    :'quality' => :'Integer',
    :'export_type' => :'AppRoutersV1DeliveryExportType',
    :'expiration' => :'Integer',
    :'filename' => :'String',
    :'store_s3' => :'Boolean',
    :'s3_filepath' => :'String',
    :'s3_bucket' => :'String',
    :'version' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
# File 'lib/templatefox/models/create_image_request.rb', line 462

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      template_id == o.template_id &&
      modifications == o.modifications &&
      data == o.data &&
      format == o.format &&
      width == o.width &&
      quality == o.quality &&
      export_type == o.export_type &&
      expiration == o.expiration &&
      filename == o.filename &&
      store_s3 == o.store_s3 &&
      s3_filepath == o.s3_filepath &&
      s3_bucket == o.s3_bucket &&
      version == o.version
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


482
483
484
# File 'lib/templatefox/models/create_image_request.rb', line 482

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



488
489
490
# File 'lib/templatefox/models/create_image_request.rb', line 488

def hash
  [template_id, modifications, data, format, width, quality, export_type, expiration, filename, store_s3, s3_filepath, s3_bucket, version].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# File 'lib/templatefox/models/create_image_request.rb', line 217

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @template_id.nil?
    invalid_properties.push('invalid value for "template_id", template_id cannot be nil.')
  end

  if @template_id.to_s.length > 12
    invalid_properties.push('invalid value for "template_id", the character length must be smaller than or equal to 12.')
  end

  if @template_id.to_s.length < 12
    invalid_properties.push('invalid value for "template_id", the character length must be greater than or equal to 12.')
  end

  if !@modifications.nil? && @modifications.length > 100
    invalid_properties.push('invalid value for "modifications", number of items must be less than or equal to 100.')
  end

  if !@width.nil? && @width > 4000
    invalid_properties.push('invalid value for "width", must be smaller than or equal to 4000.')
  end

  if !@width.nil? && @width < 100
    invalid_properties.push('invalid value for "width", must be greater than or equal to 100.')
  end

  if !@quality.nil? && @quality > 100
    invalid_properties.push('invalid value for "quality", must be smaller than or equal to 100.')
  end

  if !@quality.nil? && @quality < 1
    invalid_properties.push('invalid value for "quality", must be greater than or equal to 1.')
  end

  if !@expiration.nil? && @expiration > 604800
    invalid_properties.push('invalid value for "expiration", must be smaller than or equal to 604800.')
  end

  if !@expiration.nil? && @expiration < 60
    invalid_properties.push('invalid value for "expiration", must be greater than or equal to 60.')
  end

  if !@filename.nil? && @filename.to_s.length > 100
    invalid_properties.push('invalid value for "filename", the character length must be smaller than or equal to 100.')
  end

  pattern = Regexp.new(/^[a-zA-Z0-9_\-\.]+$/)
  if !@filename.nil? && @filename !~ pattern
    invalid_properties.push("invalid value for \"filename\", must conform to the pattern #{pattern}.")
  end

  if !@s3_filepath.nil? && @s3_filepath.to_s.length > 500
    invalid_properties.push('invalid value for "s3_filepath", the character length must be smaller than or equal to 500.')
  end

  pattern = Regexp.new(/^[a-zA-Z0-9_\-\.\/]+$/)
  if !@s3_filepath.nil? && @s3_filepath !~ pattern
    invalid_properties.push("invalid value for \"s3_filepath\", must conform to the pattern #{pattern}.")
  end

  if !@s3_bucket.nil? && @s3_bucket.to_s.length > 63
    invalid_properties.push('invalid value for "s3_bucket", the character length must be smaller than or equal to 63.')
  end

  if !@s3_bucket.nil? && @s3_bucket.to_s.length < 3
    invalid_properties.push('invalid value for "s3_bucket", the character length must be greater than or equal to 3.')
  end

  pattern = Regexp.new(/^[a-z0-9][a-z0-9.\-]*[a-z0-9]$/)
  if !@s3_bucket.nil? && @s3_bucket !~ pattern
    invalid_properties.push("invalid value for \"s3_bucket\", must conform to the pattern #{pattern}.")
  end

  if !@version.nil? && @version.to_s.length > 50
    invalid_properties.push('invalid value for "version", the character length must be smaller than or equal to 50.')
  end

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



517
518
519
520
521
522
523
524
525
526
527
528
529
# File 'lib/templatefox/models/create_image_request.rb', line 517

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
# File 'lib/templatefox/models/create_image_request.rb', line 300

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @template_id.nil?
  return false if @template_id.to_s.length > 12
  return false if @template_id.to_s.length < 12
  return false if !@modifications.nil? && @modifications.length > 100
  return false if !@width.nil? && @width > 4000
  return false if !@width.nil? && @width < 100
  return false if !@quality.nil? && @quality > 100
  return false if !@quality.nil? && @quality < 1
  return false if !@expiration.nil? && @expiration > 604800
  return false if !@expiration.nil? && @expiration < 60
  return false if !@filename.nil? && @filename.to_s.length > 100
  return false if !@filename.nil? && @filename !~ Regexp.new(/^[a-zA-Z0-9_\-\.]+$/)
  return false if !@s3_filepath.nil? && @s3_filepath.to_s.length > 500
  return false if !@s3_filepath.nil? && @s3_filepath !~ Regexp.new(/^[a-zA-Z0-9_\-\.\/]+$/)
  return false if !@s3_bucket.nil? && @s3_bucket.to_s.length > 63
  return false if !@s3_bucket.nil? && @s3_bucket.to_s.length < 3
  return false if !@s3_bucket.nil? && @s3_bucket !~ Regexp.new(/^[a-z0-9][a-z0-9.\-]*[a-z0-9]$/)
  return false if !@version.nil? && @version.to_s.length > 50
  true
end