Class: TemplateFox::CreateAsyncPdfRequest

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

Overview

Request model for async PDF 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 = {}) ⇒ CreateAsyncPdfRequest

Initializes the object

Parameters:

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

    Model attributes in the form of hash



131
132
133
134
135
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
# File 'lib/templatefox/models/create_async_pdf_request.rb', line 131

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `TemplateFox::CreateAsyncPdfRequest` 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::CreateAsyncPdfRequest`. 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?(:'data')
    if (value = attributes[:'data']).is_a?(Hash)
      self.data = value
    end
  else
    self.data = nil
  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?(:'webhook_url')
    self.webhook_url = attributes[:'webhook_url']
  end

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

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

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

Instance Attribute Details

#dataObject

Key-value data to render in the template.



23
24
25
# File 'lib/templatefox/models/create_async_pdf_request.rb', line 23

def data
  @data
end

#expirationObject

URL expiration in seconds (60-604800). Default: 86400 (24 hours).



29
30
31
# File 'lib/templatefox/models/create_async_pdf_request.rb', line 29

def expiration
  @expiration
end

#export_typeObject

Export format. Currently only ‘url` is supported for async.



26
27
28
# File 'lib/templatefox/models/create_async_pdf_request.rb', line 26

def export_type
  @export_type
end

#filenameObject

Returns the value of attribute filename.



31
32
33
# File 'lib/templatefox/models/create_async_pdf_request.rb', line 31

def filename
  @filename
end

#pdf_variantObject

Returns the value of attribute pdf_variant.



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

def pdf_variant
  @pdf_variant
end

#s3_bucketObject

Returns the value of attribute s3_bucket.



38
39
40
# File 'lib/templatefox/models/create_async_pdf_request.rb', line 38

def s3_bucket
  @s3_bucket
end

#s3_filepathObject

Returns the value of attribute s3_filepath.



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

def s3_filepath
  @s3_filepath
end

#store_s3Object

Upload to your configured S3 bucket instead of CDN.



34
35
36
# File 'lib/templatefox/models/create_async_pdf_request.rb', line 34

def store_s3
  @store_s3
end

#template_idObject

Template short ID (12 characters)



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

def template_id
  @template_id
end

#versionObject

Returns the value of attribute version.



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

def version
  @version
end

#webhook_secretObject

Returns the value of attribute webhook_secret.



42
43
44
# File 'lib/templatefox/models/create_async_pdf_request.rb', line 42

def webhook_secret
  @webhook_secret
end

#webhook_urlObject

Returns the value of attribute webhook_url.



40
41
42
# File 'lib/templatefox/models/create_async_pdf_request.rb', line 40

def webhook_url
  @webhook_url
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



89
90
91
# File 'lib/templatefox/models/create_async_pdf_request.rb', line 89

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



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

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

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



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/templatefox/models/create_async_pdf_request.rb', line 71

def self.attribute_map
  {
    :'template_id' => :'template_id',
    :'data' => :'data',
    :'export_type' => :'export_type',
    :'expiration' => :'expiration',
    :'filename' => :'filename',
    :'store_s3' => :'store_s3',
    :'s3_filepath' => :'s3_filepath',
    :'s3_bucket' => :'s3_bucket',
    :'webhook_url' => :'webhook_url',
    :'webhook_secret' => :'webhook_secret',
    :'pdf_variant' => :'pdf_variant',
    :'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



479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
# File 'lib/templatefox/models/create_async_pdf_request.rb', line 479

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



117
118
119
120
121
122
123
124
125
126
127
# File 'lib/templatefox/models/create_async_pdf_request.rb', line 117

def self.openapi_nullable
  Set.new([
    :'filename',
    :'s3_filepath',
    :'s3_bucket',
    :'webhook_url',
    :'webhook_secret',
    :'pdf_variant',
    :'version'
  ])
end

.openapi_typesObject

Attribute type mapping.



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/templatefox/models/create_async_pdf_request.rb', line 99

def self.openapi_types
  {
    :'template_id' => :'String',
    :'data' => :'Hash<String, Object>',
    :'export_type' => :'AppRoutersV1PdfAsyncExportType',
    :'expiration' => :'Integer',
    :'filename' => :'String',
    :'store_s3' => :'Boolean',
    :'s3_filepath' => :'String',
    :'s3_bucket' => :'String',
    :'webhook_url' => :'String',
    :'webhook_secret' => :'String',
    :'pdf_variant' => :'PdfVariant',
    :'version' => :'String'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
# File 'lib/templatefox/models/create_async_pdf_request.rb', line 447

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      template_id == o.template_id &&
      data == o.data &&
      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 &&
      webhook_url == o.webhook_url &&
      webhook_secret == o.webhook_secret &&
      pdf_variant == o.pdf_variant &&
      version == o.version
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


466
467
468
# File 'lib/templatefox/models/create_async_pdf_request.rb', line 466

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



472
473
474
# File 'lib/templatefox/models/create_async_pdf_request.rb', line 472

def hash
  [template_id, data, export_type, expiration, filename, store_s3, s3_filepath, s3_bucket, webhook_url, webhook_secret, pdf_variant, 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



206
207
208
209
210
211
212
213
214
215
216
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
# File 'lib/templatefox/models/create_async_pdf_request.rb', line 206

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 @data.nil?
    invalid_properties.push('invalid value for "data", data cannot be nil.')
  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 !@webhook_url.nil? && @webhook_url.to_s.length > 2083
    invalid_properties.push('invalid value for "webhook_url", the character length must be smaller than or equal to 2083.')
  end

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

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

  if !@webhook_secret.nil? && @webhook_secret.to_s.length < 16
    invalid_properties.push('invalid value for "webhook_secret", the character length must be greater than or equal to 16.')
  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



501
502
503
504
505
506
507
508
509
510
511
512
513
# File 'lib/templatefox/models/create_async_pdf_request.rb', line 501

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



289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# File 'lib/templatefox/models/create_async_pdf_request.rb', line 289

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 @data.nil?
  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 !@webhook_url.nil? && @webhook_url.to_s.length > 2083
  return false if !@webhook_url.nil? && @webhook_url.to_s.length < 1
  return false if !@webhook_secret.nil? && @webhook_secret.to_s.length > 256
  return false if !@webhook_secret.nil? && @webhook_secret.to_s.length < 16
  return false if !@version.nil? && @version.to_s.length > 50
  true
end