bleumi_pay_sdk_ruby 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/bleumi_pay_sdk_ruby.gemspec +4 -4
- data/docs/AlgorandWalletAddress.md +24 -0
- data/docs/AlgorandWalletInputs.md +23 -0
- data/docs/CheckoutToken.md +2 -0
- data/docs/EthereumWalletAddress.md +23 -0
- data/docs/EthereumWalletInputs.md +23 -0
- data/docs/HostedCheckoutsApi.md +2 -4
- data/docs/PaginatedPayments.md +51 -28
- data/docs/Payment.md +32 -10
- data/docs/PaymentAddresses.md +24 -8
- data/docs/PaymentBalances.md +15 -7
- data/docs/PaymentsApi.md +3 -0
- data/hc_create.rb +33 -0
- data/hc_list.rb +17 -0
- data/hc_validate.rb +22 -0
- data/lib/bleumi_pay_sdk_ruby.rb +4 -1
- data/lib/bleumi_pay_sdk_ruby/api/payments_api.rb +2 -2
- data/lib/bleumi_pay_sdk_ruby/api/payouts_api.rb +1 -1
- data/lib/bleumi_pay_sdk_ruby/configuration.rb +6 -3
- data/lib/bleumi_pay_sdk_ruby/models/{wallet_address.rb → algorand_wallet_address.rb} +18 -9
- data/lib/bleumi_pay_sdk_ruby/models/algorand_wallet_inputs.rb +247 -0
- data/lib/bleumi_pay_sdk_ruby/models/checkout_token.rb +19 -4
- data/lib/bleumi_pay_sdk_ruby/models/create_checkout_url_request.rb +2 -1
- data/lib/bleumi_pay_sdk_ruby/models/ethereum_wallet_address.rb +221 -0
- data/lib/bleumi_pay_sdk_ruby/models/ethereum_wallet_inputs.rb +247 -0
- data/lib/bleumi_pay_sdk_ruby/models/payment_addresses.rb +2 -2
- data/lib/bleumi_pay_sdk_ruby/version.rb +1 -1
- data/po_create.rb +39 -0
- data/po_list.rb +23 -0
- data/py_create.rb +2 -2
- data/py_get.rb +18 -0
- data/py_getop.rb +19 -0
- data/py_list.rb +24 -0
- data/py_listops.rb +21 -0
- data/py_refund.rb +33 -0
- data/py_settle.rb +32 -0
- data/spec/api/hosted_checkouts_api_spec.rb +1 -1
- data/spec/api/payments_api_spec.rb +7 -6
- data/spec/models/algorand_wallet_address_spec.rb +47 -0
- data/spec/models/{network_balance_spec.rb → algorand_wallet_inputs_spec.rb} +14 -26
- data/spec/models/checkout_token_spec.rb +13 -1
- data/spec/models/create_checkout_url_request_spec.rb +6 -0
- data/spec/models/create_payment_request_spec.rb +6 -0
- data/spec/models/ethereum_wallet_address_spec.rb +47 -0
- data/spec/models/ethereum_wallet_inputs_spec.rb +65 -0
- data/spec/models/payment_addresses_spec.rb +6 -0
- data/spec/models/payment_balances_spec.rb +6 -0
- data/spec/models/payout_spec.rb +6 -0
- metadata +33 -15
- data/docs/WalletAddress.md +0 -15
- data/spec/models/eth_address_spec.rb +0 -41
- data/spec/models/token_spec.rb +0 -41
- data/spec/models/wallet_address_spec.rb +0 -41
@@ -32,6 +32,9 @@ module BleumiPay
|
|
32
32
|
# Token decimal places
|
33
33
|
attr_accessor :decimals
|
34
34
|
|
35
|
+
# Currency code of the token
|
36
|
+
attr_accessor :currency
|
37
|
+
|
35
38
|
# Attribute mapping from ruby-style variable name to JSON key.
|
36
39
|
def self.attribute_map
|
37
40
|
{
|
@@ -40,7 +43,8 @@ module BleumiPay
|
|
40
43
|
:'addr' => :'addr',
|
41
44
|
:'name' => :'name',
|
42
45
|
:'symbol' => :'symbol',
|
43
|
-
:'decimals' => :'decimals'
|
46
|
+
:'decimals' => :'decimals',
|
47
|
+
:'currency' => :'currency'
|
44
48
|
}
|
45
49
|
end
|
46
50
|
|
@@ -52,7 +56,8 @@ module BleumiPay
|
|
52
56
|
:'addr' => :'String',
|
53
57
|
:'name' => :'String',
|
54
58
|
:'symbol' => :'String',
|
55
|
-
:'decimals' => :'Integer'
|
59
|
+
:'decimals' => :'Integer',
|
60
|
+
:'currency' => :'String'
|
56
61
|
}
|
57
62
|
end
|
58
63
|
|
@@ -100,6 +105,10 @@ module BleumiPay
|
|
100
105
|
if attributes.key?(:'decimals')
|
101
106
|
self.decimals = attributes[:'decimals']
|
102
107
|
end
|
108
|
+
|
109
|
+
if attributes.key?(:'currency')
|
110
|
+
self.currency = attributes[:'currency']
|
111
|
+
end
|
103
112
|
end
|
104
113
|
|
105
114
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -130,6 +139,10 @@ module BleumiPay
|
|
130
139
|
invalid_properties.push('invalid value for "decimals", decimals cannot be nil.')
|
131
140
|
end
|
132
141
|
|
142
|
+
if @currency.nil?
|
143
|
+
invalid_properties.push('invalid value for "currency", currency cannot be nil.')
|
144
|
+
end
|
145
|
+
|
133
146
|
invalid_properties
|
134
147
|
end
|
135
148
|
|
@@ -142,6 +155,7 @@ module BleumiPay
|
|
142
155
|
return false if @name.nil?
|
143
156
|
return false if @symbol.nil?
|
144
157
|
return false if @decimals.nil?
|
158
|
+
return false if @currency.nil?
|
145
159
|
true
|
146
160
|
end
|
147
161
|
|
@@ -155,7 +169,8 @@ module BleumiPay
|
|
155
169
|
addr == o.addr &&
|
156
170
|
name == o.name &&
|
157
171
|
symbol == o.symbol &&
|
158
|
-
decimals == o.decimals
|
172
|
+
decimals == o.decimals &&
|
173
|
+
currency == o.currency
|
159
174
|
end
|
160
175
|
|
161
176
|
# @see the `==` method
|
@@ -167,7 +182,7 @@ module BleumiPay
|
|
167
182
|
# Calculates hash code according to all attributes.
|
168
183
|
# @return [Integer] Hash code
|
169
184
|
def hash
|
170
|
-
[network, chain, addr, name, symbol, decimals].hash
|
185
|
+
[network, chain, addr, name, symbol, decimals, currency].hash
|
171
186
|
end
|
172
187
|
|
173
188
|
# Builds the object from hash
|
@@ -32,6 +32,7 @@ module BleumiPay
|
|
32
32
|
# Address of buyer. Refund operations on this payment will use this address. You can set this to your address to manually handle refunds (outside of Bleumi Pay) to your buyer. This address must be able to receive payments from smart contracts.
|
33
33
|
attr_accessor :buyer_address
|
34
34
|
|
35
|
+
# (Required if specifying 'token') Network in which the hosted checkout is to be created. Please refer to the Supported Networks.
|
35
36
|
attr_accessor :chain
|
36
37
|
|
37
38
|
# ETH - for Ethereum ; XDAI - for xDai ; XDAIT - for xDai Testnet ; ALGO - Algo; <asset id> - for Algorand Standard Asset; <contract address of ERC-20 token> - for ERC-20 Tokens;
|
@@ -64,7 +65,7 @@ module BleumiPay
|
|
64
65
|
:'cancel_url' => :'String',
|
65
66
|
:'success_url' => :'String',
|
66
67
|
:'buyer_address' => :'String',
|
67
|
-
:'chain' => :'
|
68
|
+
:'chain' => :'String',
|
68
69
|
:'token' => :'String',
|
69
70
|
:'base64_transform' => :'Boolean'
|
70
71
|
}
|
@@ -0,0 +1,221 @@
|
|
1
|
+
=begin
|
2
|
+
#Bleumi Pay REST API
|
3
|
+
|
4
|
+
#A simple and powerful REST API to integrate Algorand, Ethereum, ERC-20 and xDai payments and/or payouts into your business
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
7
|
+
Contact: info@bleumi.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.2.3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module BleumiPay
|
16
|
+
class EthereumWalletAddress
|
17
|
+
# Wallet address for the payment in the network
|
18
|
+
attr_accessor :addr
|
19
|
+
|
20
|
+
attr_accessor :inputs
|
21
|
+
|
22
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
23
|
+
def self.attribute_map
|
24
|
+
{
|
25
|
+
:'addr' => :'addr',
|
26
|
+
:'inputs' => :'inputs'
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
# Attribute type mapping.
|
31
|
+
def self.openapi_types
|
32
|
+
{
|
33
|
+
:'addr' => :'String',
|
34
|
+
:'inputs' => :'EthereumWalletInputs'
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
# List of attributes with nullable: true
|
39
|
+
def self.openapi_nullable
|
40
|
+
Set.new([
|
41
|
+
])
|
42
|
+
end
|
43
|
+
|
44
|
+
# Initializes the object
|
45
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
46
|
+
def initialize(attributes = {})
|
47
|
+
if (!attributes.is_a?(Hash))
|
48
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `BleumiPay::EthereumWalletAddress` initialize method"
|
49
|
+
end
|
50
|
+
|
51
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
52
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
53
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
54
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `BleumiPay::EthereumWalletAddress`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
55
|
+
end
|
56
|
+
h[k.to_sym] = v
|
57
|
+
}
|
58
|
+
|
59
|
+
if attributes.key?(:'addr')
|
60
|
+
self.addr = attributes[:'addr']
|
61
|
+
end
|
62
|
+
|
63
|
+
if attributes.key?(:'inputs')
|
64
|
+
self.inputs = attributes[:'inputs']
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
69
|
+
# @return Array for valid properties with the reasons
|
70
|
+
def list_invalid_properties
|
71
|
+
invalid_properties = Array.new
|
72
|
+
if @addr.nil?
|
73
|
+
invalid_properties.push('invalid value for "addr", addr cannot be nil.')
|
74
|
+
end
|
75
|
+
|
76
|
+
invalid_properties
|
77
|
+
end
|
78
|
+
|
79
|
+
# Check to see if the all the properties in the model are valid
|
80
|
+
# @return true if the model is valid
|
81
|
+
def valid?
|
82
|
+
return false if @addr.nil?
|
83
|
+
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
|
+
addr == o.addr &&
|
92
|
+
inputs == o.inputs
|
93
|
+
end
|
94
|
+
|
95
|
+
# @see the `==` method
|
96
|
+
# @param [Object] Object to be compared
|
97
|
+
def eql?(o)
|
98
|
+
self == o
|
99
|
+
end
|
100
|
+
|
101
|
+
# Calculates hash code according to all attributes.
|
102
|
+
# @return [Integer] Hash code
|
103
|
+
def hash
|
104
|
+
[addr, inputs].hash
|
105
|
+
end
|
106
|
+
|
107
|
+
# Builds the object from hash
|
108
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
109
|
+
# @return [Object] Returns the model itself
|
110
|
+
def self.build_from_hash(attributes)
|
111
|
+
new.build_from_hash(attributes)
|
112
|
+
end
|
113
|
+
|
114
|
+
# Builds the object from hash
|
115
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
116
|
+
# @return [Object] Returns the model itself
|
117
|
+
def build_from_hash(attributes)
|
118
|
+
return nil unless attributes.is_a?(Hash)
|
119
|
+
self.class.openapi_types.each_pair do |key, type|
|
120
|
+
if type =~ /\AArray<(.*)>/i
|
121
|
+
# check to ensure the input is an array given that the attribute
|
122
|
+
# is documented as an array but the input is not
|
123
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
124
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
125
|
+
end
|
126
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
127
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
128
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
129
|
+
end
|
130
|
+
|
131
|
+
self
|
132
|
+
end
|
133
|
+
|
134
|
+
# Deserializes the data based on type
|
135
|
+
# @param string type Data type
|
136
|
+
# @param string value Value to be deserialized
|
137
|
+
# @return [Object] Deserialized data
|
138
|
+
def _deserialize(type, value)
|
139
|
+
case type.to_sym
|
140
|
+
when :DateTime
|
141
|
+
DateTime.parse(value)
|
142
|
+
when :Date
|
143
|
+
Date.parse(value)
|
144
|
+
when :String
|
145
|
+
value.to_s
|
146
|
+
when :Integer
|
147
|
+
value.to_i
|
148
|
+
when :Float
|
149
|
+
value.to_f
|
150
|
+
when :Boolean
|
151
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
152
|
+
true
|
153
|
+
else
|
154
|
+
false
|
155
|
+
end
|
156
|
+
when :Object
|
157
|
+
# generic object (usually a Hash), return directly
|
158
|
+
value
|
159
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
160
|
+
inner_type = Regexp.last_match[:inner_type]
|
161
|
+
value.map { |v| _deserialize(inner_type, v) }
|
162
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
163
|
+
k_type = Regexp.last_match[:k_type]
|
164
|
+
v_type = Regexp.last_match[:v_type]
|
165
|
+
{}.tap do |hash|
|
166
|
+
value.each do |k, v|
|
167
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
else # model
|
171
|
+
BleumiPay.const_get(type).build_from_hash(value)
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
# Returns the string representation of the object
|
176
|
+
# @return [String] String presentation of the object
|
177
|
+
def to_s
|
178
|
+
to_hash.to_s
|
179
|
+
end
|
180
|
+
|
181
|
+
# to_body is an alias to to_hash (backward compatibility)
|
182
|
+
# @return [Hash] Returns the object in the form of hash
|
183
|
+
def to_body
|
184
|
+
to_hash
|
185
|
+
end
|
186
|
+
|
187
|
+
# Returns the object in the form of hash
|
188
|
+
# @return [Hash] Returns the object in the form of hash
|
189
|
+
def to_hash
|
190
|
+
hash = {}
|
191
|
+
self.class.attribute_map.each_pair do |attr, param|
|
192
|
+
value = self.send(attr)
|
193
|
+
if value.nil?
|
194
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
195
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
196
|
+
end
|
197
|
+
|
198
|
+
hash[param] = _to_hash(value)
|
199
|
+
end
|
200
|
+
hash
|
201
|
+
end
|
202
|
+
|
203
|
+
# Outputs non-array value in the form of hash
|
204
|
+
# For object, use to_hash. Otherwise, just return the value
|
205
|
+
# @param [Object] value Any valid value
|
206
|
+
# @return [Hash] Returns the value in the form of hash
|
207
|
+
def _to_hash(value)
|
208
|
+
if value.is_a?(Array)
|
209
|
+
value.compact.map { |v| _to_hash(v) }
|
210
|
+
elsif value.is_a?(Hash)
|
211
|
+
{}.tap do |hash|
|
212
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
213
|
+
end
|
214
|
+
elsif value.respond_to? :to_hash
|
215
|
+
value.to_hash
|
216
|
+
else
|
217
|
+
value
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
@@ -0,0 +1,247 @@
|
|
1
|
+
=begin
|
2
|
+
#Bleumi Pay REST API
|
3
|
+
|
4
|
+
#A simple and powerful REST API to integrate Algorand, Ethereum, ERC-20 and xDai payments and/or payouts into your business
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
7
|
+
Contact: info@bleumi.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.2.3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module BleumiPay
|
16
|
+
class EthereumWalletInputs
|
17
|
+
# Buyer Address
|
18
|
+
attr_accessor :buyer
|
19
|
+
|
20
|
+
# Merchant Address
|
21
|
+
attr_accessor :merchant
|
22
|
+
|
23
|
+
# Salt
|
24
|
+
attr_accessor :salt
|
25
|
+
|
26
|
+
# Wallet Library
|
27
|
+
attr_accessor :wallet_library
|
28
|
+
|
29
|
+
# Wallet Proxy
|
30
|
+
attr_accessor :wallet_proxy
|
31
|
+
|
32
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
33
|
+
def self.attribute_map
|
34
|
+
{
|
35
|
+
:'buyer' => :'buyer',
|
36
|
+
:'merchant' => :'merchant',
|
37
|
+
:'salt' => :'salt',
|
38
|
+
:'wallet_library' => :'walletLibrary',
|
39
|
+
:'wallet_proxy' => :'walletProxy'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
# Attribute type mapping.
|
44
|
+
def self.openapi_types
|
45
|
+
{
|
46
|
+
:'buyer' => :'String',
|
47
|
+
:'merchant' => :'String',
|
48
|
+
:'salt' => :'String',
|
49
|
+
:'wallet_library' => :'String',
|
50
|
+
:'wallet_proxy' => :'String'
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
# List of attributes with nullable: true
|
55
|
+
def self.openapi_nullable
|
56
|
+
Set.new([
|
57
|
+
])
|
58
|
+
end
|
59
|
+
|
60
|
+
# Initializes the object
|
61
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
62
|
+
def initialize(attributes = {})
|
63
|
+
if (!attributes.is_a?(Hash))
|
64
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `BleumiPay::EthereumWalletInputs` initialize method"
|
65
|
+
end
|
66
|
+
|
67
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
68
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
69
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
70
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `BleumiPay::EthereumWalletInputs`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
71
|
+
end
|
72
|
+
h[k.to_sym] = v
|
73
|
+
}
|
74
|
+
|
75
|
+
if attributes.key?(:'buyer')
|
76
|
+
self.buyer = attributes[:'buyer']
|
77
|
+
end
|
78
|
+
|
79
|
+
if attributes.key?(:'merchant')
|
80
|
+
self.merchant = attributes[:'merchant']
|
81
|
+
end
|
82
|
+
|
83
|
+
if attributes.key?(:'salt')
|
84
|
+
self.salt = attributes[:'salt']
|
85
|
+
end
|
86
|
+
|
87
|
+
if attributes.key?(:'wallet_library')
|
88
|
+
self.wallet_library = attributes[:'wallet_library']
|
89
|
+
end
|
90
|
+
|
91
|
+
if attributes.key?(:'wallet_proxy')
|
92
|
+
self.wallet_proxy = attributes[:'wallet_proxy']
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
97
|
+
# @return Array for valid properties with the reasons
|
98
|
+
def list_invalid_properties
|
99
|
+
invalid_properties = Array.new
|
100
|
+
invalid_properties
|
101
|
+
end
|
102
|
+
|
103
|
+
# Check to see if the all the properties in the model are valid
|
104
|
+
# @return true if the model is valid
|
105
|
+
def valid?
|
106
|
+
true
|
107
|
+
end
|
108
|
+
|
109
|
+
# Checks equality by comparing each attribute.
|
110
|
+
# @param [Object] Object to be compared
|
111
|
+
def ==(o)
|
112
|
+
return true if self.equal?(o)
|
113
|
+
self.class == o.class &&
|
114
|
+
buyer == o.buyer &&
|
115
|
+
merchant == o.merchant &&
|
116
|
+
salt == o.salt &&
|
117
|
+
wallet_library == o.wallet_library &&
|
118
|
+
wallet_proxy == o.wallet_proxy
|
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 [Integer] Hash code
|
129
|
+
def hash
|
130
|
+
[buyer, merchant, salt, wallet_library, wallet_proxy].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 self.build_from_hash(attributes)
|
137
|
+
new.build_from_hash(attributes)
|
138
|
+
end
|
139
|
+
|
140
|
+
# Builds the object from hash
|
141
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
142
|
+
# @return [Object] Returns the model itself
|
143
|
+
def build_from_hash(attributes)
|
144
|
+
return nil unless attributes.is_a?(Hash)
|
145
|
+
self.class.openapi_types.each_pair do |key, type|
|
146
|
+
if type =~ /\AArray<(.*)>/i
|
147
|
+
# check to ensure the input is an array given that the attribute
|
148
|
+
# is documented as an array but the input is not
|
149
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
150
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
151
|
+
end
|
152
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
153
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
154
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
155
|
+
end
|
156
|
+
|
157
|
+
self
|
158
|
+
end
|
159
|
+
|
160
|
+
# Deserializes the data based on type
|
161
|
+
# @param string type Data type
|
162
|
+
# @param string value Value to be deserialized
|
163
|
+
# @return [Object] Deserialized data
|
164
|
+
def _deserialize(type, value)
|
165
|
+
case type.to_sym
|
166
|
+
when :DateTime
|
167
|
+
DateTime.parse(value)
|
168
|
+
when :Date
|
169
|
+
Date.parse(value)
|
170
|
+
when :String
|
171
|
+
value.to_s
|
172
|
+
when :Integer
|
173
|
+
value.to_i
|
174
|
+
when :Float
|
175
|
+
value.to_f
|
176
|
+
when :Boolean
|
177
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
178
|
+
true
|
179
|
+
else
|
180
|
+
false
|
181
|
+
end
|
182
|
+
when :Object
|
183
|
+
# generic object (usually a Hash), return directly
|
184
|
+
value
|
185
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
186
|
+
inner_type = Regexp.last_match[:inner_type]
|
187
|
+
value.map { |v| _deserialize(inner_type, v) }
|
188
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
189
|
+
k_type = Regexp.last_match[:k_type]
|
190
|
+
v_type = Regexp.last_match[:v_type]
|
191
|
+
{}.tap do |hash|
|
192
|
+
value.each do |k, v|
|
193
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
else # model
|
197
|
+
BleumiPay.const_get(type).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
|
+
if value.nil?
|
220
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
221
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
222
|
+
end
|
223
|
+
|
224
|
+
hash[param] = _to_hash(value)
|
225
|
+
end
|
226
|
+
hash
|
227
|
+
end
|
228
|
+
|
229
|
+
# Outputs non-array value in the form of hash
|
230
|
+
# For object, use to_hash. Otherwise, just return the value
|
231
|
+
# @param [Object] value Any valid value
|
232
|
+
# @return [Hash] Returns the value in the form of hash
|
233
|
+
def _to_hash(value)
|
234
|
+
if value.is_a?(Array)
|
235
|
+
value.compact.map { |v| _to_hash(v) }
|
236
|
+
elsif value.is_a?(Hash)
|
237
|
+
{}.tap do |hash|
|
238
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
239
|
+
end
|
240
|
+
elsif value.respond_to? :to_hash
|
241
|
+
value.to_hash
|
242
|
+
else
|
243
|
+
value
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|