Class: TemplateFox::CreatePdfRequest
- Inherits:
-
ApiModelBase
- Object
- ApiModelBase
- TemplateFox::CreatePdfRequest
- Defined in:
- lib/templatefox/models/create_pdf_request.rb
Overview
Request model for PDF generation
Defined Under Namespace
Classes: EnumAttributeValidator
Instance Attribute Summary collapse
-
#data ⇒ Object
Key-value data to render in the template.
-
#expiration ⇒ Object
URL expiration in seconds.
-
#export_type ⇒ Object
Export format: ‘url` uploads to CDN and returns URL, `binary` returns raw PDF bytes.
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#pdf_variant ⇒ Object
Returns the value of attribute pdf_variant.
-
#s3_bucket ⇒ Object
Returns the value of attribute s3_bucket.
-
#s3_filepath ⇒ Object
Returns the value of attribute s3_filepath.
-
#store_s3 ⇒ Object
Upload to your configured S3 bucket instead of CDN.
-
#template_id ⇒ Object
Template short ID (12 characters).
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
-
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about.
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ CreatePdfRequest
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Methods inherited from ApiModelBase
_deserialize, #_to_hash, #to_body, #to_s
Constructor Details
#initialize(attributes = {}) ⇒ CreatePdfRequest
Initializes the object
121 122 123 124 125 126 127 128 129 130 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 |
# File 'lib/templatefox/models/create_pdf_request.rb', line 121 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `TemplateFox::CreatePdfRequest` 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::CreatePdfRequest`. 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?(:'pdf_variant') self.pdf_variant = attributes[:'pdf_variant'] end if attributes.key?(:'version') self.version = attributes[:'version'] end end |
Instance Attribute Details
#data ⇒ Object
Key-value data to render in the template. Keys must match template variables.
23 24 25 |
# File 'lib/templatefox/models/create_pdf_request.rb', line 23 def data @data end |
#expiration ⇒ Object
URL expiration in seconds. Min: 60 (1 min), Max: 604800 (7 days). Only applies to ‘url` export type.
29 30 31 |
# File 'lib/templatefox/models/create_pdf_request.rb', line 29 def expiration @expiration end |
#export_type ⇒ Object
Export format: ‘url` uploads to CDN and returns URL, `binary` returns raw PDF bytes
26 27 28 |
# File 'lib/templatefox/models/create_pdf_request.rb', line 26 def export_type @export_type end |
#filename ⇒ Object
Returns the value of attribute filename.
31 32 33 |
# File 'lib/templatefox/models/create_pdf_request.rb', line 31 def filename @filename end |
#pdf_variant ⇒ Object
Returns the value of attribute pdf_variant.
40 41 42 |
# File 'lib/templatefox/models/create_pdf_request.rb', line 40 def pdf_variant @pdf_variant end |
#s3_bucket ⇒ Object
Returns the value of attribute s3_bucket.
38 39 40 |
# File 'lib/templatefox/models/create_pdf_request.rb', line 38 def s3_bucket @s3_bucket end |
#s3_filepath ⇒ Object
Returns the value of attribute s3_filepath.
36 37 38 |
# File 'lib/templatefox/models/create_pdf_request.rb', line 36 def s3_filepath @s3_filepath end |
#store_s3 ⇒ Object
Upload to your configured S3 bucket instead of CDN
34 35 36 |
# File 'lib/templatefox/models/create_pdf_request.rb', line 34 def store_s3 @store_s3 end |
#template_id ⇒ Object
Template short ID (12 characters)
20 21 22 |
# File 'lib/templatefox/models/create_pdf_request.rb', line 20 def template_id @template_id end |
#version ⇒ Object
Returns the value of attribute version.
42 43 44 |
# File 'lib/templatefox/models/create_pdf_request.rb', line 42 def version @version end |
Class Method Details
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about
83 84 85 |
# File 'lib/templatefox/models/create_pdf_request.rb', line 83 def self.acceptable_attribute_map attribute_map end |
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
88 89 90 |
# File 'lib/templatefox/models/create_pdf_request.rb', line 88 def self.acceptable_attributes acceptable_attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/templatefox/models/create_pdf_request.rb', line 67 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', :'pdf_variant' => :'pdf_variant', :'version' => :'version' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
# File 'lib/templatefox/models/create_pdf_request.rb', line 411 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_nullable ⇒ Object
List of attributes with nullable: true
109 110 111 112 113 114 115 116 117 |
# File 'lib/templatefox/models/create_pdf_request.rb', line 109 def self.openapi_nullable Set.new([ :'filename', :'s3_filepath', :'s3_bucket', :'pdf_variant', :'version' ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/templatefox/models/create_pdf_request.rb', line 93 def self.openapi_types { :'template_id' => :'String', :'data' => :'Hash<String, Object>', :'export_type' => :'AppRoutersV1PdfExportType', :'expiration' => :'Integer', :'filename' => :'String', :'store_s3' => :'Boolean', :'s3_filepath' => :'String', :'s3_bucket' => :'String', :'pdf_variant' => :'PdfVariant', :'version' => :'String' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
# File 'lib/templatefox/models/create_pdf_request.rb', line 381 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 && pdf_variant == o.pdf_variant && version == o.version end |
#eql?(o) ⇒ Boolean
398 399 400 |
# File 'lib/templatefox/models/create_pdf_request.rb', line 398 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
404 405 406 |
# File 'lib/templatefox/models/create_pdf_request.rb', line 404 def hash [template_id, data, export_type, expiration, filename, store_s3, s3_filepath, s3_bucket, pdf_variant, version].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
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 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 |
# File 'lib/templatefox/models/create_pdf_request.rb', line 188 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 !@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_hash ⇒ Hash
Returns the object in the form of hash
433 434 435 436 437 438 439 440 441 442 443 444 445 |
# File 'lib/templatefox/models/create_pdf_request.rb', line 433 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
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/templatefox/models/create_pdf_request.rb', line 255 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 !@version.nil? && @version.to_s.length > 50 true end |