cloudmersive-documentai-api-client 2.2.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 (96) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/README.md +140 -0
  4. data/Rakefile +8 -0
  5. data/cloudmersive-documentai-api-client.gemspec +45 -0
  6. data/docs/AdvancedExtractClassificationRequest.md +10 -0
  7. data/docs/AdvancedExtractFieldsRequest.md +10 -0
  8. data/docs/AnalyzeApi.md +64 -0
  9. data/docs/DocumentAdvancedClassificationResult.md +9 -0
  10. data/docs/DocumentCategories.md +9 -0
  11. data/docs/DocumentClassificationResult.md +9 -0
  12. data/docs/DocumentPolicyRequest.md +9 -0
  13. data/docs/DocumentPolicyResult.md +10 -0
  14. data/docs/ExtractApi.md +534 -0
  15. data/docs/ExtractBarcodesAiResponse.md +9 -0
  16. data/docs/ExtractDocumentBatchJobResult.md +9 -0
  17. data/docs/ExtractDocumentJobStatusResult.md +15 -0
  18. data/docs/ExtractFieldsAndTablesResponse.md +10 -0
  19. data/docs/ExtractFieldsResponse.md +9 -0
  20. data/docs/ExtractTablesResponse.md +9 -0
  21. data/docs/ExtractTextResponse.md +9 -0
  22. data/docs/ExtractedBarcodeItem.md +9 -0
  23. data/docs/ExtractedTextPage.md +9 -0
  24. data/docs/FieldToExtract.md +11 -0
  25. data/docs/FieldValue.md +9 -0
  26. data/docs/PolicyRule.md +10 -0
  27. data/docs/PolicyRuleViolation.md +10 -0
  28. data/docs/RunBatchJobApi.md +298 -0
  29. data/docs/SummarizeDocumentResponse.md +9 -0
  30. data/docs/TableResult.md +9 -0
  31. data/docs/TableResultCell.md +9 -0
  32. data/docs/TableResultRow.md +8 -0
  33. data/git_push.sh +55 -0
  34. data/lib/cloudmersive-documentai-api-client/api/analyze_api.rb +73 -0
  35. data/lib/cloudmersive-documentai-api-client/api/extract_api.rb +513 -0
  36. data/lib/cloudmersive-documentai-api-client/api/run_batch_job_api.rb +290 -0
  37. data/lib/cloudmersive-documentai-api-client/api_client.rb +391 -0
  38. data/lib/cloudmersive-documentai-api-client/api_error.rb +38 -0
  39. data/lib/cloudmersive-documentai-api-client/configuration.rb +209 -0
  40. data/lib/cloudmersive-documentai-api-client/models/advanced_extract_classification_request.rb +223 -0
  41. data/lib/cloudmersive-documentai-api-client/models/advanced_extract_fields_request.rb +223 -0
  42. data/lib/cloudmersive-documentai-api-client/models/document_advanced_classification_result.rb +196 -0
  43. data/lib/cloudmersive-documentai-api-client/models/document_categories.rb +196 -0
  44. data/lib/cloudmersive-documentai-api-client/models/document_classification_result.rb +196 -0
  45. data/lib/cloudmersive-documentai-api-client/models/document_policy_request.rb +213 -0
  46. data/lib/cloudmersive-documentai-api-client/models/document_policy_result.rb +208 -0
  47. data/lib/cloudmersive-documentai-api-client/models/extract_barcodes_ai_response.rb +198 -0
  48. data/lib/cloudmersive-documentai-api-client/models/extract_document_batch_job_result.rb +196 -0
  49. data/lib/cloudmersive-documentai-api-client/models/extract_document_job_status_result.rb +252 -0
  50. data/lib/cloudmersive-documentai-api-client/models/extract_fields_and_tables_response.rb +210 -0
  51. data/lib/cloudmersive-documentai-api-client/models/extract_fields_response.rb +198 -0
  52. data/lib/cloudmersive-documentai-api-client/models/extract_tables_response.rb +198 -0
  53. data/lib/cloudmersive-documentai-api-client/models/extract_text_response.rb +198 -0
  54. data/lib/cloudmersive-documentai-api-client/models/extracted_barcode_item.rb +196 -0
  55. data/lib/cloudmersive-documentai-api-client/models/extracted_text_page.rb +196 -0
  56. data/lib/cloudmersive-documentai-api-client/models/field_to_extract.rb +216 -0
  57. data/lib/cloudmersive-documentai-api-client/models/field_value.rb +196 -0
  58. data/lib/cloudmersive-documentai-api-client/models/policy_rule.rb +205 -0
  59. data/lib/cloudmersive-documentai-api-client/models/policy_rule_violation.rb +206 -0
  60. data/lib/cloudmersive-documentai-api-client/models/summarize_document_response.rb +196 -0
  61. data/lib/cloudmersive-documentai-api-client/models/table_result.rb +198 -0
  62. data/lib/cloudmersive-documentai-api-client/models/table_result_cell.rb +196 -0
  63. data/lib/cloudmersive-documentai-api-client/models/table_result_row.rb +188 -0
  64. data/lib/cloudmersive-documentai-api-client/version.rb +15 -0
  65. data/lib/cloudmersive-documentai-api-client.rb +66 -0
  66. data/spec/api/analyze_api_spec.rb +47 -0
  67. data/spec/api/extract_api_spec.rb +154 -0
  68. data/spec/api/run_batch_job_api_spec.rb +100 -0
  69. data/spec/api_client_spec.rb +243 -0
  70. data/spec/configuration_spec.rb +42 -0
  71. data/spec/models/advanced_extract_classification_request_spec.rb +53 -0
  72. data/spec/models/advanced_extract_fields_request_spec.rb +53 -0
  73. data/spec/models/document_advanced_classification_result_spec.rb +47 -0
  74. data/spec/models/document_categories_spec.rb +47 -0
  75. data/spec/models/document_classification_result_spec.rb +47 -0
  76. data/spec/models/document_policy_request_spec.rb +47 -0
  77. data/spec/models/document_policy_result_spec.rb +53 -0
  78. data/spec/models/extract_barcodes_ai_response_spec.rb +47 -0
  79. data/spec/models/extract_document_batch_job_result_spec.rb +47 -0
  80. data/spec/models/extract_document_job_status_result_spec.rb +83 -0
  81. data/spec/models/extract_fields_and_tables_response_spec.rb +53 -0
  82. data/spec/models/extract_fields_response_spec.rb +47 -0
  83. data/spec/models/extract_tables_response_spec.rb +47 -0
  84. data/spec/models/extract_text_response_spec.rb +47 -0
  85. data/spec/models/extracted_barcode_item_spec.rb +47 -0
  86. data/spec/models/extracted_text_page_spec.rb +47 -0
  87. data/spec/models/field_to_extract_spec.rb +59 -0
  88. data/spec/models/field_value_spec.rb +47 -0
  89. data/spec/models/policy_rule_spec.rb +53 -0
  90. data/spec/models/policy_rule_violation_spec.rb +53 -0
  91. data/spec/models/summarize_document_response_spec.rb +47 -0
  92. data/spec/models/table_result_cell_spec.rb +47 -0
  93. data/spec/models/table_result_row_spec.rb +41 -0
  94. data/spec/models/table_result_spec.rb +47 -0
  95. data/spec/spec_helper.rb +111 -0
  96. metadata +319 -0
@@ -0,0 +1,196 @@
1
+ =begin
2
+ #Document AI API
3
+
4
+ #Use next-generation AI to extract data, fields, insights and text from documents. Instantly.
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.14
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module CloudmersiveDocumentaiApiClient
16
+ # Result of performing a split document batch job
17
+ class ExtractDocumentBatchJobResult
18
+ # True if successful, false otherwise
19
+ attr_accessor :successful
20
+
21
+ # When creating a job, an Async Job ID is returned. Use the GetAsyncJobStatus API to check on the status of this job using the AsyncJobID and get the result when it finishes
22
+ attr_accessor :async_job_id
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'successful' => :'Successful',
28
+ :'async_job_id' => :'AsyncJobID'
29
+ }
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.swagger_types
34
+ {
35
+ :'successful' => :'BOOLEAN',
36
+ :'async_job_id' => :'String'
37
+ }
38
+ end
39
+
40
+ # Initializes the object
41
+ # @param [Hash] attributes Model attributes in the form of hash
42
+ def initialize(attributes = {})
43
+ return unless attributes.is_a?(Hash)
44
+
45
+ # convert string to symbol for hash key
46
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
47
+
48
+ if attributes.has_key?(:'Successful')
49
+ self.successful = attributes[:'Successful']
50
+ end
51
+
52
+ if attributes.has_key?(:'AsyncJobID')
53
+ self.async_job_id = attributes[:'AsyncJobID']
54
+ end
55
+ end
56
+
57
+ # Show invalid properties with the reasons. Usually used together with valid?
58
+ # @return Array for valid properties with the reasons
59
+ def list_invalid_properties
60
+ invalid_properties = Array.new
61
+ invalid_properties
62
+ end
63
+
64
+ # Check to see if the all the properties in the model are valid
65
+ # @return true if the model is valid
66
+ def valid?
67
+ true
68
+ end
69
+
70
+ # Checks equality by comparing each attribute.
71
+ # @param [Object] Object to be compared
72
+ def ==(o)
73
+ return true if self.equal?(o)
74
+ self.class == o.class &&
75
+ successful == o.successful &&
76
+ async_job_id == o.async_job_id
77
+ end
78
+
79
+ # @see the `==` method
80
+ # @param [Object] Object to be compared
81
+ def eql?(o)
82
+ self == o
83
+ end
84
+
85
+ # Calculates hash code according to all attributes.
86
+ # @return [Fixnum] Hash code
87
+ def hash
88
+ [successful, async_job_id].hash
89
+ end
90
+
91
+ # Builds the object from hash
92
+ # @param [Hash] attributes Model attributes in the form of hash
93
+ # @return [Object] Returns the model itself
94
+ def build_from_hash(attributes)
95
+ return nil unless attributes.is_a?(Hash)
96
+ self.class.swagger_types.each_pair do |key, type|
97
+ if type =~ /\AArray<(.*)>/i
98
+ # check to ensure the input is an array given that the attribute
99
+ # is documented as an array but the input is not
100
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
101
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
102
+ end
103
+ elsif !attributes[self.class.attribute_map[key]].nil?
104
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
105
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
106
+ end
107
+
108
+ self
109
+ end
110
+
111
+ # Deserializes the data based on type
112
+ # @param string type Data type
113
+ # @param string value Value to be deserialized
114
+ # @return [Object] Deserialized data
115
+ def _deserialize(type, value)
116
+ case type.to_sym
117
+ when :DateTime
118
+ DateTime.parse(value)
119
+ when :Date
120
+ Date.parse(value)
121
+ when :String
122
+ value.to_s
123
+ when :Integer
124
+ value.to_i
125
+ when :Float
126
+ value.to_f
127
+ when :BOOLEAN
128
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
129
+ true
130
+ else
131
+ false
132
+ end
133
+ when :Object
134
+ # generic object (usually a Hash), return directly
135
+ value
136
+ when /\AArray<(?<inner_type>.+)>\z/
137
+ inner_type = Regexp.last_match[:inner_type]
138
+ value.map { |v| _deserialize(inner_type, v) }
139
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
140
+ k_type = Regexp.last_match[:k_type]
141
+ v_type = Regexp.last_match[:v_type]
142
+ {}.tap do |hash|
143
+ value.each do |k, v|
144
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
145
+ end
146
+ end
147
+ else # model
148
+ temp_model = CloudmersiveDocumentaiApiClient.const_get(type).new
149
+ temp_model.build_from_hash(value)
150
+ end
151
+ end
152
+
153
+ # Returns the string representation of the object
154
+ # @return [String] String presentation of the object
155
+ def to_s
156
+ to_hash.to_s
157
+ end
158
+
159
+ # to_body is an alias to to_hash (backward compatibility)
160
+ # @return [Hash] Returns the object in the form of hash
161
+ def to_body
162
+ to_hash
163
+ end
164
+
165
+ # Returns the object in the form of hash
166
+ # @return [Hash] Returns the object in the form of hash
167
+ def to_hash
168
+ hash = {}
169
+ self.class.attribute_map.each_pair do |attr, param|
170
+ value = self.send(attr)
171
+ next if value.nil?
172
+ hash[param] = _to_hash(value)
173
+ end
174
+ hash
175
+ end
176
+
177
+ # Outputs non-array value in the form of hash
178
+ # For object, use to_hash. Otherwise, just return the value
179
+ # @param [Object] value Any valid value
180
+ # @return [Hash] Returns the value in the form of hash
181
+ def _to_hash(value)
182
+ if value.is_a?(Array)
183
+ value.compact.map { |v| _to_hash(v) }
184
+ elsif value.is_a?(Hash)
185
+ {}.tap do |hash|
186
+ value.each { |k, v| hash[k] = _to_hash(v) }
187
+ end
188
+ elsif value.respond_to? :to_hash
189
+ value.to_hash
190
+ else
191
+ value
192
+ end
193
+ end
194
+
195
+ end
196
+ end
@@ -0,0 +1,252 @@
1
+ =begin
2
+ #Document AI API
3
+
4
+ #Use next-generation AI to extract data, fields, insights and text from documents. Instantly.
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.14
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module CloudmersiveDocumentaiApiClient
16
+ # Result of performing a batch job operation
17
+ class ExtractDocumentJobStatusResult
18
+ # True if the operation to check the status of the job was successful, false otherwise
19
+ attr_accessor :successful
20
+
21
+ # Returns the job status of the Async Job, if applicable. Possible states are STARTED and COMPLETED
22
+ attr_accessor :async_job_status
23
+
24
+ # Job ID
25
+ attr_accessor :async_job_id
26
+
27
+ attr_accessor :extract_text_result
28
+
29
+ attr_accessor :extract_fields_and_tables_result
30
+
31
+ attr_accessor :extract_fields_result
32
+
33
+ attr_accessor :extract_classification_result
34
+
35
+ # Error message (if any)
36
+ attr_accessor :error_message
37
+
38
+ # Attribute mapping from ruby-style variable name to JSON key.
39
+ def self.attribute_map
40
+ {
41
+ :'successful' => :'Successful',
42
+ :'async_job_status' => :'AsyncJobStatus',
43
+ :'async_job_id' => :'AsyncJobID',
44
+ :'extract_text_result' => :'ExtractTextResult',
45
+ :'extract_fields_and_tables_result' => :'ExtractFieldsAndTablesResult',
46
+ :'extract_fields_result' => :'ExtractFieldsResult',
47
+ :'extract_classification_result' => :'ExtractClassificationResult',
48
+ :'error_message' => :'ErrorMessage'
49
+ }
50
+ end
51
+
52
+ # Attribute type mapping.
53
+ def self.swagger_types
54
+ {
55
+ :'successful' => :'BOOLEAN',
56
+ :'async_job_status' => :'String',
57
+ :'async_job_id' => :'String',
58
+ :'extract_text_result' => :'ExtractTextResponse',
59
+ :'extract_fields_and_tables_result' => :'ExtractFieldsAndTablesResponse',
60
+ :'extract_fields_result' => :'ExtractFieldsResponse',
61
+ :'extract_classification_result' => :'DocumentClassificationResult',
62
+ :'error_message' => :'String'
63
+ }
64
+ end
65
+
66
+ # Initializes the object
67
+ # @param [Hash] attributes Model attributes in the form of hash
68
+ def initialize(attributes = {})
69
+ return unless attributes.is_a?(Hash)
70
+
71
+ # convert string to symbol for hash key
72
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
73
+
74
+ if attributes.has_key?(:'Successful')
75
+ self.successful = attributes[:'Successful']
76
+ end
77
+
78
+ if attributes.has_key?(:'AsyncJobStatus')
79
+ self.async_job_status = attributes[:'AsyncJobStatus']
80
+ end
81
+
82
+ if attributes.has_key?(:'AsyncJobID')
83
+ self.async_job_id = attributes[:'AsyncJobID']
84
+ end
85
+
86
+ if attributes.has_key?(:'ExtractTextResult')
87
+ self.extract_text_result = attributes[:'ExtractTextResult']
88
+ end
89
+
90
+ if attributes.has_key?(:'ExtractFieldsAndTablesResult')
91
+ self.extract_fields_and_tables_result = attributes[:'ExtractFieldsAndTablesResult']
92
+ end
93
+
94
+ if attributes.has_key?(:'ExtractFieldsResult')
95
+ self.extract_fields_result = attributes[:'ExtractFieldsResult']
96
+ end
97
+
98
+ if attributes.has_key?(:'ExtractClassificationResult')
99
+ self.extract_classification_result = attributes[:'ExtractClassificationResult']
100
+ end
101
+
102
+ if attributes.has_key?(:'ErrorMessage')
103
+ self.error_message = attributes[:'ErrorMessage']
104
+ end
105
+ end
106
+
107
+ # Show invalid properties with the reasons. Usually used together with valid?
108
+ # @return Array for valid properties with the reasons
109
+ def list_invalid_properties
110
+ invalid_properties = Array.new
111
+ invalid_properties
112
+ end
113
+
114
+ # Check to see if the all the properties in the model are valid
115
+ # @return true if the model is valid
116
+ def valid?
117
+ true
118
+ end
119
+
120
+ # Checks equality by comparing each attribute.
121
+ # @param [Object] Object to be compared
122
+ def ==(o)
123
+ return true if self.equal?(o)
124
+ self.class == o.class &&
125
+ successful == o.successful &&
126
+ async_job_status == o.async_job_status &&
127
+ async_job_id == o.async_job_id &&
128
+ extract_text_result == o.extract_text_result &&
129
+ extract_fields_and_tables_result == o.extract_fields_and_tables_result &&
130
+ extract_fields_result == o.extract_fields_result &&
131
+ extract_classification_result == o.extract_classification_result &&
132
+ error_message == o.error_message
133
+ end
134
+
135
+ # @see the `==` method
136
+ # @param [Object] Object to be compared
137
+ def eql?(o)
138
+ self == o
139
+ end
140
+
141
+ # Calculates hash code according to all attributes.
142
+ # @return [Fixnum] Hash code
143
+ def hash
144
+ [successful, async_job_status, async_job_id, extract_text_result, extract_fields_and_tables_result, extract_fields_result, extract_classification_result, error_message].hash
145
+ end
146
+
147
+ # Builds the object from hash
148
+ # @param [Hash] attributes Model attributes in the form of hash
149
+ # @return [Object] Returns the model itself
150
+ def build_from_hash(attributes)
151
+ return nil unless attributes.is_a?(Hash)
152
+ self.class.swagger_types.each_pair do |key, type|
153
+ if type =~ /\AArray<(.*)>/i
154
+ # check to ensure the input is an array given that the attribute
155
+ # is documented as an array but the input is not
156
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
157
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
158
+ end
159
+ elsif !attributes[self.class.attribute_map[key]].nil?
160
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
161
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
162
+ end
163
+
164
+ self
165
+ end
166
+
167
+ # Deserializes the data based on type
168
+ # @param string type Data type
169
+ # @param string value Value to be deserialized
170
+ # @return [Object] Deserialized data
171
+ def _deserialize(type, value)
172
+ case type.to_sym
173
+ when :DateTime
174
+ DateTime.parse(value)
175
+ when :Date
176
+ Date.parse(value)
177
+ when :String
178
+ value.to_s
179
+ when :Integer
180
+ value.to_i
181
+ when :Float
182
+ value.to_f
183
+ when :BOOLEAN
184
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
185
+ true
186
+ else
187
+ false
188
+ end
189
+ when :Object
190
+ # generic object (usually a Hash), return directly
191
+ value
192
+ when /\AArray<(?<inner_type>.+)>\z/
193
+ inner_type = Regexp.last_match[:inner_type]
194
+ value.map { |v| _deserialize(inner_type, v) }
195
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
196
+ k_type = Regexp.last_match[:k_type]
197
+ v_type = Regexp.last_match[:v_type]
198
+ {}.tap do |hash|
199
+ value.each do |k, v|
200
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
201
+ end
202
+ end
203
+ else # model
204
+ temp_model = CloudmersiveDocumentaiApiClient.const_get(type).new
205
+ temp_model.build_from_hash(value)
206
+ end
207
+ end
208
+
209
+ # Returns the string representation of the object
210
+ # @return [String] String presentation of the object
211
+ def to_s
212
+ to_hash.to_s
213
+ end
214
+
215
+ # to_body is an alias to to_hash (backward compatibility)
216
+ # @return [Hash] Returns the object in the form of hash
217
+ def to_body
218
+ to_hash
219
+ end
220
+
221
+ # Returns the object in the form of hash
222
+ # @return [Hash] Returns the object in the form of hash
223
+ def to_hash
224
+ hash = {}
225
+ self.class.attribute_map.each_pair do |attr, param|
226
+ value = self.send(attr)
227
+ next if value.nil?
228
+ hash[param] = _to_hash(value)
229
+ end
230
+ hash
231
+ end
232
+
233
+ # Outputs non-array value in the form of hash
234
+ # For object, use to_hash. Otherwise, just return the value
235
+ # @param [Object] value Any valid value
236
+ # @return [Hash] Returns the value in the form of hash
237
+ def _to_hash(value)
238
+ if value.is_a?(Array)
239
+ value.compact.map { |v| _to_hash(v) }
240
+ elsif value.is_a?(Hash)
241
+ {}.tap do |hash|
242
+ value.each { |k, v| hash[k] = _to_hash(v) }
243
+ end
244
+ elsif value.respond_to? :to_hash
245
+ value.to_hash
246
+ else
247
+ value
248
+ end
249
+ end
250
+
251
+ end
252
+ end
@@ -0,0 +1,210 @@
1
+ =begin
2
+ #Document AI API
3
+
4
+ #Use next-generation AI to extract data, fields, insights and text from documents. Instantly.
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.14
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module CloudmersiveDocumentaiApiClient
16
+ # Result of extracting fields from a document
17
+ class ExtractFieldsAndTablesResponse
18
+ # True if successful, false otherwise
19
+ attr_accessor :successful
20
+
21
+ # Field value results from the extraction operation
22
+ attr_accessor :field_results
23
+
24
+ # Table value results from the extraction operation
25
+ attr_accessor :table_results
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'successful' => :'Successful',
31
+ :'field_results' => :'FieldResults',
32
+ :'table_results' => :'TableResults'
33
+ }
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.swagger_types
38
+ {
39
+ :'successful' => :'BOOLEAN',
40
+ :'field_results' => :'Array<FieldValue>',
41
+ :'table_results' => :'Array<TableResult>'
42
+ }
43
+ end
44
+
45
+ # Initializes the object
46
+ # @param [Hash] attributes Model attributes in the form of hash
47
+ def initialize(attributes = {})
48
+ return unless attributes.is_a?(Hash)
49
+
50
+ # convert string to symbol for hash key
51
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
52
+
53
+ if attributes.has_key?(:'Successful')
54
+ self.successful = attributes[:'Successful']
55
+ end
56
+
57
+ if attributes.has_key?(:'FieldResults')
58
+ if (value = attributes[:'FieldResults']).is_a?(Array)
59
+ self.field_results = value
60
+ end
61
+ end
62
+
63
+ if attributes.has_key?(:'TableResults')
64
+ if (value = attributes[:'TableResults']).is_a?(Array)
65
+ self.table_results = value
66
+ end
67
+ end
68
+ end
69
+
70
+ # Show invalid properties with the reasons. Usually used together with valid?
71
+ # @return Array for valid properties with the reasons
72
+ def list_invalid_properties
73
+ invalid_properties = Array.new
74
+ invalid_properties
75
+ end
76
+
77
+ # Check to see if the all the properties in the model are valid
78
+ # @return true if the model is valid
79
+ def valid?
80
+ true
81
+ end
82
+
83
+ # Checks equality by comparing each attribute.
84
+ # @param [Object] Object to be compared
85
+ def ==(o)
86
+ return true if self.equal?(o)
87
+ self.class == o.class &&
88
+ successful == o.successful &&
89
+ field_results == o.field_results &&
90
+ table_results == o.table_results
91
+ end
92
+
93
+ # @see the `==` method
94
+ # @param [Object] Object to be compared
95
+ def eql?(o)
96
+ self == o
97
+ end
98
+
99
+ # Calculates hash code according to all attributes.
100
+ # @return [Fixnum] Hash code
101
+ def hash
102
+ [successful, field_results, table_results].hash
103
+ end
104
+
105
+ # Builds the object from hash
106
+ # @param [Hash] attributes Model attributes in the form of hash
107
+ # @return [Object] Returns the model itself
108
+ def build_from_hash(attributes)
109
+ return nil unless attributes.is_a?(Hash)
110
+ self.class.swagger_types.each_pair do |key, type|
111
+ if type =~ /\AArray<(.*)>/i
112
+ # check to ensure the input is an array given that the attribute
113
+ # is documented as an array but the input is not
114
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
115
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
116
+ end
117
+ elsif !attributes[self.class.attribute_map[key]].nil?
118
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
119
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
120
+ end
121
+
122
+ self
123
+ end
124
+
125
+ # Deserializes the data based on type
126
+ # @param string type Data type
127
+ # @param string value Value to be deserialized
128
+ # @return [Object] Deserialized data
129
+ def _deserialize(type, value)
130
+ case type.to_sym
131
+ when :DateTime
132
+ DateTime.parse(value)
133
+ when :Date
134
+ Date.parse(value)
135
+ when :String
136
+ value.to_s
137
+ when :Integer
138
+ value.to_i
139
+ when :Float
140
+ value.to_f
141
+ when :BOOLEAN
142
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
143
+ true
144
+ else
145
+ false
146
+ end
147
+ when :Object
148
+ # generic object (usually a Hash), return directly
149
+ value
150
+ when /\AArray<(?<inner_type>.+)>\z/
151
+ inner_type = Regexp.last_match[:inner_type]
152
+ value.map { |v| _deserialize(inner_type, v) }
153
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
154
+ k_type = Regexp.last_match[:k_type]
155
+ v_type = Regexp.last_match[:v_type]
156
+ {}.tap do |hash|
157
+ value.each do |k, v|
158
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
159
+ end
160
+ end
161
+ else # model
162
+ temp_model = CloudmersiveDocumentaiApiClient.const_get(type).new
163
+ temp_model.build_from_hash(value)
164
+ end
165
+ end
166
+
167
+ # Returns the string representation of the object
168
+ # @return [String] String presentation of the object
169
+ def to_s
170
+ to_hash.to_s
171
+ end
172
+
173
+ # to_body is an alias to to_hash (backward compatibility)
174
+ # @return [Hash] Returns the object in the form of hash
175
+ def to_body
176
+ to_hash
177
+ end
178
+
179
+ # Returns the object in the form of hash
180
+ # @return [Hash] Returns the object in the form of hash
181
+ def to_hash
182
+ hash = {}
183
+ self.class.attribute_map.each_pair do |attr, param|
184
+ value = self.send(attr)
185
+ next if value.nil?
186
+ hash[param] = _to_hash(value)
187
+ end
188
+ hash
189
+ end
190
+
191
+ # Outputs non-array value in the form of hash
192
+ # For object, use to_hash. Otherwise, just return the value
193
+ # @param [Object] value Any valid value
194
+ # @return [Hash] Returns the value in the form of hash
195
+ def _to_hash(value)
196
+ if value.is_a?(Array)
197
+ value.compact.map { |v| _to_hash(v) }
198
+ elsif value.is_a?(Hash)
199
+ {}.tap do |hash|
200
+ value.each { |k, v| hash[k] = _to_hash(v) }
201
+ end
202
+ elsif value.respond_to? :to_hash
203
+ value.to_hash
204
+ else
205
+ value
206
+ end
207
+ end
208
+
209
+ end
210
+ end