pier-sdk-ruby 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. data/README.md +141 -0
  2. data/docs/AuthToken.md +12 -0
  3. data/docs/BodyAccessToken.md +10 -0
  4. data/docs/CancelarCartaoResponse.md +11 -0
  5. data/docs/CartaoApi.md +252 -0
  6. data/docs/CartaoResponse.md +29 -0
  7. data/docs/ConsultarCartaoResponse.md +10 -0
  8. data/docs/ConsultarContaCartaoResponse.md +18 -0
  9. data/docs/ConsultarContaResponse.md +11 -0
  10. data/docs/ConsultarExtratoContaResponse.md +23 -0
  11. data/docs/ConsultarSaldoLimitesResponse.md +23 -0
  12. data/docs/ContaApi.md +238 -0
  13. data/docs/ContaCartaoResponse.md +21 -0
  14. data/docs/ContaResponse.md +41 -0
  15. data/docs/DesbloquearCartaoResponse.md +9 -0
  16. data/docs/ExtraInfo.md +8 -0
  17. data/docs/ExtratoResponse.md +35 -0
  18. data/docs/PessoaFisicaResponse.md +26 -0
  19. data/docs/SaldoLimiteResponse.md +39 -0
  20. data/docs/TokenApi.md +114 -0
  21. data/git_push.sh +52 -0
  22. data/lib/pier-sdk-ruby.rb +62 -0
  23. data/lib/pier-sdk-ruby/api/cartao_api.rb +355 -0
  24. data/lib/pier-sdk-ruby/api/conta_api.rb +324 -0
  25. data/lib/pier-sdk-ruby/api/token_api.rb +157 -0
  26. data/lib/pier-sdk-ruby/api_client.rb +368 -0
  27. data/lib/pier-sdk-ruby/api_error.rb +40 -0
  28. data/lib/pier-sdk-ruby/configuration.rb +177 -0
  29. data/lib/pier-sdk-ruby/models/auth_token.rb +325 -0
  30. data/lib/pier-sdk-ruby/models/body_access_token.rb +275 -0
  31. data/lib/pier-sdk-ruby/models/cancelar_cartao_response.rb +286 -0
  32. data/lib/pier-sdk-ruby/models/cartao_response.rb +736 -0
  33. data/lib/pier-sdk-ruby/models/consultar_cartao_response.rb +263 -0
  34. data/lib/pier-sdk-ruby/models/consultar_conta_cartao_response.rb +461 -0
  35. data/lib/pier-sdk-ruby/models/consultar_conta_response.rb +288 -0
  36. data/lib/pier-sdk-ruby/models/consultar_extrato_conta_response.rb +588 -0
  37. data/lib/pier-sdk-ruby/models/consultar_saldo_limites_response.rb +586 -0
  38. data/lib/pier-sdk-ruby/models/conta_cartao_response.rb +536 -0
  39. data/lib/pier-sdk-ruby/models/conta_response.rb +1036 -0
  40. data/lib/pier-sdk-ruby/models/desbloquear_cartao_response.rb +236 -0
  41. data/lib/pier-sdk-ruby/models/extra_info.rb +211 -0
  42. data/lib/pier-sdk-ruby/models/extrato_response.rb +886 -0
  43. data/lib/pier-sdk-ruby/models/pessoa_fisica_response.rb +661 -0
  44. data/lib/pier-sdk-ruby/models/saldo_limite_response.rb +986 -0
  45. data/lib/pier-sdk-ruby/version.rb +19 -0
  46. data/pier-sdk-ruby.gemspec +33 -0
  47. data/spec/api/cartao_api_spec.rb +110 -0
  48. data/spec/api/conta_api_spec.rb +107 -0
  49. data/spec/api/token_api_spec.rb +71 -0
  50. data/spec/models/auth_token_spec.rb +90 -0
  51. data/spec/models/body_access_token_spec.rb +70 -0
  52. data/spec/models/cancelar_cartao_response_spec.rb +80 -0
  53. data/spec/models/cartao_response_spec.rb +260 -0
  54. data/spec/models/consultar_cartao_response_spec.rb +70 -0
  55. data/spec/models/consultar_conta_cartao_response_spec.rb +150 -0
  56. data/spec/models/consultar_conta_response_spec.rb +80 -0
  57. data/spec/models/consultar_extrato_conta_response_spec.rb +200 -0
  58. data/spec/models/consultar_saldo_limites_response_spec.rb +200 -0
  59. data/spec/models/conta_cartao_response_spec.rb +180 -0
  60. data/spec/models/conta_response_spec.rb +380 -0
  61. data/spec/models/desbloquear_cartao_response_spec.rb +60 -0
  62. data/spec/models/extra_info_spec.rb +50 -0
  63. data/spec/models/extrato_response_spec.rb +320 -0
  64. data/spec/models/pessoa_fisica_response_spec.rb +230 -0
  65. data/spec/models/saldo_limite_response_spec.rb +360 -0
  66. metadata +310 -0
@@ -0,0 +1,288 @@
1
+ =begin
2
+ CaaS - Conductor as a Service
3
+
4
+ Gest\u00C3\u00A3o de pagamento eletr\u00C3\u00B4nicos como servi\u00C3\u00A7o
5
+
6
+ OpenAPI spec version: 0.0.1
7
+ Contact: contato@conductor.com.br
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ License: Apache 2.0
11
+ http://www.apache.org/licenses/LICENSE-2.0.html
12
+
13
+ Terms of Service: http://dev.conductor.com.br/terms/
14
+
15
+ =end
16
+
17
+ require 'date'
18
+
19
+ module Pier
20
+ class ConsultarContaResponse
21
+ attr_accessor :cod_retorno
22
+
23
+ attr_accessor :codigo_retorno
24
+
25
+ attr_accessor :contas
26
+
27
+ attr_accessor :descricao_retorno
28
+
29
+ # Attribute mapping from ruby-style variable name to JSON key.
30
+ def self.attribute_map
31
+ {
32
+
33
+ :'cod_retorno' => :'codRetorno',
34
+
35
+ :'codigo_retorno' => :'codigoRetorno',
36
+
37
+ :'contas' => :'contas',
38
+
39
+ :'descricao_retorno' => :'descricaoRetorno'
40
+
41
+ }
42
+ end
43
+
44
+ # Attribute type mapping.
45
+ def self.swagger_types
46
+ {
47
+
48
+ :'cod_retorno' => :'Integer',
49
+
50
+ :'codigo_retorno' => :'Integer',
51
+
52
+ :'contas' => :'Array<ContaCartaoResponse>',
53
+
54
+ :'descricao_retorno' => :'String'
55
+
56
+ }
57
+ end
58
+
59
+ # Initializes the object
60
+ # @param [Hash] attributes Model attributes in the form of hash
61
+ def initialize(attributes = {})
62
+ return unless attributes.is_a?(Hash)
63
+
64
+ # convert string to symbol for hash key
65
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
66
+
67
+
68
+ if attributes[:'codRetorno']
69
+
70
+
71
+ self.cod_retorno = attributes[:'codRetorno']
72
+
73
+
74
+ end
75
+
76
+
77
+ if attributes[:'codigoRetorno']
78
+
79
+
80
+ self.codigo_retorno = attributes[:'codigoRetorno']
81
+
82
+
83
+ end
84
+
85
+
86
+ if attributes[:'contas']
87
+
88
+ if (value = attributes[:'contas']).is_a?(Array)
89
+ self.contas = value
90
+ end
91
+
92
+
93
+
94
+ end
95
+
96
+
97
+ if attributes[:'descricaoRetorno']
98
+
99
+
100
+ self.descricao_retorno = attributes[:'descricaoRetorno']
101
+
102
+
103
+ end
104
+
105
+
106
+ end
107
+
108
+ # Show invalid properties with the reasons. Usually used together with valid?
109
+ # @return Array for valid properies with the reasons
110
+ def list_invalid_properties
111
+ invalid_properties = Array.new
112
+
113
+
114
+ return invalid_properties
115
+ end
116
+
117
+ # Check to see if the all the properties in the model are valid
118
+ # @return true if the model is valid
119
+ def valid?
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+ end
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+
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
+ cod_retorno == o.cod_retorno &&
166
+ codigo_retorno == o.codigo_retorno &&
167
+ contas == o.contas &&
168
+ descricao_retorno == o.descricao_retorno
169
+ end
170
+
171
+ # @see the `==` method
172
+ # @param [Object] Object to be compared
173
+ def eql?(o)
174
+ self == o
175
+ end
176
+
177
+ # Calculates hash code according to all attributes.
178
+ # @return [Fixnum] Hash code
179
+ def hash
180
+ [cod_retorno, codigo_retorno, contas, descricao_retorno].hash
181
+ end
182
+
183
+ # Builds the object from hash
184
+ # @param [Hash] attributes Model attributes in the form of hash
185
+ # @return [Object] Returns the model itself
186
+ def build_from_hash(attributes)
187
+ return nil unless attributes.is_a?(Hash)
188
+ self.class.swagger_types.each_pair do |key, type|
189
+ if type =~ /^Array<(.*)>/i
190
+ # check to ensure the input is an array given that the the attribute
191
+ # is documented as an array but the input is not
192
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
193
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
194
+ end
195
+ elsif !attributes[self.class.attribute_map[key]].nil?
196
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
197
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
198
+ end
199
+
200
+ self
201
+ end
202
+
203
+ # Deserializes the data based on type
204
+ # @param string type Data type
205
+ # @param string value Value to be deserialized
206
+ # @return [Object] Deserialized data
207
+ def _deserialize(type, value)
208
+ case type.to_sym
209
+ when :DateTime
210
+ DateTime.parse(value)
211
+ when :Date
212
+ Date.parse(value)
213
+ when :String
214
+ value.to_s
215
+ when :Integer
216
+ value.to_i
217
+ when :Float
218
+ value.to_f
219
+ when :BOOLEAN
220
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
221
+ true
222
+ else
223
+ false
224
+ end
225
+ when :Object
226
+ # generic object (usually a Hash), return directly
227
+ value
228
+ when /\AArray<(?<inner_type>.+)>\z/
229
+ inner_type = Regexp.last_match[:inner_type]
230
+ value.map { |v| _deserialize(inner_type, v) }
231
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
232
+ k_type = Regexp.last_match[:k_type]
233
+ v_type = Regexp.last_match[:v_type]
234
+ {}.tap do |hash|
235
+ value.each do |k, v|
236
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
237
+ end
238
+ end
239
+ else # model
240
+ temp_model = Pier.const_get(type).new
241
+ temp_model.build_from_hash(value)
242
+ end
243
+ end
244
+
245
+ # Returns the string representation of the object
246
+ # @return [String] String presentation of the object
247
+ def to_s
248
+ to_hash.to_s
249
+ end
250
+
251
+ # to_body is an alias to to_hash (backward compatibility)
252
+ # @return [Hash] Returns the object in the form of hash
253
+ def to_body
254
+ to_hash
255
+ end
256
+
257
+ # Returns the object in the form of hash
258
+ # @return [Hash] Returns the object in the form of hash
259
+ def to_hash
260
+ hash = {}
261
+ self.class.attribute_map.each_pair do |attr, param|
262
+ value = self.send(attr)
263
+ next if value.nil?
264
+ hash[param] = _to_hash(value)
265
+ end
266
+ hash
267
+ end
268
+
269
+ # Outputs non-array value in the form of hash
270
+ # For object, use to_hash. Otherwise, just return the value
271
+ # @param [Object] value Any valid value
272
+ # @return [Hash] Returns the value in the form of hash
273
+ def _to_hash(value)
274
+ if value.is_a?(Array)
275
+ value.compact.map{ |v| _to_hash(v) }
276
+ elsif value.is_a?(Hash)
277
+ {}.tap do |hash|
278
+ value.each { |k, v| hash[k] = _to_hash(v) }
279
+ end
280
+ elsif value.respond_to? :to_hash
281
+ value.to_hash
282
+ else
283
+ value
284
+ end
285
+ end
286
+
287
+ end
288
+ end
@@ -0,0 +1,588 @@
1
+ =begin
2
+ CaaS - Conductor as a Service
3
+
4
+ Gest\u00C3\u00A3o de pagamento eletr\u00C3\u00B4nicos como servi\u00C3\u00A7o
5
+
6
+ OpenAPI spec version: 0.0.1
7
+ Contact: contato@conductor.com.br
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+ License: Apache 2.0
11
+ http://www.apache.org/licenses/LICENSE-2.0.html
12
+
13
+ Terms of Service: http://dev.conductor.com.br/terms/
14
+
15
+ =end
16
+
17
+ require 'date'
18
+
19
+ module Pier
20
+ class ConsultarExtratoContaResponse
21
+ attr_accessor :codigo_retorno
22
+
23
+ attr_accessor :compras_nacionais
24
+
25
+ attr_accessor :cpf
26
+
27
+ attr_accessor :creditos_nacionais
28
+
29
+ attr_accessor :data_vencimento
30
+
31
+ attr_accessor :debitos_nacionais
32
+
33
+ attr_accessor :descricao_retorno
34
+
35
+ attr_accessor :extrato
36
+
37
+ attr_accessor :id_cartao
38
+
39
+ attr_accessor :id_conta
40
+
41
+ attr_accessor :multa
42
+
43
+ attr_accessor :pagamentos
44
+
45
+ attr_accessor :saldo_atual_final
46
+
47
+ attr_accessor :saldo_extrato_anterior
48
+
49
+ attr_accessor :tarifas_nacionais
50
+
51
+ attr_accessor :valor_minimo_extrato
52
+
53
+ # Attribute mapping from ruby-style variable name to JSON key.
54
+ def self.attribute_map
55
+ {
56
+
57
+ :'codigo_retorno' => :'codigoRetorno',
58
+
59
+ :'compras_nacionais' => :'comprasNacionais',
60
+
61
+ :'cpf' => :'cpf',
62
+
63
+ :'creditos_nacionais' => :'creditosNacionais',
64
+
65
+ :'data_vencimento' => :'dataVencimento',
66
+
67
+ :'debitos_nacionais' => :'debitosNacionais',
68
+
69
+ :'descricao_retorno' => :'descricaoRetorno',
70
+
71
+ :'extrato' => :'extrato',
72
+
73
+ :'id_cartao' => :'idCartao',
74
+
75
+ :'id_conta' => :'idConta',
76
+
77
+ :'multa' => :'multa',
78
+
79
+ :'pagamentos' => :'pagamentos',
80
+
81
+ :'saldo_atual_final' => :'saldoAtualFinal',
82
+
83
+ :'saldo_extrato_anterior' => :'saldoExtratoAnterior',
84
+
85
+ :'tarifas_nacionais' => :'tarifasNacionais',
86
+
87
+ :'valor_minimo_extrato' => :'valorMinimoExtrato'
88
+
89
+ }
90
+ end
91
+
92
+ # Attribute type mapping.
93
+ def self.swagger_types
94
+ {
95
+
96
+ :'codigo_retorno' => :'Integer',
97
+
98
+ :'compras_nacionais' => :'Float',
99
+
100
+ :'cpf' => :'String',
101
+
102
+ :'creditos_nacionais' => :'Float',
103
+
104
+ :'data_vencimento' => :'String',
105
+
106
+ :'debitos_nacionais' => :'Float',
107
+
108
+ :'descricao_retorno' => :'String',
109
+
110
+ :'extrato' => :'Array<ExtratoResponse>',
111
+
112
+ :'id_cartao' => :'Integer',
113
+
114
+ :'id_conta' => :'Integer',
115
+
116
+ :'multa' => :'Float',
117
+
118
+ :'pagamentos' => :'Float',
119
+
120
+ :'saldo_atual_final' => :'Float',
121
+
122
+ :'saldo_extrato_anterior' => :'Float',
123
+
124
+ :'tarifas_nacionais' => :'Float',
125
+
126
+ :'valor_minimo_extrato' => :'Float'
127
+
128
+ }
129
+ end
130
+
131
+ # Initializes the object
132
+ # @param [Hash] attributes Model attributes in the form of hash
133
+ def initialize(attributes = {})
134
+ return unless attributes.is_a?(Hash)
135
+
136
+ # convert string to symbol for hash key
137
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
138
+
139
+
140
+ if attributes[:'codigoRetorno']
141
+
142
+
143
+ self.codigo_retorno = attributes[:'codigoRetorno']
144
+
145
+
146
+ end
147
+
148
+
149
+ if attributes[:'comprasNacionais']
150
+
151
+
152
+ self.compras_nacionais = attributes[:'comprasNacionais']
153
+
154
+
155
+ end
156
+
157
+
158
+ if attributes[:'cpf']
159
+
160
+
161
+ self.cpf = attributes[:'cpf']
162
+
163
+
164
+ end
165
+
166
+
167
+ if attributes[:'creditosNacionais']
168
+
169
+
170
+ self.creditos_nacionais = attributes[:'creditosNacionais']
171
+
172
+
173
+ end
174
+
175
+
176
+ if attributes[:'dataVencimento']
177
+
178
+
179
+ self.data_vencimento = attributes[:'dataVencimento']
180
+
181
+
182
+ end
183
+
184
+
185
+ if attributes[:'debitosNacionais']
186
+
187
+
188
+ self.debitos_nacionais = attributes[:'debitosNacionais']
189
+
190
+
191
+ end
192
+
193
+
194
+ if attributes[:'descricaoRetorno']
195
+
196
+
197
+ self.descricao_retorno = attributes[:'descricaoRetorno']
198
+
199
+
200
+ end
201
+
202
+
203
+ if attributes[:'extrato']
204
+
205
+ if (value = attributes[:'extrato']).is_a?(Array)
206
+ self.extrato = value
207
+ end
208
+
209
+
210
+
211
+ end
212
+
213
+
214
+ if attributes[:'idCartao']
215
+
216
+
217
+ self.id_cartao = attributes[:'idCartao']
218
+
219
+
220
+ end
221
+
222
+
223
+ if attributes[:'idConta']
224
+
225
+
226
+ self.id_conta = attributes[:'idConta']
227
+
228
+
229
+ end
230
+
231
+
232
+ if attributes[:'multa']
233
+
234
+
235
+ self.multa = attributes[:'multa']
236
+
237
+
238
+ end
239
+
240
+
241
+ if attributes[:'pagamentos']
242
+
243
+
244
+ self.pagamentos = attributes[:'pagamentos']
245
+
246
+
247
+ end
248
+
249
+
250
+ if attributes[:'saldoAtualFinal']
251
+
252
+
253
+ self.saldo_atual_final = attributes[:'saldoAtualFinal']
254
+
255
+
256
+ end
257
+
258
+
259
+ if attributes[:'saldoExtratoAnterior']
260
+
261
+
262
+ self.saldo_extrato_anterior = attributes[:'saldoExtratoAnterior']
263
+
264
+
265
+ end
266
+
267
+
268
+ if attributes[:'tarifasNacionais']
269
+
270
+
271
+ self.tarifas_nacionais = attributes[:'tarifasNacionais']
272
+
273
+
274
+ end
275
+
276
+
277
+ if attributes[:'valorMinimoExtrato']
278
+
279
+
280
+ self.valor_minimo_extrato = attributes[:'valorMinimoExtrato']
281
+
282
+
283
+ end
284
+
285
+
286
+ end
287
+
288
+ # Show invalid properties with the reasons. Usually used together with valid?
289
+ # @return Array for valid properies with the reasons
290
+ def list_invalid_properties
291
+ invalid_properties = Array.new
292
+
293
+
294
+ return invalid_properties
295
+ end
296
+
297
+ # Check to see if the all the properties in the model are valid
298
+ # @return true if the model is valid
299
+ def valid?
300
+
301
+
302
+
303
+
304
+
305
+
306
+
307
+
308
+
309
+
310
+
311
+
312
+
313
+
314
+
315
+
316
+
317
+
318
+
319
+
320
+
321
+
322
+
323
+
324
+
325
+
326
+
327
+
328
+
329
+
330
+
331
+
332
+
333
+
334
+
335
+
336
+
337
+
338
+
339
+
340
+
341
+
342
+
343
+
344
+
345
+
346
+
347
+
348
+
349
+
350
+
351
+
352
+
353
+
354
+
355
+
356
+
357
+
358
+
359
+
360
+
361
+
362
+
363
+
364
+
365
+ end
366
+
367
+
368
+
369
+
370
+
371
+
372
+
373
+
374
+
375
+
376
+
377
+
378
+
379
+
380
+
381
+
382
+
383
+
384
+
385
+
386
+
387
+
388
+
389
+
390
+
391
+
392
+
393
+
394
+
395
+
396
+
397
+
398
+
399
+
400
+
401
+
402
+
403
+
404
+
405
+
406
+
407
+
408
+
409
+
410
+
411
+
412
+
413
+
414
+
415
+
416
+
417
+
418
+
419
+
420
+
421
+
422
+
423
+
424
+
425
+
426
+
427
+
428
+
429
+
430
+
431
+
432
+
433
+
434
+
435
+
436
+
437
+
438
+
439
+
440
+
441
+
442
+
443
+
444
+
445
+
446
+
447
+
448
+ # Checks equality by comparing each attribute.
449
+ # @param [Object] Object to be compared
450
+ def ==(o)
451
+ return true if self.equal?(o)
452
+ self.class == o.class &&
453
+ codigo_retorno == o.codigo_retorno &&
454
+ compras_nacionais == o.compras_nacionais &&
455
+ cpf == o.cpf &&
456
+ creditos_nacionais == o.creditos_nacionais &&
457
+ data_vencimento == o.data_vencimento &&
458
+ debitos_nacionais == o.debitos_nacionais &&
459
+ descricao_retorno == o.descricao_retorno &&
460
+ extrato == o.extrato &&
461
+ id_cartao == o.id_cartao &&
462
+ id_conta == o.id_conta &&
463
+ multa == o.multa &&
464
+ pagamentos == o.pagamentos &&
465
+ saldo_atual_final == o.saldo_atual_final &&
466
+ saldo_extrato_anterior == o.saldo_extrato_anterior &&
467
+ tarifas_nacionais == o.tarifas_nacionais &&
468
+ valor_minimo_extrato == o.valor_minimo_extrato
469
+ end
470
+
471
+ # @see the `==` method
472
+ # @param [Object] Object to be compared
473
+ def eql?(o)
474
+ self == o
475
+ end
476
+
477
+ # Calculates hash code according to all attributes.
478
+ # @return [Fixnum] Hash code
479
+ def hash
480
+ [codigo_retorno, compras_nacionais, cpf, creditos_nacionais, data_vencimento, debitos_nacionais, descricao_retorno, extrato, id_cartao, id_conta, multa, pagamentos, saldo_atual_final, saldo_extrato_anterior, tarifas_nacionais, valor_minimo_extrato].hash
481
+ end
482
+
483
+ # Builds the object from hash
484
+ # @param [Hash] attributes Model attributes in the form of hash
485
+ # @return [Object] Returns the model itself
486
+ def build_from_hash(attributes)
487
+ return nil unless attributes.is_a?(Hash)
488
+ self.class.swagger_types.each_pair do |key, type|
489
+ if type =~ /^Array<(.*)>/i
490
+ # check to ensure the input is an array given that the the attribute
491
+ # is documented as an array but the input is not
492
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
493
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
494
+ end
495
+ elsif !attributes[self.class.attribute_map[key]].nil?
496
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
497
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
498
+ end
499
+
500
+ self
501
+ end
502
+
503
+ # Deserializes the data based on type
504
+ # @param string type Data type
505
+ # @param string value Value to be deserialized
506
+ # @return [Object] Deserialized data
507
+ def _deserialize(type, value)
508
+ case type.to_sym
509
+ when :DateTime
510
+ DateTime.parse(value)
511
+ when :Date
512
+ Date.parse(value)
513
+ when :String
514
+ value.to_s
515
+ when :Integer
516
+ value.to_i
517
+ when :Float
518
+ value.to_f
519
+ when :BOOLEAN
520
+ if value.to_s =~ /^(true|t|yes|y|1)$/i
521
+ true
522
+ else
523
+ false
524
+ end
525
+ when :Object
526
+ # generic object (usually a Hash), return directly
527
+ value
528
+ when /\AArray<(?<inner_type>.+)>\z/
529
+ inner_type = Regexp.last_match[:inner_type]
530
+ value.map { |v| _deserialize(inner_type, v) }
531
+ when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
532
+ k_type = Regexp.last_match[:k_type]
533
+ v_type = Regexp.last_match[:v_type]
534
+ {}.tap do |hash|
535
+ value.each do |k, v|
536
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
537
+ end
538
+ end
539
+ else # model
540
+ temp_model = Pier.const_get(type).new
541
+ temp_model.build_from_hash(value)
542
+ end
543
+ end
544
+
545
+ # Returns the string representation of the object
546
+ # @return [String] String presentation of the object
547
+ def to_s
548
+ to_hash.to_s
549
+ end
550
+
551
+ # to_body is an alias to to_hash (backward compatibility)
552
+ # @return [Hash] Returns the object in the form of hash
553
+ def to_body
554
+ to_hash
555
+ end
556
+
557
+ # Returns the object in the form of hash
558
+ # @return [Hash] Returns the object in the form of hash
559
+ def to_hash
560
+ hash = {}
561
+ self.class.attribute_map.each_pair do |attr, param|
562
+ value = self.send(attr)
563
+ next if value.nil?
564
+ hash[param] = _to_hash(value)
565
+ end
566
+ hash
567
+ end
568
+
569
+ # Outputs non-array value in the form of hash
570
+ # For object, use to_hash. Otherwise, just return the value
571
+ # @param [Object] value Any valid value
572
+ # @return [Hash] Returns the value in the form of hash
573
+ def _to_hash(value)
574
+ if value.is_a?(Array)
575
+ value.compact.map{ |v| _to_hash(v) }
576
+ elsif value.is_a?(Hash)
577
+ {}.tap do |hash|
578
+ value.each { |k, v| hash[k] = _to_hash(v) }
579
+ end
580
+ elsif value.respond_to? :to_hash
581
+ value.to_hash
582
+ else
583
+ value
584
+ end
585
+ end
586
+
587
+ end
588
+ end