docspring 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +39 -0
  3. data/.openapi-generator-ignore +23 -0
  4. data/.openapi-generator/VERSION +1 -0
  5. data/.rspec +2 -0
  6. data/.rubocop.yml +154 -0
  7. data/.swagger-codegen-ignore +31 -0
  8. data/.swagger-codegen/VERSION +1 -0
  9. data/.swagger-revision +1 -0
  10. data/.travis.yml +8 -0
  11. data/CHANGELOG.md +48 -0
  12. data/Gemfile +8 -0
  13. data/Gemfile.lock +80 -0
  14. data/LICENSE +7 -0
  15. data/README.md +162 -0
  16. data/Rakefile +10 -0
  17. data/docs/AuthenticationError.md +9 -0
  18. data/docs/AuthenticationSuccessResponse.md +8 -0
  19. data/docs/CombinePdfsData.md +12 -0
  20. data/docs/CombinedSubmission.md +16 -0
  21. data/docs/CombinedSubmissionAction.md +13 -0
  22. data/docs/CombinedSubmissionData.md +11 -0
  23. data/docs/CreateCombinedSubmissionResponse.md +10 -0
  24. data/docs/CreateCustomFileData.md +8 -0
  25. data/docs/CreateCustomFileResponse.md +10 -0
  26. data/docs/CreateFolderData.md +8 -0
  27. data/docs/CreateSubmissionBatchResponse.md +12 -0
  28. data/docs/CreateSubmissionBatchSubmissionsResponse.md +10 -0
  29. data/docs/CreateSubmissionDataRequestData.md +20 -0
  30. data/docs/CreateSubmissionDataRequestTokenResponse.md +10 -0
  31. data/docs/CreateSubmissionDataRequestTokenResponseToken.md +11 -0
  32. data/docs/CreateSubmissionResponse.md +10 -0
  33. data/docs/CreateTemplateData.md +8 -0
  34. data/docs/CustomFile.md +9 -0
  35. data/docs/Error.md +9 -0
  36. data/docs/Folder.md +11 -0
  37. data/docs/FoldersFolder.md +9 -0
  38. data/docs/InvalidRequest.md +9 -0
  39. data/docs/MoveFolderData.md +8 -0
  40. data/docs/MoveTemplateData.md +8 -0
  41. data/docs/PDFApi.md +1385 -0
  42. data/docs/PendingTemplate.md +22 -0
  43. data/docs/RenameFolderData.md +8 -0
  44. data/docs/Submission.md +21 -0
  45. data/docs/SubmissionAction.md +13 -0
  46. data/docs/SubmissionBatch.md +16 -0
  47. data/docs/SubmissionBatchData.md +11 -0
  48. data/docs/SubmissionData.md +13 -0
  49. data/docs/SubmissionDataBatchRequest.md +13 -0
  50. data/docs/SubmissionDataRequest.md +24 -0
  51. data/docs/Template.md +25 -0
  52. data/docs/Templatesv2Template.md +19 -0
  53. data/docs/Templatesv2TemplateDocument.md +10 -0
  54. data/docs/Templatesv2TemplateDocumentMetadata.md +10 -0
  55. data/docs/UpdateDataRequestResponse.md +10 -0
  56. data/docs/UpdateSubmissionDataRequestData.md +20 -0
  57. data/docspring.gemspec +47 -0
  58. data/git_push.sh +55 -0
  59. data/lib/docspring.rb +82 -0
  60. data/lib/docspring/api/client.rb +174 -0
  61. data/lib/docspring/api/pdf_api.rb +1481 -0
  62. data/lib/docspring/api_client.rb +406 -0
  63. data/lib/docspring/api_error.rb +38 -0
  64. data/lib/docspring/configuration.rb +230 -0
  65. data/lib/docspring/models/authentication_error.rb +231 -0
  66. data/lib/docspring/models/authentication_success_response.rb +217 -0
  67. data/lib/docspring/models/combine_pdfs_data.rb +226 -0
  68. data/lib/docspring/models/combined_submission.rb +295 -0
  69. data/lib/docspring/models/combined_submission_action.rb +316 -0
  70. data/lib/docspring/models/combined_submission_data.rb +217 -0
  71. data/lib/docspring/models/create_combined_submission_response.rb +237 -0
  72. data/lib/docspring/models/create_custom_file_data.rb +207 -0
  73. data/lib/docspring/models/create_custom_file_response.rb +237 -0
  74. data/lib/docspring/models/create_folder_data.rb +188 -0
  75. data/lib/docspring/models/create_submission_batch_response.rb +257 -0
  76. data/lib/docspring/models/create_submission_batch_submissions_response.rb +237 -0
  77. data/lib/docspring/models/create_submission_data_request_data.rb +339 -0
  78. data/lib/docspring/models/create_submission_data_request_token_response.rb +237 -0
  79. data/lib/docspring/models/create_submission_data_request_token_response_token.rb +210 -0
  80. data/lib/docspring/models/create_submission_response.rb +237 -0
  81. data/lib/docspring/models/create_template_data.rb +188 -0
  82. data/lib/docspring/models/custom_file.rb +192 -0
  83. data/lib/docspring/models/error.rb +236 -0
  84. data/lib/docspring/models/folder.rb +210 -0
  85. data/lib/docspring/models/folders_folder.rb +192 -0
  86. data/lib/docspring/models/invalid_request.rb +238 -0
  87. data/lib/docspring/models/move_folder_data.rb +183 -0
  88. data/lib/docspring/models/move_template_data.rb +183 -0
  89. data/lib/docspring/models/pending_template.rb +343 -0
  90. data/lib/docspring/models/rename_folder_data.rb +188 -0
  91. data/lib/docspring/models/submission.rb +358 -0
  92. data/lib/docspring/models/submission_action.rb +316 -0
  93. data/lib/docspring/models/submission_batch.rb +291 -0
  94. data/lib/docspring/models/submission_batch_data.rb +217 -0
  95. data/lib/docspring/models/submission_data.rb +235 -0
  96. data/lib/docspring/models/submission_data_batch_request.rb +228 -0
  97. data/lib/docspring/models/submission_data_request.rb +422 -0
  98. data/lib/docspring/models/template.rb +372 -0
  99. data/lib/docspring/models/templatesv2_template.rb +316 -0
  100. data/lib/docspring/models/templatesv2_template_document.rb +235 -0
  101. data/lib/docspring/models/templatesv2_template_document_metadata.rb +235 -0
  102. data/lib/docspring/models/update_data_request_response.rb +237 -0
  103. data/lib/docspring/models/update_submission_data_request_data.rb +339 -0
  104. data/lib/docspring/version.rb +15 -0
  105. data/spec/api/client_integration_spec.rb +259 -0
  106. data/spec/api/pdf_api_integration_spec.rb +377 -0
  107. data/spec/api/pdf_api_spec_original.skipped.rb +397 -0
  108. data/spec/api_client_spec.rb +226 -0
  109. data/spec/configuration_spec.rb +53 -0
  110. data/spec/models/authentication_error_spec.rb +51 -0
  111. data/spec/models/authentication_success_response_spec.rb +45 -0
  112. data/spec/models/combine_pdfs_data_spec.rb +65 -0
  113. data/spec/models/combined_submission_action_spec.rb +83 -0
  114. data/spec/models/combined_submission_data_spec.rb +59 -0
  115. data/spec/models/combined_submission_spec.rb +93 -0
  116. data/spec/models/create_combined_submission_response_spec.rb +57 -0
  117. data/spec/models/create_custom_file_data_spec.rb +41 -0
  118. data/spec/models/create_custom_file_response_spec.rb +57 -0
  119. data/spec/models/create_folder_data_spec.rb +41 -0
  120. data/spec/models/create_submission_batch_response_spec.rb +69 -0
  121. data/spec/models/create_submission_batch_submissions_response_spec.rb +57 -0
  122. data/spec/models/create_submission_data_request_data_spec.rb +121 -0
  123. data/spec/models/create_submission_data_request_token_response_spec.rb +57 -0
  124. data/spec/models/create_submission_data_request_token_response_token_spec.rb +59 -0
  125. data/spec/models/create_submission_response_spec.rb +57 -0
  126. data/spec/models/create_template_data_spec.rb +41 -0
  127. data/spec/models/custom_file_spec.rb +47 -0
  128. data/spec/models/error_spec.rb +51 -0
  129. data/spec/models/folder_spec.rb +59 -0
  130. data/spec/models/folders_folder_spec.rb +47 -0
  131. data/spec/models/invalid_request_spec.rb +51 -0
  132. data/spec/models/move_folder_data_spec.rb +41 -0
  133. data/spec/models/move_template_data_spec.rb +41 -0
  134. data/spec/models/pending_template_spec.rb +129 -0
  135. data/spec/models/rename_folder_data_spec.rb +41 -0
  136. data/spec/models/submission_action_spec.rb +83 -0
  137. data/spec/models/submission_batch_data_spec.rb +59 -0
  138. data/spec/models/submission_batch_spec.rb +93 -0
  139. data/spec/models/submission_data_batch_request_spec.rb +71 -0
  140. data/spec/models/submission_data_request_spec.rb +149 -0
  141. data/spec/models/submission_data_spec.rb +71 -0
  142. data/spec/models/submission_spec.rb +123 -0
  143. data/spec/models/template_spec.rb +147 -0
  144. data/spec/models/templatesv2_template_document_metadata_spec.rb +57 -0
  145. data/spec/models/templatesv2_template_document_spec.rb +57 -0
  146. data/spec/models/templatesv2_template_spec.rb +111 -0
  147. data/spec/models/update_data_request_response_spec.rb +57 -0
  148. data/spec/models/update_submission_data_request_data_spec.rb +121 -0
  149. data/spec/spec_helper.rb +117 -0
  150. metadata +430 -0
@@ -0,0 +1,295 @@
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-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module DocSpring
16
+ class CombinedSubmission
17
+ attr_accessor :metadata
18
+
19
+ attr_accessor :expired
20
+
21
+ attr_accessor :expires_at
22
+
23
+ attr_accessor :source_pdfs
24
+
25
+ attr_accessor :download_url
26
+
27
+ attr_accessor :submission_ids
28
+
29
+ attr_accessor :id
30
+
31
+ attr_accessor :state
32
+
33
+ attr_accessor :actions
34
+
35
+ class EnumAttributeValidator
36
+ attr_reader :datatype
37
+ attr_reader :allowable_values
38
+
39
+ def initialize(datatype, allowable_values)
40
+ @allowable_values = allowable_values.map do |value|
41
+ case datatype.to_s
42
+ when /Integer/i
43
+ value.to_i
44
+ when /Float/i
45
+ value.to_f
46
+ else
47
+ value
48
+ end
49
+ end
50
+ end
51
+
52
+ def valid?(value)
53
+ !value || allowable_values.include?(value)
54
+ end
55
+ end
56
+
57
+ # Attribute mapping from ruby-style variable name to JSON key.
58
+ def self.attribute_map
59
+ {
60
+ :'metadata' => :'metadata',
61
+ :'expired' => :'expired',
62
+ :'expires_at' => :'expires_at',
63
+ :'source_pdfs' => :'source_pdfs',
64
+ :'download_url' => :'download_url',
65
+ :'submission_ids' => :'submission_ids',
66
+ :'id' => :'id',
67
+ :'state' => :'state',
68
+ :'actions' => :'actions'
69
+ }
70
+ end
71
+
72
+ # Attribute type mapping.
73
+ def self.openapi_types
74
+ {
75
+ :'metadata' => :'Object',
76
+ :'expired' => :'BOOLEAN',
77
+ :'expires_at' => :'String',
78
+ :'source_pdfs' => :'Array<Object>',
79
+ :'download_url' => :'String',
80
+ :'submission_ids' => :'Array<String>',
81
+ :'id' => :'String',
82
+ :'state' => :'String',
83
+ :'actions' => :'Array<CombinedSubmissionAction>'
84
+ }
85
+ end
86
+
87
+ # Initializes the object
88
+ # @param [Hash] attributes Model attributes in the form of hash
89
+ def initialize(attributes = {})
90
+ return unless attributes.is_a?(Hash)
91
+
92
+ # convert string to symbol for hash key
93
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
94
+
95
+ if attributes.has_key?(:'metadata')
96
+ self.metadata = attributes[:'metadata']
97
+ end
98
+
99
+ if attributes.has_key?(:'expired')
100
+ self.expired = attributes[:'expired']
101
+ end
102
+
103
+ if attributes.has_key?(:'expires_at')
104
+ self.expires_at = attributes[:'expires_at']
105
+ end
106
+
107
+ if attributes.has_key?(:'source_pdfs')
108
+ if (value = attributes[:'source_pdfs']).is_a?(Array)
109
+ self.source_pdfs = value
110
+ end
111
+ end
112
+
113
+ if attributes.has_key?(:'download_url')
114
+ self.download_url = attributes[:'download_url']
115
+ end
116
+
117
+ if attributes.has_key?(:'submission_ids')
118
+ if (value = attributes[:'submission_ids']).is_a?(Array)
119
+ self.submission_ids = value
120
+ end
121
+ end
122
+
123
+ if attributes.has_key?(:'id')
124
+ self.id = attributes[:'id']
125
+ end
126
+
127
+ if attributes.has_key?(:'state')
128
+ self.state = attributes[:'state']
129
+ end
130
+
131
+ if attributes.has_key?(:'actions')
132
+ if (value = attributes[:'actions']).is_a?(Array)
133
+ self.actions = value
134
+ end
135
+ end
136
+ end
137
+
138
+ # Show invalid properties with the reasons. Usually used together with valid?
139
+ # @return Array for valid properties with the reasons
140
+ def list_invalid_properties
141
+ invalid_properties = Array.new
142
+ invalid_properties
143
+ end
144
+
145
+ # Check to see if the all the properties in the model are valid
146
+ # @return true if the model is valid
147
+ def valid?
148
+ state_validator = EnumAttributeValidator.new('String', ['pending', 'processed', 'error'])
149
+ return false unless state_validator.valid?(@state)
150
+ true
151
+ end
152
+
153
+ # Custom attribute writer method checking allowed values (enum).
154
+ # @param [Object] state Object to be assigned
155
+ def state=(state)
156
+ validator = EnumAttributeValidator.new('String', ['pending', 'processed', 'error'])
157
+ unless validator.valid?(state)
158
+ fail ArgumentError, 'invalid value for "state", must be one of #{validator.allowable_values}.'
159
+ end
160
+ @state = state
161
+ end
162
+
163
+ # Checks equality by comparing each attribute.
164
+ # @param [Object] Object to be compared
165
+ def ==(o)
166
+ return true if self.equal?(o)
167
+ self.class == o.class &&
168
+ metadata == o.metadata &&
169
+ expired == o.expired &&
170
+ expires_at == o.expires_at &&
171
+ source_pdfs == o.source_pdfs &&
172
+ download_url == o.download_url &&
173
+ submission_ids == o.submission_ids &&
174
+ id == o.id &&
175
+ state == o.state &&
176
+ actions == o.actions
177
+ end
178
+
179
+ # @see the `==` method
180
+ # @param [Object] Object to be compared
181
+ def eql?(o)
182
+ self == o
183
+ end
184
+
185
+ # Calculates hash code according to all attributes.
186
+ # @return [Fixnum] Hash code
187
+ def hash
188
+ [metadata, expired, expires_at, source_pdfs, download_url, submission_ids, id, state, actions].hash
189
+ end
190
+
191
+ # Builds the object from hash
192
+ # @param [Hash] attributes Model attributes in the form of hash
193
+ # @return [Object] Returns the model itself
194
+ def build_from_hash(attributes)
195
+ return nil unless attributes.is_a?(Hash)
196
+ self.class.openapi_types.each_pair do |key, type|
197
+ if type =~ /\AArray<(.*)>/i
198
+ # check to ensure the input is an array given that the the attribute
199
+ # is documented as an array but the input is not
200
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
201
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
202
+ end
203
+ elsif !attributes[self.class.attribute_map[key]].nil?
204
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
205
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
206
+ end
207
+
208
+ self
209
+ end
210
+
211
+ # Deserializes the data based on type
212
+ # @param string type Data type
213
+ # @param string value Value to be deserialized
214
+ # @return [Object] Deserialized data
215
+ def _deserialize(type, value)
216
+ case type.to_sym
217
+ when :DateTime
218
+ DateTime.parse(value)
219
+ when :Date
220
+ Date.parse(value)
221
+ when :String
222
+ value.to_s
223
+ when :Integer
224
+ value.to_i
225
+ when :Float
226
+ value.to_f
227
+ when :BOOLEAN
228
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
229
+ true
230
+ else
231
+ false
232
+ end
233
+ when :Object
234
+ # generic object (usually a Hash), return directly
235
+ value
236
+ when /\AArray<(?<inner_type>.+)>\z/
237
+ inner_type = Regexp.last_match[:inner_type]
238
+ value.map { |v| _deserialize(inner_type, v) }
239
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
240
+ k_type = Regexp.last_match[:k_type]
241
+ v_type = Regexp.last_match[:v_type]
242
+ {}.tap do |hash|
243
+ value.each do |k, v|
244
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
245
+ end
246
+ end
247
+ else # model
248
+ temp_model = DocSpring.const_get(type).new
249
+ temp_model.build_from_hash(value)
250
+ end
251
+ end
252
+
253
+ # Returns the string representation of the object
254
+ # @return [String] String presentation of the object
255
+ def to_s
256
+ to_hash.to_s
257
+ end
258
+
259
+ # to_body is an alias to to_hash (backward compatibility)
260
+ # @return [Hash] Returns the object in the form of hash
261
+ def to_body
262
+ to_hash
263
+ end
264
+
265
+ # Returns the object in the form of hash
266
+ # @return [Hash] Returns the object in the form of hash
267
+ def to_hash
268
+ hash = {}
269
+ self.class.attribute_map.each_pair do |attr, param|
270
+ value = self.send(attr)
271
+ next if value.nil?
272
+ hash[param] = _to_hash(value)
273
+ end
274
+ hash
275
+ end
276
+
277
+ # Outputs non-array value in the form of hash
278
+ # For object, use to_hash. Otherwise, just return the value
279
+ # @param [Object] value Any valid value
280
+ # @return [Hash] Returns the value in the form of hash
281
+ def _to_hash(value)
282
+ if value.is_a?(Array)
283
+ value.compact.map { |v| _to_hash(v) }
284
+ elsif value.is_a?(Hash)
285
+ {}.tap do |hash|
286
+ value.each { |k, v| hash[k] = _to_hash(v) }
287
+ end
288
+ elsif value.respond_to? :to_hash
289
+ value.to_hash
290
+ else
291
+ value
292
+ end
293
+ end
294
+ end
295
+ end
@@ -0,0 +1,316 @@
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-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module DocSpring
16
+ class CombinedSubmissionAction
17
+ attr_accessor :id
18
+
19
+ attr_accessor :integration_id
20
+
21
+ attr_accessor :state
22
+
23
+ attr_accessor :action_category
24
+
25
+ attr_accessor :action_type
26
+
27
+ attr_accessor :result_data
28
+
29
+ class EnumAttributeValidator
30
+ attr_reader :datatype
31
+ attr_reader :allowable_values
32
+
33
+ def initialize(datatype, allowable_values)
34
+ @allowable_values = allowable_values.map do |value|
35
+ case datatype.to_s
36
+ when /Integer/i
37
+ value.to_i
38
+ when /Float/i
39
+ value.to_f
40
+ else
41
+ value
42
+ end
43
+ end
44
+ end
45
+
46
+ def valid?(value)
47
+ !value || allowable_values.include?(value)
48
+ end
49
+ end
50
+
51
+ # Attribute mapping from ruby-style variable name to JSON key.
52
+ def self.attribute_map
53
+ {
54
+ :'id' => :'id',
55
+ :'integration_id' => :'integration_id',
56
+ :'state' => :'state',
57
+ :'action_category' => :'action_category',
58
+ :'action_type' => :'action_type',
59
+ :'result_data' => :'result_data'
60
+ }
61
+ end
62
+
63
+ # Attribute type mapping.
64
+ def self.openapi_types
65
+ {
66
+ :'id' => :'String',
67
+ :'integration_id' => :'String',
68
+ :'state' => :'String',
69
+ :'action_category' => :'String',
70
+ :'action_type' => :'String',
71
+ :'result_data' => :'Object'
72
+ }
73
+ end
74
+
75
+ # Initializes the object
76
+ # @param [Hash] attributes Model attributes in the form of hash
77
+ def initialize(attributes = {})
78
+ return unless attributes.is_a?(Hash)
79
+
80
+ # convert string to symbol for hash key
81
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
82
+
83
+ if attributes.has_key?(:'id')
84
+ self.id = attributes[:'id']
85
+ end
86
+
87
+ if attributes.has_key?(:'integration_id')
88
+ self.integration_id = attributes[:'integration_id']
89
+ end
90
+
91
+ if attributes.has_key?(:'state')
92
+ self.state = attributes[:'state']
93
+ end
94
+
95
+ if attributes.has_key?(:'action_category')
96
+ self.action_category = attributes[:'action_category']
97
+ end
98
+
99
+ if attributes.has_key?(:'action_type')
100
+ self.action_type = attributes[:'action_type']
101
+ end
102
+
103
+ if attributes.has_key?(:'result_data')
104
+ self.result_data = attributes[:'result_data']
105
+ end
106
+ end
107
+
108
+ # Show invalid properties with the reasons. Usually used together with valid?
109
+ # @return Array for valid properties with the reasons
110
+ def list_invalid_properties
111
+ invalid_properties = Array.new
112
+ if @id.nil?
113
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
114
+ end
115
+
116
+ if @integration_id.nil?
117
+ invalid_properties.push('invalid value for "integration_id", integration_id cannot be nil.')
118
+ end
119
+
120
+ if @state.nil?
121
+ invalid_properties.push('invalid value for "state", state cannot be nil.')
122
+ end
123
+
124
+ if @action_category.nil?
125
+ invalid_properties.push('invalid value for "action_category", action_category cannot be nil.')
126
+ end
127
+
128
+ if @action_type.nil?
129
+ invalid_properties.push('invalid value for "action_type", action_type cannot be nil.')
130
+ end
131
+
132
+ if @result_data.nil?
133
+ invalid_properties.push('invalid value for "result_data", result_data cannot be nil.')
134
+ end
135
+
136
+ invalid_properties
137
+ end
138
+
139
+ # Check to see if the all the properties in the model are valid
140
+ # @return true if the model is valid
141
+ def valid?
142
+ return false if @id.nil?
143
+ return false if @integration_id.nil?
144
+ return false if @state.nil?
145
+ state_validator = EnumAttributeValidator.new('String', ['pending', 'processed', 'failed', 'error'])
146
+ return false unless state_validator.valid?(@state)
147
+ return false if @action_category.nil?
148
+ action_category_validator = EnumAttributeValidator.new('String', ['notification', 'file_upload'])
149
+ return false unless action_category_validator.valid?(@action_category)
150
+ return false if @action_type.nil?
151
+ action_type_validator = EnumAttributeValidator.new('String', ['webhook', 'slack_webhook', 'email', 'aws_s3_upload'])
152
+ return false unless action_type_validator.valid?(@action_type)
153
+ return false if @result_data.nil?
154
+ true
155
+ end
156
+
157
+ # Custom attribute writer method checking allowed values (enum).
158
+ # @param [Object] state Object to be assigned
159
+ def state=(state)
160
+ validator = EnumAttributeValidator.new('String', ['pending', 'processed', 'failed', 'error'])
161
+ unless validator.valid?(state)
162
+ fail ArgumentError, 'invalid value for "state", must be one of #{validator.allowable_values}.'
163
+ end
164
+ @state = state
165
+ end
166
+
167
+ # Custom attribute writer method checking allowed values (enum).
168
+ # @param [Object] action_category Object to be assigned
169
+ def action_category=(action_category)
170
+ validator = EnumAttributeValidator.new('String', ['notification', 'file_upload'])
171
+ unless validator.valid?(action_category)
172
+ fail ArgumentError, 'invalid value for "action_category", must be one of #{validator.allowable_values}.'
173
+ end
174
+ @action_category = action_category
175
+ end
176
+
177
+ # Custom attribute writer method checking allowed values (enum).
178
+ # @param [Object] action_type Object to be assigned
179
+ def action_type=(action_type)
180
+ validator = EnumAttributeValidator.new('String', ['webhook', 'slack_webhook', 'email', 'aws_s3_upload'])
181
+ unless validator.valid?(action_type)
182
+ fail ArgumentError, 'invalid value for "action_type", must be one of #{validator.allowable_values}.'
183
+ end
184
+ @action_type = action_type
185
+ end
186
+
187
+ # Checks equality by comparing each attribute.
188
+ # @param [Object] Object to be compared
189
+ def ==(o)
190
+ return true if self.equal?(o)
191
+ self.class == o.class &&
192
+ id == o.id &&
193
+ integration_id == o.integration_id &&
194
+ state == o.state &&
195
+ action_category == o.action_category &&
196
+ action_type == o.action_type &&
197
+ result_data == o.result_data
198
+ end
199
+
200
+ # @see the `==` method
201
+ # @param [Object] Object to be compared
202
+ def eql?(o)
203
+ self == o
204
+ end
205
+
206
+ # Calculates hash code according to all attributes.
207
+ # @return [Fixnum] Hash code
208
+ def hash
209
+ [id, integration_id, state, action_category, action_type, result_data].hash
210
+ end
211
+
212
+ # Builds the object from hash
213
+ # @param [Hash] attributes Model attributes in the form of hash
214
+ # @return [Object] Returns the model itself
215
+ def build_from_hash(attributes)
216
+ return nil unless attributes.is_a?(Hash)
217
+ self.class.openapi_types.each_pair do |key, type|
218
+ if type =~ /\AArray<(.*)>/i
219
+ # check to ensure the input is an array given that the the attribute
220
+ # is documented as an array but the input is not
221
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
222
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
223
+ end
224
+ elsif !attributes[self.class.attribute_map[key]].nil?
225
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
226
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
227
+ end
228
+
229
+ self
230
+ end
231
+
232
+ # Deserializes the data based on type
233
+ # @param string type Data type
234
+ # @param string value Value to be deserialized
235
+ # @return [Object] Deserialized data
236
+ def _deserialize(type, value)
237
+ case type.to_sym
238
+ when :DateTime
239
+ DateTime.parse(value)
240
+ when :Date
241
+ Date.parse(value)
242
+ when :String
243
+ value.to_s
244
+ when :Integer
245
+ value.to_i
246
+ when :Float
247
+ value.to_f
248
+ when :BOOLEAN
249
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
250
+ true
251
+ else
252
+ false
253
+ end
254
+ when :Object
255
+ # generic object (usually a Hash), return directly
256
+ value
257
+ when /\AArray<(?<inner_type>.+)>\z/
258
+ inner_type = Regexp.last_match[:inner_type]
259
+ value.map { |v| _deserialize(inner_type, v) }
260
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
261
+ k_type = Regexp.last_match[:k_type]
262
+ v_type = Regexp.last_match[:v_type]
263
+ {}.tap do |hash|
264
+ value.each do |k, v|
265
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
266
+ end
267
+ end
268
+ else # model
269
+ temp_model = DocSpring.const_get(type).new
270
+ temp_model.build_from_hash(value)
271
+ end
272
+ end
273
+
274
+ # Returns the string representation of the object
275
+ # @return [String] String presentation of the object
276
+ def to_s
277
+ to_hash.to_s
278
+ end
279
+
280
+ # to_body is an alias to to_hash (backward compatibility)
281
+ # @return [Hash] Returns the object in the form of hash
282
+ def to_body
283
+ to_hash
284
+ end
285
+
286
+ # Returns the object in the form of hash
287
+ # @return [Hash] Returns the object in the form of hash
288
+ def to_hash
289
+ hash = {}
290
+ self.class.attribute_map.each_pair do |attr, param|
291
+ value = self.send(attr)
292
+ next if value.nil?
293
+ hash[param] = _to_hash(value)
294
+ end
295
+ hash
296
+ end
297
+
298
+ # Outputs non-array value in the form of hash
299
+ # For object, use to_hash. Otherwise, just return the value
300
+ # @param [Object] value Any valid value
301
+ # @return [Hash] Returns the value in the form of hash
302
+ def _to_hash(value)
303
+ if value.is_a?(Array)
304
+ value.compact.map { |v| _to_hash(v) }
305
+ elsif value.is_a?(Hash)
306
+ {}.tap do |hash|
307
+ value.each { |k, v| hash[k] = _to_hash(v) }
308
+ end
309
+ elsif value.respond_to? :to_hash
310
+ value.to_hash
311
+ else
312
+ value
313
+ end
314
+ end
315
+ end
316
+ end