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
+ # Field value result of extracting fields from a document
17
+ class FieldValue
18
+ # Name of the field (note that spaces will be replaced with underscore)
19
+ attr_accessor :field_name
20
+
21
+ # String value of the field that was extractged from the document
22
+ attr_accessor :field_string_value
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'field_name' => :'FieldName',
28
+ :'field_string_value' => :'FieldStringValue'
29
+ }
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.swagger_types
34
+ {
35
+ :'field_name' => :'String',
36
+ :'field_string_value' => :'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?(:'FieldName')
49
+ self.field_name = attributes[:'FieldName']
50
+ end
51
+
52
+ if attributes.has_key?(:'FieldStringValue')
53
+ self.field_string_value = attributes[:'FieldStringValue']
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
+ field_name == o.field_name &&
76
+ field_string_value == o.field_string_value
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
+ [field_name, field_string_value].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,205 @@
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
+ class PolicyRule
17
+ #
18
+ attr_accessor :rule_id
19
+
20
+ # Possible values are ALLOW and DENY
21
+ attr_accessor :rule_type
22
+
23
+ # Description of the rule in natural language, e.g. Do not allow documents that contain offensive language
24
+ attr_accessor :rule_description
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :'rule_id' => :'RuleId',
30
+ :'rule_type' => :'RuleType',
31
+ :'rule_description' => :'RuleDescription'
32
+ }
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.swagger_types
37
+ {
38
+ :'rule_id' => :'String',
39
+ :'rule_type' => :'String',
40
+ :'rule_description' => :'String'
41
+ }
42
+ end
43
+
44
+ # Initializes the object
45
+ # @param [Hash] attributes Model attributes in the form of hash
46
+ def initialize(attributes = {})
47
+ return unless attributes.is_a?(Hash)
48
+
49
+ # convert string to symbol for hash key
50
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
51
+
52
+ if attributes.has_key?(:'RuleId')
53
+ self.rule_id = attributes[:'RuleId']
54
+ end
55
+
56
+ if attributes.has_key?(:'RuleType')
57
+ self.rule_type = attributes[:'RuleType']
58
+ end
59
+
60
+ if attributes.has_key?(:'RuleDescription')
61
+ self.rule_description = attributes[:'RuleDescription']
62
+ end
63
+ end
64
+
65
+ # Show invalid properties with the reasons. Usually used together with valid?
66
+ # @return Array for valid properties with the reasons
67
+ def list_invalid_properties
68
+ invalid_properties = Array.new
69
+ invalid_properties
70
+ end
71
+
72
+ # Check to see if the all the properties in the model are valid
73
+ # @return true if the model is valid
74
+ def valid?
75
+ true
76
+ end
77
+
78
+ # Checks equality by comparing each attribute.
79
+ # @param [Object] Object to be compared
80
+ def ==(o)
81
+ return true if self.equal?(o)
82
+ self.class == o.class &&
83
+ rule_id == o.rule_id &&
84
+ rule_type == o.rule_type &&
85
+ rule_description == o.rule_description
86
+ end
87
+
88
+ # @see the `==` method
89
+ # @param [Object] Object to be compared
90
+ def eql?(o)
91
+ self == o
92
+ end
93
+
94
+ # Calculates hash code according to all attributes.
95
+ # @return [Fixnum] Hash code
96
+ def hash
97
+ [rule_id, rule_type, rule_description].hash
98
+ end
99
+
100
+ # Builds the object from hash
101
+ # @param [Hash] attributes Model attributes in the form of hash
102
+ # @return [Object] Returns the model itself
103
+ def build_from_hash(attributes)
104
+ return nil unless attributes.is_a?(Hash)
105
+ self.class.swagger_types.each_pair do |key, type|
106
+ if type =~ /\AArray<(.*)>/i
107
+ # check to ensure the input is an array given that the attribute
108
+ # is documented as an array but the input is not
109
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
110
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
111
+ end
112
+ elsif !attributes[self.class.attribute_map[key]].nil?
113
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
114
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
115
+ end
116
+
117
+ self
118
+ end
119
+
120
+ # Deserializes the data based on type
121
+ # @param string type Data type
122
+ # @param string value Value to be deserialized
123
+ # @return [Object] Deserialized data
124
+ def _deserialize(type, value)
125
+ case type.to_sym
126
+ when :DateTime
127
+ DateTime.parse(value)
128
+ when :Date
129
+ Date.parse(value)
130
+ when :String
131
+ value.to_s
132
+ when :Integer
133
+ value.to_i
134
+ when :Float
135
+ value.to_f
136
+ when :BOOLEAN
137
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
138
+ true
139
+ else
140
+ false
141
+ end
142
+ when :Object
143
+ # generic object (usually a Hash), return directly
144
+ value
145
+ when /\AArray<(?<inner_type>.+)>\z/
146
+ inner_type = Regexp.last_match[:inner_type]
147
+ value.map { |v| _deserialize(inner_type, v) }
148
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
149
+ k_type = Regexp.last_match[:k_type]
150
+ v_type = Regexp.last_match[:v_type]
151
+ {}.tap do |hash|
152
+ value.each do |k, v|
153
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
154
+ end
155
+ end
156
+ else # model
157
+ temp_model = CloudmersiveDocumentaiApiClient.const_get(type).new
158
+ temp_model.build_from_hash(value)
159
+ end
160
+ end
161
+
162
+ # Returns the string representation of the object
163
+ # @return [String] String presentation of the object
164
+ def to_s
165
+ to_hash.to_s
166
+ end
167
+
168
+ # to_body is an alias to to_hash (backward compatibility)
169
+ # @return [Hash] Returns the object in the form of hash
170
+ def to_body
171
+ to_hash
172
+ end
173
+
174
+ # Returns the object in the form of hash
175
+ # @return [Hash] Returns the object in the form of hash
176
+ def to_hash
177
+ hash = {}
178
+ self.class.attribute_map.each_pair do |attr, param|
179
+ value = self.send(attr)
180
+ next if value.nil?
181
+ hash[param] = _to_hash(value)
182
+ end
183
+ hash
184
+ end
185
+
186
+ # Outputs non-array value in the form of hash
187
+ # For object, use to_hash. Otherwise, just return the value
188
+ # @param [Object] value Any valid value
189
+ # @return [Hash] Returns the value in the form of hash
190
+ def _to_hash(value)
191
+ if value.is_a?(Array)
192
+ value.compact.map { |v| _to_hash(v) }
193
+ elsif value.is_a?(Hash)
194
+ {}.tap do |hash|
195
+ value.each { |k, v| hash[k] = _to_hash(v) }
196
+ end
197
+ elsif value.respond_to? :to_hash
198
+ value.to_hash
199
+ else
200
+ value
201
+ end
202
+ end
203
+
204
+ end
205
+ end
@@ -0,0 +1,206 @@
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
+ # Instances of a policy rule violation
17
+ class PolicyRuleViolation
18
+ # ID of the rule; if no ID was supplied, the ID is the 1-based index of the rule
19
+ attr_accessor :rule_id
20
+
21
+ # Risk score between 0.0 and 1.0 where values above 0.5 are increasing levels of risk
22
+ attr_accessor :rule_violation_risk_score
23
+
24
+ # AI natural language rationale for why this policy was violated
25
+ attr_accessor :rule_violation_rationale
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'rule_id' => :'RuleId',
31
+ :'rule_violation_risk_score' => :'RuleViolationRiskScore',
32
+ :'rule_violation_rationale' => :'RuleViolationRationale'
33
+ }
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.swagger_types
38
+ {
39
+ :'rule_id' => :'String',
40
+ :'rule_violation_risk_score' => :'Float',
41
+ :'rule_violation_rationale' => :'String'
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?(:'RuleId')
54
+ self.rule_id = attributes[:'RuleId']
55
+ end
56
+
57
+ if attributes.has_key?(:'RuleViolationRiskScore')
58
+ self.rule_violation_risk_score = attributes[:'RuleViolationRiskScore']
59
+ end
60
+
61
+ if attributes.has_key?(:'RuleViolationRationale')
62
+ self.rule_violation_rationale = attributes[:'RuleViolationRationale']
63
+ end
64
+ end
65
+
66
+ # Show invalid properties with the reasons. Usually used together with valid?
67
+ # @return Array for valid properties with the reasons
68
+ def list_invalid_properties
69
+ invalid_properties = Array.new
70
+ invalid_properties
71
+ end
72
+
73
+ # Check to see if the all the properties in the model are valid
74
+ # @return true if the model is valid
75
+ def valid?
76
+ true
77
+ end
78
+
79
+ # Checks equality by comparing each attribute.
80
+ # @param [Object] Object to be compared
81
+ def ==(o)
82
+ return true if self.equal?(o)
83
+ self.class == o.class &&
84
+ rule_id == o.rule_id &&
85
+ rule_violation_risk_score == o.rule_violation_risk_score &&
86
+ rule_violation_rationale == o.rule_violation_rationale
87
+ end
88
+
89
+ # @see the `==` method
90
+ # @param [Object] Object to be compared
91
+ def eql?(o)
92
+ self == o
93
+ end
94
+
95
+ # Calculates hash code according to all attributes.
96
+ # @return [Fixnum] Hash code
97
+ def hash
98
+ [rule_id, rule_violation_risk_score, rule_violation_rationale].hash
99
+ end
100
+
101
+ # Builds the object from hash
102
+ # @param [Hash] attributes Model attributes in the form of hash
103
+ # @return [Object] Returns the model itself
104
+ def build_from_hash(attributes)
105
+ return nil unless attributes.is_a?(Hash)
106
+ self.class.swagger_types.each_pair do |key, type|
107
+ if type =~ /\AArray<(.*)>/i
108
+ # check to ensure the input is an array given that the attribute
109
+ # is documented as an array but the input is not
110
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
111
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
112
+ end
113
+ elsif !attributes[self.class.attribute_map[key]].nil?
114
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
115
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
116
+ end
117
+
118
+ self
119
+ end
120
+
121
+ # Deserializes the data based on type
122
+ # @param string type Data type
123
+ # @param string value Value to be deserialized
124
+ # @return [Object] Deserialized data
125
+ def _deserialize(type, value)
126
+ case type.to_sym
127
+ when :DateTime
128
+ DateTime.parse(value)
129
+ when :Date
130
+ Date.parse(value)
131
+ when :String
132
+ value.to_s
133
+ when :Integer
134
+ value.to_i
135
+ when :Float
136
+ value.to_f
137
+ when :BOOLEAN
138
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
139
+ true
140
+ else
141
+ false
142
+ end
143
+ when :Object
144
+ # generic object (usually a Hash), return directly
145
+ value
146
+ when /\AArray<(?<inner_type>.+)>\z/
147
+ inner_type = Regexp.last_match[:inner_type]
148
+ value.map { |v| _deserialize(inner_type, v) }
149
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
150
+ k_type = Regexp.last_match[:k_type]
151
+ v_type = Regexp.last_match[:v_type]
152
+ {}.tap do |hash|
153
+ value.each do |k, v|
154
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
155
+ end
156
+ end
157
+ else # model
158
+ temp_model = CloudmersiveDocumentaiApiClient.const_get(type).new
159
+ temp_model.build_from_hash(value)
160
+ end
161
+ end
162
+
163
+ # Returns the string representation of the object
164
+ # @return [String] String presentation of the object
165
+ def to_s
166
+ to_hash.to_s
167
+ end
168
+
169
+ # to_body is an alias to to_hash (backward compatibility)
170
+ # @return [Hash] Returns the object in the form of hash
171
+ def to_body
172
+ to_hash
173
+ end
174
+
175
+ # Returns the object in the form of hash
176
+ # @return [Hash] Returns the object in the form of hash
177
+ def to_hash
178
+ hash = {}
179
+ self.class.attribute_map.each_pair do |attr, param|
180
+ value = self.send(attr)
181
+ next if value.nil?
182
+ hash[param] = _to_hash(value)
183
+ end
184
+ hash
185
+ end
186
+
187
+ # Outputs non-array value in the form of hash
188
+ # For object, use to_hash. Otherwise, just return the value
189
+ # @param [Object] value Any valid value
190
+ # @return [Hash] Returns the value in the form of hash
191
+ def _to_hash(value)
192
+ if value.is_a?(Array)
193
+ value.compact.map { |v| _to_hash(v) }
194
+ elsif value.is_a?(Hash)
195
+ {}.tap do |hash|
196
+ value.each { |k, v| hash[k] = _to_hash(v) }
197
+ end
198
+ elsif value.respond_to? :to_hash
199
+ value.to_hash
200
+ else
201
+ value
202
+ end
203
+ end
204
+
205
+ end
206
+ end