cloudmersive-image-recognition-api-client 1.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +7 -0
- data/README.md +132 -0
- data/Rakefile +8 -0
- data/cloudmersive-image-recognition-api-client.gemspec +45 -0
- data/docs/AgeDetectionResult.md +10 -0
- data/docs/ArtisticApi.md +66 -0
- data/docs/DetectedLicensePlate.md +14 -0
- data/docs/DetectedObject.md +13 -0
- data/docs/DrawRectangleInstance.md +14 -0
- data/docs/DrawRectangleRequest.md +10 -0
- data/docs/DrawTextInstance.md +15 -0
- data/docs/DrawTextRequest.md +10 -0
- data/docs/EditApi.md +179 -0
- data/docs/Face.md +11 -0
- data/docs/FaceApi.md +228 -0
- data/docs/FaceLocateResponse.md +11 -0
- data/docs/ImageDescriptionResponse.md +11 -0
- data/docs/NsfwApi.md +63 -0
- data/docs/NsfwResult.md +10 -0
- data/docs/ObjectDetectionResult.md +10 -0
- data/docs/PersonWithAge.md +10 -0
- data/docs/RecognitionOutcome.md +9 -0
- data/docs/RecognizeApi.md +287 -0
- data/docs/ResizeApi.md +69 -0
- data/docs/VehicleLicensePlateDetectionResult.md +10 -0
- data/git_push.sh +55 -0
- data/lib/cloudmersive-image-recognition-api-client.rb +60 -0
- data/lib/cloudmersive-image-recognition-api-client/api/artistic_api.rb +85 -0
- data/lib/cloudmersive-image-recognition-api-client/api/edit_api.rb +202 -0
- data/lib/cloudmersive-image-recognition-api-client/api/face_api.rb +247 -0
- data/lib/cloudmersive-image-recognition-api-client/api/nsfw_api.rb +79 -0
- data/lib/cloudmersive-image-recognition-api-client/api/recognize_api.rb +306 -0
- data/lib/cloudmersive-image-recognition-api-client/api/resize_api.rb +91 -0
- data/lib/cloudmersive-image-recognition-api-client/api_client.rb +389 -0
- data/lib/cloudmersive-image-recognition-api-client/api_error.rb +38 -0
- data/lib/cloudmersive-image-recognition-api-client/configuration.rb +209 -0
- data/lib/cloudmersive-image-recognition-api-client/models/age_detection_result.rb +211 -0
- data/lib/cloudmersive-image-recognition-api-client/models/detected_license_plate.rb +245 -0
- data/lib/cloudmersive-image-recognition-api-client/models/detected_object.rb +239 -0
- data/lib/cloudmersive-image-recognition-api-client/models/draw_rectangle_instance.rb +249 -0
- data/lib/cloudmersive-image-recognition-api-client/models/draw_rectangle_request.rb +227 -0
- data/lib/cloudmersive-image-recognition-api-client/models/draw_text_instance.rb +259 -0
- data/lib/cloudmersive-image-recognition-api-client/models/draw_text_request.rb +227 -0
- data/lib/cloudmersive-image-recognition-api-client/models/face.rb +219 -0
- data/lib/cloudmersive-image-recognition-api-client/models/face_locate_response.rb +220 -0
- data/lib/cloudmersive-image-recognition-api-client/models/image_description_response.rb +219 -0
- data/lib/cloudmersive-image-recognition-api-client/models/nsfw_result.rb +209 -0
- data/lib/cloudmersive-image-recognition-api-client/models/object_detection_result.rb +211 -0
- data/lib/cloudmersive-image-recognition-api-client/models/person_with_age.rb +209 -0
- data/lib/cloudmersive-image-recognition-api-client/models/recognition_outcome.rb +199 -0
- data/lib/cloudmersive-image-recognition-api-client/models/vehicle_license_plate_detection_result.rb +211 -0
- data/lib/cloudmersive-image-recognition-api-client/version.rb +15 -0
- data/spec/api/artistic_api_spec.rb +48 -0
- data/spec/api/edit_api_spec.rb +73 -0
- data/spec/api/face_api_spec.rb +83 -0
- data/spec/api/nsfw_api_spec.rb +47 -0
- data/spec/api/recognize_api_spec.rb +96 -0
- data/spec/api/resize_api_spec.rb +49 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/age_detection_result_spec.rb +54 -0
- data/spec/models/detected_license_plate_spec.rb +78 -0
- data/spec/models/detected_object_spec.rb +72 -0
- data/spec/models/draw_rectangle_instance_spec.rb +78 -0
- data/spec/models/draw_rectangle_request_spec.rb +54 -0
- data/spec/models/draw_text_instance_spec.rb +84 -0
- data/spec/models/draw_text_request_spec.rb +54 -0
- data/spec/models/face_locate_response_spec.rb +60 -0
- data/spec/models/face_spec.rb +60 -0
- data/spec/models/image_description_response_spec.rb +60 -0
- data/spec/models/nsfw_result_spec.rb +54 -0
- data/spec/models/object_detection_result_spec.rb +54 -0
- data/spec/models/person_with_age_spec.rb +54 -0
- data/spec/models/recognition_outcome_spec.rb +48 -0
- data/spec/models/vehicle_license_plate_detection_result_spec.rb +54 -0
- data/spec/spec_helper.rb +111 -0
- metadata +302 -0
@@ -0,0 +1,245 @@
|
|
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: unset
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module CloudmersiveImageRecognitionApiClient
|
16
|
+
# License plate found in the image
|
17
|
+
class DetectedLicensePlate
|
18
|
+
attr_accessor :location_x
|
19
|
+
|
20
|
+
attr_accessor :location_y
|
21
|
+
|
22
|
+
attr_accessor :width
|
23
|
+
|
24
|
+
attr_accessor :height
|
25
|
+
|
26
|
+
# Text from the license plate, highest-confidence result
|
27
|
+
attr_accessor :license_plate_text_best_match
|
28
|
+
|
29
|
+
# Alternate text from the license plate, based on second-highest-confidence result
|
30
|
+
attr_accessor :license_plate_text_runner_up
|
31
|
+
|
32
|
+
# Confidence score on a range of 0.0 - 1.0 of the accuracy of the detected license plate, with higher scores being better; values about 0.75 are high confidence
|
33
|
+
attr_accessor :license_plate_recognition_confidence_level
|
34
|
+
|
35
|
+
|
36
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
37
|
+
def self.attribute_map
|
38
|
+
{
|
39
|
+
:'location_x' => :'LocationX',
|
40
|
+
:'location_y' => :'LocationY',
|
41
|
+
:'width' => :'Width',
|
42
|
+
:'height' => :'Height',
|
43
|
+
:'license_plate_text_best_match' => :'LicensePlateText_BestMatch',
|
44
|
+
:'license_plate_text_runner_up' => :'LicensePlateText_RunnerUp',
|
45
|
+
:'license_plate_recognition_confidence_level' => :'LicensePlateRecognitionConfidenceLevel'
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
# Attribute type mapping.
|
50
|
+
def self.swagger_types
|
51
|
+
{
|
52
|
+
:'location_x' => :'Integer',
|
53
|
+
:'location_y' => :'Integer',
|
54
|
+
:'width' => :'Integer',
|
55
|
+
:'height' => :'Integer',
|
56
|
+
:'license_plate_text_best_match' => :'String',
|
57
|
+
:'license_plate_text_runner_up' => :'String',
|
58
|
+
:'license_plate_recognition_confidence_level' => :'Float'
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
# Initializes the object
|
63
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
64
|
+
def initialize(attributes = {})
|
65
|
+
return unless attributes.is_a?(Hash)
|
66
|
+
|
67
|
+
# convert string to symbol for hash key
|
68
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
69
|
+
|
70
|
+
if attributes.has_key?(:'LocationX')
|
71
|
+
self.location_x = attributes[:'LocationX']
|
72
|
+
end
|
73
|
+
|
74
|
+
if attributes.has_key?(:'LocationY')
|
75
|
+
self.location_y = attributes[:'LocationY']
|
76
|
+
end
|
77
|
+
|
78
|
+
if attributes.has_key?(:'Width')
|
79
|
+
self.width = attributes[:'Width']
|
80
|
+
end
|
81
|
+
|
82
|
+
if attributes.has_key?(:'Height')
|
83
|
+
self.height = attributes[:'Height']
|
84
|
+
end
|
85
|
+
|
86
|
+
if attributes.has_key?(:'LicensePlateText_BestMatch')
|
87
|
+
self.license_plate_text_best_match = attributes[:'LicensePlateText_BestMatch']
|
88
|
+
end
|
89
|
+
|
90
|
+
if attributes.has_key?(:'LicensePlateText_RunnerUp')
|
91
|
+
self.license_plate_text_runner_up = attributes[:'LicensePlateText_RunnerUp']
|
92
|
+
end
|
93
|
+
|
94
|
+
if attributes.has_key?(:'LicensePlateRecognitionConfidenceLevel')
|
95
|
+
self.license_plate_recognition_confidence_level = attributes[:'LicensePlateRecognitionConfidenceLevel']
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
101
|
+
# @return Array for valid properties with the reasons
|
102
|
+
def list_invalid_properties
|
103
|
+
invalid_properties = Array.new
|
104
|
+
return invalid_properties
|
105
|
+
end
|
106
|
+
|
107
|
+
# Check to see if the all the properties in the model are valid
|
108
|
+
# @return true if the model is valid
|
109
|
+
def valid?
|
110
|
+
return true
|
111
|
+
end
|
112
|
+
|
113
|
+
# Checks equality by comparing each attribute.
|
114
|
+
# @param [Object] Object to be compared
|
115
|
+
def ==(o)
|
116
|
+
return true if self.equal?(o)
|
117
|
+
self.class == o.class &&
|
118
|
+
location_x == o.location_x &&
|
119
|
+
location_y == o.location_y &&
|
120
|
+
width == o.width &&
|
121
|
+
height == o.height &&
|
122
|
+
license_plate_text_best_match == o.license_plate_text_best_match &&
|
123
|
+
license_plate_text_runner_up == o.license_plate_text_runner_up &&
|
124
|
+
license_plate_recognition_confidence_level == o.license_plate_recognition_confidence_level
|
125
|
+
end
|
126
|
+
|
127
|
+
# @see the `==` method
|
128
|
+
# @param [Object] Object to be compared
|
129
|
+
def eql?(o)
|
130
|
+
self == o
|
131
|
+
end
|
132
|
+
|
133
|
+
# Calculates hash code according to all attributes.
|
134
|
+
# @return [Fixnum] Hash code
|
135
|
+
def hash
|
136
|
+
[location_x, location_y, width, height, license_plate_text_best_match, license_plate_text_runner_up, license_plate_recognition_confidence_level].hash
|
137
|
+
end
|
138
|
+
|
139
|
+
# Builds the object from hash
|
140
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
141
|
+
# @return [Object] Returns the model itself
|
142
|
+
def build_from_hash(attributes)
|
143
|
+
return nil unless attributes.is_a?(Hash)
|
144
|
+
self.class.swagger_types.each_pair do |key, type|
|
145
|
+
if type =~ /\AArray<(.*)>/i
|
146
|
+
# check to ensure the input is an array given that the the attribute
|
147
|
+
# is documented as an array but the input is not
|
148
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
149
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
150
|
+
end
|
151
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
152
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
153
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
154
|
+
end
|
155
|
+
|
156
|
+
self
|
157
|
+
end
|
158
|
+
|
159
|
+
# Deserializes the data based on type
|
160
|
+
# @param string type Data type
|
161
|
+
# @param string value Value to be deserialized
|
162
|
+
# @return [Object] Deserialized data
|
163
|
+
def _deserialize(type, value)
|
164
|
+
case type.to_sym
|
165
|
+
when :DateTime
|
166
|
+
DateTime.parse(value)
|
167
|
+
when :Date
|
168
|
+
Date.parse(value)
|
169
|
+
when :String
|
170
|
+
value.to_s
|
171
|
+
when :Integer
|
172
|
+
value.to_i
|
173
|
+
when :Float
|
174
|
+
value.to_f
|
175
|
+
when :BOOLEAN
|
176
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
177
|
+
true
|
178
|
+
else
|
179
|
+
false
|
180
|
+
end
|
181
|
+
when :Object
|
182
|
+
# generic object (usually a Hash), return directly
|
183
|
+
value
|
184
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
185
|
+
inner_type = Regexp.last_match[:inner_type]
|
186
|
+
value.map { |v| _deserialize(inner_type, v) }
|
187
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
188
|
+
k_type = Regexp.last_match[:k_type]
|
189
|
+
v_type = Regexp.last_match[:v_type]
|
190
|
+
{}.tap do |hash|
|
191
|
+
value.each do |k, v|
|
192
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
else # model
|
196
|
+
temp_model = CloudmersiveImageRecognitionApiClient.const_get(type).new
|
197
|
+
temp_model.build_from_hash(value)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
# Returns the string representation of the object
|
202
|
+
# @return [String] String presentation of the object
|
203
|
+
def to_s
|
204
|
+
to_hash.to_s
|
205
|
+
end
|
206
|
+
|
207
|
+
# to_body is an alias to to_hash (backward compatibility)
|
208
|
+
# @return [Hash] Returns the object in the form of hash
|
209
|
+
def to_body
|
210
|
+
to_hash
|
211
|
+
end
|
212
|
+
|
213
|
+
# Returns the object in the form of hash
|
214
|
+
# @return [Hash] Returns the object in the form of hash
|
215
|
+
def to_hash
|
216
|
+
hash = {}
|
217
|
+
self.class.attribute_map.each_pair do |attr, param|
|
218
|
+
value = self.send(attr)
|
219
|
+
next if value.nil?
|
220
|
+
hash[param] = _to_hash(value)
|
221
|
+
end
|
222
|
+
hash
|
223
|
+
end
|
224
|
+
|
225
|
+
# Outputs non-array value in the form of hash
|
226
|
+
# For object, use to_hash. Otherwise, just return the value
|
227
|
+
# @param [Object] value Any valid value
|
228
|
+
# @return [Hash] Returns the value in the form of hash
|
229
|
+
def _to_hash(value)
|
230
|
+
if value.is_a?(Array)
|
231
|
+
value.compact.map{ |v| _to_hash(v) }
|
232
|
+
elsif value.is_a?(Hash)
|
233
|
+
{}.tap do |hash|
|
234
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
235
|
+
end
|
236
|
+
elsif value.respond_to? :to_hash
|
237
|
+
value.to_hash
|
238
|
+
else
|
239
|
+
value
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
end
|
244
|
+
|
245
|
+
end
|
@@ -0,0 +1,239 @@
|
|
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: unset
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module CloudmersiveImageRecognitionApiClient
|
16
|
+
# Single object instance, and associated details, detected in an image
|
17
|
+
class DetectedObject
|
18
|
+
# Class of the object. Example values are \"person\", \"car\", \"dining table\", etc.
|
19
|
+
attr_accessor :object_class_name
|
20
|
+
|
21
|
+
# Height, in pixels, of the object
|
22
|
+
attr_accessor :height
|
23
|
+
|
24
|
+
# Width, in pixels, of the object
|
25
|
+
attr_accessor :width
|
26
|
+
|
27
|
+
# Confidence score of detected object; possible values are between 0.0 and 1.0; values closer to 1.0 are higher confidence
|
28
|
+
attr_accessor :score
|
29
|
+
|
30
|
+
# X location, in pixels, of the left side location of the object, with the right side being X + Width
|
31
|
+
attr_accessor :x
|
32
|
+
|
33
|
+
# Y location, in pixels, of the top side location of the object, with the bottom side being Y + Height
|
34
|
+
attr_accessor :y
|
35
|
+
|
36
|
+
|
37
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
38
|
+
def self.attribute_map
|
39
|
+
{
|
40
|
+
:'object_class_name' => :'ObjectClassName',
|
41
|
+
:'height' => :'Height',
|
42
|
+
:'width' => :'Width',
|
43
|
+
:'score' => :'Score',
|
44
|
+
:'x' => :'X',
|
45
|
+
:'y' => :'Y'
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
# Attribute type mapping.
|
50
|
+
def self.swagger_types
|
51
|
+
{
|
52
|
+
:'object_class_name' => :'String',
|
53
|
+
:'height' => :'Integer',
|
54
|
+
:'width' => :'Integer',
|
55
|
+
:'score' => :'Float',
|
56
|
+
:'x' => :'Integer',
|
57
|
+
:'y' => :'Integer'
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
# Initializes the object
|
62
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
63
|
+
def initialize(attributes = {})
|
64
|
+
return unless attributes.is_a?(Hash)
|
65
|
+
|
66
|
+
# convert string to symbol for hash key
|
67
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
68
|
+
|
69
|
+
if attributes.has_key?(:'ObjectClassName')
|
70
|
+
self.object_class_name = attributes[:'ObjectClassName']
|
71
|
+
end
|
72
|
+
|
73
|
+
if attributes.has_key?(:'Height')
|
74
|
+
self.height = attributes[:'Height']
|
75
|
+
end
|
76
|
+
|
77
|
+
if attributes.has_key?(:'Width')
|
78
|
+
self.width = attributes[:'Width']
|
79
|
+
end
|
80
|
+
|
81
|
+
if attributes.has_key?(:'Score')
|
82
|
+
self.score = attributes[:'Score']
|
83
|
+
end
|
84
|
+
|
85
|
+
if attributes.has_key?(:'X')
|
86
|
+
self.x = attributes[:'X']
|
87
|
+
end
|
88
|
+
|
89
|
+
if attributes.has_key?(:'Y')
|
90
|
+
self.y = attributes[:'Y']
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
96
|
+
# @return Array for valid properties with the reasons
|
97
|
+
def list_invalid_properties
|
98
|
+
invalid_properties = Array.new
|
99
|
+
return invalid_properties
|
100
|
+
end
|
101
|
+
|
102
|
+
# Check to see if the all the properties in the model are valid
|
103
|
+
# @return true if the model is valid
|
104
|
+
def valid?
|
105
|
+
return true
|
106
|
+
end
|
107
|
+
|
108
|
+
# Checks equality by comparing each attribute.
|
109
|
+
# @param [Object] Object to be compared
|
110
|
+
def ==(o)
|
111
|
+
return true if self.equal?(o)
|
112
|
+
self.class == o.class &&
|
113
|
+
object_class_name == o.object_class_name &&
|
114
|
+
height == o.height &&
|
115
|
+
width == o.width &&
|
116
|
+
score == o.score &&
|
117
|
+
x == o.x &&
|
118
|
+
y == o.y
|
119
|
+
end
|
120
|
+
|
121
|
+
# @see the `==` method
|
122
|
+
# @param [Object] Object to be compared
|
123
|
+
def eql?(o)
|
124
|
+
self == o
|
125
|
+
end
|
126
|
+
|
127
|
+
# Calculates hash code according to all attributes.
|
128
|
+
# @return [Fixnum] Hash code
|
129
|
+
def hash
|
130
|
+
[object_class_name, height, width, score, x, y].hash
|
131
|
+
end
|
132
|
+
|
133
|
+
# Builds the object from hash
|
134
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
135
|
+
# @return [Object] Returns the model itself
|
136
|
+
def build_from_hash(attributes)
|
137
|
+
return nil unless attributes.is_a?(Hash)
|
138
|
+
self.class.swagger_types.each_pair do |key, type|
|
139
|
+
if type =~ /\AArray<(.*)>/i
|
140
|
+
# check to ensure the input is an array given that the the attribute
|
141
|
+
# is documented as an array but the input is not
|
142
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
143
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
144
|
+
end
|
145
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
146
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
147
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
148
|
+
end
|
149
|
+
|
150
|
+
self
|
151
|
+
end
|
152
|
+
|
153
|
+
# Deserializes the data based on type
|
154
|
+
# @param string type Data type
|
155
|
+
# @param string value Value to be deserialized
|
156
|
+
# @return [Object] Deserialized data
|
157
|
+
def _deserialize(type, value)
|
158
|
+
case type.to_sym
|
159
|
+
when :DateTime
|
160
|
+
DateTime.parse(value)
|
161
|
+
when :Date
|
162
|
+
Date.parse(value)
|
163
|
+
when :String
|
164
|
+
value.to_s
|
165
|
+
when :Integer
|
166
|
+
value.to_i
|
167
|
+
when :Float
|
168
|
+
value.to_f
|
169
|
+
when :BOOLEAN
|
170
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
171
|
+
true
|
172
|
+
else
|
173
|
+
false
|
174
|
+
end
|
175
|
+
when :Object
|
176
|
+
# generic object (usually a Hash), return directly
|
177
|
+
value
|
178
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
179
|
+
inner_type = Regexp.last_match[:inner_type]
|
180
|
+
value.map { |v| _deserialize(inner_type, v) }
|
181
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
182
|
+
k_type = Regexp.last_match[:k_type]
|
183
|
+
v_type = Regexp.last_match[:v_type]
|
184
|
+
{}.tap do |hash|
|
185
|
+
value.each do |k, v|
|
186
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
else # model
|
190
|
+
temp_model = CloudmersiveImageRecognitionApiClient.const_get(type).new
|
191
|
+
temp_model.build_from_hash(value)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
# Returns the string representation of the object
|
196
|
+
# @return [String] String presentation of the object
|
197
|
+
def to_s
|
198
|
+
to_hash.to_s
|
199
|
+
end
|
200
|
+
|
201
|
+
# to_body is an alias to to_hash (backward compatibility)
|
202
|
+
# @return [Hash] Returns the object in the form of hash
|
203
|
+
def to_body
|
204
|
+
to_hash
|
205
|
+
end
|
206
|
+
|
207
|
+
# Returns the object in the form of hash
|
208
|
+
# @return [Hash] Returns the object in the form of hash
|
209
|
+
def to_hash
|
210
|
+
hash = {}
|
211
|
+
self.class.attribute_map.each_pair do |attr, param|
|
212
|
+
value = self.send(attr)
|
213
|
+
next if value.nil?
|
214
|
+
hash[param] = _to_hash(value)
|
215
|
+
end
|
216
|
+
hash
|
217
|
+
end
|
218
|
+
|
219
|
+
# Outputs non-array value in the form of hash
|
220
|
+
# For object, use to_hash. Otherwise, just return the value
|
221
|
+
# @param [Object] value Any valid value
|
222
|
+
# @return [Hash] Returns the value in the form of hash
|
223
|
+
def _to_hash(value)
|
224
|
+
if value.is_a?(Array)
|
225
|
+
value.compact.map{ |v| _to_hash(v) }
|
226
|
+
elsif value.is_a?(Hash)
|
227
|
+
{}.tap do |hash|
|
228
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
229
|
+
end
|
230
|
+
elsif value.respond_to? :to_hash
|
231
|
+
value.to_hash
|
232
|
+
else
|
233
|
+
value
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
end
|
238
|
+
|
239
|
+
end
|