templatefox 1.0.1 → 1.6.0

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.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/lib/templatefox/api/account_api.rb +6 -6
  3. data/lib/templatefox/api/integrations_api.rb +10 -10
  4. data/lib/templatefox/api/pdf_api.rb +4 -4
  5. data/lib/templatefox/api/pdf_async_api.rb +219 -0
  6. data/lib/templatefox/api/templates_api.rb +6 -6
  7. data/lib/templatefox/api_client.rb +2 -2
  8. data/lib/templatefox/api_error.rb +2 -2
  9. data/lib/templatefox/api_model_base.rb +2 -2
  10. data/lib/templatefox/configuration.rb +2 -2
  11. data/lib/templatefox/models/account_info_response.rb +2 -2
  12. data/lib/templatefox/models/app_routers_v1_pdf_async_export_type.rb +39 -0
  13. data/lib/templatefox/models/{export_type.rb → app_routers_v1_pdf_export_type.rb} +5 -5
  14. data/lib/templatefox/models/create_async_pdf_request.rb +482 -0
  15. data/lib/templatefox/models/create_async_pdf_response.rb +242 -0
  16. data/lib/templatefox/models/create_pdf_request.rb +3 -3
  17. data/lib/templatefox/models/create_pdf_response.rb +2 -2
  18. data/lib/templatefox/models/http_validation_error.rb +2 -2
  19. data/lib/templatefox/models/job_list_response.rb +249 -0
  20. data/lib/templatefox/models/job_status.rb +42 -0
  21. data/lib/templatefox/models/job_status_response.rb +440 -0
  22. data/lib/templatefox/models/location_inner.rb +2 -2
  23. data/lib/templatefox/models/s3_config_request.rb +2 -2
  24. data/lib/templatefox/models/s3_config_response.rb +2 -2
  25. data/lib/templatefox/models/s3_success_response.rb +2 -2
  26. data/lib/templatefox/models/s3_test_response.rb +2 -2
  27. data/lib/templatefox/models/template_field.rb +21 -9
  28. data/lib/templatefox/models/template_field_spec.rb +205 -0
  29. data/lib/templatefox/models/template_list_item.rb +2 -2
  30. data/lib/templatefox/models/templates_list_response.rb +2 -2
  31. data/lib/templatefox/models/transaction.rb +2 -2
  32. data/lib/templatefox/models/transactions_response.rb +2 -2
  33. data/lib/templatefox/models/validation_error.rb +2 -2
  34. data/lib/templatefox/version.rb +3 -3
  35. data/lib/templatefox.rb +11 -3
  36. data/spec/api/account_api_spec.rb +4 -4
  37. data/spec/api/integrations_api_spec.rb +6 -6
  38. data/spec/api/pdf_api_spec.rb +3 -3
  39. data/spec/api/pdf_async_api_spec.rb +73 -0
  40. data/spec/api/templates_api_spec.rb +4 -4
  41. data/spec/models/account_info_response_spec.rb +2 -2
  42. data/spec/models/app_routers_v1_pdf_async_export_type_spec.rb +30 -0
  43. data/spec/models/app_routers_v1_pdf_export_type_spec.rb +30 -0
  44. data/spec/models/create_async_pdf_request_spec.rb +90 -0
  45. data/spec/models/create_async_pdf_response_spec.rb +48 -0
  46. data/spec/models/create_pdf_request_spec.rb +2 -2
  47. data/spec/models/create_pdf_response_spec.rb +2 -2
  48. data/spec/models/http_validation_error_spec.rb +2 -2
  49. data/spec/models/job_list_response_spec.rb +54 -0
  50. data/spec/models/job_status_response_spec.rb +126 -0
  51. data/spec/models/job_status_spec.rb +30 -0
  52. data/spec/models/location_inner_spec.rb +2 -2
  53. data/spec/models/s3_config_request_spec.rb +2 -2
  54. data/spec/models/s3_config_response_spec.rb +2 -2
  55. data/spec/models/s3_success_response_spec.rb +2 -2
  56. data/spec/models/s3_test_response_spec.rb +2 -2
  57. data/spec/models/template_field_spec.rb +8 -2
  58. data/spec/models/template_field_spec_spec.rb +48 -0
  59. data/spec/models/template_list_item_spec.rb +2 -2
  60. data/spec/models/templates_list_response_spec.rb +2 -2
  61. data/spec/models/transaction_spec.rb +2 -2
  62. data/spec/models/transactions_response_spec.rb +2 -2
  63. data/spec/models/validation_error_spec.rb +2 -2
  64. data/spec/spec_helper.rb +2 -2
  65. data/templatefox.gemspec +2 -2
  66. metadata +39 -15
  67. data/spec/models/export_type_spec.rb +0 -30
@@ -0,0 +1,482 @@
1
+ =begin
2
+ #TemplateFox API
3
+
4
+ #Generate beautiful PDFs from HTML/CSS templates with Jinja2 via API. Design once, generate thousands.
5
+
6
+ The version of the OpenAPI document: 1.6.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.19.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module TemplateFox
17
+ # Request model for async PDF generation
18
+ class CreateAsyncPdfRequest < ApiModelBase
19
+ # **Required.** Template short ID (12 characters)
20
+ attr_accessor :template_id
21
+
22
+ # **Required.** Key-value data to render in the template.
23
+ attr_accessor :data
24
+
25
+ # Export format. Currently only `url` is supported for async.
26
+ attr_accessor :export_type
27
+
28
+ # URL expiration in seconds (60-604800). Default: 86400 (24 hours).
29
+ attr_accessor :expiration
30
+
31
+ attr_accessor :filename
32
+
33
+ # Upload to your configured S3 bucket instead of CDN.
34
+ attr_accessor :store_s3
35
+
36
+ attr_accessor :s3_filepath
37
+
38
+ attr_accessor :s3_bucket
39
+
40
+ attr_accessor :webhook_url
41
+
42
+ attr_accessor :webhook_secret
43
+
44
+ class EnumAttributeValidator
45
+ attr_reader :datatype
46
+ attr_reader :allowable_values
47
+
48
+ def initialize(datatype, allowable_values)
49
+ @allowable_values = allowable_values.map do |value|
50
+ case datatype.to_s
51
+ when /Integer/i
52
+ value.to_i
53
+ when /Float/i
54
+ value.to_f
55
+ else
56
+ value
57
+ end
58
+ end
59
+ end
60
+
61
+ def valid?(value)
62
+ !value || allowable_values.include?(value)
63
+ end
64
+ end
65
+
66
+ # Attribute mapping from ruby-style variable name to JSON key.
67
+ def self.attribute_map
68
+ {
69
+ :'template_id' => :'template_id',
70
+ :'data' => :'data',
71
+ :'export_type' => :'export_type',
72
+ :'expiration' => :'expiration',
73
+ :'filename' => :'filename',
74
+ :'store_s3' => :'store_s3',
75
+ :'s3_filepath' => :'s3_filepath',
76
+ :'s3_bucket' => :'s3_bucket',
77
+ :'webhook_url' => :'webhook_url',
78
+ :'webhook_secret' => :'webhook_secret'
79
+ }
80
+ end
81
+
82
+ # Returns attribute mapping this model knows about
83
+ def self.acceptable_attribute_map
84
+ attribute_map
85
+ end
86
+
87
+ # Returns all the JSON keys this model knows about
88
+ def self.acceptable_attributes
89
+ acceptable_attribute_map.values
90
+ end
91
+
92
+ # Attribute type mapping.
93
+ def self.openapi_types
94
+ {
95
+ :'template_id' => :'String',
96
+ :'data' => :'Hash<String, Object>',
97
+ :'export_type' => :'AppRoutersV1PdfAsyncExportType',
98
+ :'expiration' => :'Integer',
99
+ :'filename' => :'String',
100
+ :'store_s3' => :'Boolean',
101
+ :'s3_filepath' => :'String',
102
+ :'s3_bucket' => :'String',
103
+ :'webhook_url' => :'String',
104
+ :'webhook_secret' => :'String'
105
+ }
106
+ end
107
+
108
+ # List of attributes with nullable: true
109
+ def self.openapi_nullable
110
+ Set.new([
111
+ :'filename',
112
+ :'s3_filepath',
113
+ :'s3_bucket',
114
+ :'webhook_url',
115
+ :'webhook_secret'
116
+ ])
117
+ end
118
+
119
+ # Initializes the object
120
+ # @param [Hash] attributes Model attributes in the form of hash
121
+ def initialize(attributes = {})
122
+ if (!attributes.is_a?(Hash))
123
+ fail ArgumentError, "The input argument (attributes) must be a hash in `TemplateFox::CreateAsyncPdfRequest` initialize method"
124
+ end
125
+
126
+ # check to see if the attribute exists and convert string to symbol for hash key
127
+ acceptable_attribute_map = self.class.acceptable_attribute_map
128
+ attributes = attributes.each_with_object({}) { |(k, v), h|
129
+ if (!acceptable_attribute_map.key?(k.to_sym))
130
+ 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
131
+ end
132
+ h[k.to_sym] = v
133
+ }
134
+
135
+ if attributes.key?(:'template_id')
136
+ self.template_id = attributes[:'template_id']
137
+ else
138
+ self.template_id = nil
139
+ end
140
+
141
+ if attributes.key?(:'data')
142
+ if (value = attributes[:'data']).is_a?(Hash)
143
+ self.data = value
144
+ end
145
+ else
146
+ self.data = nil
147
+ end
148
+
149
+ if attributes.key?(:'export_type')
150
+ self.export_type = attributes[:'export_type']
151
+ end
152
+
153
+ if attributes.key?(:'expiration')
154
+ self.expiration = attributes[:'expiration']
155
+ else
156
+ self.expiration = 86400
157
+ end
158
+
159
+ if attributes.key?(:'filename')
160
+ self.filename = attributes[:'filename']
161
+ end
162
+
163
+ if attributes.key?(:'store_s3')
164
+ self.store_s3 = attributes[:'store_s3']
165
+ else
166
+ self.store_s3 = false
167
+ end
168
+
169
+ if attributes.key?(:'s3_filepath')
170
+ self.s3_filepath = attributes[:'s3_filepath']
171
+ end
172
+
173
+ if attributes.key?(:'s3_bucket')
174
+ self.s3_bucket = attributes[:'s3_bucket']
175
+ end
176
+
177
+ if attributes.key?(:'webhook_url')
178
+ self.webhook_url = attributes[:'webhook_url']
179
+ end
180
+
181
+ if attributes.key?(:'webhook_secret')
182
+ self.webhook_secret = attributes[:'webhook_secret']
183
+ end
184
+ end
185
+
186
+ # Show invalid properties with the reasons. Usually used together with valid?
187
+ # @return Array for valid properties with the reasons
188
+ def list_invalid_properties
189
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
190
+ invalid_properties = Array.new
191
+ if @template_id.nil?
192
+ invalid_properties.push('invalid value for "template_id", template_id cannot be nil.')
193
+ end
194
+
195
+ if @template_id.to_s.length > 12
196
+ invalid_properties.push('invalid value for "template_id", the character length must be smaller than or equal to 12.')
197
+ end
198
+
199
+ if @template_id.to_s.length < 12
200
+ invalid_properties.push('invalid value for "template_id", the character length must be greater than or equal to 12.')
201
+ end
202
+
203
+ if @data.nil?
204
+ invalid_properties.push('invalid value for "data", data cannot be nil.')
205
+ end
206
+
207
+ if !@expiration.nil? && @expiration > 604800
208
+ invalid_properties.push('invalid value for "expiration", must be smaller than or equal to 604800.')
209
+ end
210
+
211
+ if !@expiration.nil? && @expiration < 60
212
+ invalid_properties.push('invalid value for "expiration", must be greater than or equal to 60.')
213
+ end
214
+
215
+ if !@filename.nil? && @filename.to_s.length > 100
216
+ invalid_properties.push('invalid value for "filename", the character length must be smaller than or equal to 100.')
217
+ end
218
+
219
+ pattern = Regexp.new(/^[a-zA-Z0-9_\-\.]+$/)
220
+ if !@filename.nil? && @filename !~ pattern
221
+ invalid_properties.push("invalid value for \"filename\", must conform to the pattern #{pattern}.")
222
+ end
223
+
224
+ if !@s3_filepath.nil? && @s3_filepath.to_s.length > 500
225
+ invalid_properties.push('invalid value for "s3_filepath", the character length must be smaller than or equal to 500.')
226
+ end
227
+
228
+ pattern = Regexp.new(/^[a-zA-Z0-9_\-\.\/]+$/)
229
+ if !@s3_filepath.nil? && @s3_filepath !~ pattern
230
+ invalid_properties.push("invalid value for \"s3_filepath\", must conform to the pattern #{pattern}.")
231
+ end
232
+
233
+ if !@s3_bucket.nil? && @s3_bucket.to_s.length > 63
234
+ invalid_properties.push('invalid value for "s3_bucket", the character length must be smaller than or equal to 63.')
235
+ end
236
+
237
+ if !@s3_bucket.nil? && @s3_bucket.to_s.length < 3
238
+ invalid_properties.push('invalid value for "s3_bucket", the character length must be greater than or equal to 3.')
239
+ end
240
+
241
+ pattern = Regexp.new(/^[a-z0-9][a-z0-9.\-]*[a-z0-9]$/)
242
+ if !@s3_bucket.nil? && @s3_bucket !~ pattern
243
+ invalid_properties.push("invalid value for \"s3_bucket\", must conform to the pattern #{pattern}.")
244
+ end
245
+
246
+ if !@webhook_url.nil? && @webhook_url.to_s.length > 2083
247
+ invalid_properties.push('invalid value for "webhook_url", the character length must be smaller than or equal to 2083.')
248
+ end
249
+
250
+ if !@webhook_url.nil? && @webhook_url.to_s.length < 1
251
+ invalid_properties.push('invalid value for "webhook_url", the character length must be greater than or equal to 1.')
252
+ end
253
+
254
+ if !@webhook_secret.nil? && @webhook_secret.to_s.length > 256
255
+ invalid_properties.push('invalid value for "webhook_secret", the character length must be smaller than or equal to 256.')
256
+ end
257
+
258
+ if !@webhook_secret.nil? && @webhook_secret.to_s.length < 16
259
+ invalid_properties.push('invalid value for "webhook_secret", the character length must be greater than or equal to 16.')
260
+ end
261
+
262
+ invalid_properties
263
+ end
264
+
265
+ # Check to see if the all the properties in the model are valid
266
+ # @return true if the model is valid
267
+ def valid?
268
+ warn '[DEPRECATED] the `valid?` method is obsolete'
269
+ return false if @template_id.nil?
270
+ return false if @template_id.to_s.length > 12
271
+ return false if @template_id.to_s.length < 12
272
+ return false if @data.nil?
273
+ return false if !@expiration.nil? && @expiration > 604800
274
+ return false if !@expiration.nil? && @expiration < 60
275
+ return false if !@filename.nil? && @filename.to_s.length > 100
276
+ return false if !@filename.nil? && @filename !~ Regexp.new(/^[a-zA-Z0-9_\-\.]+$/)
277
+ return false if !@s3_filepath.nil? && @s3_filepath.to_s.length > 500
278
+ return false if !@s3_filepath.nil? && @s3_filepath !~ Regexp.new(/^[a-zA-Z0-9_\-\.\/]+$/)
279
+ return false if !@s3_bucket.nil? && @s3_bucket.to_s.length > 63
280
+ return false if !@s3_bucket.nil? && @s3_bucket.to_s.length < 3
281
+ return false if !@s3_bucket.nil? && @s3_bucket !~ Regexp.new(/^[a-z0-9][a-z0-9.\-]*[a-z0-9]$/)
282
+ return false if !@webhook_url.nil? && @webhook_url.to_s.length > 2083
283
+ return false if !@webhook_url.nil? && @webhook_url.to_s.length < 1
284
+ return false if !@webhook_secret.nil? && @webhook_secret.to_s.length > 256
285
+ return false if !@webhook_secret.nil? && @webhook_secret.to_s.length < 16
286
+ true
287
+ end
288
+
289
+ # Custom attribute writer method with validation
290
+ # @param [Object] template_id Value to be assigned
291
+ def template_id=(template_id)
292
+ if template_id.nil?
293
+ fail ArgumentError, 'template_id cannot be nil'
294
+ end
295
+
296
+ if template_id.to_s.length > 12
297
+ fail ArgumentError, 'invalid value for "template_id", the character length must be smaller than or equal to 12.'
298
+ end
299
+
300
+ if template_id.to_s.length < 12
301
+ fail ArgumentError, 'invalid value for "template_id", the character length must be greater than or equal to 12.'
302
+ end
303
+
304
+ @template_id = template_id
305
+ end
306
+
307
+ # Custom attribute writer method with validation
308
+ # @param [Object] data Value to be assigned
309
+ def data=(data)
310
+ if data.nil?
311
+ fail ArgumentError, 'data cannot be nil'
312
+ end
313
+
314
+ @data = data
315
+ end
316
+
317
+ # Custom attribute writer method with validation
318
+ # @param [Object] expiration Value to be assigned
319
+ def expiration=(expiration)
320
+ if expiration.nil?
321
+ fail ArgumentError, 'expiration cannot be nil'
322
+ end
323
+
324
+ if expiration > 604800
325
+ fail ArgumentError, 'invalid value for "expiration", must be smaller than or equal to 604800.'
326
+ end
327
+
328
+ if expiration < 60
329
+ fail ArgumentError, 'invalid value for "expiration", must be greater than or equal to 60.'
330
+ end
331
+
332
+ @expiration = expiration
333
+ end
334
+
335
+ # Custom attribute writer method with validation
336
+ # @param [Object] filename Value to be assigned
337
+ def filename=(filename)
338
+ if !filename.nil? && filename.to_s.length > 100
339
+ fail ArgumentError, 'invalid value for "filename", the character length must be smaller than or equal to 100.'
340
+ end
341
+
342
+ pattern = Regexp.new(/^[a-zA-Z0-9_\-\.]+$/)
343
+ if !filename.nil? && filename !~ pattern
344
+ fail ArgumentError, "invalid value for \"filename\", must conform to the pattern #{pattern}."
345
+ end
346
+
347
+ @filename = filename
348
+ end
349
+
350
+ # Custom attribute writer method with validation
351
+ # @param [Object] s3_filepath Value to be assigned
352
+ def s3_filepath=(s3_filepath)
353
+ if !s3_filepath.nil? && s3_filepath.to_s.length > 500
354
+ fail ArgumentError, 'invalid value for "s3_filepath", the character length must be smaller than or equal to 500.'
355
+ end
356
+
357
+ pattern = Regexp.new(/^[a-zA-Z0-9_\-\.\/]+$/)
358
+ if !s3_filepath.nil? && s3_filepath !~ pattern
359
+ fail ArgumentError, "invalid value for \"s3_filepath\", must conform to the pattern #{pattern}."
360
+ end
361
+
362
+ @s3_filepath = s3_filepath
363
+ end
364
+
365
+ # Custom attribute writer method with validation
366
+ # @param [Object] s3_bucket Value to be assigned
367
+ def s3_bucket=(s3_bucket)
368
+ if !s3_bucket.nil? && s3_bucket.to_s.length > 63
369
+ fail ArgumentError, 'invalid value for "s3_bucket", the character length must be smaller than or equal to 63.'
370
+ end
371
+
372
+ if !s3_bucket.nil? && s3_bucket.to_s.length < 3
373
+ fail ArgumentError, 'invalid value for "s3_bucket", the character length must be greater than or equal to 3.'
374
+ end
375
+
376
+ pattern = Regexp.new(/^[a-z0-9][a-z0-9.\-]*[a-z0-9]$/)
377
+ if !s3_bucket.nil? && s3_bucket !~ pattern
378
+ fail ArgumentError, "invalid value for \"s3_bucket\", must conform to the pattern #{pattern}."
379
+ end
380
+
381
+ @s3_bucket = s3_bucket
382
+ end
383
+
384
+ # Custom attribute writer method with validation
385
+ # @param [Object] webhook_url Value to be assigned
386
+ def webhook_url=(webhook_url)
387
+ if !webhook_url.nil? && webhook_url.to_s.length > 2083
388
+ fail ArgumentError, 'invalid value for "webhook_url", the character length must be smaller than or equal to 2083.'
389
+ end
390
+
391
+ if !webhook_url.nil? && webhook_url.to_s.length < 1
392
+ fail ArgumentError, 'invalid value for "webhook_url", the character length must be greater than or equal to 1.'
393
+ end
394
+
395
+ @webhook_url = webhook_url
396
+ end
397
+
398
+ # Custom attribute writer method with validation
399
+ # @param [Object] webhook_secret Value to be assigned
400
+ def webhook_secret=(webhook_secret)
401
+ if !webhook_secret.nil? && webhook_secret.to_s.length > 256
402
+ fail ArgumentError, 'invalid value for "webhook_secret", the character length must be smaller than or equal to 256.'
403
+ end
404
+
405
+ if !webhook_secret.nil? && webhook_secret.to_s.length < 16
406
+ fail ArgumentError, 'invalid value for "webhook_secret", the character length must be greater than or equal to 16.'
407
+ end
408
+
409
+ @webhook_secret = webhook_secret
410
+ end
411
+
412
+ # Checks equality by comparing each attribute.
413
+ # @param [Object] Object to be compared
414
+ def ==(o)
415
+ return true if self.equal?(o)
416
+ self.class == o.class &&
417
+ template_id == o.template_id &&
418
+ data == o.data &&
419
+ export_type == o.export_type &&
420
+ expiration == o.expiration &&
421
+ filename == o.filename &&
422
+ store_s3 == o.store_s3 &&
423
+ s3_filepath == o.s3_filepath &&
424
+ s3_bucket == o.s3_bucket &&
425
+ webhook_url == o.webhook_url &&
426
+ webhook_secret == o.webhook_secret
427
+ end
428
+
429
+ # @see the `==` method
430
+ # @param [Object] Object to be compared
431
+ def eql?(o)
432
+ self == o
433
+ end
434
+
435
+ # Calculates hash code according to all attributes.
436
+ # @return [Integer] Hash code
437
+ def hash
438
+ [template_id, data, export_type, expiration, filename, store_s3, s3_filepath, s3_bucket, webhook_url, webhook_secret].hash
439
+ end
440
+
441
+ # Builds the object from hash
442
+ # @param [Hash] attributes Model attributes in the form of hash
443
+ # @return [Object] Returns the model itself
444
+ def self.build_from_hash(attributes)
445
+ return nil unless attributes.is_a?(Hash)
446
+ attributes = attributes.transform_keys(&:to_sym)
447
+ transformed_hash = {}
448
+ openapi_types.each_pair do |key, type|
449
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
450
+ transformed_hash["#{key}"] = nil
451
+ elsif type =~ /\AArray<(.*)>/i
452
+ # check to ensure the input is an array given that the attribute
453
+ # is documented as an array but the input is not
454
+ if attributes[attribute_map[key]].is_a?(Array)
455
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
456
+ end
457
+ elsif !attributes[attribute_map[key]].nil?
458
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
459
+ end
460
+ end
461
+ new(transformed_hash)
462
+ end
463
+
464
+ # Returns the object in the form of hash
465
+ # @return [Hash] Returns the object in the form of hash
466
+ def to_hash
467
+ hash = {}
468
+ self.class.attribute_map.each_pair do |attr, param|
469
+ value = self.send(attr)
470
+ if value.nil?
471
+ is_nullable = self.class.openapi_nullable.include?(attr)
472
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
473
+ end
474
+
475
+ hash[param] = _to_hash(value)
476
+ end
477
+ hash
478
+ end
479
+
480
+ end
481
+
482
+ end