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,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
+ # A pairing target field and actual value read from form
17
+ class FieldResult
18
+ # Target field to extract from the form
19
+ attr_accessor :target_field
20
+
21
+ # Result field value(s) extracted
22
+ attr_accessor :field_values
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'target_field' => :'TargetField',
28
+ :'field_values' => :'FieldValues'
29
+ }
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.swagger_types
34
+ {
35
+ :'target_field' => :'FormFieldDefinition',
36
+ :'field_values' => :'Array<OcrPhotoTextElement>'
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?(:'TargetField')
49
+ self.target_field = attributes[:'TargetField']
50
+ end
51
+
52
+ if attributes.has_key?(:'FieldValues')
53
+ if (value = attributes[:'FieldValues']).is_a?(Array)
54
+ self.field_values = 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
+ target_field == o.target_field &&
78
+ field_values == o.field_values
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
+ [target_field, field_values].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
@@ -0,0 +1,200 @@
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 template; use a form template definition to recognize the fields in a form with Cloudmersive OCR
17
+ class FormDefinitionTemplate
18
+ # Field definitions in the template; a field is comprised of a key/value pair
19
+ attr_accessor :field_definitions
20
+
21
+ # Table definitions in the template; a table is comprised of columns and rows and exists in a 2-dimensional layout; a common example of a table would be an invoice
22
+ attr_accessor :table_definitions
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'field_definitions' => :'FieldDefinitions',
28
+ :'table_definitions' => :'TableDefinitions'
29
+ }
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.swagger_types
34
+ {
35
+ :'field_definitions' => :'Array<FormFieldDefinition>',
36
+ :'table_definitions' => :'Array<FormTableDefinition>'
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?(:'FieldDefinitions')
49
+ if (value = attributes[:'FieldDefinitions']).is_a?(Array)
50
+ self.field_definitions = value
51
+ end
52
+ end
53
+
54
+ if attributes.has_key?(:'TableDefinitions')
55
+ if (value = attributes[:'TableDefinitions']).is_a?(Array)
56
+ self.table_definitions = value
57
+ end
58
+ end
59
+ end
60
+
61
+ # Show invalid properties with the reasons. Usually used together with valid?
62
+ # @return Array for valid properties with the reasons
63
+ def list_invalid_properties
64
+ invalid_properties = Array.new
65
+ invalid_properties
66
+ end
67
+
68
+ # Check to see if the all the properties in the model are valid
69
+ # @return true if the model is valid
70
+ def valid?
71
+ true
72
+ end
73
+
74
+ # Checks equality by comparing each attribute.
75
+ # @param [Object] Object to be compared
76
+ def ==(o)
77
+ return true if self.equal?(o)
78
+ self.class == o.class &&
79
+ field_definitions == o.field_definitions &&
80
+ table_definitions == o.table_definitions
81
+ end
82
+
83
+ # @see the `==` method
84
+ # @param [Object] Object to be compared
85
+ def eql?(o)
86
+ self == o
87
+ end
88
+
89
+ # Calculates hash code according to all attributes.
90
+ # @return [Fixnum] Hash code
91
+ def hash
92
+ [field_definitions, table_definitions].hash
93
+ end
94
+
95
+ # Builds the object from hash
96
+ # @param [Hash] attributes Model attributes in the form of hash
97
+ # @return [Object] Returns the model itself
98
+ def build_from_hash(attributes)
99
+ return nil unless attributes.is_a?(Hash)
100
+ self.class.swagger_types.each_pair do |key, type|
101
+ if type =~ /\AArray<(.*)>/i
102
+ # check to ensure the input is an array given that the attribute
103
+ # is documented as an array but the input is not
104
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
105
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
106
+ end
107
+ elsif !attributes[self.class.attribute_map[key]].nil?
108
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
109
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
110
+ end
111
+
112
+ self
113
+ end
114
+
115
+ # Deserializes the data based on type
116
+ # @param string type Data type
117
+ # @param string value Value to be deserialized
118
+ # @return [Object] Deserialized data
119
+ def _deserialize(type, value)
120
+ case type.to_sym
121
+ when :DateTime
122
+ DateTime.parse(value)
123
+ when :Date
124
+ Date.parse(value)
125
+ when :String
126
+ value.to_s
127
+ when :Integer
128
+ value.to_i
129
+ when :Float
130
+ value.to_f
131
+ when :BOOLEAN
132
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
133
+ true
134
+ else
135
+ false
136
+ end
137
+ when :Object
138
+ # generic object (usually a Hash), return directly
139
+ value
140
+ when /\AArray<(?<inner_type>.+)>\z/
141
+ inner_type = Regexp.last_match[:inner_type]
142
+ value.map { |v| _deserialize(inner_type, v) }
143
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
144
+ k_type = Regexp.last_match[:k_type]
145
+ v_type = Regexp.last_match[:v_type]
146
+ {}.tap do |hash|
147
+ value.each do |k, v|
148
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
149
+ end
150
+ end
151
+ else # model
152
+ temp_model = CloudmersiveOcrApiClient.const_get(type).new
153
+ temp_model.build_from_hash(value)
154
+ end
155
+ end
156
+
157
+ # Returns the string representation of the object
158
+ # @return [String] String presentation of the object
159
+ def to_s
160
+ to_hash.to_s
161
+ end
162
+
163
+ # to_body is an alias to to_hash (backward compatibility)
164
+ # @return [Hash] Returns the object in the form of hash
165
+ def to_body
166
+ to_hash
167
+ end
168
+
169
+ # Returns the object in the form of hash
170
+ # @return [Hash] Returns the object in the form of hash
171
+ def to_hash
172
+ hash = {}
173
+ self.class.attribute_map.each_pair do |attr, param|
174
+ value = self.send(attr)
175
+ next if value.nil?
176
+ hash[param] = _to_hash(value)
177
+ end
178
+ hash
179
+ end
180
+
181
+ # Outputs non-array value in the form of hash
182
+ # For object, use to_hash. Otherwise, just return the value
183
+ # @param [Object] value Any valid value
184
+ # @return [Hash] Returns the value in the form of hash
185
+ def _to_hash(value)
186
+ if value.is_a?(Array)
187
+ value.compact.map { |v| _to_hash(v) }
188
+ elsif value.is_a?(Hash)
189
+ {}.tap do |hash|
190
+ value.each { |k, v| hash[k] = _to_hash(v) }
191
+ end
192
+ elsif value.respond_to? :to_hash
193
+ value.to_hash
194
+ else
195
+ value
196
+ end
197
+ end
198
+
199
+ end
200
+ end
@@ -0,0 +1,358 @@
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 field for OCR data extraction from images
17
+ class FormFieldDefinition
18
+ # The identifier of the field; use this to identify which field is being referenced. Set to SkipField if you do not wish to return the value of this field in the result.
19
+ attr_accessor :field_id
20
+
21
+ # Optional - the left-hand anchor of the field
22
+ attr_accessor :left_anchor
23
+
24
+ # Optional - the top anchor of the field
25
+ attr_accessor :top_anchor
26
+
27
+ # Optional - the bottom anchor of the field
28
+ attr_accessor :bottom_anchor
29
+
30
+ # Optional - alterate match text for the specified anchor
31
+ attr_accessor :alternate_anchor
32
+
33
+ # Optional - the matching mode for the anchor. Possible values are Complete (requires the entire anchor to match) and Partial (allows only part of the anchor to match) and Horizontal (anchor must be laid out horizontally). Default is Partial.
34
+ attr_accessor :anchor_mode
35
+
36
+ # The data type of the field; possible values are INTEGER (Integer value), STRING (Arbitrary string value, spaces are permitted), DATE (Date in a structured format), DECIMAL (Decimal number), ALPHANUMERIC (Continuous alphanumeric string with no spaces), STRINGNOWHITESPACE (A string that contains no whitespace characters), SERIALNUMBER (A serial-number style string that contains letters and numbers, and certain symbols; must contain at least one number), ALPHAONLY (Alphabet characters only, no numbers or symbols or whitespace)
37
+ attr_accessor :data_type
38
+
39
+ # Optional - the target number of digits in the field; useful for fixed-length fields
40
+ attr_accessor :target_digit_count
41
+
42
+ # Optional - the target number of digits in the field; useful for fixed-length fields
43
+ attr_accessor :minimum_character_count
44
+
45
+ # Optional - set to false to block values that contain numeric digits, set to true to allow numeric digits
46
+ attr_accessor :allow_numeric_digits
47
+
48
+ # Vertical alignment of target value area relative to the field anchor; Possible values are VCenter, Top, Bottom
49
+ attr_accessor :vertical_alignment_type
50
+
51
+ # Horizontal alignment of target value area relative to the field anchor; Possible values are Left, Right
52
+ attr_accessor :horizontal_alignment_type
53
+
54
+ # Optional - scale factor for target field width - relative to width of field title; a value of 1.0 indicates the target value area has the same width as the field value as occurring in the image; a value of 2.0 would indicate that the target value area has 2 times the width of the field value as occurring in the image.
55
+ attr_accessor :target_field_width_relative
56
+
57
+ # Optional - scale factor for target field height - relative to height of field title
58
+ attr_accessor :target_field_height_relative
59
+
60
+ # Optional - horizontal adjestment in relative width of the field
61
+ attr_accessor :target_field_horizontal_adjustment
62
+
63
+ # Optional - vertical adjestment in relative height of the field
64
+ attr_accessor :target_field_vertical_adjustment
65
+
66
+ # Optional - Ignore any result items that contain a partial or complete match with these text strings
67
+ attr_accessor :ignore
68
+
69
+ # Optional - additional options that can be set for this field definition, separated by commas. Possible values are AllowMultiMatch (allow the same anchor to be matched to multiple fields)
70
+ attr_accessor :options
71
+
72
+ # Attribute mapping from ruby-style variable name to JSON key.
73
+ def self.attribute_map
74
+ {
75
+ :'field_id' => :'FieldID',
76
+ :'left_anchor' => :'LeftAnchor',
77
+ :'top_anchor' => :'TopAnchor',
78
+ :'bottom_anchor' => :'BottomAnchor',
79
+ :'alternate_anchor' => :'AlternateAnchor',
80
+ :'anchor_mode' => :'AnchorMode',
81
+ :'data_type' => :'DataType',
82
+ :'target_digit_count' => :'TargetDigitCount',
83
+ :'minimum_character_count' => :'MinimumCharacterCount',
84
+ :'allow_numeric_digits' => :'AllowNumericDigits',
85
+ :'vertical_alignment_type' => :'VerticalAlignmentType',
86
+ :'horizontal_alignment_type' => :'HorizontalAlignmentType',
87
+ :'target_field_width_relative' => :'TargetFieldWidth_Relative',
88
+ :'target_field_height_relative' => :'TargetFieldHeight_Relative',
89
+ :'target_field_horizontal_adjustment' => :'TargetFieldHorizontalAdjustment',
90
+ :'target_field_vertical_adjustment' => :'TargetFieldVerticalAdjustment',
91
+ :'ignore' => :'Ignore',
92
+ :'options' => :'Options'
93
+ }
94
+ end
95
+
96
+ # Attribute type mapping.
97
+ def self.swagger_types
98
+ {
99
+ :'field_id' => :'String',
100
+ :'left_anchor' => :'String',
101
+ :'top_anchor' => :'String',
102
+ :'bottom_anchor' => :'String',
103
+ :'alternate_anchor' => :'String',
104
+ :'anchor_mode' => :'String',
105
+ :'data_type' => :'String',
106
+ :'target_digit_count' => :'Integer',
107
+ :'minimum_character_count' => :'Integer',
108
+ :'allow_numeric_digits' => :'BOOLEAN',
109
+ :'vertical_alignment_type' => :'String',
110
+ :'horizontal_alignment_type' => :'String',
111
+ :'target_field_width_relative' => :'Float',
112
+ :'target_field_height_relative' => :'Float',
113
+ :'target_field_horizontal_adjustment' => :'Float',
114
+ :'target_field_vertical_adjustment' => :'Float',
115
+ :'ignore' => :'Array<String>',
116
+ :'options' => :'String'
117
+ }
118
+ end
119
+
120
+ # Initializes the object
121
+ # @param [Hash] attributes Model attributes in the form of hash
122
+ def initialize(attributes = {})
123
+ return unless attributes.is_a?(Hash)
124
+
125
+ # convert string to symbol for hash key
126
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
127
+
128
+ if attributes.has_key?(:'FieldID')
129
+ self.field_id = attributes[:'FieldID']
130
+ end
131
+
132
+ if attributes.has_key?(:'LeftAnchor')
133
+ self.left_anchor = attributes[:'LeftAnchor']
134
+ end
135
+
136
+ if attributes.has_key?(:'TopAnchor')
137
+ self.top_anchor = attributes[:'TopAnchor']
138
+ end
139
+
140
+ if attributes.has_key?(:'BottomAnchor')
141
+ self.bottom_anchor = attributes[:'BottomAnchor']
142
+ end
143
+
144
+ if attributes.has_key?(:'AlternateAnchor')
145
+ self.alternate_anchor = attributes[:'AlternateAnchor']
146
+ end
147
+
148
+ if attributes.has_key?(:'AnchorMode')
149
+ self.anchor_mode = attributes[:'AnchorMode']
150
+ end
151
+
152
+ if attributes.has_key?(:'DataType')
153
+ self.data_type = attributes[:'DataType']
154
+ end
155
+
156
+ if attributes.has_key?(:'TargetDigitCount')
157
+ self.target_digit_count = attributes[:'TargetDigitCount']
158
+ end
159
+
160
+ if attributes.has_key?(:'MinimumCharacterCount')
161
+ self.minimum_character_count = attributes[:'MinimumCharacterCount']
162
+ end
163
+
164
+ if attributes.has_key?(:'AllowNumericDigits')
165
+ self.allow_numeric_digits = attributes[:'AllowNumericDigits']
166
+ end
167
+
168
+ if attributes.has_key?(:'VerticalAlignmentType')
169
+ self.vertical_alignment_type = attributes[:'VerticalAlignmentType']
170
+ end
171
+
172
+ if attributes.has_key?(:'HorizontalAlignmentType')
173
+ self.horizontal_alignment_type = attributes[:'HorizontalAlignmentType']
174
+ end
175
+
176
+ if attributes.has_key?(:'TargetFieldWidth_Relative')
177
+ self.target_field_width_relative = attributes[:'TargetFieldWidth_Relative']
178
+ end
179
+
180
+ if attributes.has_key?(:'TargetFieldHeight_Relative')
181
+ self.target_field_height_relative = attributes[:'TargetFieldHeight_Relative']
182
+ end
183
+
184
+ if attributes.has_key?(:'TargetFieldHorizontalAdjustment')
185
+ self.target_field_horizontal_adjustment = attributes[:'TargetFieldHorizontalAdjustment']
186
+ end
187
+
188
+ if attributes.has_key?(:'TargetFieldVerticalAdjustment')
189
+ self.target_field_vertical_adjustment = attributes[:'TargetFieldVerticalAdjustment']
190
+ end
191
+
192
+ if attributes.has_key?(:'Ignore')
193
+ if (value = attributes[:'Ignore']).is_a?(Array)
194
+ self.ignore = value
195
+ end
196
+ end
197
+
198
+ if attributes.has_key?(:'Options')
199
+ self.options = attributes[:'Options']
200
+ end
201
+ end
202
+
203
+ # Show invalid properties with the reasons. Usually used together with valid?
204
+ # @return Array for valid properties with the reasons
205
+ def list_invalid_properties
206
+ invalid_properties = Array.new
207
+ invalid_properties
208
+ end
209
+
210
+ # Check to see if the all the properties in the model are valid
211
+ # @return true if the model is valid
212
+ def valid?
213
+ true
214
+ end
215
+
216
+ # Checks equality by comparing each attribute.
217
+ # @param [Object] Object to be compared
218
+ def ==(o)
219
+ return true if self.equal?(o)
220
+ self.class == o.class &&
221
+ field_id == o.field_id &&
222
+ left_anchor == o.left_anchor &&
223
+ top_anchor == o.top_anchor &&
224
+ bottom_anchor == o.bottom_anchor &&
225
+ alternate_anchor == o.alternate_anchor &&
226
+ anchor_mode == o.anchor_mode &&
227
+ data_type == o.data_type &&
228
+ target_digit_count == o.target_digit_count &&
229
+ minimum_character_count == o.minimum_character_count &&
230
+ allow_numeric_digits == o.allow_numeric_digits &&
231
+ vertical_alignment_type == o.vertical_alignment_type &&
232
+ horizontal_alignment_type == o.horizontal_alignment_type &&
233
+ target_field_width_relative == o.target_field_width_relative &&
234
+ target_field_height_relative == o.target_field_height_relative &&
235
+ target_field_horizontal_adjustment == o.target_field_horizontal_adjustment &&
236
+ target_field_vertical_adjustment == o.target_field_vertical_adjustment &&
237
+ ignore == o.ignore &&
238
+ options == o.options
239
+ end
240
+
241
+ # @see the `==` method
242
+ # @param [Object] Object to be compared
243
+ def eql?(o)
244
+ self == o
245
+ end
246
+
247
+ # Calculates hash code according to all attributes.
248
+ # @return [Fixnum] Hash code
249
+ def hash
250
+ [field_id, left_anchor, top_anchor, bottom_anchor, alternate_anchor, anchor_mode, data_type, target_digit_count, minimum_character_count, allow_numeric_digits, vertical_alignment_type, horizontal_alignment_type, target_field_width_relative, target_field_height_relative, target_field_horizontal_adjustment, target_field_vertical_adjustment, ignore, options].hash
251
+ end
252
+
253
+ # Builds the object from hash
254
+ # @param [Hash] attributes Model attributes in the form of hash
255
+ # @return [Object] Returns the model itself
256
+ def build_from_hash(attributes)
257
+ return nil unless attributes.is_a?(Hash)
258
+ self.class.swagger_types.each_pair do |key, type|
259
+ if type =~ /\AArray<(.*)>/i
260
+ # check to ensure the input is an array given that the attribute
261
+ # is documented as an array but the input is not
262
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
263
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
264
+ end
265
+ elsif !attributes[self.class.attribute_map[key]].nil?
266
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
267
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
268
+ end
269
+
270
+ self
271
+ end
272
+
273
+ # Deserializes the data based on type
274
+ # @param string type Data type
275
+ # @param string value Value to be deserialized
276
+ # @return [Object] Deserialized data
277
+ def _deserialize(type, value)
278
+ case type.to_sym
279
+ when :DateTime
280
+ DateTime.parse(value)
281
+ when :Date
282
+ Date.parse(value)
283
+ when :String
284
+ value.to_s
285
+ when :Integer
286
+ value.to_i
287
+ when :Float
288
+ value.to_f
289
+ when :BOOLEAN
290
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
291
+ true
292
+ else
293
+ false
294
+ end
295
+ when :Object
296
+ # generic object (usually a Hash), return directly
297
+ value
298
+ when /\AArray<(?<inner_type>.+)>\z/
299
+ inner_type = Regexp.last_match[:inner_type]
300
+ value.map { |v| _deserialize(inner_type, v) }
301
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
302
+ k_type = Regexp.last_match[:k_type]
303
+ v_type = Regexp.last_match[:v_type]
304
+ {}.tap do |hash|
305
+ value.each do |k, v|
306
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
307
+ end
308
+ end
309
+ else # model
310
+ temp_model = CloudmersiveOcrApiClient.const_get(type).new
311
+ temp_model.build_from_hash(value)
312
+ end
313
+ end
314
+
315
+ # Returns the string representation of the object
316
+ # @return [String] String presentation of the object
317
+ def to_s
318
+ to_hash.to_s
319
+ end
320
+
321
+ # to_body is an alias to to_hash (backward compatibility)
322
+ # @return [Hash] Returns the object in the form of hash
323
+ def to_body
324
+ to_hash
325
+ end
326
+
327
+ # Returns the object in the form of hash
328
+ # @return [Hash] Returns the object in the form of hash
329
+ def to_hash
330
+ hash = {}
331
+ self.class.attribute_map.each_pair do |attr, param|
332
+ value = self.send(attr)
333
+ next if value.nil?
334
+ hash[param] = _to_hash(value)
335
+ end
336
+ hash
337
+ end
338
+
339
+ # Outputs non-array value in the form of hash
340
+ # For object, use to_hash. Otherwise, just return the value
341
+ # @param [Object] value Any valid value
342
+ # @return [Hash] Returns the value in the form of hash
343
+ def _to_hash(value)
344
+ if value.is_a?(Array)
345
+ value.compact.map { |v| _to_hash(v) }
346
+ elsif value.is_a?(Hash)
347
+ {}.tap do |hash|
348
+ value.each { |k, v| hash[k] = _to_hash(v) }
349
+ end
350
+ elsif value.respond_to? :to_hash
351
+ value.to_hash
352
+ else
353
+ value
354
+ end
355
+ end
356
+
357
+ end
358
+ end