cloudmersive-ocr-api-client 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +7 -0
  3. data/README.md +150 -0
  4. data/Rakefile +8 -0
  5. data/cloudmersive-ocr-api-client.gemspec +45 -0
  6. data/docs/BusinessCardRecognitionResult.md +15 -0
  7. data/docs/FieldResult.md +9 -0
  8. data/docs/FormDefinitionTemplate.md +9 -0
  9. data/docs/FormFieldDefinition.md +25 -0
  10. data/docs/FormRecognitionResult.md +12 -0
  11. data/docs/FormTableColumnDefinition.md +13 -0
  12. data/docs/FormTableDefinition.md +11 -0
  13. data/docs/GetPageAngleResult.md +9 -0
  14. data/docs/ImageOcrApi.md +571 -0
  15. data/docs/ImageToLinesWithLocationResult.md +9 -0
  16. data/docs/ImageToTextResponse.md +9 -0
  17. data/docs/ImageToWordsWithLocationResult.md +9 -0
  18. data/docs/OcrLineElement.md +9 -0
  19. data/docs/OcrPageResult.md +10 -0
  20. data/docs/OcrPageResultWithLinesWithLocation.md +10 -0
  21. data/docs/OcrPageResultWithWordsWithLocation.md +10 -0
  22. data/docs/OcrPhotoTextElement.md +14 -0
  23. data/docs/OcrWordElement.md +18 -0
  24. data/docs/PdfOcrApi.md +191 -0
  25. data/docs/PdfToLinesWithLocationResult.md +9 -0
  26. data/docs/PdfToTextResponse.md +9 -0
  27. data/docs/PdfToWordsWithLocationResult.md +9 -0
  28. data/docs/PhotoToWordsWithLocationResult.md +10 -0
  29. data/docs/Point.md +9 -0
  30. data/docs/PreprocessingApi.md +338 -0
  31. data/docs/ReceiptLineItem.md +9 -0
  32. data/docs/ReceiptRecognitionResult.md +16 -0
  33. data/docs/ReceiptsApi.md +63 -0
  34. data/docs/TableCellResult.md +9 -0
  35. data/docs/TableResult.md +9 -0
  36. data/docs/TableRowResult.md +8 -0
  37. data/git_push.sh +55 -0
  38. data/lib/cloudmersive-ocr-api-client.rb +70 -0
  39. data/lib/cloudmersive-ocr-api-client/api/image_ocr_api.rb +596 -0
  40. data/lib/cloudmersive-ocr-api-client/api/pdf_ocr_api.rb +207 -0
  41. data/lib/cloudmersive-ocr-api-client/api/preprocessing_api.rb +353 -0
  42. data/lib/cloudmersive-ocr-api-client/api/receipts_api.rb +78 -0
  43. data/lib/cloudmersive-ocr-api-client/api_client.rb +391 -0
  44. data/lib/cloudmersive-ocr-api-client/api_error.rb +38 -0
  45. data/lib/cloudmersive-ocr-api-client/configuration.rb +209 -0
  46. data/lib/cloudmersive-ocr-api-client/models/business_card_recognition_result.rb +256 -0
  47. data/lib/cloudmersive-ocr-api-client/models/field_result.rb +198 -0
  48. data/lib/cloudmersive-ocr-api-client/models/form_definition_template.rb +200 -0
  49. data/lib/cloudmersive-ocr-api-client/models/form_field_definition.rb +358 -0
  50. data/lib/cloudmersive-ocr-api-client/models/form_recognition_result.rb +232 -0
  51. data/lib/cloudmersive-ocr-api-client/models/form_table_column_definition.rb +236 -0
  52. data/lib/cloudmersive-ocr-api-client/models/form_table_definition.rb +218 -0
  53. data/lib/cloudmersive-ocr-api-client/models/get_page_angle_result.rb +196 -0
  54. data/lib/cloudmersive-ocr-api-client/models/image_to_lines_with_location_result.rb +198 -0
  55. data/lib/cloudmersive-ocr-api-client/models/image_to_text_response.rb +196 -0
  56. data/lib/cloudmersive-ocr-api-client/models/image_to_words_with_location_result.rb +198 -0
  57. data/lib/cloudmersive-ocr-api-client/models/ocr_line_element.rb +198 -0
  58. data/lib/cloudmersive-ocr-api-client/models/ocr_page_result.rb +205 -0
  59. data/lib/cloudmersive-ocr-api-client/models/ocr_page_result_with_lines_with_location.rb +208 -0
  60. data/lib/cloudmersive-ocr-api-client/models/ocr_page_result_with_words_with_location.rb +208 -0
  61. data/lib/cloudmersive-ocr-api-client/models/ocr_photo_text_element.rb +248 -0
  62. data/lib/cloudmersive-ocr-api-client/models/ocr_word_element.rb +286 -0
  63. data/lib/cloudmersive-ocr-api-client/models/pdf_to_lines_with_location_result.rb +198 -0
  64. data/lib/cloudmersive-ocr-api-client/models/pdf_to_text_response.rb +198 -0
  65. data/lib/cloudmersive-ocr-api-client/models/pdf_to_words_with_location_result.rb +198 -0
  66. data/lib/cloudmersive-ocr-api-client/models/photo_to_words_with_location_result.rb +223 -0
  67. data/lib/cloudmersive-ocr-api-client/models/point.rb +196 -0
  68. data/lib/cloudmersive-ocr-api-client/models/receipt_line_item.rb +196 -0
  69. data/lib/cloudmersive-ocr-api-client/models/receipt_recognition_result.rb +268 -0
  70. data/lib/cloudmersive-ocr-api-client/models/table_cell_result.rb +198 -0
  71. data/lib/cloudmersive-ocr-api-client/models/table_result.rb +198 -0
  72. data/lib/cloudmersive-ocr-api-client/models/table_row_result.rb +188 -0
  73. data/lib/cloudmersive-ocr-api-client/version.rb +15 -0
  74. data/spec/api/image_ocr_api_spec.rb +169 -0
  75. data/spec/api/pdf_ocr_api_spec.rb +77 -0
  76. data/spec/api/preprocessing_api_spec.rb +107 -0
  77. data/spec/api/receipts_api_spec.rb +47 -0
  78. data/spec/api_client_spec.rb +243 -0
  79. data/spec/configuration_spec.rb +42 -0
  80. data/spec/models/business_card_recognition_result_spec.rb +83 -0
  81. data/spec/models/field_result_spec.rb +47 -0
  82. data/spec/models/form_definition_template_spec.rb +47 -0
  83. data/spec/models/form_field_definition_spec.rb +143 -0
  84. data/spec/models/form_recognition_result_spec.rb +65 -0
  85. data/spec/models/form_table_column_definition_spec.rb +71 -0
  86. data/spec/models/form_table_definition_spec.rb +59 -0
  87. data/spec/models/get_page_angle_result_spec.rb +47 -0
  88. data/spec/models/image_to_lines_with_location_result_spec.rb +47 -0
  89. data/spec/models/image_to_text_response_spec.rb +47 -0
  90. data/spec/models/image_to_words_with_location_result_spec.rb +47 -0
  91. data/spec/models/ocr_line_element_spec.rb +47 -0
  92. data/spec/models/ocr_page_result_spec.rb +53 -0
  93. data/spec/models/ocr_page_result_with_lines_with_location_spec.rb +53 -0
  94. data/spec/models/ocr_page_result_with_words_with_location_spec.rb +53 -0
  95. data/spec/models/ocr_photo_text_element_spec.rb +77 -0
  96. data/spec/models/ocr_word_element_spec.rb +101 -0
  97. data/spec/models/pdf_to_lines_with_location_result_spec.rb +47 -0
  98. data/spec/models/pdf_to_text_response_spec.rb +47 -0
  99. data/spec/models/pdf_to_words_with_location_result_spec.rb +47 -0
  100. data/spec/models/photo_to_words_with_location_result_spec.rb +53 -0
  101. data/spec/models/point_spec.rb +47 -0
  102. data/spec/models/receipt_line_item_spec.rb +47 -0
  103. data/spec/models/receipt_recognition_result_spec.rb +89 -0
  104. data/spec/models/table_cell_result_spec.rb +47 -0
  105. data/spec/models/table_result_spec.rb +47 -0
  106. data/spec/models/table_row_result_spec.rb +41 -0
  107. data/spec/spec_helper.rb +111 -0
  108. metadata +109 -3
@@ -0,0 +1,218 @@
1
+ =begin
2
+ #ocrapi
3
+
4
+ #The powerful Optical Character Recognition (OCR) APIs let you convert scanned images of pages into recognized text.
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 CloudmersiveOcrApiClient
16
+ # Definition of a form table for OCR data extraction from images
17
+ class FormTableDefinition
18
+ # Optional; the ID of the table
19
+ attr_accessor :table_id
20
+
21
+ # Definition of the columns in the table
22
+ attr_accessor :column_definitions
23
+
24
+ # Optional - scale factor for target table height - relative to maximum height of headers of columns
25
+ attr_accessor :target_table_height_relative
26
+
27
+ # Optional - scale factor for target row height - relative to height of column header
28
+ attr_accessor :target_row_height_relative
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'table_id' => :'TableID',
34
+ :'column_definitions' => :'ColumnDefinitions',
35
+ :'target_table_height_relative' => :'TargetTableHeight_Relative',
36
+ :'target_row_height_relative' => :'TargetRowHeight_Relative'
37
+ }
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.swagger_types
42
+ {
43
+ :'table_id' => :'String',
44
+ :'column_definitions' => :'Array<FormTableColumnDefinition>',
45
+ :'target_table_height_relative' => :'Float',
46
+ :'target_row_height_relative' => :'Float'
47
+ }
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ return unless attributes.is_a?(Hash)
54
+
55
+ # convert string to symbol for hash key
56
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
57
+
58
+ if attributes.has_key?(:'TableID')
59
+ self.table_id = attributes[:'TableID']
60
+ end
61
+
62
+ if attributes.has_key?(:'ColumnDefinitions')
63
+ if (value = attributes[:'ColumnDefinitions']).is_a?(Array)
64
+ self.column_definitions = value
65
+ end
66
+ end
67
+
68
+ if attributes.has_key?(:'TargetTableHeight_Relative')
69
+ self.target_table_height_relative = attributes[:'TargetTableHeight_Relative']
70
+ end
71
+
72
+ if attributes.has_key?(:'TargetRowHeight_Relative')
73
+ self.target_row_height_relative = attributes[:'TargetRowHeight_Relative']
74
+ end
75
+ end
76
+
77
+ # Show invalid properties with the reasons. Usually used together with valid?
78
+ # @return Array for valid properties with the reasons
79
+ def list_invalid_properties
80
+ invalid_properties = Array.new
81
+ invalid_properties
82
+ end
83
+
84
+ # Check to see if the all the properties in the model are valid
85
+ # @return true if the model is valid
86
+ def valid?
87
+ true
88
+ end
89
+
90
+ # Checks equality by comparing each attribute.
91
+ # @param [Object] Object to be compared
92
+ def ==(o)
93
+ return true if self.equal?(o)
94
+ self.class == o.class &&
95
+ table_id == o.table_id &&
96
+ column_definitions == o.column_definitions &&
97
+ target_table_height_relative == o.target_table_height_relative &&
98
+ target_row_height_relative == o.target_row_height_relative
99
+ end
100
+
101
+ # @see the `==` method
102
+ # @param [Object] Object to be compared
103
+ def eql?(o)
104
+ self == o
105
+ end
106
+
107
+ # Calculates hash code according to all attributes.
108
+ # @return [Fixnum] Hash code
109
+ def hash
110
+ [table_id, column_definitions, target_table_height_relative, target_row_height_relative].hash
111
+ end
112
+
113
+ # Builds the object from hash
114
+ # @param [Hash] attributes Model attributes in the form of hash
115
+ # @return [Object] Returns the model itself
116
+ def build_from_hash(attributes)
117
+ return nil unless attributes.is_a?(Hash)
118
+ self.class.swagger_types.each_pair do |key, type|
119
+ if type =~ /\AArray<(.*)>/i
120
+ # check to ensure the input is an array given that the attribute
121
+ # is documented as an array but the input is not
122
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
123
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
124
+ end
125
+ elsif !attributes[self.class.attribute_map[key]].nil?
126
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
127
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
128
+ end
129
+
130
+ self
131
+ end
132
+
133
+ # Deserializes the data based on type
134
+ # @param string type Data type
135
+ # @param string value Value to be deserialized
136
+ # @return [Object] Deserialized data
137
+ def _deserialize(type, value)
138
+ case type.to_sym
139
+ when :DateTime
140
+ DateTime.parse(value)
141
+ when :Date
142
+ Date.parse(value)
143
+ when :String
144
+ value.to_s
145
+ when :Integer
146
+ value.to_i
147
+ when :Float
148
+ value.to_f
149
+ when :BOOLEAN
150
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
151
+ true
152
+ else
153
+ false
154
+ end
155
+ when :Object
156
+ # generic object (usually a Hash), return directly
157
+ value
158
+ when /\AArray<(?<inner_type>.+)>\z/
159
+ inner_type = Regexp.last_match[:inner_type]
160
+ value.map { |v| _deserialize(inner_type, v) }
161
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
162
+ k_type = Regexp.last_match[:k_type]
163
+ v_type = Regexp.last_match[:v_type]
164
+ {}.tap do |hash|
165
+ value.each do |k, v|
166
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
167
+ end
168
+ end
169
+ else # model
170
+ temp_model = CloudmersiveOcrApiClient.const_get(type).new
171
+ temp_model.build_from_hash(value)
172
+ end
173
+ end
174
+
175
+ # Returns the string representation of the object
176
+ # @return [String] String presentation of the object
177
+ def to_s
178
+ to_hash.to_s
179
+ end
180
+
181
+ # to_body is an alias to to_hash (backward compatibility)
182
+ # @return [Hash] Returns the object in the form of hash
183
+ def to_body
184
+ to_hash
185
+ end
186
+
187
+ # Returns the object in the form of hash
188
+ # @return [Hash] Returns the object in the form of hash
189
+ def to_hash
190
+ hash = {}
191
+ self.class.attribute_map.each_pair do |attr, param|
192
+ value = self.send(attr)
193
+ next if value.nil?
194
+ hash[param] = _to_hash(value)
195
+ end
196
+ hash
197
+ end
198
+
199
+ # Outputs non-array value in the form of hash
200
+ # For object, use to_hash. Otherwise, just return the value
201
+ # @param [Object] value Any valid value
202
+ # @return [Hash] Returns the value in the form of hash
203
+ def _to_hash(value)
204
+ if value.is_a?(Array)
205
+ value.compact.map { |v| _to_hash(v) }
206
+ elsif value.is_a?(Hash)
207
+ {}.tap do |hash|
208
+ value.each { |k, v| hash[k] = _to_hash(v) }
209
+ end
210
+ elsif value.respond_to? :to_hash
211
+ value.to_hash
212
+ else
213
+ value
214
+ end
215
+ end
216
+
217
+ end
218
+ end
@@ -0,0 +1,196 @@
1
+ =begin
2
+ #ocrapi
3
+
4
+ #The powerful Optical Character Recognition (OCR) APIs let you convert scanned images of pages into recognized text.
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 CloudmersiveOcrApiClient
16
+ # Result of performing a get-page-angle operation
17
+ class GetPageAngleResult
18
+ # True if the operation was successful, false otherwise
19
+ attr_accessor :successful
20
+
21
+ # Angle of the page in radians; 0 represents perfectly horizontal
22
+ attr_accessor :angle
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'successful' => :'Successful',
28
+ :'angle' => :'Angle'
29
+ }
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.swagger_types
34
+ {
35
+ :'successful' => :'BOOLEAN',
36
+ :'angle' => :'Float'
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?(:'Angle')
53
+ self.angle = attributes[:'Angle']
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
+ angle == o.angle
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, angle].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 = CloudmersiveOcrApiClient.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,198 @@
1
+ =begin
2
+ #ocrapi
3
+
4
+ #The powerful Optical Character Recognition (OCR) APIs let you convert scanned images of pages into recognized text.
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 CloudmersiveOcrApiClient
16
+ # Result of an image to lines-with-location OCR operation
17
+ class ImageToLinesWithLocationResult
18
+ # True if successful, false otherwise
19
+ attr_accessor :successful
20
+
21
+ # Words in the image
22
+ attr_accessor :lines
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'successful' => :'Successful',
28
+ :'lines' => :'Lines'
29
+ }
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.swagger_types
34
+ {
35
+ :'successful' => :'BOOLEAN',
36
+ :'lines' => :'Array<OcrLineElement>'
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?(:'Lines')
53
+ if (value = attributes[:'Lines']).is_a?(Array)
54
+ self.lines = value
55
+ end
56
+ end
57
+ end
58
+
59
+ # Show invalid properties with the reasons. Usually used together with valid?
60
+ # @return Array for valid properties with the reasons
61
+ def list_invalid_properties
62
+ invalid_properties = Array.new
63
+ invalid_properties
64
+ end
65
+
66
+ # Check to see if the all the properties in the model are valid
67
+ # @return true if the model is valid
68
+ def valid?
69
+ true
70
+ end
71
+
72
+ # Checks equality by comparing each attribute.
73
+ # @param [Object] Object to be compared
74
+ def ==(o)
75
+ return true if self.equal?(o)
76
+ self.class == o.class &&
77
+ successful == o.successful &&
78
+ lines == o.lines
79
+ end
80
+
81
+ # @see the `==` method
82
+ # @param [Object] Object to be compared
83
+ def eql?(o)
84
+ self == o
85
+ end
86
+
87
+ # Calculates hash code according to all attributes.
88
+ # @return [Fixnum] Hash code
89
+ def hash
90
+ [successful, lines].hash
91
+ end
92
+
93
+ # Builds the object from hash
94
+ # @param [Hash] attributes Model attributes in the form of hash
95
+ # @return [Object] Returns the model itself
96
+ def build_from_hash(attributes)
97
+ return nil unless attributes.is_a?(Hash)
98
+ self.class.swagger_types.each_pair do |key, type|
99
+ if type =~ /\AArray<(.*)>/i
100
+ # check to ensure the input is an array given that the attribute
101
+ # is documented as an array but the input is not
102
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
103
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
104
+ end
105
+ elsif !attributes[self.class.attribute_map[key]].nil?
106
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
107
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
108
+ end
109
+
110
+ self
111
+ end
112
+
113
+ # Deserializes the data based on type
114
+ # @param string type Data type
115
+ # @param string value Value to be deserialized
116
+ # @return [Object] Deserialized data
117
+ def _deserialize(type, value)
118
+ case type.to_sym
119
+ when :DateTime
120
+ DateTime.parse(value)
121
+ when :Date
122
+ Date.parse(value)
123
+ when :String
124
+ value.to_s
125
+ when :Integer
126
+ value.to_i
127
+ when :Float
128
+ value.to_f
129
+ when :BOOLEAN
130
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
131
+ true
132
+ else
133
+ false
134
+ end
135
+ when :Object
136
+ # generic object (usually a Hash), return directly
137
+ value
138
+ when /\AArray<(?<inner_type>.+)>\z/
139
+ inner_type = Regexp.last_match[:inner_type]
140
+ value.map { |v| _deserialize(inner_type, v) }
141
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
142
+ k_type = Regexp.last_match[:k_type]
143
+ v_type = Regexp.last_match[:v_type]
144
+ {}.tap do |hash|
145
+ value.each do |k, v|
146
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
147
+ end
148
+ end
149
+ else # model
150
+ temp_model = CloudmersiveOcrApiClient.const_get(type).new
151
+ temp_model.build_from_hash(value)
152
+ end
153
+ end
154
+
155
+ # Returns the string representation of the object
156
+ # @return [String] String presentation of the object
157
+ def to_s
158
+ to_hash.to_s
159
+ end
160
+
161
+ # to_body is an alias to to_hash (backward compatibility)
162
+ # @return [Hash] Returns the object in the form of hash
163
+ def to_body
164
+ to_hash
165
+ end
166
+
167
+ # Returns the object in the form of hash
168
+ # @return [Hash] Returns the object in the form of hash
169
+ def to_hash
170
+ hash = {}
171
+ self.class.attribute_map.each_pair do |attr, param|
172
+ value = self.send(attr)
173
+ next if value.nil?
174
+ hash[param] = _to_hash(value)
175
+ end
176
+ hash
177
+ end
178
+
179
+ # Outputs non-array value in the form of hash
180
+ # For object, use to_hash. Otherwise, just return the value
181
+ # @param [Object] value Any valid value
182
+ # @return [Hash] Returns the value in the form of hash
183
+ def _to_hash(value)
184
+ if value.is_a?(Array)
185
+ value.compact.map { |v| _to_hash(v) }
186
+ elsif value.is_a?(Hash)
187
+ {}.tap do |hash|
188
+ value.each { |k, v| hash[k] = _to_hash(v) }
189
+ end
190
+ elsif value.respond_to? :to_hash
191
+ value.to_hash
192
+ else
193
+ value
194
+ end
195
+ end
196
+
197
+ end
198
+ end