aimastering 1.0.0
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 +167 -0
- data/Rakefile +8 -0
- data/aimastering.gemspec +45 -0
- data/docs/AccessToken.md +8 -0
- data/docs/AccessTokenApi.md +55 -0
- data/docs/AnonymizedMastering.md +29 -0
- data/docs/Audio.md +29 -0
- data/docs/AudioAnalysis.md +10 -0
- data/docs/AudioApi.md +374 -0
- data/docs/AudioDownloadToken.md +9 -0
- data/docs/Config.md +10 -0
- data/docs/ConfigApi.md +55 -0
- data/docs/ConfigAuth0.md +10 -0
- data/docs/ConfigPaypal.md +9 -0
- data/docs/ConfigStripe.md +8 -0
- data/docs/DateTime.md +7 -0
- data/docs/ExternalSearchApi.md +64 -0
- data/docs/ExternalSearchResult.md +9 -0
- data/docs/ExternalSearchResultItunes.md +18 -0
- data/docs/ExternalSearchResultYoutube.md +15 -0
- data/docs/JWT.md +7 -0
- data/docs/Kpi.md +7 -0
- data/docs/LibraryAudio.md +38 -0
- data/docs/LibraryAudioAnalysis.md +10 -0
- data/docs/LibraryAudioApi.md +378 -0
- data/docs/LibraryAudioLike.md +10 -0
- data/docs/Mastering.md +35 -0
- data/docs/MasteringApi.md +482 -0
- data/docs/Payment.md +14 -0
- data/docs/PaymentApi.md +224 -0
- data/docs/PaymentCustomer.md +11 -0
- data/docs/PaymentCustomerApi.md +55 -0
- data/docs/Plan.md +12 -0
- data/docs/PlanApi.md +55 -0
- data/docs/StatisticsApi.md +102 -0
- data/docs/Subscription.md +17 -0
- data/docs/SubscriptionApi.md +273 -0
- data/docs/User.md +14 -0
- data/docs/UserApi.md +111 -0
- data/docs/Video.md +13 -0
- data/docs/VideoApi.md +267 -0
- data/docs/VideoDownloadToken.md +9 -0
- data/git_push.sh +55 -0
- data/lib/aimastering.rb +77 -0
- data/lib/aimastering/api/access_token_api.rb +70 -0
- data/lib/aimastering/api/audio_api.rb +404 -0
- data/lib/aimastering/api/config_api.rb +70 -0
- data/lib/aimastering/api/external_search_api.rb +84 -0
- data/lib/aimastering/api/library_audio_api.rb +416 -0
- data/lib/aimastering/api/mastering_api.rb +596 -0
- data/lib/aimastering/api/payment_api.rb +263 -0
- data/lib/aimastering/api/payment_customer_api.rb +70 -0
- data/lib/aimastering/api/plan_api.rb +70 -0
- data/lib/aimastering/api/statistics_api.rb +117 -0
- data/lib/aimastering/api/subscription_api.rb +311 -0
- data/lib/aimastering/api/user_api.rb +125 -0
- data/lib/aimastering/api/video_api.rb +295 -0
- data/lib/aimastering/api_client.rb +389 -0
- data/lib/aimastering/api_error.rb +38 -0
- data/lib/aimastering/configuration.rb +209 -0
- data/lib/aimastering/models/access_token.rb +188 -0
- data/lib/aimastering/models/anonymized_mastering.rb +520 -0
- data/lib/aimastering/models/audio.rb +377 -0
- data/lib/aimastering/models/audio_analysis.rb +209 -0
- data/lib/aimastering/models/audio_download_token.rb +197 -0
- data/lib/aimastering/models/config.rb +206 -0
- data/lib/aimastering/models/config_auth0.rb +206 -0
- data/lib/aimastering/models/config_paypal.rb +197 -0
- data/lib/aimastering/models/config_stripe.rb +188 -0
- data/lib/aimastering/models/date_time.rb +179 -0
- data/lib/aimastering/models/external_search_result.rb +201 -0
- data/lib/aimastering/models/external_search_result_itunes.rb +278 -0
- data/lib/aimastering/models/external_search_result_youtube.rb +251 -0
- data/lib/aimastering/models/jwt.rb +179 -0
- data/lib/aimastering/models/kpi.rb +179 -0
- data/lib/aimastering/models/library_audio.rb +458 -0
- data/lib/aimastering/models/library_audio_analysis.rb +209 -0
- data/lib/aimastering/models/library_audio_like.rb +209 -0
- data/lib/aimastering/models/mastering.rb +587 -0
- data/lib/aimastering/models/payment.rb +275 -0
- data/lib/aimastering/models/payment_customer.rb +215 -0
- data/lib/aimastering/models/plan.rb +269 -0
- data/lib/aimastering/models/subscription.rb +302 -0
- data/lib/aimastering/models/user.rb +275 -0
- data/lib/aimastering/models/video.rb +233 -0
- data/lib/aimastering/models/video_download_token.rb +197 -0
- data/lib/aimastering/version.rb +15 -0
- data/spec/api/access_token_api_spec.rb +46 -0
- data/spec/api/audio_api_spec.rb +118 -0
- data/spec/api/config_api_spec.rb +46 -0
- data/spec/api/external_search_api_spec.rb +48 -0
- data/spec/api/library_audio_api_spec.rb +119 -0
- data/spec/api/mastering_api_spec.rb +154 -0
- data/spec/api/payment_api_spec.rb +85 -0
- data/spec/api/payment_customer_api_spec.rb +46 -0
- data/spec/api/plan_api_spec.rb +46 -0
- data/spec/api/statistics_api_spec.rb +57 -0
- data/spec/api/subscription_api_spec.rb +96 -0
- data/spec/api/user_api_spec.rb +59 -0
- data/spec/api/video_api_spec.rb +94 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/access_token_spec.rb +42 -0
- data/spec/models/anonymized_mastering_spec.rb +192 -0
- data/spec/models/audio_analysis_spec.rb +54 -0
- data/spec/models/audio_download_token_spec.rb +48 -0
- data/spec/models/audio_spec.rb +168 -0
- data/spec/models/config_auth0_spec.rb +54 -0
- data/spec/models/config_paypal_spec.rb +48 -0
- data/spec/models/config_spec.rb +54 -0
- data/spec/models/config_stripe_spec.rb +42 -0
- data/spec/models/date_time_spec.rb +36 -0
- data/spec/models/external_search_result_itunes_spec.rb +102 -0
- data/spec/models/external_search_result_spec.rb +48 -0
- data/spec/models/external_search_result_youtube_spec.rb +84 -0
- data/spec/models/jwt_spec.rb +36 -0
- data/spec/models/kpi_spec.rb +36 -0
- data/spec/models/library_audio_analysis_spec.rb +54 -0
- data/spec/models/library_audio_like_spec.rb +54 -0
- data/spec/models/library_audio_spec.rb +222 -0
- data/spec/models/mastering_spec.rb +224 -0
- data/spec/models/payment_customer_spec.rb +60 -0
- data/spec/models/payment_spec.rb +82 -0
- data/spec/models/plan_spec.rb +74 -0
- data/spec/models/subscription_spec.rb +100 -0
- data/spec/models/user_spec.rb +82 -0
- data/spec/models/video_download_token_spec.rb +48 -0
- data/spec/models/video_spec.rb +72 -0
- data/spec/spec_helper.rb +111 -0
- metadata +397 -0
@@ -0,0 +1,275 @@
|
|
1
|
+
=begin
|
2
|
+
#AI Mastering API
|
3
|
+
|
4
|
+
#This is a AI Mastering API document. You can use the mastering feature of [AI Mastering](https://aimastering.com) through this API.
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.0
|
7
|
+
Contact: aimasteringcom@gmail.com
|
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 Aimastering
|
16
|
+
|
17
|
+
class Payment
|
18
|
+
attr_accessor :id
|
19
|
+
|
20
|
+
attr_accessor :service
|
21
|
+
|
22
|
+
attr_accessor :product_given
|
23
|
+
|
24
|
+
attr_accessor :product
|
25
|
+
|
26
|
+
attr_accessor :transaction_id
|
27
|
+
|
28
|
+
attr_accessor :transaction_detail
|
29
|
+
|
30
|
+
attr_accessor :created_at
|
31
|
+
|
32
|
+
class EnumAttributeValidator
|
33
|
+
attr_reader :datatype
|
34
|
+
attr_reader :allowable_values
|
35
|
+
|
36
|
+
def initialize(datatype, allowable_values)
|
37
|
+
@allowable_values = allowable_values.map do |value|
|
38
|
+
case datatype.to_s
|
39
|
+
when /Integer/i
|
40
|
+
value.to_i
|
41
|
+
when /Float/i
|
42
|
+
value.to_f
|
43
|
+
else
|
44
|
+
value
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def valid?(value)
|
50
|
+
!value || allowable_values.include?(value)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
55
|
+
def self.attribute_map
|
56
|
+
{
|
57
|
+
:'id' => :'id',
|
58
|
+
:'service' => :'service',
|
59
|
+
:'product_given' => :'product_given',
|
60
|
+
:'product' => :'product',
|
61
|
+
:'transaction_id' => :'transaction_id',
|
62
|
+
:'transaction_detail' => :'transaction_detail',
|
63
|
+
:'created_at' => :'created_at'
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
# Attribute type mapping.
|
68
|
+
def self.swagger_types
|
69
|
+
{
|
70
|
+
:'id' => :'Integer',
|
71
|
+
:'service' => :'String',
|
72
|
+
:'product_given' => :'BOOLEAN',
|
73
|
+
:'product' => :'Object',
|
74
|
+
:'transaction_id' => :'String',
|
75
|
+
:'transaction_detail' => :'Object',
|
76
|
+
:'created_at' => :'DateTime'
|
77
|
+
}
|
78
|
+
end
|
79
|
+
|
80
|
+
# Initializes the object
|
81
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
82
|
+
def initialize(attributes = {})
|
83
|
+
return unless attributes.is_a?(Hash)
|
84
|
+
|
85
|
+
# convert string to symbol for hash key
|
86
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
87
|
+
|
88
|
+
if attributes.has_key?(:'id')
|
89
|
+
self.id = attributes[:'id']
|
90
|
+
end
|
91
|
+
|
92
|
+
if attributes.has_key?(:'service')
|
93
|
+
self.service = attributes[:'service']
|
94
|
+
end
|
95
|
+
|
96
|
+
if attributes.has_key?(:'product_given')
|
97
|
+
self.product_given = attributes[:'product_given']
|
98
|
+
end
|
99
|
+
|
100
|
+
if attributes.has_key?(:'product')
|
101
|
+
self.product = attributes[:'product']
|
102
|
+
end
|
103
|
+
|
104
|
+
if attributes.has_key?(:'transaction_id')
|
105
|
+
self.transaction_id = attributes[:'transaction_id']
|
106
|
+
end
|
107
|
+
|
108
|
+
if attributes.has_key?(:'transaction_detail')
|
109
|
+
self.transaction_detail = attributes[:'transaction_detail']
|
110
|
+
end
|
111
|
+
|
112
|
+
if attributes.has_key?(:'created_at')
|
113
|
+
self.created_at = attributes[:'created_at']
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
119
|
+
# @return Array for valid properties with the reasons
|
120
|
+
def list_invalid_properties
|
121
|
+
invalid_properties = Array.new
|
122
|
+
return invalid_properties
|
123
|
+
end
|
124
|
+
|
125
|
+
# Check to see if the all the properties in the model are valid
|
126
|
+
# @return true if the model is valid
|
127
|
+
def valid?
|
128
|
+
service_validator = EnumAttributeValidator.new('String', ["paypal", "stripe"])
|
129
|
+
return false unless service_validator.valid?(@service)
|
130
|
+
return true
|
131
|
+
end
|
132
|
+
|
133
|
+
# Custom attribute writer method checking allowed values (enum).
|
134
|
+
# @param [Object] service Object to be assigned
|
135
|
+
def service=(service)
|
136
|
+
validator = EnumAttributeValidator.new('String', ["paypal", "stripe"])
|
137
|
+
unless validator.valid?(service)
|
138
|
+
fail ArgumentError, "invalid value for 'service', must be one of #{validator.allowable_values}."
|
139
|
+
end
|
140
|
+
@service = service
|
141
|
+
end
|
142
|
+
|
143
|
+
# Checks equality by comparing each attribute.
|
144
|
+
# @param [Object] Object to be compared
|
145
|
+
def ==(o)
|
146
|
+
return true if self.equal?(o)
|
147
|
+
self.class == o.class &&
|
148
|
+
id == o.id &&
|
149
|
+
service == o.service &&
|
150
|
+
product_given == o.product_given &&
|
151
|
+
product == o.product &&
|
152
|
+
transaction_id == o.transaction_id &&
|
153
|
+
transaction_detail == o.transaction_detail &&
|
154
|
+
created_at == o.created_at
|
155
|
+
end
|
156
|
+
|
157
|
+
# @see the `==` method
|
158
|
+
# @param [Object] Object to be compared
|
159
|
+
def eql?(o)
|
160
|
+
self == o
|
161
|
+
end
|
162
|
+
|
163
|
+
# Calculates hash code according to all attributes.
|
164
|
+
# @return [Fixnum] Hash code
|
165
|
+
def hash
|
166
|
+
[id, service, product_given, product, transaction_id, transaction_detail, created_at].hash
|
167
|
+
end
|
168
|
+
|
169
|
+
# Builds the object from hash
|
170
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
171
|
+
# @return [Object] Returns the model itself
|
172
|
+
def build_from_hash(attributes)
|
173
|
+
return nil unless attributes.is_a?(Hash)
|
174
|
+
self.class.swagger_types.each_pair do |key, type|
|
175
|
+
if type =~ /\AArray<(.*)>/i
|
176
|
+
# check to ensure the input is an array given that the the attribute
|
177
|
+
# is documented as an array but the input is not
|
178
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
179
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
180
|
+
end
|
181
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
182
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
183
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
184
|
+
end
|
185
|
+
|
186
|
+
self
|
187
|
+
end
|
188
|
+
|
189
|
+
# Deserializes the data based on type
|
190
|
+
# @param string type Data type
|
191
|
+
# @param string value Value to be deserialized
|
192
|
+
# @return [Object] Deserialized data
|
193
|
+
def _deserialize(type, value)
|
194
|
+
case type.to_sym
|
195
|
+
when :DateTime
|
196
|
+
DateTime.parse(value)
|
197
|
+
when :Date
|
198
|
+
Date.parse(value)
|
199
|
+
when :String
|
200
|
+
value.to_s
|
201
|
+
when :Integer
|
202
|
+
value.to_i
|
203
|
+
when :Float
|
204
|
+
value.to_f
|
205
|
+
when :BOOLEAN
|
206
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
207
|
+
true
|
208
|
+
else
|
209
|
+
false
|
210
|
+
end
|
211
|
+
when :Object
|
212
|
+
# generic object (usually a Hash), return directly
|
213
|
+
value
|
214
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
215
|
+
inner_type = Regexp.last_match[:inner_type]
|
216
|
+
value.map { |v| _deserialize(inner_type, v) }
|
217
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
218
|
+
k_type = Regexp.last_match[:k_type]
|
219
|
+
v_type = Regexp.last_match[:v_type]
|
220
|
+
{}.tap do |hash|
|
221
|
+
value.each do |k, v|
|
222
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
223
|
+
end
|
224
|
+
end
|
225
|
+
else # model
|
226
|
+
temp_model = Aimastering.const_get(type).new
|
227
|
+
temp_model.build_from_hash(value)
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
# Returns the string representation of the object
|
232
|
+
# @return [String] String presentation of the object
|
233
|
+
def to_s
|
234
|
+
to_hash.to_s
|
235
|
+
end
|
236
|
+
|
237
|
+
# to_body is an alias to to_hash (backward compatibility)
|
238
|
+
# @return [Hash] Returns the object in the form of hash
|
239
|
+
def to_body
|
240
|
+
to_hash
|
241
|
+
end
|
242
|
+
|
243
|
+
# Returns the object in the form of hash
|
244
|
+
# @return [Hash] Returns the object in the form of hash
|
245
|
+
def to_hash
|
246
|
+
hash = {}
|
247
|
+
self.class.attribute_map.each_pair do |attr, param|
|
248
|
+
value = self.send(attr)
|
249
|
+
next if value.nil?
|
250
|
+
hash[param] = _to_hash(value)
|
251
|
+
end
|
252
|
+
hash
|
253
|
+
end
|
254
|
+
|
255
|
+
# Outputs non-array value in the form of hash
|
256
|
+
# For object, use to_hash. Otherwise, just return the value
|
257
|
+
# @param [Object] value Any valid value
|
258
|
+
# @return [Hash] Returns the value in the form of hash
|
259
|
+
def _to_hash(value)
|
260
|
+
if value.is_a?(Array)
|
261
|
+
value.compact.map{ |v| _to_hash(v) }
|
262
|
+
elsif value.is_a?(Hash)
|
263
|
+
{}.tap do |hash|
|
264
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
265
|
+
end
|
266
|
+
elsif value.respond_to? :to_hash
|
267
|
+
value.to_hash
|
268
|
+
else
|
269
|
+
value
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
end
|
274
|
+
|
275
|
+
end
|
@@ -0,0 +1,215 @@
|
|
1
|
+
=begin
|
2
|
+
#AI Mastering API
|
3
|
+
|
4
|
+
#This is a AI Mastering API document. You can use the mastering feature of [AI Mastering](https://aimastering.com) through this API.
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0.0
|
7
|
+
Contact: aimasteringcom@gmail.com
|
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 Aimastering
|
16
|
+
|
17
|
+
class PaymentCustomer
|
18
|
+
attr_accessor :id
|
19
|
+
|
20
|
+
attr_accessor :payment_customer_detail
|
21
|
+
|
22
|
+
attr_accessor :created_at
|
23
|
+
|
24
|
+
attr_accessor :updated_at
|
25
|
+
|
26
|
+
|
27
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
28
|
+
def self.attribute_map
|
29
|
+
{
|
30
|
+
:'id' => :'id',
|
31
|
+
:'payment_customer_detail' => :'payment_customer_detail',
|
32
|
+
:'created_at' => :'created_at',
|
33
|
+
:'updated_at' => :'updated_at'
|
34
|
+
}
|
35
|
+
end
|
36
|
+
|
37
|
+
# Attribute type mapping.
|
38
|
+
def self.swagger_types
|
39
|
+
{
|
40
|
+
:'id' => :'Integer',
|
41
|
+
:'payment_customer_detail' => :'Object',
|
42
|
+
:'created_at' => :'DateTime',
|
43
|
+
:'updated_at' => :'DateTime'
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
# Initializes the object
|
48
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
49
|
+
def initialize(attributes = {})
|
50
|
+
return unless attributes.is_a?(Hash)
|
51
|
+
|
52
|
+
# convert string to symbol for hash key
|
53
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
54
|
+
|
55
|
+
if attributes.has_key?(:'id')
|
56
|
+
self.id = attributes[:'id']
|
57
|
+
end
|
58
|
+
|
59
|
+
if attributes.has_key?(:'payment_customer_detail')
|
60
|
+
self.payment_customer_detail = attributes[:'payment_customer_detail']
|
61
|
+
end
|
62
|
+
|
63
|
+
if attributes.has_key?(:'created_at')
|
64
|
+
self.created_at = attributes[:'created_at']
|
65
|
+
end
|
66
|
+
|
67
|
+
if attributes.has_key?(:'updated_at')
|
68
|
+
self.updated_at = attributes[:'updated_at']
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
74
|
+
# @return Array for valid properties with the reasons
|
75
|
+
def list_invalid_properties
|
76
|
+
invalid_properties = Array.new
|
77
|
+
return invalid_properties
|
78
|
+
end
|
79
|
+
|
80
|
+
# Check to see if the all the properties in the model are valid
|
81
|
+
# @return true if the model is valid
|
82
|
+
def valid?
|
83
|
+
return true
|
84
|
+
end
|
85
|
+
|
86
|
+
# Checks equality by comparing each attribute.
|
87
|
+
# @param [Object] Object to be compared
|
88
|
+
def ==(o)
|
89
|
+
return true if self.equal?(o)
|
90
|
+
self.class == o.class &&
|
91
|
+
id == o.id &&
|
92
|
+
payment_customer_detail == o.payment_customer_detail &&
|
93
|
+
created_at == o.created_at &&
|
94
|
+
updated_at == o.updated_at
|
95
|
+
end
|
96
|
+
|
97
|
+
# @see the `==` method
|
98
|
+
# @param [Object] Object to be compared
|
99
|
+
def eql?(o)
|
100
|
+
self == o
|
101
|
+
end
|
102
|
+
|
103
|
+
# Calculates hash code according to all attributes.
|
104
|
+
# @return [Fixnum] Hash code
|
105
|
+
def hash
|
106
|
+
[id, payment_customer_detail, created_at, updated_at].hash
|
107
|
+
end
|
108
|
+
|
109
|
+
# Builds the object from hash
|
110
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
111
|
+
# @return [Object] Returns the model itself
|
112
|
+
def build_from_hash(attributes)
|
113
|
+
return nil unless attributes.is_a?(Hash)
|
114
|
+
self.class.swagger_types.each_pair do |key, type|
|
115
|
+
if type =~ /\AArray<(.*)>/i
|
116
|
+
# check to ensure the input is an array given that the the attribute
|
117
|
+
# is documented as an array but the input is not
|
118
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
119
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
120
|
+
end
|
121
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
122
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
123
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
124
|
+
end
|
125
|
+
|
126
|
+
self
|
127
|
+
end
|
128
|
+
|
129
|
+
# Deserializes the data based on type
|
130
|
+
# @param string type Data type
|
131
|
+
# @param string value Value to be deserialized
|
132
|
+
# @return [Object] Deserialized data
|
133
|
+
def _deserialize(type, value)
|
134
|
+
case type.to_sym
|
135
|
+
when :DateTime
|
136
|
+
DateTime.parse(value)
|
137
|
+
when :Date
|
138
|
+
Date.parse(value)
|
139
|
+
when :String
|
140
|
+
value.to_s
|
141
|
+
when :Integer
|
142
|
+
value.to_i
|
143
|
+
when :Float
|
144
|
+
value.to_f
|
145
|
+
when :BOOLEAN
|
146
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
147
|
+
true
|
148
|
+
else
|
149
|
+
false
|
150
|
+
end
|
151
|
+
when :Object
|
152
|
+
# generic object (usually a Hash), return directly
|
153
|
+
value
|
154
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
155
|
+
inner_type = Regexp.last_match[:inner_type]
|
156
|
+
value.map { |v| _deserialize(inner_type, v) }
|
157
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
158
|
+
k_type = Regexp.last_match[:k_type]
|
159
|
+
v_type = Regexp.last_match[:v_type]
|
160
|
+
{}.tap do |hash|
|
161
|
+
value.each do |k, v|
|
162
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
else # model
|
166
|
+
temp_model = Aimastering.const_get(type).new
|
167
|
+
temp_model.build_from_hash(value)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
# Returns the string representation of the object
|
172
|
+
# @return [String] String presentation of the object
|
173
|
+
def to_s
|
174
|
+
to_hash.to_s
|
175
|
+
end
|
176
|
+
|
177
|
+
# to_body is an alias to to_hash (backward compatibility)
|
178
|
+
# @return [Hash] Returns the object in the form of hash
|
179
|
+
def to_body
|
180
|
+
to_hash
|
181
|
+
end
|
182
|
+
|
183
|
+
# Returns the object in the form of hash
|
184
|
+
# @return [Hash] Returns the object in the form of hash
|
185
|
+
def to_hash
|
186
|
+
hash = {}
|
187
|
+
self.class.attribute_map.each_pair do |attr, param|
|
188
|
+
value = self.send(attr)
|
189
|
+
next if value.nil?
|
190
|
+
hash[param] = _to_hash(value)
|
191
|
+
end
|
192
|
+
hash
|
193
|
+
end
|
194
|
+
|
195
|
+
# Outputs non-array value in the form of hash
|
196
|
+
# For object, use to_hash. Otherwise, just return the value
|
197
|
+
# @param [Object] value Any valid value
|
198
|
+
# @return [Hash] Returns the value in the form of hash
|
199
|
+
def _to_hash(value)
|
200
|
+
if value.is_a?(Array)
|
201
|
+
value.compact.map{ |v| _to_hash(v) }
|
202
|
+
elsif value.is_a?(Hash)
|
203
|
+
{}.tap do |hash|
|
204
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
205
|
+
end
|
206
|
+
elsif value.respond_to? :to_hash
|
207
|
+
value.to_hash
|
208
|
+
else
|
209
|
+
value
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
end
|
214
|
+
|
215
|
+
end
|