bleumi_pay_sdk_ruby 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
data/hc_create.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Load the gem
|
2
|
+
require 'bleumi_pay_sdk_ruby'
|
3
|
+
|
4
|
+
# Setup authorization
|
5
|
+
BleumiPay.configure do |config|
|
6
|
+
# Configure API key authorization: ApiKeyAuth
|
7
|
+
config.api_key['x-api-key'] = 'hwE7QJcJ1raJicN8K0jwca4eIKAiVne179CK8wro'
|
8
|
+
end
|
9
|
+
|
10
|
+
api_instance = BleumiPay::HostedCheckoutsApi.new
|
11
|
+
|
12
|
+
create_checkout_url_request = BleumiPay::CreateCheckoutUrlRequest.new # CreatePayoutRequest | Specify payout creation parameters.
|
13
|
+
create_checkout_url_request.id = '31'
|
14
|
+
create_checkout_url_request.currency = 'USD'
|
15
|
+
create_checkout_url_request.amount = '10'
|
16
|
+
create_checkout_url_request.success_url = 'https://demo.store/api/completeOrder'
|
17
|
+
create_checkout_url_request.cancel_url = 'https://demo.store/api/cancelOrder'
|
18
|
+
create_checkout_url_request.token = '0x115615DbD0f835344725146Fa6343219315F15E5'
|
19
|
+
create_checkout_url_request.chain = BleumiPay::Chain::GOERLI
|
20
|
+
|
21
|
+
# create_checkout_url_request.token = 'ALGO'
|
22
|
+
# create_checkout_url_request.currency = 'ALGO'
|
23
|
+
# create_checkout_url_request.chain = BleumiPay::Chain::ALG_TESTNET
|
24
|
+
# create_checkout_url_request.buyer_address = '0x713883BF69B786f0A7aB6E2248a70C50577F6b34'
|
25
|
+
create_checkout_url_request.buyer_address = 'W5XU4IWCTVBTYXSYIGJYXEPXH2O5S6RPHLF4JK25NEPYT3RACD4Z3EBS4A'
|
26
|
+
|
27
|
+
begin
|
28
|
+
#Create an unique wallet address to accept payments for an ERC-20 token from a buyer
|
29
|
+
result = api_instance.create_checkout_url(create_checkout_url_request)
|
30
|
+
p result
|
31
|
+
rescue BleumiPay::ApiError => e
|
32
|
+
puts "Exception when calling HostedCheckoutsApi->create_checkout_url: #{e}"
|
33
|
+
end
|
data/hc_list.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# load the gem
|
2
|
+
require 'bleumi_pay_sdk_ruby'
|
3
|
+
# setup authorization
|
4
|
+
BleumiPay.configure do |config|
|
5
|
+
# Configure API key authorization: ApiKeyAuth
|
6
|
+
config.api_key['x-api-key'] = 'hwE7QJcJ1raJicN8K0jwca4eIKAiVne179CK8wro'
|
7
|
+
end
|
8
|
+
|
9
|
+
api_instance = BleumiPay::HostedCheckoutsApi.new
|
10
|
+
|
11
|
+
begin
|
12
|
+
#Retrieve all tokens configured for the Hosted Checkout in your account in the Bleumi Pay Dashboard
|
13
|
+
result = api_instance.list_tokens
|
14
|
+
p result
|
15
|
+
rescue BleumiPay::ApiError => e
|
16
|
+
puts "Exception when calling HostedCheckoutsApi->list_tokens: #{e}"
|
17
|
+
end
|
data/hc_validate.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# load the gem
|
2
|
+
require 'bleumi_pay_sdk_ruby'
|
3
|
+
# setup authorization
|
4
|
+
BleumiPay.configure do |config|
|
5
|
+
# Configure API key authorization: ApiKeyAuth
|
6
|
+
config.api_key['x-api-key'] = 'hwE7QJcJ1raJicN8K0jwca4eIKAiVne179CK8wro'
|
7
|
+
end
|
8
|
+
|
9
|
+
api_instance = BleumiPay::HostedCheckoutsApi.new
|
10
|
+
|
11
|
+
begin
|
12
|
+
validate_checkout_request = BleumiPay::ValidateCheckoutRequest.new # WalletSettleOperationInput | Request body - used to specify the amount to settle.
|
13
|
+
validate_checkout_request.hmac_alg = 'HMAC-SHA256-HEX'
|
14
|
+
validate_checkout_request.hmac_input = 'goerli|0xbeaea438bc2e19d097906b597219c288e8eb7b2e|0x115615dbd0f835344725146fa6343219315f15e5|10|12'
|
15
|
+
validate_checkout_request.hmac_key_id = 'v1'
|
16
|
+
validate_checkout_request.hmac_value = 'bdf82eb42efac09150d62ac1bcadd2fd0f64852ded2b571567c905217adf246a'
|
17
|
+
#Settle a wallet, amount received will be transferred even if less than payment amount
|
18
|
+
result = api_instance.validate_checkout_payment(validate_checkout_request)
|
19
|
+
p result
|
20
|
+
rescue BleumiPay::ApiError => e
|
21
|
+
puts "Exception when calling HostedCheckoutsApi->validate_checkout_payment: #{e}"
|
22
|
+
end
|
data/lib/bleumi_pay_sdk_ruby.rb
CHANGED
@@ -18,6 +18,8 @@ require 'bleumi_pay_sdk_ruby/configuration'
|
|
18
18
|
|
19
19
|
# Models
|
20
20
|
require 'bleumi_pay_sdk_ruby/models/algorand_balance'
|
21
|
+
require 'bleumi_pay_sdk_ruby/models/algorand_wallet_address'
|
22
|
+
require 'bleumi_pay_sdk_ruby/models/algorand_wallet_inputs'
|
21
23
|
require 'bleumi_pay_sdk_ruby/models/bad_request'
|
22
24
|
require 'bleumi_pay_sdk_ruby/models/chain'
|
23
25
|
require 'bleumi_pay_sdk_ruby/models/checkout_token'
|
@@ -28,6 +30,8 @@ require 'bleumi_pay_sdk_ruby/models/create_payment_response'
|
|
28
30
|
require 'bleumi_pay_sdk_ruby/models/create_payout_request'
|
29
31
|
require 'bleumi_pay_sdk_ruby/models/create_payout_response'
|
30
32
|
require 'bleumi_pay_sdk_ruby/models/ethereum_balance'
|
33
|
+
require 'bleumi_pay_sdk_ruby/models/ethereum_wallet_address'
|
34
|
+
require 'bleumi_pay_sdk_ruby/models/ethereum_wallet_inputs'
|
31
35
|
require 'bleumi_pay_sdk_ruby/models/paginated_payment_operations'
|
32
36
|
require 'bleumi_pay_sdk_ruby/models/paginated_payments'
|
33
37
|
require 'bleumi_pay_sdk_ruby/models/paginated_payout_items'
|
@@ -44,7 +48,6 @@ require 'bleumi_pay_sdk_ruby/models/payout_item'
|
|
44
48
|
require 'bleumi_pay_sdk_ruby/models/payout_item_inputs'
|
45
49
|
require 'bleumi_pay_sdk_ruby/models/validate_checkout_request'
|
46
50
|
require 'bleumi_pay_sdk_ruby/models/validate_checkout_response'
|
47
|
-
require 'bleumi_pay_sdk_ruby/models/wallet_address'
|
48
51
|
require 'bleumi_pay_sdk_ruby/models/wallet_balance'
|
49
52
|
|
50
53
|
# APIs
|
@@ -57,7 +57,7 @@ module BleumiPay
|
|
57
57
|
|
58
58
|
# query parameters
|
59
59
|
query_params = opts[:query_params] || {}
|
60
|
-
query_params[:'chain'] = chain
|
60
|
+
query_params[:'chain'] = opts[:'chain'] if !opts[:'chain'].nil?
|
61
61
|
|
62
62
|
# header parameters
|
63
63
|
header_params = opts[:header_params] || {}
|
@@ -400,7 +400,7 @@ module BleumiPay
|
|
400
400
|
|
401
401
|
# query parameters
|
402
402
|
query_params = opts[:query_params] || {}
|
403
|
-
query_params[:'chain'] = chain
|
403
|
+
query_params[:'chain'] = opts[:'chain'] if !opts[:'chain'].nil?
|
404
404
|
|
405
405
|
# header parameters
|
406
406
|
header_params = opts[:header_params] || {}
|
@@ -127,8 +127,10 @@ module BleumiPay
|
|
127
127
|
|
128
128
|
def initialize
|
129
129
|
@scheme = 'https'
|
130
|
-
@host = 'api.pay.bleumi.com'
|
131
|
-
@
|
130
|
+
# @host = 'api.pay.bleumi.com'
|
131
|
+
@host = 'ej8fsqadb7.execute-api.us-east-1.amazonaws.com'
|
132
|
+
# @base_path = ''
|
133
|
+
@base_path = '/prod/'
|
132
134
|
@api_key = {}
|
133
135
|
@api_key_prefix = {}
|
134
136
|
@timeout = 0
|
@@ -207,7 +209,8 @@ module BleumiPay
|
|
207
209
|
def server_settings
|
208
210
|
[
|
209
211
|
{
|
210
|
-
url: "https://api.pay.bleumi.com/",
|
212
|
+
#url: "https://api.pay.bleumi.com/",
|
213
|
+
url: "ej8fsqadb7.execute-api.us-east-1.amazonaws.com/",
|
211
214
|
description: "Bleumi Pay REST API",
|
212
215
|
}
|
213
216
|
]
|
@@ -1,33 +1,37 @@
|
|
1
1
|
=begin
|
2
2
|
#Bleumi Pay REST API
|
3
3
|
|
4
|
-
#A simple and powerful REST API to integrate
|
4
|
+
#A simple and powerful REST API to integrate Algorand, Ethereum, ERC-20 and xDai payments and/or payouts into your business
|
5
5
|
|
6
6
|
The version of the OpenAPI document: 1.0.0
|
7
7
|
Contact: info@bleumi.com
|
8
8
|
Generated by: https://openapi-generator.tech
|
9
|
-
OpenAPI Generator version: 4.2.
|
9
|
+
OpenAPI Generator version: 4.2.3
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
13
13
|
require 'date'
|
14
14
|
|
15
15
|
module BleumiPay
|
16
|
-
class
|
16
|
+
class AlgorandWalletAddress
|
17
17
|
# Wallet address for the payment in the network
|
18
18
|
attr_accessor :addr
|
19
19
|
|
20
|
+
attr_accessor :inputs
|
21
|
+
|
20
22
|
# Attribute mapping from ruby-style variable name to JSON key.
|
21
23
|
def self.attribute_map
|
22
24
|
{
|
23
|
-
:'addr' => :'addr'
|
25
|
+
:'addr' => :'addr',
|
26
|
+
:'inputs' => :'inputs'
|
24
27
|
}
|
25
28
|
end
|
26
29
|
|
27
30
|
# Attribute type mapping.
|
28
31
|
def self.openapi_types
|
29
32
|
{
|
30
|
-
:'addr' => :'String'
|
33
|
+
:'addr' => :'String',
|
34
|
+
:'inputs' => :'AlgorandWalletInputs'
|
31
35
|
}
|
32
36
|
end
|
33
37
|
|
@@ -41,13 +45,13 @@ module BleumiPay
|
|
41
45
|
# @param [Hash] attributes Model attributes in the form of hash
|
42
46
|
def initialize(attributes = {})
|
43
47
|
if (!attributes.is_a?(Hash))
|
44
|
-
fail ArgumentError, "The input argument (attributes) must be a hash in `BleumiPay::
|
48
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `BleumiPay::AlgorandWalletAddress` initialize method"
|
45
49
|
end
|
46
50
|
|
47
51
|
# check to see if the attribute exists and convert string to symbol for hash key
|
48
52
|
attributes = attributes.each_with_object({}) { |(k, v), h|
|
49
53
|
if (!self.class.attribute_map.key?(k.to_sym))
|
50
|
-
fail ArgumentError, "`#{k}` is not a valid attribute in `BleumiPay::
|
54
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `BleumiPay::AlgorandWalletAddress`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
51
55
|
end
|
52
56
|
h[k.to_sym] = v
|
53
57
|
}
|
@@ -55,6 +59,10 @@ module BleumiPay
|
|
55
59
|
if attributes.key?(:'addr')
|
56
60
|
self.addr = attributes[:'addr']
|
57
61
|
end
|
62
|
+
|
63
|
+
if attributes.key?(:'inputs')
|
64
|
+
self.inputs = attributes[:'inputs']
|
65
|
+
end
|
58
66
|
end
|
59
67
|
|
60
68
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -80,7 +88,8 @@ module BleumiPay
|
|
80
88
|
def ==(o)
|
81
89
|
return true if self.equal?(o)
|
82
90
|
self.class == o.class &&
|
83
|
-
addr == o.addr
|
91
|
+
addr == o.addr &&
|
92
|
+
inputs == o.inputs
|
84
93
|
end
|
85
94
|
|
86
95
|
# @see the `==` method
|
@@ -92,7 +101,7 @@ module BleumiPay
|
|
92
101
|
# Calculates hash code according to all attributes.
|
93
102
|
# @return [Integer] Hash code
|
94
103
|
def hash
|
95
|
-
[addr].hash
|
104
|
+
[addr, inputs].hash
|
96
105
|
end
|
97
106
|
|
98
107
|
# Builds the object from hash
|
@@ -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 AlgorandWalletInputs
|
17
|
+
# Buyer Address
|
18
|
+
attr_accessor :buyer
|
19
|
+
|
20
|
+
# Merchant Address
|
21
|
+
attr_accessor :merchant
|
22
|
+
|
23
|
+
# Salt
|
24
|
+
attr_accessor :salt
|
25
|
+
|
26
|
+
# Gas account Address
|
27
|
+
attr_accessor :gas
|
28
|
+
|
29
|
+
# Program Bytes
|
30
|
+
attr_accessor :program_bytes
|
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
|
+
:'gas' => :'gas',
|
39
|
+
:'program_bytes' => :'programBytes'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
# Attribute type mapping.
|
44
|
+
def self.openapi_types
|
45
|
+
{
|
46
|
+
:'buyer' => :'String',
|
47
|
+
:'merchant' => :'String',
|
48
|
+
:'salt' => :'String',
|
49
|
+
:'gas' => :'String',
|
50
|
+
:'program_bytes' => :'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::AlgorandWalletInputs` 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::AlgorandWalletInputs`. 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?(:'gas')
|
88
|
+
self.gas = attributes[:'gas']
|
89
|
+
end
|
90
|
+
|
91
|
+
if attributes.key?(:'program_bytes')
|
92
|
+
self.program_bytes = attributes[:'program_bytes']
|
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
|
+
gas == o.gas &&
|
118
|
+
program_bytes == o.program_bytes
|
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, gas, program_bytes].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
|