cloudmersive-ocr-api-client 1.3.9 → 1.4.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.
@@ -0,0 +1,190 @@
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: unset
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
+ attr_accessor :field_definitions
19
+
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'field_definitions' => :'FieldDefinitions'
25
+ }
26
+ end
27
+
28
+ # Attribute type mapping.
29
+ def self.swagger_types
30
+ {
31
+ :'field_definitions' => :'Array<FormFieldDefinition>'
32
+ }
33
+ end
34
+
35
+ # Initializes the object
36
+ # @param [Hash] attributes Model attributes in the form of hash
37
+ def initialize(attributes = {})
38
+ return unless attributes.is_a?(Hash)
39
+
40
+ # convert string to symbol for hash key
41
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
42
+
43
+ if attributes.has_key?(:'FieldDefinitions')
44
+ if (value = attributes[:'FieldDefinitions']).is_a?(Array)
45
+ self.field_definitions = value
46
+ end
47
+ end
48
+
49
+ end
50
+
51
+ # Show invalid properties with the reasons. Usually used together with valid?
52
+ # @return Array for valid properties with the reasons
53
+ def list_invalid_properties
54
+ invalid_properties = Array.new
55
+ return invalid_properties
56
+ end
57
+
58
+ # Check to see if the all the properties in the model are valid
59
+ # @return true if the model is valid
60
+ def valid?
61
+ return true
62
+ end
63
+
64
+ # Checks equality by comparing each attribute.
65
+ # @param [Object] Object to be compared
66
+ def ==(o)
67
+ return true if self.equal?(o)
68
+ self.class == o.class &&
69
+ field_definitions == o.field_definitions
70
+ end
71
+
72
+ # @see the `==` method
73
+ # @param [Object] Object to be compared
74
+ def eql?(o)
75
+ self == o
76
+ end
77
+
78
+ # Calculates hash code according to all attributes.
79
+ # @return [Fixnum] Hash code
80
+ def hash
81
+ [field_definitions].hash
82
+ end
83
+
84
+ # Builds the object from hash
85
+ # @param [Hash] attributes Model attributes in the form of hash
86
+ # @return [Object] Returns the model itself
87
+ def build_from_hash(attributes)
88
+ return nil unless attributes.is_a?(Hash)
89
+ self.class.swagger_types.each_pair do |key, type|
90
+ if type =~ /\AArray<(.*)>/i
91
+ # check to ensure the input is an array given that the the attribute
92
+ # is documented as an array but the input is not
93
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
94
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
95
+ end
96
+ elsif !attributes[self.class.attribute_map[key]].nil?
97
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
98
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
99
+ end
100
+
101
+ self
102
+ end
103
+
104
+ # Deserializes the data based on type
105
+ # @param string type Data type
106
+ # @param string value Value to be deserialized
107
+ # @return [Object] Deserialized data
108
+ def _deserialize(type, value)
109
+ case type.to_sym
110
+ when :DateTime
111
+ DateTime.parse(value)
112
+ when :Date
113
+ Date.parse(value)
114
+ when :String
115
+ value.to_s
116
+ when :Integer
117
+ value.to_i
118
+ when :Float
119
+ value.to_f
120
+ when :BOOLEAN
121
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
122
+ true
123
+ else
124
+ false
125
+ end
126
+ when :Object
127
+ # generic object (usually a Hash), return directly
128
+ value
129
+ when /\AArray<(?<inner_type>.+)>\z/
130
+ inner_type = Regexp.last_match[:inner_type]
131
+ value.map { |v| _deserialize(inner_type, v) }
132
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
133
+ k_type = Regexp.last_match[:k_type]
134
+ v_type = Regexp.last_match[:v_type]
135
+ {}.tap do |hash|
136
+ value.each do |k, v|
137
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
138
+ end
139
+ end
140
+ else # model
141
+ temp_model = CloudmersiveOcrApiClient.const_get(type).new
142
+ temp_model.build_from_hash(value)
143
+ end
144
+ end
145
+
146
+ # Returns the string representation of the object
147
+ # @return [String] String presentation of the object
148
+ def to_s
149
+ to_hash.to_s
150
+ end
151
+
152
+ # to_body is an alias to to_hash (backward compatibility)
153
+ # @return [Hash] Returns the object in the form of hash
154
+ def to_body
155
+ to_hash
156
+ end
157
+
158
+ # Returns the object in the form of hash
159
+ # @return [Hash] Returns the object in the form of hash
160
+ def to_hash
161
+ hash = {}
162
+ self.class.attribute_map.each_pair do |attr, param|
163
+ value = self.send(attr)
164
+ next if value.nil?
165
+ hash[param] = _to_hash(value)
166
+ end
167
+ hash
168
+ end
169
+
170
+ # Outputs non-array value in the form of hash
171
+ # For object, use to_hash. Otherwise, just return the value
172
+ # @param [Object] value Any valid value
173
+ # @return [Hash] Returns the value in the form of hash
174
+ def _to_hash(value)
175
+ if value.is_a?(Array)
176
+ value.compact.map{ |v| _to_hash(v) }
177
+ elsif value.is_a?(Hash)
178
+ {}.tap do |hash|
179
+ value.each { |k, v| hash[k] = _to_hash(v) }
180
+ end
181
+ elsif value.respond_to? :to_hash
182
+ value.to_hash
183
+ else
184
+ value
185
+ end
186
+ end
187
+
188
+ end
189
+
190
+ end
@@ -0,0 +1,298 @@
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: unset
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
+ attr_accessor :field_id
19
+
20
+ attr_accessor :left_anchor
21
+
22
+ attr_accessor :top_anchor
23
+
24
+ attr_accessor :anchor_mode
25
+
26
+ attr_accessor :data_type
27
+
28
+ attr_accessor :target_digit_count
29
+
30
+ attr_accessor :minimum_character_count
31
+
32
+ attr_accessor :allow_numeric_digits
33
+
34
+ attr_accessor :vertical_alignment_type
35
+
36
+ attr_accessor :horizontal_alignment_type
37
+
38
+ attr_accessor :target_field_width_relative
39
+
40
+ attr_accessor :target_field_height_relative
41
+
42
+ attr_accessor :ignore
43
+
44
+
45
+ # Attribute mapping from ruby-style variable name to JSON key.
46
+ def self.attribute_map
47
+ {
48
+ :'field_id' => :'FieldID',
49
+ :'left_anchor' => :'LeftAnchor',
50
+ :'top_anchor' => :'TopAnchor',
51
+ :'anchor_mode' => :'AnchorMode',
52
+ :'data_type' => :'DataType',
53
+ :'target_digit_count' => :'TargetDigitCount',
54
+ :'minimum_character_count' => :'MinimumCharacterCount',
55
+ :'allow_numeric_digits' => :'AllowNumericDigits',
56
+ :'vertical_alignment_type' => :'VerticalAlignmentType',
57
+ :'horizontal_alignment_type' => :'HorizontalAlignmentType',
58
+ :'target_field_width_relative' => :'TargetFieldWidth_Relative',
59
+ :'target_field_height_relative' => :'TargetFieldHeight_Relative',
60
+ :'ignore' => :'Ignore'
61
+ }
62
+ end
63
+
64
+ # Attribute type mapping.
65
+ def self.swagger_types
66
+ {
67
+ :'field_id' => :'String',
68
+ :'left_anchor' => :'String',
69
+ :'top_anchor' => :'String',
70
+ :'anchor_mode' => :'String',
71
+ :'data_type' => :'String',
72
+ :'target_digit_count' => :'Integer',
73
+ :'minimum_character_count' => :'Integer',
74
+ :'allow_numeric_digits' => :'BOOLEAN',
75
+ :'vertical_alignment_type' => :'String',
76
+ :'horizontal_alignment_type' => :'String',
77
+ :'target_field_width_relative' => :'Float',
78
+ :'target_field_height_relative' => :'Float',
79
+ :'ignore' => :'Array<String>'
80
+ }
81
+ end
82
+
83
+ # Initializes the object
84
+ # @param [Hash] attributes Model attributes in the form of hash
85
+ def initialize(attributes = {})
86
+ return unless attributes.is_a?(Hash)
87
+
88
+ # convert string to symbol for hash key
89
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
90
+
91
+ if attributes.has_key?(:'FieldID')
92
+ self.field_id = attributes[:'FieldID']
93
+ end
94
+
95
+ if attributes.has_key?(:'LeftAnchor')
96
+ self.left_anchor = attributes[:'LeftAnchor']
97
+ end
98
+
99
+ if attributes.has_key?(:'TopAnchor')
100
+ self.top_anchor = attributes[:'TopAnchor']
101
+ end
102
+
103
+ if attributes.has_key?(:'AnchorMode')
104
+ self.anchor_mode = attributes[:'AnchorMode']
105
+ end
106
+
107
+ if attributes.has_key?(:'DataType')
108
+ self.data_type = attributes[:'DataType']
109
+ end
110
+
111
+ if attributes.has_key?(:'TargetDigitCount')
112
+ self.target_digit_count = attributes[:'TargetDigitCount']
113
+ end
114
+
115
+ if attributes.has_key?(:'MinimumCharacterCount')
116
+ self.minimum_character_count = attributes[:'MinimumCharacterCount']
117
+ end
118
+
119
+ if attributes.has_key?(:'AllowNumericDigits')
120
+ self.allow_numeric_digits = attributes[:'AllowNumericDigits']
121
+ end
122
+
123
+ if attributes.has_key?(:'VerticalAlignmentType')
124
+ self.vertical_alignment_type = attributes[:'VerticalAlignmentType']
125
+ end
126
+
127
+ if attributes.has_key?(:'HorizontalAlignmentType')
128
+ self.horizontal_alignment_type = attributes[:'HorizontalAlignmentType']
129
+ end
130
+
131
+ if attributes.has_key?(:'TargetFieldWidth_Relative')
132
+ self.target_field_width_relative = attributes[:'TargetFieldWidth_Relative']
133
+ end
134
+
135
+ if attributes.has_key?(:'TargetFieldHeight_Relative')
136
+ self.target_field_height_relative = attributes[:'TargetFieldHeight_Relative']
137
+ end
138
+
139
+ if attributes.has_key?(:'Ignore')
140
+ if (value = attributes[:'Ignore']).is_a?(Array)
141
+ self.ignore = value
142
+ end
143
+ end
144
+
145
+ end
146
+
147
+ # Show invalid properties with the reasons. Usually used together with valid?
148
+ # @return Array for valid properties with the reasons
149
+ def list_invalid_properties
150
+ invalid_properties = Array.new
151
+ return invalid_properties
152
+ end
153
+
154
+ # Check to see if the all the properties in the model are valid
155
+ # @return true if the model is valid
156
+ def valid?
157
+ return true
158
+ end
159
+
160
+ # Checks equality by comparing each attribute.
161
+ # @param [Object] Object to be compared
162
+ def ==(o)
163
+ return true if self.equal?(o)
164
+ self.class == o.class &&
165
+ field_id == o.field_id &&
166
+ left_anchor == o.left_anchor &&
167
+ top_anchor == o.top_anchor &&
168
+ anchor_mode == o.anchor_mode &&
169
+ data_type == o.data_type &&
170
+ target_digit_count == o.target_digit_count &&
171
+ minimum_character_count == o.minimum_character_count &&
172
+ allow_numeric_digits == o.allow_numeric_digits &&
173
+ vertical_alignment_type == o.vertical_alignment_type &&
174
+ horizontal_alignment_type == o.horizontal_alignment_type &&
175
+ target_field_width_relative == o.target_field_width_relative &&
176
+ target_field_height_relative == o.target_field_height_relative &&
177
+ ignore == o.ignore
178
+ end
179
+
180
+ # @see the `==` method
181
+ # @param [Object] Object to be compared
182
+ def eql?(o)
183
+ self == o
184
+ end
185
+
186
+ # Calculates hash code according to all attributes.
187
+ # @return [Fixnum] Hash code
188
+ def hash
189
+ [field_id, left_anchor, top_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, ignore].hash
190
+ end
191
+
192
+ # Builds the object from hash
193
+ # @param [Hash] attributes Model attributes in the form of hash
194
+ # @return [Object] Returns the model itself
195
+ def build_from_hash(attributes)
196
+ return nil unless attributes.is_a?(Hash)
197
+ self.class.swagger_types.each_pair do |key, type|
198
+ if type =~ /\AArray<(.*)>/i
199
+ # check to ensure the input is an array given that the the attribute
200
+ # is documented as an array but the input is not
201
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
202
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
203
+ end
204
+ elsif !attributes[self.class.attribute_map[key]].nil?
205
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
206
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
207
+ end
208
+
209
+ self
210
+ end
211
+
212
+ # Deserializes the data based on type
213
+ # @param string type Data type
214
+ # @param string value Value to be deserialized
215
+ # @return [Object] Deserialized data
216
+ def _deserialize(type, value)
217
+ case type.to_sym
218
+ when :DateTime
219
+ DateTime.parse(value)
220
+ when :Date
221
+ Date.parse(value)
222
+ when :String
223
+ value.to_s
224
+ when :Integer
225
+ value.to_i
226
+ when :Float
227
+ value.to_f
228
+ when :BOOLEAN
229
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
230
+ true
231
+ else
232
+ false
233
+ end
234
+ when :Object
235
+ # generic object (usually a Hash), return directly
236
+ value
237
+ when /\AArray<(?<inner_type>.+)>\z/
238
+ inner_type = Regexp.last_match[:inner_type]
239
+ value.map { |v| _deserialize(inner_type, v) }
240
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
241
+ k_type = Regexp.last_match[:k_type]
242
+ v_type = Regexp.last_match[:v_type]
243
+ {}.tap do |hash|
244
+ value.each do |k, v|
245
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
246
+ end
247
+ end
248
+ else # model
249
+ temp_model = CloudmersiveOcrApiClient.const_get(type).new
250
+ temp_model.build_from_hash(value)
251
+ end
252
+ end
253
+
254
+ # Returns the string representation of the object
255
+ # @return [String] String presentation of the object
256
+ def to_s
257
+ to_hash.to_s
258
+ end
259
+
260
+ # to_body is an alias to to_hash (backward compatibility)
261
+ # @return [Hash] Returns the object in the form of hash
262
+ def to_body
263
+ to_hash
264
+ end
265
+
266
+ # Returns the object in the form of hash
267
+ # @return [Hash] Returns the object in the form of hash
268
+ def to_hash
269
+ hash = {}
270
+ self.class.attribute_map.each_pair do |attr, param|
271
+ value = self.send(attr)
272
+ next if value.nil?
273
+ hash[param] = _to_hash(value)
274
+ end
275
+ hash
276
+ end
277
+
278
+ # Outputs non-array value in the form of hash
279
+ # For object, use to_hash. Otherwise, just return the value
280
+ # @param [Object] value Any valid value
281
+ # @return [Hash] Returns the value in the form of hash
282
+ def _to_hash(value)
283
+ if value.is_a?(Array)
284
+ value.compact.map{ |v| _to_hash(v) }
285
+ elsif value.is_a?(Hash)
286
+ {}.tap do |hash|
287
+ value.each { |k, v| hash[k] = _to_hash(v) }
288
+ end
289
+ elsif value.respond_to? :to_hash
290
+ value.to_hash
291
+ else
292
+ value
293
+ end
294
+ end
295
+
296
+ end
297
+
298
+ end