cloudmersive-image-recognition-api-client 1.3.0 → 1.3.1

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 (77) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -4
  3. data/cloudmersive-image-recognition-api-client.gemspec +1 -1
  4. data/docs/FineTextDetectionResult.md +10 -0
  5. data/docs/FineTextItem.md +15 -0
  6. data/docs/RecognizeApi.md +104 -0
  7. data/docs/TextDetectionResult.md +10 -0
  8. data/docs/TextItem.md +11 -0
  9. data/lib/cloudmersive-image-recognition-api-client.rb +5 -1
  10. data/lib/cloudmersive-image-recognition-api-client/api/artistic_api.rb +1 -1
  11. data/lib/cloudmersive-image-recognition-api-client/api/edit_api.rb +1 -1
  12. data/lib/cloudmersive-image-recognition-api-client/api/face_api.rb +1 -1
  13. data/lib/cloudmersive-image-recognition-api-client/api/nsfw_api.rb +1 -1
  14. data/lib/cloudmersive-image-recognition-api-client/api/recognize_api.rb +104 -1
  15. data/lib/cloudmersive-image-recognition-api-client/api/resize_api.rb +1 -1
  16. data/lib/cloudmersive-image-recognition-api-client/api_client.rb +1 -1
  17. data/lib/cloudmersive-image-recognition-api-client/api_error.rb +1 -1
  18. data/lib/cloudmersive-image-recognition-api-client/configuration.rb +1 -1
  19. data/lib/cloudmersive-image-recognition-api-client/models/age_detection_result.rb +1 -1
  20. data/lib/cloudmersive-image-recognition-api-client/models/detected_license_plate.rb +1 -1
  21. data/lib/cloudmersive-image-recognition-api-client/models/detected_object.rb +1 -1
  22. data/lib/cloudmersive-image-recognition-api-client/models/draw_rectangle_instance.rb +1 -1
  23. data/lib/cloudmersive-image-recognition-api-client/models/draw_rectangle_request.rb +1 -1
  24. data/lib/cloudmersive-image-recognition-api-client/models/draw_text_instance.rb +1 -1
  25. data/lib/cloudmersive-image-recognition-api-client/models/draw_text_request.rb +1 -1
  26. data/lib/cloudmersive-image-recognition-api-client/models/face.rb +1 -1
  27. data/lib/cloudmersive-image-recognition-api-client/models/face_compare_response.rb +1 -1
  28. data/lib/cloudmersive-image-recognition-api-client/models/face_locate_response.rb +1 -1
  29. data/lib/cloudmersive-image-recognition-api-client/models/face_locate_with_landmarks_response.rb +1 -1
  30. data/lib/cloudmersive-image-recognition-api-client/models/face_match.rb +1 -1
  31. data/lib/cloudmersive-image-recognition-api-client/models/face_point.rb +1 -1
  32. data/lib/cloudmersive-image-recognition-api-client/models/face_with_landmarks.rb +1 -1
  33. data/lib/cloudmersive-image-recognition-api-client/models/fine_text_detection_result.rb +211 -0
  34. data/lib/cloudmersive-image-recognition-api-client/models/fine_text_item.rb +259 -0
  35. data/lib/cloudmersive-image-recognition-api-client/models/image_description_response.rb +1 -1
  36. data/lib/cloudmersive-image-recognition-api-client/models/nsfw_result.rb +1 -1
  37. data/lib/cloudmersive-image-recognition-api-client/models/object_detection_result.rb +1 -1
  38. data/lib/cloudmersive-image-recognition-api-client/models/person_with_age.rb +1 -1
  39. data/lib/cloudmersive-image-recognition-api-client/models/recognition_outcome.rb +1 -1
  40. data/lib/cloudmersive-image-recognition-api-client/models/text_detection_result.rb +211 -0
  41. data/lib/cloudmersive-image-recognition-api-client/models/text_item.rb +219 -0
  42. data/lib/cloudmersive-image-recognition-api-client/models/vehicle_license_plate_detection_result.rb +1 -1
  43. data/lib/cloudmersive-image-recognition-api-client/version.rb +2 -2
  44. data/spec/api/artistic_api_spec.rb +1 -1
  45. data/spec/api/edit_api_spec.rb +1 -1
  46. data/spec/api/face_api_spec.rb +1 -1
  47. data/spec/api/nsfw_api_spec.rb +1 -1
  48. data/spec/api/recognize_api_spec.rb +24 -1
  49. data/spec/api/resize_api_spec.rb +1 -1
  50. data/spec/api_client_spec.rb +1 -1
  51. data/spec/configuration_spec.rb +1 -1
  52. data/spec/models/age_detection_result_spec.rb +1 -1
  53. data/spec/models/detected_license_plate_spec.rb +1 -1
  54. data/spec/models/detected_object_spec.rb +1 -1
  55. data/spec/models/draw_rectangle_instance_spec.rb +1 -1
  56. data/spec/models/draw_rectangle_request_spec.rb +1 -1
  57. data/spec/models/draw_text_instance_spec.rb +1 -1
  58. data/spec/models/draw_text_request_spec.rb +1 -1
  59. data/spec/models/face_compare_response_spec.rb +1 -1
  60. data/spec/models/face_locate_response_spec.rb +1 -1
  61. data/spec/models/face_locate_with_landmarks_response_spec.rb +1 -1
  62. data/spec/models/face_match_spec.rb +1 -1
  63. data/spec/models/face_point_spec.rb +1 -1
  64. data/spec/models/face_spec.rb +1 -1
  65. data/spec/models/face_with_landmarks_spec.rb +1 -1
  66. data/spec/models/fine_text_detection_result_spec.rb +54 -0
  67. data/spec/models/fine_text_item_spec.rb +84 -0
  68. data/spec/models/image_description_response_spec.rb +1 -1
  69. data/spec/models/nsfw_result_spec.rb +1 -1
  70. data/spec/models/object_detection_result_spec.rb +1 -1
  71. data/spec/models/person_with_age_spec.rb +1 -1
  72. data/spec/models/recognition_outcome_spec.rb +1 -1
  73. data/spec/models/text_detection_result_spec.rb +54 -0
  74. data/spec/models/text_item_spec.rb +60 -0
  75. data/spec/models/vehicle_license_plate_detection_result_spec.rb +1 -1
  76. data/spec/spec_helper.rb +1 -1
  77. metadata +27 -16
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: v1
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: unset
9
+ Swagger Codegen version: 2.3.1
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: v1
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: unset
9
+ Swagger Codegen version: 2.3.1
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: v1
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: unset
9
+ Swagger Codegen version: 2.3.1
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: v1
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: unset
9
+ Swagger Codegen version: 2.3.1
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: v1
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: unset
9
+ Swagger Codegen version: 2.3.1
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: v1
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: unset
9
+ Swagger Codegen version: 2.3.1
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: v1
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: unset
9
+ Swagger Codegen version: 2.3.1
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: v1
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: unset
9
+ Swagger Codegen version: 2.3.1
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: v1
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: unset
9
+ Swagger Codegen version: 2.3.1
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: v1
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: unset
9
+ Swagger Codegen version: 2.3.1
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: v1
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: unset
9
+ Swagger Codegen version: 2.3.1
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: v1
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: unset
9
+ Swagger Codegen version: 2.3.1
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: v1
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: unset
9
+ Swagger Codegen version: 2.3.1
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: v1
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: unset
9
+ Swagger Codegen version: 2.3.1
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: v1
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: unset
9
+ Swagger Codegen version: 2.3.1
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: v1
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: unset
9
+ Swagger Codegen version: 2.3.1
10
10
 
11
11
  =end
12
12
 
@@ -0,0 +1,211 @@
1
+ =begin
2
+ #imageapi
3
+
4
+ #Image Recognition and Processing APIs let you use Machine Learning to recognize and process images, and also perform useful image modification operations.
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module CloudmersiveImageRecognitionApiClient
16
+ # Result of an operation to detect text in a photo
17
+ class FineTextDetectionResult
18
+ # True if the operation was successful, false otherwise
19
+ attr_accessor :successful
20
+
21
+ # Text items found in the input image
22
+ attr_accessor :text_items
23
+
24
+ # Count of text items found in the input image
25
+ attr_accessor :text_items_count
26
+
27
+
28
+ # Attribute mapping from ruby-style variable name to JSON key.
29
+ def self.attribute_map
30
+ {
31
+ :'successful' => :'Successful',
32
+ :'text_items' => :'TextItems',
33
+ :'text_items_count' => :'TextItemsCount'
34
+ }
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.swagger_types
39
+ {
40
+ :'successful' => :'BOOLEAN',
41
+ :'text_items' => :'Array<FineTextItem>',
42
+ :'text_items_count' => :'Integer'
43
+ }
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ return unless attributes.is_a?(Hash)
50
+
51
+ # convert string to symbol for hash key
52
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
53
+
54
+ if attributes.has_key?(:'Successful')
55
+ self.successful = attributes[:'Successful']
56
+ end
57
+
58
+ if attributes.has_key?(:'TextItems')
59
+ if (value = attributes[:'TextItems']).is_a?(Array)
60
+ self.text_items = value
61
+ end
62
+ end
63
+
64
+ if attributes.has_key?(:'TextItemsCount')
65
+ self.text_items_count = attributes[:'TextItemsCount']
66
+ end
67
+
68
+ end
69
+
70
+ # Show invalid properties with the reasons. Usually used together with valid?
71
+ # @return Array for valid properties with the reasons
72
+ def list_invalid_properties
73
+ invalid_properties = Array.new
74
+ return invalid_properties
75
+ end
76
+
77
+ # Check to see if the all the properties in the model are valid
78
+ # @return true if the model is valid
79
+ def valid?
80
+ return true
81
+ end
82
+
83
+ # Checks equality by comparing each attribute.
84
+ # @param [Object] Object to be compared
85
+ def ==(o)
86
+ return true if self.equal?(o)
87
+ self.class == o.class &&
88
+ successful == o.successful &&
89
+ text_items == o.text_items &&
90
+ text_items_count == o.text_items_count
91
+ end
92
+
93
+ # @see the `==` method
94
+ # @param [Object] Object to be compared
95
+ def eql?(o)
96
+ self == o
97
+ end
98
+
99
+ # Calculates hash code according to all attributes.
100
+ # @return [Fixnum] Hash code
101
+ def hash
102
+ [successful, text_items, text_items_count].hash
103
+ end
104
+
105
+ # Builds the object from hash
106
+ # @param [Hash] attributes Model attributes in the form of hash
107
+ # @return [Object] Returns the model itself
108
+ def build_from_hash(attributes)
109
+ return nil unless attributes.is_a?(Hash)
110
+ self.class.swagger_types.each_pair do |key, type|
111
+ if type =~ /\AArray<(.*)>/i
112
+ # check to ensure the input is an array given that the the attribute
113
+ # is documented as an array but the input is not
114
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
115
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
116
+ end
117
+ elsif !attributes[self.class.attribute_map[key]].nil?
118
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
119
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
120
+ end
121
+
122
+ self
123
+ end
124
+
125
+ # Deserializes the data based on type
126
+ # @param string type Data type
127
+ # @param string value Value to be deserialized
128
+ # @return [Object] Deserialized data
129
+ def _deserialize(type, value)
130
+ case type.to_sym
131
+ when :DateTime
132
+ DateTime.parse(value)
133
+ when :Date
134
+ Date.parse(value)
135
+ when :String
136
+ value.to_s
137
+ when :Integer
138
+ value.to_i
139
+ when :Float
140
+ value.to_f
141
+ when :BOOLEAN
142
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
143
+ true
144
+ else
145
+ false
146
+ end
147
+ when :Object
148
+ # generic object (usually a Hash), return directly
149
+ value
150
+ when /\AArray<(?<inner_type>.+)>\z/
151
+ inner_type = Regexp.last_match[:inner_type]
152
+ value.map { |v| _deserialize(inner_type, v) }
153
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
154
+ k_type = Regexp.last_match[:k_type]
155
+ v_type = Regexp.last_match[:v_type]
156
+ {}.tap do |hash|
157
+ value.each do |k, v|
158
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
159
+ end
160
+ end
161
+ else # model
162
+ temp_model = CloudmersiveImageRecognitionApiClient.const_get(type).new
163
+ temp_model.build_from_hash(value)
164
+ end
165
+ end
166
+
167
+ # Returns the string representation of the object
168
+ # @return [String] String presentation of the object
169
+ def to_s
170
+ to_hash.to_s
171
+ end
172
+
173
+ # to_body is an alias to to_hash (backward compatibility)
174
+ # @return [Hash] Returns the object in the form of hash
175
+ def to_body
176
+ to_hash
177
+ end
178
+
179
+ # Returns the object in the form of hash
180
+ # @return [Hash] Returns the object in the form of hash
181
+ def to_hash
182
+ hash = {}
183
+ self.class.attribute_map.each_pair do |attr, param|
184
+ value = self.send(attr)
185
+ next if value.nil?
186
+ hash[param] = _to_hash(value)
187
+ end
188
+ hash
189
+ end
190
+
191
+ # Outputs non-array value in the form of hash
192
+ # For object, use to_hash. Otherwise, just return the value
193
+ # @param [Object] value Any valid value
194
+ # @return [Hash] Returns the value in the form of hash
195
+ def _to_hash(value)
196
+ if value.is_a?(Array)
197
+ value.compact.map{ |v| _to_hash(v) }
198
+ elsif value.is_a?(Hash)
199
+ {}.tap do |hash|
200
+ value.each { |k, v| hash[k] = _to_hash(v) }
201
+ end
202
+ elsif value.respond_to? :to_hash
203
+ value.to_hash
204
+ else
205
+ value
206
+ end
207
+ end
208
+
209
+ end
210
+
211
+ end
@@ -0,0 +1,259 @@
1
+ =begin
2
+ #imageapi
3
+
4
+ #Image Recognition and Processing APIs let you use Machine Learning to recognize and process images, and also perform useful image modification operations.
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module CloudmersiveImageRecognitionApiClient
16
+ # Individual instance of text occuring in an image; one piece of text
17
+ class FineTextItem
18
+ # X coordinate of the top/left text location; 0 represents the left edge of the input image
19
+ attr_accessor :top_left_x
20
+
21
+ # Y coordinate of the top/left text location; 0 represents the top edge of the input image
22
+ attr_accessor :top_left_y
23
+
24
+ # X coordinate of the top/right text location; 0 represents the left edge of the input image
25
+ attr_accessor :top_right_x
26
+
27
+ # Y coordinate of the top/right text location; 0 represents the top edge of the input image
28
+ attr_accessor :top_right_y
29
+
30
+ # X coordinate of the bottom/left text location; 0 represents the left edge of the input image
31
+ attr_accessor :bottom_left_x
32
+
33
+ # Y coordinate of the bottom/left text location; 0 represents the top edge of the input image
34
+ attr_accessor :bottom_left_y
35
+
36
+ # X coordinate of the bottom/right text location; 0 represents the left edge of the input image
37
+ attr_accessor :bottom_right_x
38
+
39
+ # Y coordinate of the bottom/right text location; 0 represents the top edge of the input image
40
+ attr_accessor :bottom_right_y
41
+
42
+
43
+ # Attribute mapping from ruby-style variable name to JSON key.
44
+ def self.attribute_map
45
+ {
46
+ :'top_left_x' => :'TopLeftX',
47
+ :'top_left_y' => :'TopLeftY',
48
+ :'top_right_x' => :'TopRightX',
49
+ :'top_right_y' => :'TopRightY',
50
+ :'bottom_left_x' => :'BottomLeftX',
51
+ :'bottom_left_y' => :'BottomLeftY',
52
+ :'bottom_right_x' => :'BottomRightX',
53
+ :'bottom_right_y' => :'BottomRightY'
54
+ }
55
+ end
56
+
57
+ # Attribute type mapping.
58
+ def self.swagger_types
59
+ {
60
+ :'top_left_x' => :'Integer',
61
+ :'top_left_y' => :'Integer',
62
+ :'top_right_x' => :'Integer',
63
+ :'top_right_y' => :'Integer',
64
+ :'bottom_left_x' => :'Integer',
65
+ :'bottom_left_y' => :'Integer',
66
+ :'bottom_right_x' => :'Integer',
67
+ :'bottom_right_y' => :'Integer'
68
+ }
69
+ end
70
+
71
+ # Initializes the object
72
+ # @param [Hash] attributes Model attributes in the form of hash
73
+ def initialize(attributes = {})
74
+ return unless attributes.is_a?(Hash)
75
+
76
+ # convert string to symbol for hash key
77
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
78
+
79
+ if attributes.has_key?(:'TopLeftX')
80
+ self.top_left_x = attributes[:'TopLeftX']
81
+ end
82
+
83
+ if attributes.has_key?(:'TopLeftY')
84
+ self.top_left_y = attributes[:'TopLeftY']
85
+ end
86
+
87
+ if attributes.has_key?(:'TopRightX')
88
+ self.top_right_x = attributes[:'TopRightX']
89
+ end
90
+
91
+ if attributes.has_key?(:'TopRightY')
92
+ self.top_right_y = attributes[:'TopRightY']
93
+ end
94
+
95
+ if attributes.has_key?(:'BottomLeftX')
96
+ self.bottom_left_x = attributes[:'BottomLeftX']
97
+ end
98
+
99
+ if attributes.has_key?(:'BottomLeftY')
100
+ self.bottom_left_y = attributes[:'BottomLeftY']
101
+ end
102
+
103
+ if attributes.has_key?(:'BottomRightX')
104
+ self.bottom_right_x = attributes[:'BottomRightX']
105
+ end
106
+
107
+ if attributes.has_key?(:'BottomRightY')
108
+ self.bottom_right_y = attributes[:'BottomRightY']
109
+ end
110
+
111
+ end
112
+
113
+ # Show invalid properties with the reasons. Usually used together with valid?
114
+ # @return Array for valid properties with the reasons
115
+ def list_invalid_properties
116
+ invalid_properties = Array.new
117
+ return invalid_properties
118
+ end
119
+
120
+ # Check to see if the all the properties in the model are valid
121
+ # @return true if the model is valid
122
+ def valid?
123
+ return true
124
+ end
125
+
126
+ # Checks equality by comparing each attribute.
127
+ # @param [Object] Object to be compared
128
+ def ==(o)
129
+ return true if self.equal?(o)
130
+ self.class == o.class &&
131
+ top_left_x == o.top_left_x &&
132
+ top_left_y == o.top_left_y &&
133
+ top_right_x == o.top_right_x &&
134
+ top_right_y == o.top_right_y &&
135
+ bottom_left_x == o.bottom_left_x &&
136
+ bottom_left_y == o.bottom_left_y &&
137
+ bottom_right_x == o.bottom_right_x &&
138
+ bottom_right_y == o.bottom_right_y
139
+ end
140
+
141
+ # @see the `==` method
142
+ # @param [Object] Object to be compared
143
+ def eql?(o)
144
+ self == o
145
+ end
146
+
147
+ # Calculates hash code according to all attributes.
148
+ # @return [Fixnum] Hash code
149
+ def hash
150
+ [top_left_x, top_left_y, top_right_x, top_right_y, bottom_left_x, bottom_left_y, bottom_right_x, bottom_right_y].hash
151
+ end
152
+
153
+ # Builds the object from hash
154
+ # @param [Hash] attributes Model attributes in the form of hash
155
+ # @return [Object] Returns the model itself
156
+ def build_from_hash(attributes)
157
+ return nil unless attributes.is_a?(Hash)
158
+ self.class.swagger_types.each_pair do |key, type|
159
+ if type =~ /\AArray<(.*)>/i
160
+ # check to ensure the input is an array given that the the attribute
161
+ # is documented as an array but the input is not
162
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
163
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
164
+ end
165
+ elsif !attributes[self.class.attribute_map[key]].nil?
166
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
167
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
168
+ end
169
+
170
+ self
171
+ end
172
+
173
+ # Deserializes the data based on type
174
+ # @param string type Data type
175
+ # @param string value Value to be deserialized
176
+ # @return [Object] Deserialized data
177
+ def _deserialize(type, value)
178
+ case type.to_sym
179
+ when :DateTime
180
+ DateTime.parse(value)
181
+ when :Date
182
+ Date.parse(value)
183
+ when :String
184
+ value.to_s
185
+ when :Integer
186
+ value.to_i
187
+ when :Float
188
+ value.to_f
189
+ when :BOOLEAN
190
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
191
+ true
192
+ else
193
+ false
194
+ end
195
+ when :Object
196
+ # generic object (usually a Hash), return directly
197
+ value
198
+ when /\AArray<(?<inner_type>.+)>\z/
199
+ inner_type = Regexp.last_match[:inner_type]
200
+ value.map { |v| _deserialize(inner_type, v) }
201
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
202
+ k_type = Regexp.last_match[:k_type]
203
+ v_type = Regexp.last_match[:v_type]
204
+ {}.tap do |hash|
205
+ value.each do |k, v|
206
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
207
+ end
208
+ end
209
+ else # model
210
+ temp_model = CloudmersiveImageRecognitionApiClient.const_get(type).new
211
+ temp_model.build_from_hash(value)
212
+ end
213
+ end
214
+
215
+ # Returns the string representation of the object
216
+ # @return [String] String presentation of the object
217
+ def to_s
218
+ to_hash.to_s
219
+ end
220
+
221
+ # to_body is an alias to to_hash (backward compatibility)
222
+ # @return [Hash] Returns the object in the form of hash
223
+ def to_body
224
+ to_hash
225
+ end
226
+
227
+ # Returns the object in the form of hash
228
+ # @return [Hash] Returns the object in the form of hash
229
+ def to_hash
230
+ hash = {}
231
+ self.class.attribute_map.each_pair do |attr, param|
232
+ value = self.send(attr)
233
+ next if value.nil?
234
+ hash[param] = _to_hash(value)
235
+ end
236
+ hash
237
+ end
238
+
239
+ # Outputs non-array value in the form of hash
240
+ # For object, use to_hash. Otherwise, just return the value
241
+ # @param [Object] value Any valid value
242
+ # @return [Hash] Returns the value in the form of hash
243
+ def _to_hash(value)
244
+ if value.is_a?(Array)
245
+ value.compact.map{ |v| _to_hash(v) }
246
+ elsif value.is_a?(Hash)
247
+ {}.tap do |hash|
248
+ value.each { |k, v| hash[k] = _to_hash(v) }
249
+ end
250
+ elsif value.respond_to? :to_hash
251
+ value.to_hash
252
+ else
253
+ value
254
+ end
255
+ end
256
+
257
+ end
258
+
259
+ end