transferzero-sdk 1.9.0 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +93 -0
- data/README.md +10 -4
- data/docs/PayoutMethodCashProviderEnum.md +16 -0
- data/docs/PayoutMethodDetails.md +6 -4
- data/docs/PayoutMethodDetailsXOFCash.md +27 -0
- data/docs/ProofOfPayment.md +23 -0
- data/docs/ProofOfPaymentListResponse.md +17 -0
- data/docs/Recipient.md +2 -0
- data/docs/RecipientStateReasonDetails.md +23 -0
- data/docs/RecipientsApi.md +62 -0
- data/docs/Sender.md +2 -0
- data/lib/transferzero-sdk.rb +5 -0
- data/lib/transferzero-sdk/api/recipients_api.rb +54 -0
- data/lib/transferzero-sdk/api_client.rb +1 -1
- data/lib/transferzero-sdk/models/payout_method_cash_provider_enum.rb +31 -0
- data/lib/transferzero-sdk/models/payout_method_details.rb +29 -19
- data/lib/transferzero-sdk/models/payout_method_details_xof_bank.rb +1 -1
- data/lib/transferzero-sdk/models/payout_method_details_xof_cash.rb +263 -0
- data/lib/transferzero-sdk/models/payout_method_details_xof_mobile.rb +1 -1
- data/lib/transferzero-sdk/models/proof_of_payment.rb +233 -0
- data/lib/transferzero-sdk/models/proof_of_payment_list_response.rb +204 -0
- data/lib/transferzero-sdk/models/recipient.rb +10 -1
- data/lib/transferzero-sdk/models/recipient_state_reason_details.rb +235 -0
- data/lib/transferzero-sdk/models/sender.rb +11 -1
- data/lib/transferzero-sdk/version.rb +1 -1
- data/spec/models/payout_method_cash_provider_enum_spec.rb +35 -0
- data/spec/models/payout_method_details_xof_cash_spec.rb +71 -0
- data/spec/models/proof_of_payment_list_response_spec.rb +41 -0
- data/spec/models/proof_of_payment_spec.rb +59 -0
- data/spec/models/recipient_state_reason_details_spec.rb +59 -0
- metadata +33 -12
@@ -217,5 +217,59 @@ module TransferZero
|
|
217
217
|
end
|
218
218
|
return data, status_code, headers
|
219
219
|
end
|
220
|
+
|
221
|
+
|
222
|
+
# Returns list of proof of payments
|
223
|
+
# Returns a list of uploaded proof of payment files for a transaction recipient
|
224
|
+
# @param recipient_id ID of the recipient for whom the proof of payments will be returned. Example: `/v1/recipients/9d4d7b73-a94c-4979-ab57-09074fd55d33/proof_of_payments`
|
225
|
+
# @param [Hash] opts the optional parameters
|
226
|
+
# @return [ProofOfPaymentListResponse]
|
227
|
+
def proof_of_payments(recipient_id, opts = {})
|
228
|
+
data, _status_code, _headers = proof_of_payments_with_http_info(recipient_id, opts)
|
229
|
+
data
|
230
|
+
end
|
231
|
+
|
232
|
+
# Returns list of proof of payments
|
233
|
+
# Returns a list of uploaded proof of payment files for a transaction recipient
|
234
|
+
# @param recipient_id ID of the recipient for whom the proof of payments will be returned. Example: `/v1/recipients/9d4d7b73-a94c-4979-ab57-09074fd55d33/proof_of_payments`
|
235
|
+
# @param [Hash] opts the optional parameters
|
236
|
+
# @return [Array<(ProofOfPaymentListResponse, Fixnum, Hash)>] ProofOfPaymentListResponse data, response status code and response headers
|
237
|
+
def proof_of_payments_with_http_info(recipient_id, opts = {})
|
238
|
+
if @api_client.config.debugging
|
239
|
+
@api_client.config.logger.debug 'Calling API: RecipientsApi.proof_of_payments ...'
|
240
|
+
end
|
241
|
+
# verify the required parameter 'recipient_id' is set
|
242
|
+
if @api_client.config.client_side_validation && recipient_id.nil?
|
243
|
+
fail ArgumentError, "Missing the required parameter 'recipient_id' when calling RecipientsApi.proof_of_payments"
|
244
|
+
end
|
245
|
+
# resource path
|
246
|
+
local_var_path = '/recipients/{Recipient ID}/proof_of_payments'.sub('{' + 'Recipient ID' + '}', recipient_id.to_s)
|
247
|
+
|
248
|
+
# query parameters
|
249
|
+
query_params = {}
|
250
|
+
|
251
|
+
# header parameters
|
252
|
+
header_params = {}
|
253
|
+
# HTTP header 'Accept' (if needed)
|
254
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
255
|
+
|
256
|
+
# form parameters
|
257
|
+
form_params = {}
|
258
|
+
|
259
|
+
# http body (model)
|
260
|
+
post_body = nil
|
261
|
+
auth_names = ['AuthorizationKey', 'AuthorizationNonce', 'AuthorizationSecret', 'AuthorizationSignature']
|
262
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
|
263
|
+
:header_params => header_params,
|
264
|
+
:query_params => query_params,
|
265
|
+
:form_params => form_params,
|
266
|
+
:body => post_body,
|
267
|
+
:auth_names => auth_names,
|
268
|
+
:return_type => 'ProofOfPaymentListResponse')
|
269
|
+
if @api_client.config.debugging
|
270
|
+
@api_client.config.logger.debug "API called: RecipientsApi#proof_of_payments\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
271
|
+
end
|
272
|
+
return data, status_code, headers
|
273
|
+
end
|
220
274
|
end
|
221
275
|
end
|
@@ -35,7 +35,7 @@ module TransferZero
|
|
35
35
|
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
|
36
36
|
def initialize(config = Configuration.default)
|
37
37
|
@config = config
|
38
|
-
@user_agent = "TransferZero-SDK/Ruby/1.
|
38
|
+
@user_agent = "TransferZero-SDK/Ruby/1.10.0"
|
39
39
|
@default_headers = {
|
40
40
|
'Content-Type' => 'application/json',
|
41
41
|
'User-Agent' => @user_agent
|
@@ -0,0 +1,31 @@
|
|
1
|
+
=begin
|
2
|
+
#TransferZero API
|
3
|
+
|
4
|
+
#Reference documentation for the TransferZero API V1
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.0.0-beta3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module TransferZero
|
16
|
+
class PayoutMethodCashProviderEnum
|
17
|
+
|
18
|
+
WARI = "wari".freeze
|
19
|
+
WIZALL = "wizall".freeze
|
20
|
+
|
21
|
+
# Builds the enum from string
|
22
|
+
# @param [String] The enum value in the form of the string
|
23
|
+
# @return [String] The enum value
|
24
|
+
def build_from_hash(value)
|
25
|
+
constantValues = PayoutMethodCashProviderEnum.constants.select { |c| PayoutMethodCashProviderEnum::const_get(c) == value }
|
26
|
+
raise "Invalid ENUM value #{value} for class #PayoutMethodCashProviderEnum" if constantValues.empty? && !value.empty?
|
27
|
+
value
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -34,6 +34,12 @@ class PayoutMethodDetails
|
|
34
34
|
|
35
35
|
attr_accessor :bank_country
|
36
36
|
|
37
|
+
attr_accessor :identity_card_id
|
38
|
+
|
39
|
+
attr_accessor :identity_card_type
|
40
|
+
|
41
|
+
attr_accessor :cash_provider
|
42
|
+
|
37
43
|
attr_accessor :sort_code
|
38
44
|
|
39
45
|
attr_accessor :bic
|
@@ -50,10 +56,6 @@ class PayoutMethodDetails
|
|
50
56
|
|
51
57
|
attr_accessor :reason
|
52
58
|
|
53
|
-
attr_accessor :identity_card_type
|
54
|
-
|
55
|
-
attr_accessor :identity_card_id
|
56
|
-
|
57
59
|
attr_accessor :reference
|
58
60
|
|
59
61
|
attr_accessor :name
|
@@ -83,6 +85,9 @@ class PayoutMethodDetails
|
|
83
85
|
:'iban' => :'iban',
|
84
86
|
:'bank_name' => :'bank_name',
|
85
87
|
:'bank_country' => :'bank_country',
|
88
|
+
:'identity_card_id' => :'identity_card_id',
|
89
|
+
:'identity_card_type' => :'identity_card_type',
|
90
|
+
:'cash_provider' => :'cash_provider',
|
86
91
|
:'sort_code' => :'sort_code',
|
87
92
|
:'bic' => :'bic',
|
88
93
|
:'sender_identity_card_type' => :'sender_identity_card_type',
|
@@ -91,8 +96,6 @@ class PayoutMethodDetails
|
|
91
96
|
:'sender_country_of_birth' => :'sender_country_of_birth',
|
92
97
|
:'sender_gender' => :'sender_gender',
|
93
98
|
:'reason' => :'reason',
|
94
|
-
:'identity_card_type' => :'identity_card_type',
|
95
|
-
:'identity_card_id' => :'identity_card_id',
|
96
99
|
:'reference' => :'reference',
|
97
100
|
:'name' => :'name',
|
98
101
|
:'address' => :'address',
|
@@ -117,6 +120,9 @@ class PayoutMethodDetails
|
|
117
120
|
:'iban' => :'String',
|
118
121
|
:'bank_name' => :'String',
|
119
122
|
:'bank_country' => :'String',
|
123
|
+
:'identity_card_id' => :'String',
|
124
|
+
:'identity_card_type' => :'PayoutMethodIdentityCardTypeEnum',
|
125
|
+
:'cash_provider' => :'PayoutMethodCashProviderEnum',
|
120
126
|
:'sort_code' => :'String',
|
121
127
|
:'bic' => :'String',
|
122
128
|
:'sender_identity_card_type' => :'PayoutMethodIdentityCardTypeEnum',
|
@@ -125,8 +131,6 @@ class PayoutMethodDetails
|
|
125
131
|
:'sender_country_of_birth' => :'String',
|
126
132
|
:'sender_gender' => :'PayoutMethodGenderEnum',
|
127
133
|
:'reason' => :'String',
|
128
|
-
:'identity_card_type' => :'PayoutMethodIdentityCardTypeEnum',
|
129
|
-
:'identity_card_id' => :'String',
|
130
134
|
:'reference' => :'String',
|
131
135
|
:'name' => :'String',
|
132
136
|
:'address' => :'String',
|
@@ -150,6 +154,7 @@ class PayoutMethodDetails
|
|
150
154
|
:'PayoutMethodDetailsMobile',
|
151
155
|
:'PayoutMethodDetailsNGNBank',
|
152
156
|
:'PayoutMethodDetailsXOFBank',
|
157
|
+
:'PayoutMethodDetailsXOFCash',
|
153
158
|
:'PayoutMethodDetailsXOFMobile',
|
154
159
|
:'PayoutMethodDetailsZARBank'
|
155
160
|
]
|
@@ -210,6 +215,18 @@ class PayoutMethodDetails
|
|
210
215
|
self.bank_country = attributes[:'bank_country']
|
211
216
|
end
|
212
217
|
|
218
|
+
if attributes.key?(:'identity_card_id')
|
219
|
+
self.identity_card_id = attributes[:'identity_card_id']
|
220
|
+
end
|
221
|
+
|
222
|
+
if attributes.key?(:'identity_card_type')
|
223
|
+
self.identity_card_type = attributes[:'identity_card_type']
|
224
|
+
end
|
225
|
+
|
226
|
+
if attributes.key?(:'cash_provider')
|
227
|
+
self.cash_provider = attributes[:'cash_provider']
|
228
|
+
end
|
229
|
+
|
213
230
|
if attributes.key?(:'sort_code')
|
214
231
|
self.sort_code = attributes[:'sort_code']
|
215
232
|
end
|
@@ -242,14 +259,6 @@ class PayoutMethodDetails
|
|
242
259
|
self.reason = attributes[:'reason']
|
243
260
|
end
|
244
261
|
|
245
|
-
if attributes.key?(:'identity_card_type')
|
246
|
-
self.identity_card_type = attributes[:'identity_card_type']
|
247
|
-
end
|
248
|
-
|
249
|
-
if attributes.key?(:'identity_card_id')
|
250
|
-
self.identity_card_id = attributes[:'identity_card_id']
|
251
|
-
end
|
252
|
-
|
253
262
|
if attributes.key?(:'reference')
|
254
263
|
self.reference = attributes[:'reference']
|
255
264
|
end
|
@@ -422,6 +431,9 @@ class PayoutMethodDetails
|
|
422
431
|
iban == o.iban &&
|
423
432
|
bank_name == o.bank_name &&
|
424
433
|
bank_country == o.bank_country &&
|
434
|
+
identity_card_id == o.identity_card_id &&
|
435
|
+
identity_card_type == o.identity_card_type &&
|
436
|
+
cash_provider == o.cash_provider &&
|
425
437
|
sort_code == o.sort_code &&
|
426
438
|
bic == o.bic &&
|
427
439
|
sender_identity_card_type == o.sender_identity_card_type &&
|
@@ -430,8 +442,6 @@ class PayoutMethodDetails
|
|
430
442
|
sender_country_of_birth == o.sender_country_of_birth &&
|
431
443
|
sender_gender == o.sender_gender &&
|
432
444
|
reason == o.reason &&
|
433
|
-
identity_card_type == o.identity_card_type &&
|
434
|
-
identity_card_id == o.identity_card_id &&
|
435
445
|
reference == o.reference &&
|
436
446
|
name == o.name &&
|
437
447
|
address == o.address &&
|
@@ -451,7 +461,7 @@ class PayoutMethodDetails
|
|
451
461
|
# Calculates hash code according to all attributes.
|
452
462
|
# @return [Integer] Hash code
|
453
463
|
def hash
|
454
|
-
[first_name, last_name, bank_code, bank_account, bank_account_type, phone_number, mobile_provider, iban, bank_name, bank_country, sort_code, bic, sender_identity_card_type, sender_identity_card_id, sender_city_of_birth, sender_country_of_birth, sender_gender, reason,
|
464
|
+
[first_name, last_name, bank_code, bank_account, bank_account_type, phone_number, mobile_provider, iban, bank_name, bank_country, identity_card_id, identity_card_type, cash_provider, sort_code, bic, sender_identity_card_type, sender_identity_card_id, sender_city_of_birth, sender_country_of_birth, sender_gender, reason, reference, name, address, street, postal_code, city, email, transfer_reason_code].hash
|
455
465
|
end
|
456
466
|
|
457
467
|
require 'active_support/core_ext/hash'
|
@@ -13,7 +13,7 @@ OpenAPI Generator version: 4.0.0-beta3
|
|
13
13
|
require 'date'
|
14
14
|
|
15
15
|
module TransferZero
|
16
|
-
# ```JSON \"details\": { \"first_name\": \"First\", \"last_name\": \"Last\", \"iban\": \"SN08SN0000000000000000000000\", \"bank_name\": \"BRM\", \"bank_country\": \"SN\" # ISO country code for Senegal } ```
|
16
|
+
# ```JSON \"details\": { \"first_name\": \"First\", \"last_name\": \"Last\", \"iban\": \"SN08SN0000000000000000000000\", \"bank_name\": \"BRM\", \"bank_country\": \"SN\" # ISO country code for Senegal } ```
|
17
17
|
class PayoutMethodDetailsXOFBank
|
18
18
|
attr_accessor :first_name
|
19
19
|
|
@@ -0,0 +1,263 @@
|
|
1
|
+
=begin
|
2
|
+
#TransferZero API
|
3
|
+
|
4
|
+
#Reference documentation for the TransferZero API V1
|
5
|
+
|
6
|
+
OpenAPI spec version: 1.0
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.0.0-beta3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module TransferZero
|
16
|
+
# ```JSON \"details\": { \"first_name\": \"First\", \"last_name\": \"Last\", \"phone_number\": \"774044436\", // local or international Senegalese format \"identity_card_id\": \"2231324232\", // Required if cash_provider value is \"wizall\" \"identity_card_type\": \"PP\", // Required if cash_provider value is \"wizall\" \"cash_provider\": \"wizall\" // Optional; Values: \"wari\" or \"wizall; Default value is \"wari\" } ``` Please note when sending Wari cash pickup requests you should subscribe to the recipient.pending webhook, as that will broadcast the payment reference ID the customer need to use to obtain the funds. Example webhook response excerpt - ```JSON { (...) \"state\":\"pending\", \"metadata\": { \"payment_reference\":\"9M5GJRJUBCY\" }, (...) } ```
|
17
|
+
class PayoutMethodDetailsXOFCash
|
18
|
+
attr_accessor :first_name
|
19
|
+
|
20
|
+
attr_accessor :last_name
|
21
|
+
|
22
|
+
attr_accessor :identity_card_id
|
23
|
+
|
24
|
+
attr_accessor :identity_card_type
|
25
|
+
|
26
|
+
attr_accessor :phone_number
|
27
|
+
|
28
|
+
attr_accessor :cash_provider
|
29
|
+
|
30
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
31
|
+
def self.attribute_map
|
32
|
+
{
|
33
|
+
:'first_name' => :'first_name',
|
34
|
+
:'last_name' => :'last_name',
|
35
|
+
:'identity_card_id' => :'identity_card_id',
|
36
|
+
:'identity_card_type' => :'identity_card_type',
|
37
|
+
:'phone_number' => :'phone_number',
|
38
|
+
:'cash_provider' => :'cash_provider'
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
# Attribute type mapping.
|
43
|
+
def self.openapi_types
|
44
|
+
{
|
45
|
+
:'first_name' => :'String',
|
46
|
+
:'last_name' => :'String',
|
47
|
+
:'identity_card_id' => :'String',
|
48
|
+
:'identity_card_type' => :'PayoutMethodIdentityCardTypeEnum',
|
49
|
+
:'phone_number' => :'String',
|
50
|
+
:'cash_provider' => :'PayoutMethodCashProviderEnum'
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
# Initializes the object
|
55
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
56
|
+
def initialize(attributes = {})
|
57
|
+
if (!attributes.is_a?(Hash))
|
58
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `TransferZero::PayoutMethodDetailsXOFCash` initialize method"
|
59
|
+
end
|
60
|
+
|
61
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
62
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
63
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
64
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `TransferZero::PayoutMethodDetailsXOFCash`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
65
|
+
end
|
66
|
+
h[k.to_sym] = v
|
67
|
+
}
|
68
|
+
|
69
|
+
if attributes.key?(:'first_name')
|
70
|
+
self.first_name = attributes[:'first_name']
|
71
|
+
end
|
72
|
+
|
73
|
+
if attributes.key?(:'last_name')
|
74
|
+
self.last_name = attributes[:'last_name']
|
75
|
+
end
|
76
|
+
|
77
|
+
if attributes.key?(:'identity_card_id')
|
78
|
+
self.identity_card_id = attributes[:'identity_card_id']
|
79
|
+
end
|
80
|
+
|
81
|
+
if attributes.key?(:'identity_card_type')
|
82
|
+
self.identity_card_type = attributes[:'identity_card_type']
|
83
|
+
end
|
84
|
+
|
85
|
+
if attributes.key?(:'phone_number')
|
86
|
+
self.phone_number = attributes[:'phone_number']
|
87
|
+
end
|
88
|
+
|
89
|
+
if attributes.key?(:'cash_provider')
|
90
|
+
self.cash_provider = attributes[:'cash_provider']
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
95
|
+
# @return Array for valid properties with the reasons
|
96
|
+
def list_invalid_properties
|
97
|
+
invalid_properties = Array.new
|
98
|
+
if @first_name.nil?
|
99
|
+
invalid_properties.push('invalid value for "first_name", first_name cannot be nil.')
|
100
|
+
end
|
101
|
+
|
102
|
+
if @last_name.nil?
|
103
|
+
invalid_properties.push('invalid value for "last_name", last_name cannot be nil.')
|
104
|
+
end
|
105
|
+
|
106
|
+
if @phone_number.nil?
|
107
|
+
invalid_properties.push('invalid value for "phone_number", phone_number cannot be nil.')
|
108
|
+
end
|
109
|
+
|
110
|
+
invalid_properties
|
111
|
+
end
|
112
|
+
|
113
|
+
# Check to see if the all the properties in the model are valid
|
114
|
+
# @return true if the model is valid
|
115
|
+
def valid?
|
116
|
+
return false if @first_name.nil?
|
117
|
+
return false if @last_name.nil?
|
118
|
+
return false if @phone_number.nil?
|
119
|
+
true
|
120
|
+
end
|
121
|
+
|
122
|
+
# Checks equality by comparing each attribute.
|
123
|
+
# @param [Object] Object to be compared
|
124
|
+
def ==(o)
|
125
|
+
return true if self.equal?(o)
|
126
|
+
self.class == o.class &&
|
127
|
+
first_name == o.first_name &&
|
128
|
+
last_name == o.last_name &&
|
129
|
+
identity_card_id == o.identity_card_id &&
|
130
|
+
identity_card_type == o.identity_card_type &&
|
131
|
+
phone_number == o.phone_number &&
|
132
|
+
cash_provider == o.cash_provider
|
133
|
+
end
|
134
|
+
|
135
|
+
# @see the `==` method
|
136
|
+
# @param [Object] Object to be compared
|
137
|
+
def eql?(o)
|
138
|
+
self == o
|
139
|
+
end
|
140
|
+
|
141
|
+
# Calculates hash code according to all attributes.
|
142
|
+
# @return [Integer] Hash code
|
143
|
+
def hash
|
144
|
+
[first_name, last_name, identity_card_id, identity_card_type, phone_number, cash_provider].hash
|
145
|
+
end
|
146
|
+
|
147
|
+
require 'active_support/core_ext/hash'
|
148
|
+
require 'active_support/hash_with_indifferent_access.rb'
|
149
|
+
# Builds the object from hash
|
150
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
151
|
+
# @return [Object] Returns the model itself
|
152
|
+
def build_from_hash(attributes)
|
153
|
+
return nil unless attributes.is_a?(Hash)
|
154
|
+
self.class.openapi_types.each_pair do |key, type|
|
155
|
+
if type =~ /\AArray<(.*)>/i
|
156
|
+
# check to ensure the input is an array given that the the attribute
|
157
|
+
# is documented as an array but the input is not
|
158
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
159
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
160
|
+
end
|
161
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
162
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
163
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
164
|
+
end
|
165
|
+
|
166
|
+
self
|
167
|
+
end
|
168
|
+
|
169
|
+
# Deserializes the data based on type
|
170
|
+
# @param string type Data type
|
171
|
+
# @param string value Value to be deserialized
|
172
|
+
# @return [Object] Deserialized data
|
173
|
+
def _deserialize(type, value)
|
174
|
+
case type.to_sym
|
175
|
+
when :DateTime
|
176
|
+
DateTime.parse(value)
|
177
|
+
when :Date
|
178
|
+
Date.parse(value)
|
179
|
+
when :String
|
180
|
+
value.to_s
|
181
|
+
when :Integer
|
182
|
+
value.to_i
|
183
|
+
when :Float
|
184
|
+
value.to_f
|
185
|
+
when :Boolean
|
186
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
187
|
+
true
|
188
|
+
else
|
189
|
+
false
|
190
|
+
end
|
191
|
+
when :Object
|
192
|
+
# generic object (usually a Hash), return directly
|
193
|
+
value
|
194
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
195
|
+
inner_type = Regexp.last_match[:inner_type]
|
196
|
+
value.map { |v| _deserialize(inner_type, v) }
|
197
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
198
|
+
k_type = Regexp.last_match[:k_type]
|
199
|
+
v_type = Regexp.last_match[:v_type]
|
200
|
+
{}.tap do |hash|
|
201
|
+
value.each do |k, v|
|
202
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
203
|
+
end
|
204
|
+
end
|
205
|
+
else # model
|
206
|
+
temp_model = TransferZero.const_get(type).new
|
207
|
+
temp_model.build_from_hash(value)
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
# Returns the string representation of the object
|
212
|
+
# @return [String] String presentation of the object
|
213
|
+
def to_s
|
214
|
+
to_hash.to_s
|
215
|
+
end
|
216
|
+
|
217
|
+
# to_body is an alias to to_hash (backward compatibility)
|
218
|
+
# @return [Hash] Returns the object in the form of hash
|
219
|
+
def to_body
|
220
|
+
to_hash
|
221
|
+
end
|
222
|
+
|
223
|
+
# Returns the object in the form of hash
|
224
|
+
# @return [Hash] Returns the object in the form of hash
|
225
|
+
def to_hash
|
226
|
+
hash = {}
|
227
|
+
self.class.attribute_map.each_pair do |attr, param|
|
228
|
+
value = self.send(attr)
|
229
|
+
next if value.nil?
|
230
|
+
hash[param] = _to_hash(value)
|
231
|
+
end
|
232
|
+
::ActiveSupport::HashWithIndifferentAccess.new(hash)
|
233
|
+
end
|
234
|
+
|
235
|
+
def [](key)
|
236
|
+
to_hash[key]
|
237
|
+
end
|
238
|
+
|
239
|
+
def dig(*args)
|
240
|
+
to_hash.dig(*args)
|
241
|
+
end
|
242
|
+
|
243
|
+
# Outputs non-array value in the form of hash
|
244
|
+
# For object, use to_hash. Otherwise, just return the value
|
245
|
+
# @param [Object] value Any valid value
|
246
|
+
# @return [Hash] Returns the value in the form of hash
|
247
|
+
def _to_hash(value)
|
248
|
+
if value.is_a?(Array)
|
249
|
+
value.compact.map { |v| _to_hash(v) }
|
250
|
+
elsif value.is_a?(Hash)
|
251
|
+
{}.tap do |hash|
|
252
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
253
|
+
end
|
254
|
+
elsif value.respond_to? :to_hash
|
255
|
+
value.to_hash
|
256
|
+
else
|
257
|
+
value
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
end
|
262
|
+
|
263
|
+
end
|