docspring 1.0.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. data/.openapi-generator/VERSION +1 -1
  3. data/CHANGELOG.md +14 -37
  4. data/Gemfile +2 -1
  5. data/Gemfile.lock +37 -32
  6. data/LICENSE +1 -1
  7. data/README.md +26 -15
  8. data/docs/AddFieldsData.md +8 -0
  9. data/docs/AddFieldsTemplateResponse.md +10 -0
  10. data/docs/CombinePdfsData.md +4 -4
  11. data/docs/CombinedSubmission.md +1 -0
  12. data/docs/CombinedSubmissionData.md +3 -3
  13. data/docs/{CreateTemplateData.md → CreateHtmlTemplateData.md} +2 -2
  14. data/docs/CreateSubmissionDataRequestData.md +2 -2
  15. data/docs/CreateTemplateFromUploadData.md +8 -0
  16. data/docs/HtmlTemplateData.md +24 -0
  17. data/docs/PDFApi.md +169 -15
  18. data/docs/PendingTemplate.md +2 -0
  19. data/docs/Submission.md +5 -0
  20. data/docs/SubmissionBatchData.md +2 -2
  21. data/docs/SubmissionData.md +4 -3
  22. data/docs/SubmissionDataBatchRequest.md +2 -2
  23. data/docs/SubmissionDataRequest.md +2 -0
  24. data/docs/Template.md +2 -0
  25. data/docs/{Templatesv2Template.md → TemplateData.md} +11 -7
  26. data/docs/TemplatestemplateIdaddFieldsFields.md +92 -0
  27. data/docs/UpdateSubmissionDataRequestData.md +9 -9
  28. data/docs/UpdateTemplateData.md +8 -0
  29. data/docs/UpdateTemplateResponse.md +9 -0
  30. data/docs/UploadTemplateData.md +25 -0
  31. data/docs/{Templatesv2TemplateDocument.md → UploadTemplateDataDocument.md} +2 -2
  32. data/docs/{Templatesv2TemplateDocumentMetadata.md → UploadTemplateDataDocumentMetadata.md} +1 -1
  33. data/docspring.gemspec +3 -3
  34. data/lib/docspring.rb +13 -5
  35. data/lib/docspring/api/pdf_api.rb +193 -22
  36. data/lib/docspring/api_client.rb +1 -1
  37. data/lib/docspring/api_error.rb +1 -1
  38. data/lib/docspring/configuration.rb +1 -1
  39. data/lib/docspring/models/add_fields_data.rb +190 -0
  40. data/lib/docspring/models/add_fields_template_response.rb +239 -0
  41. data/lib/docspring/models/authentication_error.rb +1 -1
  42. data/lib/docspring/models/authentication_success_response.rb +1 -1
  43. data/lib/docspring/models/combine_pdfs_data.rb +28 -28
  44. data/lib/docspring/models/combined_submission.rb +11 -2
  45. data/lib/docspring/models/combined_submission_action.rb +1 -6
  46. data/lib/docspring/models/combined_submission_data.rb +23 -23
  47. data/lib/docspring/models/create_combined_submission_response.rb +1 -1
  48. data/lib/docspring/models/create_custom_file_data.rb +1 -1
  49. data/lib/docspring/models/create_custom_file_response.rb +1 -1
  50. data/lib/docspring/models/create_folder_data.rb +1 -1
  51. data/lib/docspring/models/{create_template_data.rb → create_html_template_data.rb} +3 -3
  52. data/lib/docspring/models/create_submission_batch_response.rb +1 -1
  53. data/lib/docspring/models/create_submission_batch_submissions_response.rb +1 -1
  54. data/lib/docspring/models/create_submission_data_request_data.rb +20 -20
  55. data/lib/docspring/models/create_submission_data_request_token_response.rb +1 -1
  56. data/lib/docspring/models/create_submission_data_request_token_response_token.rb +1 -1
  57. data/lib/docspring/models/create_submission_response.rb +1 -1
  58. data/lib/docspring/models/create_template_from_upload_data.rb +188 -0
  59. data/lib/docspring/models/custom_file.rb +1 -1
  60. data/lib/docspring/models/error.rb +1 -1
  61. data/lib/docspring/models/folder.rb +1 -1
  62. data/lib/docspring/models/folders_folder.rb +1 -1
  63. data/lib/docspring/models/html_template_data.rb +373 -0
  64. data/lib/docspring/models/invalid_request.rb +1 -1
  65. data/lib/docspring/models/move_folder_data.rb +1 -1
  66. data/lib/docspring/models/move_template_data.rb +1 -1
  67. data/lib/docspring/models/pending_template.rb +20 -2
  68. data/lib/docspring/models/rename_folder_data.rb +1 -1
  69. data/lib/docspring/models/submission.rb +52 -7
  70. data/lib/docspring/models/submission_action.rb +1 -6
  71. data/lib/docspring/models/submission_batch.rb +1 -1
  72. data/lib/docspring/models/submission_batch_data.rb +16 -16
  73. data/lib/docspring/models/submission_data.rb +34 -25
  74. data/lib/docspring/models/submission_data_batch_request.rb +20 -20
  75. data/lib/docspring/models/submission_data_request.rb +23 -20
  76. data/lib/docspring/models/template.rb +20 -2
  77. data/lib/docspring/models/{templatesv2_template.rb → template_data.rb} +81 -45
  78. data/lib/docspring/models/templatestemplate_idadd_fields_fields.rb +1306 -0
  79. data/lib/docspring/models/update_data_request_response.rb +1 -1
  80. data/lib/docspring/models/update_submission_data_request_data.rb +79 -79
  81. data/lib/docspring/models/update_template_data.rb +188 -0
  82. data/lib/docspring/models/update_template_response.rb +228 -0
  83. data/lib/docspring/models/upload_template_data.rb +382 -0
  84. data/lib/docspring/models/{templatesv2_template_document.rb → upload_template_data_document.rb} +3 -3
  85. data/lib/docspring/models/{templatesv2_template_document_metadata.rb → upload_template_data_document_metadata.rb} +2 -2
  86. data/lib/docspring/version.rb +2 -2
  87. data/spec/api/client_integration_spec.rb +14 -2
  88. data/spec/api/pdf_api_integration_spec.rb +49 -18
  89. data/spec/api/pdf_api_spec_original.skipped.rb +51 -11
  90. data/spec/api_client_spec.rb +1 -1
  91. data/spec/configuration_spec.rb +1 -1
  92. data/spec/models/add_fields_data_spec.rb +41 -0
  93. data/spec/models/add_fields_template_response_spec.rb +57 -0
  94. data/spec/models/authentication_error_spec.rb +1 -1
  95. data/spec/models/authentication_success_response_spec.rb +1 -1
  96. data/spec/models/combine_pdfs_data_spec.rb +5 -5
  97. data/spec/models/combined_submission_action_spec.rb +1 -1
  98. data/spec/models/combined_submission_data_spec.rb +5 -5
  99. data/spec/models/combined_submission_spec.rb +7 -1
  100. data/spec/models/create_combined_submission_response_spec.rb +1 -1
  101. data/spec/models/create_custom_file_data_spec.rb +1 -1
  102. data/spec/models/create_custom_file_response_spec.rb +1 -1
  103. data/spec/models/create_folder_data_spec.rb +1 -1
  104. data/spec/models/create_html_template_data_spec.rb +41 -0
  105. data/spec/models/create_submission_batch_response_spec.rb +1 -1
  106. data/spec/models/create_submission_batch_submissions_response_spec.rb +1 -1
  107. data/spec/models/create_submission_data_request_data_spec.rb +9 -9
  108. data/spec/models/create_submission_data_request_token_response_spec.rb +1 -1
  109. data/spec/models/create_submission_data_request_token_response_token_spec.rb +1 -1
  110. data/spec/models/create_submission_response_spec.rb +1 -1
  111. data/spec/models/{create_template_data_spec.rb → create_template_from_upload_data_spec.rb} +7 -7
  112. data/spec/models/custom_file_spec.rb +1 -1
  113. data/spec/models/error_spec.rb +1 -1
  114. data/spec/models/folder_spec.rb +1 -1
  115. data/spec/models/folders_folder_spec.rb +1 -1
  116. data/spec/models/html_template_data_spec.rb +145 -0
  117. data/spec/models/invalid_request_spec.rb +1 -1
  118. data/spec/models/move_folder_data_spec.rb +1 -1
  119. data/spec/models/move_template_data_spec.rb +1 -1
  120. data/spec/models/pending_template_spec.rb +13 -1
  121. data/spec/models/rename_folder_data_spec.rb +1 -1
  122. data/spec/models/submission_action_spec.rb +1 -1
  123. data/spec/models/submission_batch_data_spec.rb +3 -3
  124. data/spec/models/submission_batch_spec.rb +1 -1
  125. data/spec/models/submission_data_batch_request_spec.rb +5 -5
  126. data/spec/models/submission_data_request_spec.rb +13 -1
  127. data/spec/models/submission_data_spec.rb +11 -5
  128. data/spec/models/submission_spec.rb +32 -2
  129. data/spec/models/{templatesv2_template_spec.rb → template_data_spec.rb} +40 -16
  130. data/spec/models/template_spec.rb +13 -1
  131. data/spec/models/templatestemplate_idadd_fields_fields_spec.rb +589 -0
  132. data/spec/models/update_data_request_response_spec.rb +1 -1
  133. data/spec/models/update_submission_data_request_data_spec.rb +17 -17
  134. data/spec/models/update_template_data_spec.rb +41 -0
  135. data/spec/models/update_template_response_spec.rb +51 -0
  136. data/spec/models/{templatesv2_template_document_metadata_spec.rb → upload_template_data_document_metadata_spec.rb} +7 -7
  137. data/spec/models/{templatesv2_template_document_spec.rb → upload_template_data_document_spec.rb} +7 -7
  138. data/spec/models/upload_template_data_spec.rb +151 -0
  139. data/spec/spec_helper.rb +1 -1
  140. metadata +60 -32
  141. data/.swagger-codegen-ignore +0 -31
  142. data/.swagger-codegen/VERSION +0 -1
  143. data/.swagger-revision +0 -1
  144. data/.travis.yml +0 -8
@@ -0,0 +1,228 @@
1
+ =begin
2
+ #API v1
3
+
4
+ #DocSpring is a service that helps you fill out and sign PDF templates.
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 3.3.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module DocSpring
16
+ class UpdateTemplateResponse
17
+ attr_accessor :errors
18
+
19
+ attr_accessor :status
20
+
21
+ class EnumAttributeValidator
22
+ attr_reader :datatype
23
+ attr_reader :allowable_values
24
+
25
+ def initialize(datatype, allowable_values)
26
+ @allowable_values = allowable_values.map do |value|
27
+ case datatype.to_s
28
+ when /Integer/i
29
+ value.to_i
30
+ when /Float/i
31
+ value.to_f
32
+ else
33
+ value
34
+ end
35
+ end
36
+ end
37
+
38
+ def valid?(value)
39
+ !value || allowable_values.include?(value)
40
+ end
41
+ end
42
+
43
+ # Attribute mapping from ruby-style variable name to JSON key.
44
+ def self.attribute_map
45
+ {
46
+ :'errors' => :'errors',
47
+ :'status' => :'status'
48
+ }
49
+ end
50
+
51
+ # Attribute type mapping.
52
+ def self.openapi_types
53
+ {
54
+ :'errors' => :'Array<String>',
55
+ :'status' => :'String'
56
+ }
57
+ end
58
+
59
+ # Initializes the object
60
+ # @param [Hash] attributes Model attributes in the form of hash
61
+ def initialize(attributes = {})
62
+ return unless attributes.is_a?(Hash)
63
+
64
+ # convert string to symbol for hash key
65
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
66
+
67
+ if attributes.has_key?(:'errors')
68
+ if (value = attributes[:'errors']).is_a?(Array)
69
+ self.errors = value
70
+ end
71
+ end
72
+
73
+ if attributes.has_key?(:'status')
74
+ self.status = attributes[:'status']
75
+ end
76
+ end
77
+
78
+ # Show invalid properties with the reasons. Usually used together with valid?
79
+ # @return Array for valid properties with the reasons
80
+ def list_invalid_properties
81
+ invalid_properties = Array.new
82
+ invalid_properties
83
+ end
84
+
85
+ # Check to see if the all the properties in the model are valid
86
+ # @return true if the model is valid
87
+ def valid?
88
+ status_validator = EnumAttributeValidator.new('String', ['success', 'error'])
89
+ return false unless status_validator.valid?(@status)
90
+ true
91
+ end
92
+
93
+ # Custom attribute writer method checking allowed values (enum).
94
+ # @param [Object] status Object to be assigned
95
+ def status=(status)
96
+ validator = EnumAttributeValidator.new('String', ['success', 'error'])
97
+ unless validator.valid?(status)
98
+ fail ArgumentError, 'invalid value for "status", must be one of #{validator.allowable_values}.'
99
+ end
100
+ @status = status
101
+ end
102
+
103
+ # Checks equality by comparing each attribute.
104
+ # @param [Object] Object to be compared
105
+ def ==(o)
106
+ return true if self.equal?(o)
107
+ self.class == o.class &&
108
+ errors == o.errors &&
109
+ status == o.status
110
+ end
111
+
112
+ # @see the `==` method
113
+ # @param [Object] Object to be compared
114
+ def eql?(o)
115
+ self == o
116
+ end
117
+
118
+ # Calculates hash code according to all attributes.
119
+ # @return [Fixnum] Hash code
120
+ def hash
121
+ [errors, status].hash
122
+ end
123
+
124
+ # Builds the object from hash
125
+ # @param [Hash] attributes Model attributes in the form of hash
126
+ # @return [Object] Returns the model itself
127
+ def build_from_hash(attributes)
128
+ return nil unless attributes.is_a?(Hash)
129
+ self.class.openapi_types.each_pair do |key, type|
130
+ if type =~ /\AArray<(.*)>/i
131
+ # check to ensure the input is an array given that the the attribute
132
+ # is documented as an array but the input is not
133
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
134
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
135
+ end
136
+ elsif !attributes[self.class.attribute_map[key]].nil?
137
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
138
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
139
+ end
140
+
141
+ self
142
+ end
143
+
144
+ # Deserializes the data based on type
145
+ # @param string type Data type
146
+ # @param string value Value to be deserialized
147
+ # @return [Object] Deserialized data
148
+ def _deserialize(type, value)
149
+ case type.to_sym
150
+ when :DateTime
151
+ DateTime.parse(value)
152
+ when :Date
153
+ Date.parse(value)
154
+ when :String
155
+ value.to_s
156
+ when :Integer
157
+ value.to_i
158
+ when :Float
159
+ value.to_f
160
+ when :BOOLEAN
161
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
162
+ true
163
+ else
164
+ false
165
+ end
166
+ when :Object
167
+ # generic object (usually a Hash), return directly
168
+ value
169
+ when /\AArray<(?<inner_type>.+)>\z/
170
+ inner_type = Regexp.last_match[:inner_type]
171
+ value.map { |v| _deserialize(inner_type, v) }
172
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
173
+ k_type = Regexp.last_match[:k_type]
174
+ v_type = Regexp.last_match[:v_type]
175
+ {}.tap do |hash|
176
+ value.each do |k, v|
177
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
178
+ end
179
+ end
180
+ else # model
181
+ temp_model = DocSpring.const_get(type).new
182
+ temp_model.build_from_hash(value)
183
+ end
184
+ end
185
+
186
+ # Returns the string representation of the object
187
+ # @return [String] String presentation of the object
188
+ def to_s
189
+ to_hash.to_s
190
+ end
191
+
192
+ # to_body is an alias to to_hash (backward compatibility)
193
+ # @return [Hash] Returns the object in the form of hash
194
+ def to_body
195
+ to_hash
196
+ end
197
+
198
+ # Returns the object in the form of hash
199
+ # @return [Hash] Returns the object in the form of hash
200
+ def to_hash
201
+ hash = {}
202
+ self.class.attribute_map.each_pair do |attr, param|
203
+ value = self.send(attr)
204
+ next if value.nil?
205
+ hash[param] = _to_hash(value)
206
+ end
207
+ hash
208
+ end
209
+
210
+ # Outputs non-array value in the form of hash
211
+ # For object, use to_hash. Otherwise, just return the value
212
+ # @param [Object] value Any valid value
213
+ # @return [Hash] Returns the value in the form of hash
214
+ def _to_hash(value)
215
+ if value.is_a?(Array)
216
+ value.compact.map { |v| _to_hash(v) }
217
+ elsif value.is_a?(Hash)
218
+ {}.tap do |hash|
219
+ value.each { |k, v| hash[k] = _to_hash(v) }
220
+ end
221
+ elsif value.respond_to? :to_hash
222
+ value.to_hash
223
+ else
224
+ value
225
+ end
226
+ end
227
+ end
228
+ end
@@ -0,0 +1,382 @@
1
+ =begin
2
+ #API v1
3
+
4
+ #DocSpring is a service that helps you fill out and sign PDF templates.
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 3.3.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module DocSpring
16
+ class UploadTemplateData
17
+ attr_accessor :expiration_interval
18
+
19
+ attr_accessor :webhook_url
20
+
21
+ attr_accessor :scss
22
+
23
+ attr_accessor :allow_additional_properties
24
+
25
+ attr_accessor :document
26
+
27
+ attr_accessor :expire_after
28
+
29
+ attr_accessor :description
30
+
31
+ attr_accessor :public_submissions
32
+
33
+ attr_accessor :slack_webhook_url
34
+
35
+ attr_accessor :header_html
36
+
37
+ attr_accessor :public_web_form
38
+
39
+ attr_accessor :editable_submissions
40
+
41
+ attr_accessor :expire_submissions
42
+
43
+ attr_accessor :name
44
+
45
+ attr_accessor :footer_html
46
+
47
+ attr_accessor :html
48
+
49
+ attr_accessor :template_type
50
+
51
+ attr_accessor :redirect_url
52
+
53
+ class EnumAttributeValidator
54
+ attr_reader :datatype
55
+ attr_reader :allowable_values
56
+
57
+ def initialize(datatype, allowable_values)
58
+ @allowable_values = allowable_values.map do |value|
59
+ case datatype.to_s
60
+ when /Integer/i
61
+ value.to_i
62
+ when /Float/i
63
+ value.to_f
64
+ else
65
+ value
66
+ end
67
+ end
68
+ end
69
+
70
+ def valid?(value)
71
+ !value || allowable_values.include?(value)
72
+ end
73
+ end
74
+
75
+ # Attribute mapping from ruby-style variable name to JSON key.
76
+ def self.attribute_map
77
+ {
78
+ :'expiration_interval' => :'expiration_interval',
79
+ :'webhook_url' => :'webhook_url',
80
+ :'scss' => :'scss',
81
+ :'allow_additional_properties' => :'allow_additional_properties',
82
+ :'document' => :'document',
83
+ :'expire_after' => :'expire_after',
84
+ :'description' => :'description',
85
+ :'public_submissions' => :'public_submissions',
86
+ :'slack_webhook_url' => :'slack_webhook_url',
87
+ :'header_html' => :'header_html',
88
+ :'public_web_form' => :'public_web_form',
89
+ :'editable_submissions' => :'editable_submissions',
90
+ :'expire_submissions' => :'expire_submissions',
91
+ :'name' => :'name',
92
+ :'footer_html' => :'footer_html',
93
+ :'html' => :'html',
94
+ :'template_type' => :'template_type',
95
+ :'redirect_url' => :'redirect_url'
96
+ }
97
+ end
98
+
99
+ # Attribute type mapping.
100
+ def self.openapi_types
101
+ {
102
+ :'expiration_interval' => :'String',
103
+ :'webhook_url' => :'String',
104
+ :'scss' => :'String',
105
+ :'allow_additional_properties' => :'BOOLEAN',
106
+ :'document' => :'UploadTemplateDataDocument',
107
+ :'expire_after' => :'Float',
108
+ :'description' => :'String',
109
+ :'public_submissions' => :'BOOLEAN',
110
+ :'slack_webhook_url' => :'String',
111
+ :'header_html' => :'String',
112
+ :'public_web_form' => :'BOOLEAN',
113
+ :'editable_submissions' => :'BOOLEAN',
114
+ :'expire_submissions' => :'BOOLEAN',
115
+ :'name' => :'String',
116
+ :'footer_html' => :'String',
117
+ :'html' => :'String',
118
+ :'template_type' => :'String',
119
+ :'redirect_url' => :'String'
120
+ }
121
+ end
122
+
123
+ # Initializes the object
124
+ # @param [Hash] attributes Model attributes in the form of hash
125
+ def initialize(attributes = {})
126
+ return unless attributes.is_a?(Hash)
127
+
128
+ # convert string to symbol for hash key
129
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
130
+
131
+ if attributes.has_key?(:'expiration_interval')
132
+ self.expiration_interval = attributes[:'expiration_interval']
133
+ end
134
+
135
+ if attributes.has_key?(:'webhook_url')
136
+ self.webhook_url = attributes[:'webhook_url']
137
+ end
138
+
139
+ if attributes.has_key?(:'scss')
140
+ self.scss = attributes[:'scss']
141
+ end
142
+
143
+ if attributes.has_key?(:'allow_additional_properties')
144
+ self.allow_additional_properties = attributes[:'allow_additional_properties']
145
+ end
146
+
147
+ if attributes.has_key?(:'document')
148
+ self.document = attributes[:'document']
149
+ end
150
+
151
+ if attributes.has_key?(:'expire_after')
152
+ self.expire_after = attributes[:'expire_after']
153
+ end
154
+
155
+ if attributes.has_key?(:'description')
156
+ self.description = attributes[:'description']
157
+ end
158
+
159
+ if attributes.has_key?(:'public_submissions')
160
+ self.public_submissions = attributes[:'public_submissions']
161
+ end
162
+
163
+ if attributes.has_key?(:'slack_webhook_url')
164
+ self.slack_webhook_url = attributes[:'slack_webhook_url']
165
+ end
166
+
167
+ if attributes.has_key?(:'header_html')
168
+ self.header_html = attributes[:'header_html']
169
+ end
170
+
171
+ if attributes.has_key?(:'public_web_form')
172
+ self.public_web_form = attributes[:'public_web_form']
173
+ end
174
+
175
+ if attributes.has_key?(:'editable_submissions')
176
+ self.editable_submissions = attributes[:'editable_submissions']
177
+ end
178
+
179
+ if attributes.has_key?(:'expire_submissions')
180
+ self.expire_submissions = attributes[:'expire_submissions']
181
+ end
182
+
183
+ if attributes.has_key?(:'name')
184
+ self.name = attributes[:'name']
185
+ end
186
+
187
+ if attributes.has_key?(:'footer_html')
188
+ self.footer_html = attributes[:'footer_html']
189
+ end
190
+
191
+ if attributes.has_key?(:'html')
192
+ self.html = attributes[:'html']
193
+ end
194
+
195
+ if attributes.has_key?(:'template_type')
196
+ self.template_type = attributes[:'template_type']
197
+ end
198
+
199
+ if attributes.has_key?(:'redirect_url')
200
+ self.redirect_url = attributes[:'redirect_url']
201
+ end
202
+ end
203
+
204
+ # Show invalid properties with the reasons. Usually used together with valid?
205
+ # @return Array for valid properties with the reasons
206
+ def list_invalid_properties
207
+ invalid_properties = Array.new
208
+ invalid_properties
209
+ end
210
+
211
+ # Check to see if the all the properties in the model are valid
212
+ # @return true if the model is valid
213
+ def valid?
214
+ expiration_interval_validator = EnumAttributeValidator.new('String', ['minutes', 'hours', 'days'])
215
+ return false unless expiration_interval_validator.valid?(@expiration_interval)
216
+ template_type_validator = EnumAttributeValidator.new('String', ['pdf', 'html'])
217
+ return false unless template_type_validator.valid?(@template_type)
218
+ true
219
+ end
220
+
221
+ # Custom attribute writer method checking allowed values (enum).
222
+ # @param [Object] expiration_interval Object to be assigned
223
+ def expiration_interval=(expiration_interval)
224
+ validator = EnumAttributeValidator.new('String', ['minutes', 'hours', 'days'])
225
+ unless validator.valid?(expiration_interval)
226
+ fail ArgumentError, 'invalid value for "expiration_interval", must be one of #{validator.allowable_values}.'
227
+ end
228
+ @expiration_interval = expiration_interval
229
+ end
230
+
231
+ # Custom attribute writer method checking allowed values (enum).
232
+ # @param [Object] template_type Object to be assigned
233
+ def template_type=(template_type)
234
+ validator = EnumAttributeValidator.new('String', ['pdf', 'html'])
235
+ unless validator.valid?(template_type)
236
+ fail ArgumentError, 'invalid value for "template_type", must be one of #{validator.allowable_values}.'
237
+ end
238
+ @template_type = template_type
239
+ end
240
+
241
+ # Checks equality by comparing each attribute.
242
+ # @param [Object] Object to be compared
243
+ def ==(o)
244
+ return true if self.equal?(o)
245
+ self.class == o.class &&
246
+ expiration_interval == o.expiration_interval &&
247
+ webhook_url == o.webhook_url &&
248
+ scss == o.scss &&
249
+ allow_additional_properties == o.allow_additional_properties &&
250
+ document == o.document &&
251
+ expire_after == o.expire_after &&
252
+ description == o.description &&
253
+ public_submissions == o.public_submissions &&
254
+ slack_webhook_url == o.slack_webhook_url &&
255
+ header_html == o.header_html &&
256
+ public_web_form == o.public_web_form &&
257
+ editable_submissions == o.editable_submissions &&
258
+ expire_submissions == o.expire_submissions &&
259
+ name == o.name &&
260
+ footer_html == o.footer_html &&
261
+ html == o.html &&
262
+ template_type == o.template_type &&
263
+ redirect_url == o.redirect_url
264
+ end
265
+
266
+ # @see the `==` method
267
+ # @param [Object] Object to be compared
268
+ def eql?(o)
269
+ self == o
270
+ end
271
+
272
+ # Calculates hash code according to all attributes.
273
+ # @return [Fixnum] Hash code
274
+ def hash
275
+ [expiration_interval, webhook_url, scss, allow_additional_properties, document, expire_after, description, public_submissions, slack_webhook_url, header_html, public_web_form, editable_submissions, expire_submissions, name, footer_html, html, template_type, redirect_url].hash
276
+ end
277
+
278
+ # Builds the object from hash
279
+ # @param [Hash] attributes Model attributes in the form of hash
280
+ # @return [Object] Returns the model itself
281
+ def build_from_hash(attributes)
282
+ return nil unless attributes.is_a?(Hash)
283
+ self.class.openapi_types.each_pair do |key, type|
284
+ if type =~ /\AArray<(.*)>/i
285
+ # check to ensure the input is an array given that the the attribute
286
+ # is documented as an array but the input is not
287
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
288
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
289
+ end
290
+ elsif !attributes[self.class.attribute_map[key]].nil?
291
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
292
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
293
+ end
294
+
295
+ self
296
+ end
297
+
298
+ # Deserializes the data based on type
299
+ # @param string type Data type
300
+ # @param string value Value to be deserialized
301
+ # @return [Object] Deserialized data
302
+ def _deserialize(type, value)
303
+ case type.to_sym
304
+ when :DateTime
305
+ DateTime.parse(value)
306
+ when :Date
307
+ Date.parse(value)
308
+ when :String
309
+ value.to_s
310
+ when :Integer
311
+ value.to_i
312
+ when :Float
313
+ value.to_f
314
+ when :BOOLEAN
315
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
316
+ true
317
+ else
318
+ false
319
+ end
320
+ when :Object
321
+ # generic object (usually a Hash), return directly
322
+ value
323
+ when /\AArray<(?<inner_type>.+)>\z/
324
+ inner_type = Regexp.last_match[:inner_type]
325
+ value.map { |v| _deserialize(inner_type, v) }
326
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
327
+ k_type = Regexp.last_match[:k_type]
328
+ v_type = Regexp.last_match[:v_type]
329
+ {}.tap do |hash|
330
+ value.each do |k, v|
331
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
332
+ end
333
+ end
334
+ else # model
335
+ temp_model = DocSpring.const_get(type).new
336
+ temp_model.build_from_hash(value)
337
+ end
338
+ end
339
+
340
+ # Returns the string representation of the object
341
+ # @return [String] String presentation of the object
342
+ def to_s
343
+ to_hash.to_s
344
+ end
345
+
346
+ # to_body is an alias to to_hash (backward compatibility)
347
+ # @return [Hash] Returns the object in the form of hash
348
+ def to_body
349
+ to_hash
350
+ end
351
+
352
+ # Returns the object in the form of hash
353
+ # @return [Hash] Returns the object in the form of hash
354
+ def to_hash
355
+ hash = {}
356
+ self.class.attribute_map.each_pair do |attr, param|
357
+ value = self.send(attr)
358
+ next if value.nil?
359
+ hash[param] = _to_hash(value)
360
+ end
361
+ hash
362
+ end
363
+
364
+ # Outputs non-array value in the form of hash
365
+ # For object, use to_hash. Otherwise, just return the value
366
+ # @param [Object] value Any valid value
367
+ # @return [Hash] Returns the value in the form of hash
368
+ def _to_hash(value)
369
+ if value.is_a?(Array)
370
+ value.compact.map { |v| _to_hash(v) }
371
+ elsif value.is_a?(Hash)
372
+ {}.tap do |hash|
373
+ value.each { |k, v| hash[k] = _to_hash(v) }
374
+ end
375
+ elsif value.respond_to? :to_hash
376
+ value.to_hash
377
+ else
378
+ value
379
+ end
380
+ end
381
+ end
382
+ end