boxx_loki 1.5.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 +91 -0
- data/Rakefile +8 -0
- data/boxx_loki.gemspec +46 -0
- data/dist/boxx_loki-1.5.0.gem +0 -0
- data/dist/examples/get_recommendation.rb +0 -0
- data/docs/InlineResponse200.md +10 -0
- data/docs/InlineResponse400.md +9 -0
- data/docs/RecommendationApi.md +55 -0
- data/docs/RecommendationRequestData.md +14 -0
- data/docs/RecommendationRequestDataQuery.md +31 -0
- data/git_push.sh +55 -0
- data/lib/boxx_loki.rb +44 -0
- data/lib/boxx_loki/api/recommendation_api.rb +78 -0
- data/lib/boxx_loki/api_client.rb +388 -0
- data/lib/boxx_loki/api_error.rb +38 -0
- data/lib/boxx_loki/configuration.rb +202 -0
- data/lib/boxx_loki/models/inline_response_200.rb +206 -0
- data/lib/boxx_loki/models/inline_response_400.rb +197 -0
- data/lib/boxx_loki/models/recommendation_request_data.rb +262 -0
- data/lib/boxx_loki/models/recommendation_request_data_query.rb +520 -0
- data/lib/boxx_loki/version.rb +15 -0
- data/spec/api/recommendation_api_spec.rb +47 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/inline_response_200_spec.rb +54 -0
- data/spec/models/inline_response_400_spec.rb +48 -0
- data/spec/models/recommendation_request_data_query_spec.rb +180 -0
- data/spec/models/recommendation_request_data_spec.rb +78 -0
- data/spec/spec_helper.rb +111 -0
- metadata +261 -0
@@ -0,0 +1,520 @@
|
|
1
|
+
=begin
|
2
|
+
#Recommendation API 2
|
3
|
+
|
4
|
+
#No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.5.0
|
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 BoxxLoki
|
16
|
+
|
17
|
+
class RecommendationRequestDataQuery
|
18
|
+
attr_accessor :userid
|
19
|
+
|
20
|
+
attr_accessor :boxx_token_id
|
21
|
+
|
22
|
+
attr_accessor :get_product_properties
|
23
|
+
|
24
|
+
attr_accessor :num
|
25
|
+
|
26
|
+
attr_accessor :user_attribute_weight
|
27
|
+
|
28
|
+
attr_accessor :transaction_weight
|
29
|
+
|
30
|
+
attr_accessor :group_by_attribute
|
31
|
+
|
32
|
+
attr_accessor :location
|
33
|
+
|
34
|
+
attr_accessor :radius
|
35
|
+
|
36
|
+
attr_accessor :item_filters
|
37
|
+
|
38
|
+
attr_accessor :recent_actions
|
39
|
+
|
40
|
+
attr_accessor :repeat
|
41
|
+
|
42
|
+
attr_accessor :exclude
|
43
|
+
|
44
|
+
attr_accessor :num_out_of
|
45
|
+
|
46
|
+
attr_accessor :offset
|
47
|
+
|
48
|
+
attr_accessor :random
|
49
|
+
|
50
|
+
attr_accessor :related_products
|
51
|
+
|
52
|
+
attr_accessor :related_action_type
|
53
|
+
|
54
|
+
attr_accessor :dont_repeat_transaction_types
|
55
|
+
|
56
|
+
attr_accessor :product_ids
|
57
|
+
|
58
|
+
attr_accessor :page_num
|
59
|
+
|
60
|
+
attr_accessor :maximize
|
61
|
+
|
62
|
+
attr_accessor :latest_transactions
|
63
|
+
|
64
|
+
attr_accessor :ignore_filters
|
65
|
+
|
66
|
+
|
67
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
68
|
+
def self.attribute_map
|
69
|
+
{
|
70
|
+
:'userid' => :'userid',
|
71
|
+
:'boxx_token_id' => :'boxx_token_id',
|
72
|
+
:'get_product_properties' => :'get_product_properties',
|
73
|
+
:'num' => :'num',
|
74
|
+
:'user_attribute_weight' => :'user_attribute_weight',
|
75
|
+
:'transaction_weight' => :'transaction_weight',
|
76
|
+
:'group_by_attribute' => :'group_by_attribute',
|
77
|
+
:'location' => :'location',
|
78
|
+
:'radius' => :'radius',
|
79
|
+
:'item_filters' => :'item_filters',
|
80
|
+
:'recent_actions' => :'recent_actions',
|
81
|
+
:'repeat' => :'repeat',
|
82
|
+
:'exclude' => :'exclude',
|
83
|
+
:'num_out_of' => :'num_out_of',
|
84
|
+
:'offset' => :'offset',
|
85
|
+
:'random' => :'random',
|
86
|
+
:'related_products' => :'related_products',
|
87
|
+
:'related_action_type' => :'related_action_type',
|
88
|
+
:'dont_repeat_transaction_types' => :'dont_repeat_transaction_types',
|
89
|
+
:'product_ids' => :'product_ids',
|
90
|
+
:'page_num' => :'page_num',
|
91
|
+
:'maximize' => :'maximize',
|
92
|
+
:'latest_transactions' => :'latest_transactions',
|
93
|
+
:'ignore_filters' => :'ignore_filters'
|
94
|
+
}
|
95
|
+
end
|
96
|
+
|
97
|
+
# Attribute type mapping.
|
98
|
+
def self.swagger_types
|
99
|
+
{
|
100
|
+
:'userid' => :'String',
|
101
|
+
:'boxx_token_id' => :'String',
|
102
|
+
:'get_product_properties' => :'BOOLEAN',
|
103
|
+
:'num' => :'Integer',
|
104
|
+
:'user_attribute_weight' => :'Float',
|
105
|
+
:'transaction_weight' => :'Float',
|
106
|
+
:'group_by_attribute' => :'BOOLEAN',
|
107
|
+
:'location' => :'Array<Float>',
|
108
|
+
:'radius' => :'Integer',
|
109
|
+
:'item_filters' => :'Object',
|
110
|
+
:'recent_actions' => :'Object',
|
111
|
+
:'repeat' => :'BOOLEAN',
|
112
|
+
:'exclude' => :'Array<String>',
|
113
|
+
:'num_out_of' => :'Float',
|
114
|
+
:'offset' => :'Float',
|
115
|
+
:'random' => :'Float',
|
116
|
+
:'related_products' => :'Array<String>',
|
117
|
+
:'related_action_type' => :'String',
|
118
|
+
:'dont_repeat_transaction_types' => :'Array<String>',
|
119
|
+
:'product_ids' => :'Array<String>',
|
120
|
+
:'page_num' => :'Float',
|
121
|
+
:'maximize' => :'String',
|
122
|
+
:'latest_transactions' => :'BOOLEAN',
|
123
|
+
:'ignore_filters' => :'BOOLEAN'
|
124
|
+
}
|
125
|
+
end
|
126
|
+
|
127
|
+
# Initializes the object
|
128
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
129
|
+
def initialize(attributes = {})
|
130
|
+
return unless attributes.is_a?(Hash)
|
131
|
+
|
132
|
+
# convert string to symbol for hash key
|
133
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
134
|
+
|
135
|
+
if attributes.has_key?(:'userid')
|
136
|
+
self.userid = attributes[:'userid']
|
137
|
+
end
|
138
|
+
|
139
|
+
if attributes.has_key?(:'boxx_token_id')
|
140
|
+
self.boxx_token_id = attributes[:'boxx_token_id']
|
141
|
+
end
|
142
|
+
|
143
|
+
if attributes.has_key?(:'get_product_properties')
|
144
|
+
self.get_product_properties = attributes[:'get_product_properties']
|
145
|
+
else
|
146
|
+
self.get_product_properties = false
|
147
|
+
end
|
148
|
+
|
149
|
+
if attributes.has_key?(:'num')
|
150
|
+
self.num = attributes[:'num']
|
151
|
+
end
|
152
|
+
|
153
|
+
if attributes.has_key?(:'user_attribute_weight')
|
154
|
+
self.user_attribute_weight = attributes[:'user_attribute_weight']
|
155
|
+
end
|
156
|
+
|
157
|
+
if attributes.has_key?(:'transaction_weight')
|
158
|
+
self.transaction_weight = attributes[:'transaction_weight']
|
159
|
+
end
|
160
|
+
|
161
|
+
if attributes.has_key?(:'group_by_attribute')
|
162
|
+
self.group_by_attribute = attributes[:'group_by_attribute']
|
163
|
+
end
|
164
|
+
|
165
|
+
if attributes.has_key?(:'location')
|
166
|
+
if (value = attributes[:'location']).is_a?(Array)
|
167
|
+
self.location = value
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
if attributes.has_key?(:'radius')
|
172
|
+
self.radius = attributes[:'radius']
|
173
|
+
end
|
174
|
+
|
175
|
+
if attributes.has_key?(:'item_filters')
|
176
|
+
self.item_filters = attributes[:'item_filters']
|
177
|
+
end
|
178
|
+
|
179
|
+
if attributes.has_key?(:'recent_actions')
|
180
|
+
self.recent_actions = attributes[:'recent_actions']
|
181
|
+
end
|
182
|
+
|
183
|
+
if attributes.has_key?(:'repeat')
|
184
|
+
self.repeat = attributes[:'repeat']
|
185
|
+
else
|
186
|
+
self.repeat = true
|
187
|
+
end
|
188
|
+
|
189
|
+
if attributes.has_key?(:'exclude')
|
190
|
+
if (value = attributes[:'exclude']).is_a?(Array)
|
191
|
+
self.exclude = value
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
if attributes.has_key?(:'num_out_of')
|
196
|
+
self.num_out_of = attributes[:'num_out_of']
|
197
|
+
end
|
198
|
+
|
199
|
+
if attributes.has_key?(:'offset')
|
200
|
+
self.offset = attributes[:'offset']
|
201
|
+
end
|
202
|
+
|
203
|
+
if attributes.has_key?(:'random')
|
204
|
+
self.random = attributes[:'random']
|
205
|
+
end
|
206
|
+
|
207
|
+
if attributes.has_key?(:'related_products')
|
208
|
+
if (value = attributes[:'related_products']).is_a?(Array)
|
209
|
+
self.related_products = value
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
if attributes.has_key?(:'related_action_type')
|
214
|
+
self.related_action_type = attributes[:'related_action_type']
|
215
|
+
end
|
216
|
+
|
217
|
+
if attributes.has_key?(:'dont_repeat_transaction_types')
|
218
|
+
if (value = attributes[:'dont_repeat_transaction_types']).is_a?(Array)
|
219
|
+
self.dont_repeat_transaction_types = value
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
if attributes.has_key?(:'product_ids')
|
224
|
+
if (value = attributes[:'product_ids']).is_a?(Array)
|
225
|
+
self.product_ids = value
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
if attributes.has_key?(:'page_num')
|
230
|
+
self.page_num = attributes[:'page_num']
|
231
|
+
end
|
232
|
+
|
233
|
+
if attributes.has_key?(:'maximize')
|
234
|
+
self.maximize = attributes[:'maximize']
|
235
|
+
end
|
236
|
+
|
237
|
+
if attributes.has_key?(:'latest_transactions')
|
238
|
+
self.latest_transactions = attributes[:'latest_transactions']
|
239
|
+
else
|
240
|
+
self.latest_transactions = false
|
241
|
+
end
|
242
|
+
|
243
|
+
if attributes.has_key?(:'ignore_filters')
|
244
|
+
self.ignore_filters = attributes[:'ignore_filters']
|
245
|
+
else
|
246
|
+
self.ignore_filters = false
|
247
|
+
end
|
248
|
+
|
249
|
+
end
|
250
|
+
|
251
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
252
|
+
# @return Array for valid properties with the reasons
|
253
|
+
def list_invalid_properties
|
254
|
+
invalid_properties = Array.new
|
255
|
+
if !@num.nil? && @num < 0
|
256
|
+
invalid_properties.push("invalid value for 'num', must be greater than or equal to 0.")
|
257
|
+
end
|
258
|
+
|
259
|
+
if !@user_attribute_weight.nil? && @user_attribute_weight > 1
|
260
|
+
invalid_properties.push("invalid value for 'user_attribute_weight', must be smaller than or equal to 1.")
|
261
|
+
end
|
262
|
+
|
263
|
+
if !@user_attribute_weight.nil? && @user_attribute_weight < 0
|
264
|
+
invalid_properties.push("invalid value for 'user_attribute_weight', must be greater than or equal to 0.")
|
265
|
+
end
|
266
|
+
|
267
|
+
if !@transaction_weight.nil? && @transaction_weight > 1
|
268
|
+
invalid_properties.push("invalid value for 'transaction_weight', must be smaller than or equal to 1.")
|
269
|
+
end
|
270
|
+
|
271
|
+
if !@transaction_weight.nil? && @transaction_weight < 0
|
272
|
+
invalid_properties.push("invalid value for 'transaction_weight', must be greater than or equal to 0.")
|
273
|
+
end
|
274
|
+
|
275
|
+
if !@random.nil? && @random > 1
|
276
|
+
invalid_properties.push("invalid value for 'random', must be smaller than or equal to 1.")
|
277
|
+
end
|
278
|
+
|
279
|
+
if !@random.nil? && @random < 0
|
280
|
+
invalid_properties.push("invalid value for 'random', must be greater than or equal to 0.")
|
281
|
+
end
|
282
|
+
|
283
|
+
if !@page_num.nil? && @page_num < 1
|
284
|
+
invalid_properties.push("invalid value for 'page_num', must be greater than or equal to 1.")
|
285
|
+
end
|
286
|
+
|
287
|
+
return invalid_properties
|
288
|
+
end
|
289
|
+
|
290
|
+
# Check to see if the all the properties in the model are valid
|
291
|
+
# @return true if the model is valid
|
292
|
+
def valid?
|
293
|
+
return false if !@num.nil? && @num < 0
|
294
|
+
return false if !@user_attribute_weight.nil? && @user_attribute_weight > 1
|
295
|
+
return false if !@user_attribute_weight.nil? && @user_attribute_weight < 0
|
296
|
+
return false if !@transaction_weight.nil? && @transaction_weight > 1
|
297
|
+
return false if !@transaction_weight.nil? && @transaction_weight < 0
|
298
|
+
return false if !@random.nil? && @random > 1
|
299
|
+
return false if !@random.nil? && @random < 0
|
300
|
+
return false if !@page_num.nil? && @page_num < 1
|
301
|
+
return true
|
302
|
+
end
|
303
|
+
|
304
|
+
# Custom attribute writer method with validation
|
305
|
+
# @param [Object] num Value to be assigned
|
306
|
+
def num=(num)
|
307
|
+
|
308
|
+
if !num.nil? && num < 0
|
309
|
+
fail ArgumentError, "invalid value for 'num', must be greater than or equal to 0."
|
310
|
+
end
|
311
|
+
|
312
|
+
@num = num
|
313
|
+
end
|
314
|
+
|
315
|
+
# Custom attribute writer method with validation
|
316
|
+
# @param [Object] user_attribute_weight Value to be assigned
|
317
|
+
def user_attribute_weight=(user_attribute_weight)
|
318
|
+
|
319
|
+
if !user_attribute_weight.nil? && user_attribute_weight > 1
|
320
|
+
fail ArgumentError, "invalid value for 'user_attribute_weight', must be smaller than or equal to 1."
|
321
|
+
end
|
322
|
+
|
323
|
+
if !user_attribute_weight.nil? && user_attribute_weight < 0
|
324
|
+
fail ArgumentError, "invalid value for 'user_attribute_weight', must be greater than or equal to 0."
|
325
|
+
end
|
326
|
+
|
327
|
+
@user_attribute_weight = user_attribute_weight
|
328
|
+
end
|
329
|
+
|
330
|
+
# Custom attribute writer method with validation
|
331
|
+
# @param [Object] transaction_weight Value to be assigned
|
332
|
+
def transaction_weight=(transaction_weight)
|
333
|
+
|
334
|
+
if !transaction_weight.nil? && transaction_weight > 1
|
335
|
+
fail ArgumentError, "invalid value for 'transaction_weight', must be smaller than or equal to 1."
|
336
|
+
end
|
337
|
+
|
338
|
+
if !transaction_weight.nil? && transaction_weight < 0
|
339
|
+
fail ArgumentError, "invalid value for 'transaction_weight', must be greater than or equal to 0."
|
340
|
+
end
|
341
|
+
|
342
|
+
@transaction_weight = transaction_weight
|
343
|
+
end
|
344
|
+
|
345
|
+
# Custom attribute writer method with validation
|
346
|
+
# @param [Object] random Value to be assigned
|
347
|
+
def random=(random)
|
348
|
+
|
349
|
+
if !random.nil? && random > 1
|
350
|
+
fail ArgumentError, "invalid value for 'random', must be smaller than or equal to 1."
|
351
|
+
end
|
352
|
+
|
353
|
+
if !random.nil? && random < 0
|
354
|
+
fail ArgumentError, "invalid value for 'random', must be greater than or equal to 0."
|
355
|
+
end
|
356
|
+
|
357
|
+
@random = random
|
358
|
+
end
|
359
|
+
|
360
|
+
# Custom attribute writer method with validation
|
361
|
+
# @param [Object] page_num Value to be assigned
|
362
|
+
def page_num=(page_num)
|
363
|
+
|
364
|
+
if !page_num.nil? && page_num < 1
|
365
|
+
fail ArgumentError, "invalid value for 'page_num', must be greater than or equal to 1."
|
366
|
+
end
|
367
|
+
|
368
|
+
@page_num = page_num
|
369
|
+
end
|
370
|
+
|
371
|
+
# Checks equality by comparing each attribute.
|
372
|
+
# @param [Object] Object to be compared
|
373
|
+
def ==(o)
|
374
|
+
return true if self.equal?(o)
|
375
|
+
self.class == o.class &&
|
376
|
+
userid == o.userid &&
|
377
|
+
boxx_token_id == o.boxx_token_id &&
|
378
|
+
get_product_properties == o.get_product_properties &&
|
379
|
+
num == o.num &&
|
380
|
+
user_attribute_weight == o.user_attribute_weight &&
|
381
|
+
transaction_weight == o.transaction_weight &&
|
382
|
+
group_by_attribute == o.group_by_attribute &&
|
383
|
+
location == o.location &&
|
384
|
+
radius == o.radius &&
|
385
|
+
item_filters == o.item_filters &&
|
386
|
+
recent_actions == o.recent_actions &&
|
387
|
+
repeat == o.repeat &&
|
388
|
+
exclude == o.exclude &&
|
389
|
+
num_out_of == o.num_out_of &&
|
390
|
+
offset == o.offset &&
|
391
|
+
random == o.random &&
|
392
|
+
related_products == o.related_products &&
|
393
|
+
related_action_type == o.related_action_type &&
|
394
|
+
dont_repeat_transaction_types == o.dont_repeat_transaction_types &&
|
395
|
+
product_ids == o.product_ids &&
|
396
|
+
page_num == o.page_num &&
|
397
|
+
maximize == o.maximize &&
|
398
|
+
latest_transactions == o.latest_transactions &&
|
399
|
+
ignore_filters == o.ignore_filters
|
400
|
+
end
|
401
|
+
|
402
|
+
# @see the `==` method
|
403
|
+
# @param [Object] Object to be compared
|
404
|
+
def eql?(o)
|
405
|
+
self == o
|
406
|
+
end
|
407
|
+
|
408
|
+
# Calculates hash code according to all attributes.
|
409
|
+
# @return [Fixnum] Hash code
|
410
|
+
def hash
|
411
|
+
[userid, boxx_token_id, get_product_properties, num, user_attribute_weight, transaction_weight, group_by_attribute, location, radius, item_filters, recent_actions, repeat, exclude, num_out_of, offset, random, related_products, related_action_type, dont_repeat_transaction_types, product_ids, page_num, maximize, latest_transactions, ignore_filters].hash
|
412
|
+
end
|
413
|
+
|
414
|
+
# Builds the object from hash
|
415
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
416
|
+
# @return [Object] Returns the model itself
|
417
|
+
def build_from_hash(attributes)
|
418
|
+
return nil unless attributes.is_a?(Hash)
|
419
|
+
self.class.swagger_types.each_pair do |key, type|
|
420
|
+
if type =~ /\AArray<(.*)>/i
|
421
|
+
# check to ensure the input is an array given that the the attribute
|
422
|
+
# is documented as an array but the input is not
|
423
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
424
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
425
|
+
end
|
426
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
427
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
428
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
429
|
+
end
|
430
|
+
|
431
|
+
self
|
432
|
+
end
|
433
|
+
|
434
|
+
# Deserializes the data based on type
|
435
|
+
# @param string type Data type
|
436
|
+
# @param string value Value to be deserialized
|
437
|
+
# @return [Object] Deserialized data
|
438
|
+
def _deserialize(type, value)
|
439
|
+
case type.to_sym
|
440
|
+
when :DateTime
|
441
|
+
DateTime.parse(value)
|
442
|
+
when :Date
|
443
|
+
Date.parse(value)
|
444
|
+
when :String
|
445
|
+
value.to_s
|
446
|
+
when :Integer
|
447
|
+
value.to_i
|
448
|
+
when :Float
|
449
|
+
value.to_f
|
450
|
+
when :BOOLEAN
|
451
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
452
|
+
true
|
453
|
+
else
|
454
|
+
false
|
455
|
+
end
|
456
|
+
when :Object
|
457
|
+
# generic object (usually a Hash), return directly
|
458
|
+
value
|
459
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
460
|
+
inner_type = Regexp.last_match[:inner_type]
|
461
|
+
value.map { |v| _deserialize(inner_type, v) }
|
462
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
463
|
+
k_type = Regexp.last_match[:k_type]
|
464
|
+
v_type = Regexp.last_match[:v_type]
|
465
|
+
{}.tap do |hash|
|
466
|
+
value.each do |k, v|
|
467
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
468
|
+
end
|
469
|
+
end
|
470
|
+
else # model
|
471
|
+
temp_model = BoxxLoki.const_get(type).new
|
472
|
+
temp_model.build_from_hash(value)
|
473
|
+
end
|
474
|
+
end
|
475
|
+
|
476
|
+
# Returns the string representation of the object
|
477
|
+
# @return [String] String presentation of the object
|
478
|
+
def to_s
|
479
|
+
to_hash.to_s
|
480
|
+
end
|
481
|
+
|
482
|
+
# to_body is an alias to to_hash (backward compatibility)
|
483
|
+
# @return [Hash] Returns the object in the form of hash
|
484
|
+
def to_body
|
485
|
+
to_hash
|
486
|
+
end
|
487
|
+
|
488
|
+
# Returns the object in the form of hash
|
489
|
+
# @return [Hash] Returns the object in the form of hash
|
490
|
+
def to_hash
|
491
|
+
hash = {}
|
492
|
+
self.class.attribute_map.each_pair do |attr, param|
|
493
|
+
value = self.send(attr)
|
494
|
+
next if value.nil?
|
495
|
+
hash[param] = _to_hash(value)
|
496
|
+
end
|
497
|
+
hash
|
498
|
+
end
|
499
|
+
|
500
|
+
# Outputs non-array value in the form of hash
|
501
|
+
# For object, use to_hash. Otherwise, just return the value
|
502
|
+
# @param [Object] value Any valid value
|
503
|
+
# @return [Hash] Returns the value in the form of hash
|
504
|
+
def _to_hash(value)
|
505
|
+
if value.is_a?(Array)
|
506
|
+
value.compact.map{ |v| _to_hash(v) }
|
507
|
+
elsif value.is_a?(Hash)
|
508
|
+
{}.tap do |hash|
|
509
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
510
|
+
end
|
511
|
+
elsif value.respond_to? :to_hash
|
512
|
+
value.to_hash
|
513
|
+
else
|
514
|
+
value
|
515
|
+
end
|
516
|
+
end
|
517
|
+
|
518
|
+
end
|
519
|
+
|
520
|
+
end
|