bleumi_pay_sdk_ruby 1.0.2 → 1.0.7
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/README.md +67 -47
- data/bleumi_pay_sdk_ruby.gemspec +4 -5
- data/docs/AlgorandBalance.md +28 -0
- data/docs/AlgorandWalletAddress.md +24 -0
- data/docs/AlgorandWalletInputs.md +23 -0
- data/docs/BadRequest.md +2 -1
- data/docs/Chain.md +14 -0
- data/docs/CheckoutToken.md +28 -0
- data/docs/CreateCheckoutUrlRequest.md +28 -0
- data/docs/CreateCheckoutUrlResponse.md +17 -0
- data/docs/CreatePaymentRequest.md +19 -0
- data/docs/CreatePaymentResponse.md +15 -0
- data/docs/CreatePayoutRequest.md +28 -0
- data/docs/CreatePayoutResponse.md +15 -0
- data/docs/EthereumBalance.md +30 -0
- data/docs/EthereumWalletAddress.md +23 -0
- data/docs/EthereumWalletInputs.md +23 -0
- data/docs/HostedCheckoutsApi.md +197 -0
- data/docs/PaginatedPaymentOperations.md +28 -0
- data/docs/PaginatedPayments.md +95 -0
- data/docs/PaginatedPayoutItems.md +59 -0
- data/docs/Payment.md +67 -0
- data/docs/PaymentAddresses.md +21 -0
- data/docs/PaymentBalances.md +21 -0
- data/docs/PaymentOperation.md +46 -0
- data/docs/PaymentOperationInputs.md +31 -0
- data/docs/PaymentOperationResponse.md +15 -0
- data/docs/PaymentRefundRequest.md +14 -0
- data/docs/PaymentSettleRequest.md +17 -0
- data/docs/PaymentsApi.md +368 -0
- data/docs/Payout.md +18 -0
- data/docs/PayoutItem.md +39 -0
- data/docs/PayoutItemInputs.md +28 -0
- data/docs/PayoutsApi.md +137 -0
- data/docs/RskBalance.md +28 -0
- data/docs/ValidateCheckoutRequest.md +21 -0
- data/docs/ValidateCheckoutResponse.md +15 -0
- data/docs/WalletBalance.md +18 -4
- data/hc_create.rb +40 -0
- data/hc_list.rb +17 -0
- data/hc_validate.rb +22 -0
- data/lib/bleumi_pay_sdk_ruby.rb +38 -17
- data/lib/bleumi_pay_sdk_ruby/api/hosted_checkouts_api.rb +212 -0
- data/lib/bleumi_pay_sdk_ruby/api/payments_api.rb +517 -0
- data/lib/bleumi_pay_sdk_ruby/api/payouts_api.rb +157 -0
- data/lib/bleumi_pay_sdk_ruby/api/request_validator.rb +288 -0
- data/lib/bleumi_pay_sdk_ruby/api_client.rb +11 -9
- data/lib/bleumi_pay_sdk_ruby/api_error.rb +3 -3
- data/lib/bleumi_pay_sdk_ruby/configuration.rb +4 -4
- data/lib/bleumi_pay_sdk_ruby/models/algorand_balance.rb +219 -0
- data/lib/bleumi_pay_sdk_ruby/models/algorand_wallet_address.rb +221 -0
- data/lib/bleumi_pay_sdk_ruby/models/algorand_wallet_inputs.rb +247 -0
- data/lib/bleumi_pay_sdk_ruby/models/bad_request.rb +15 -5
- data/lib/bleumi_pay_sdk_ruby/models/{eth_network.rb → chain.rb} +12 -9
- data/lib/bleumi_pay_sdk_ruby/models/checkout_token.rb +302 -0
- data/lib/bleumi_pay_sdk_ruby/models/create_checkout_url_request.rb +312 -0
- data/lib/bleumi_pay_sdk_ruby/models/create_checkout_url_response.rb +227 -0
- data/lib/bleumi_pay_sdk_ruby/models/{wallet_create_input.rb → create_payment_request.rb} +33 -11
- data/lib/bleumi_pay_sdk_ruby/models/{wallet_create_output.rb → create_payment_response.rb} +19 -23
- data/lib/bleumi_pay_sdk_ruby/models/create_payout_request.rb +244 -0
- data/lib/bleumi_pay_sdk_ruby/models/create_payout_response.rb +212 -0
- data/lib/bleumi_pay_sdk_ruby/models/ethereum_balance.rb +241 -0
- data/lib/bleumi_pay_sdk_ruby/models/ethereum_wallet_address.rb +221 -0
- data/lib/bleumi_pay_sdk_ruby/models/{wallet_inputs.rb → ethereum_wallet_inputs.rb} +35 -50
- data/lib/bleumi_pay_sdk_ruby/models/paginated_payment_operations.rb +224 -0
- data/lib/bleumi_pay_sdk_ruby/models/{paginated_wallet_operations.rb → paginated_payments.rb} +19 -9
- data/lib/bleumi_pay_sdk_ruby/models/{paginated_wallets.rb → paginated_payout_items.rb} +19 -9
- data/lib/bleumi_pay_sdk_ruby/models/{wallet.rb → payment.rb} +31 -54
- data/lib/bleumi_pay_sdk_ruby/models/payment_addresses.rb +231 -0
- data/lib/bleumi_pay_sdk_ruby/models/payment_balances.rb +225 -0
- data/lib/bleumi_pay_sdk_ruby/models/{wallet_operation.rb → payment_operation.rb} +44 -18
- data/lib/bleumi_pay_sdk_ruby/models/{wallet_operation_inputs.rb → payment_operation_inputs.rb} +38 -12
- data/lib/bleumi_pay_sdk_ruby/models/{wallet_operation_output.rb → payment_operation_response.rb} +18 -8
- data/lib/bleumi_pay_sdk_ruby/models/{wallet_refund_operation_input.rb → payment_refund_request.rb} +18 -8
- data/lib/bleumi_pay_sdk_ruby/models/{wallet_settle_operation_input.rb → payment_settle_request.rb} +18 -8
- data/lib/bleumi_pay_sdk_ruby/models/payout.rb +237 -0
- data/lib/bleumi_pay_sdk_ruby/models/payout_item.rb +286 -0
- data/lib/bleumi_pay_sdk_ruby/models/payout_item_inputs.rb +244 -0
- data/lib/bleumi_pay_sdk_ruby/models/rsk_balance.rb +219 -0
- data/lib/bleumi_pay_sdk_ruby/models/validate_checkout_request.rb +257 -0
- data/lib/bleumi_pay_sdk_ruby/models/validate_checkout_response.rb +212 -0
- data/lib/bleumi_pay_sdk_ruby/models/wallet_balance.rb +37 -12
- data/lib/bleumi_pay_sdk_ruby/version.rb +4 -4
- data/po_create.rb +39 -0
- data/po_list.rb +23 -0
- data/py_create.rb +48 -0
- 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 +43 -0
- data/py_settle.rb +43 -0
- data/spec/api/hosted_checkouts_api_spec.rb +67 -0
- data/spec/api/payments_api_spec.rb +123 -0
- data/spec/api/payouts_api_spec.rb +61 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/algorand_balance_spec.rb +47 -0
- data/spec/models/algorand_wallet_address_spec.rb +47 -0
- data/spec/models/algorand_wallet_inputs_spec.rb +65 -0
- data/spec/models/bad_request_spec.rb +47 -0
- data/spec/models/chain_spec.rb +35 -0
- data/spec/models/checkout_token_spec.rb +77 -0
- data/spec/models/create_checkout_url_request_spec.rb +89 -0
- data/spec/models/create_checkout_url_response_spec.rb +47 -0
- data/spec/models/create_payment_request_spec.rb +59 -0
- data/spec/models/create_payment_response_spec.rb +41 -0
- data/spec/models/create_payout_request_spec.rb +53 -0
- data/spec/models/create_payout_response_spec.rb +41 -0
- data/spec/models/ethereum_balance_spec.rb +59 -0
- data/spec/models/ethereum_wallet_address_spec.rb +47 -0
- data/spec/models/ethereum_wallet_inputs_spec.rb +65 -0
- data/spec/models/paginated_payment_operations_spec.rb +47 -0
- data/spec/models/paginated_payments_spec.rb +47 -0
- data/spec/models/paginated_payout_items_spec.rb +47 -0
- data/spec/models/payment_addresses_spec.rb +53 -0
- data/spec/models/payment_balances_spec.rb +53 -0
- data/spec/models/payment_operation_inputs_spec.rb +65 -0
- data/spec/models/payment_operation_response_spec.rb +41 -0
- data/spec/models/payment_operation_spec.rb +71 -0
- data/spec/models/payment_refund_request_spec.rb +41 -0
- data/spec/models/payment_settle_request_spec.rb +47 -0
- data/spec/models/payment_spec.rb +65 -0
- data/spec/models/payout_item_inputs_spec.rb +53 -0
- data/spec/models/payout_item_spec.rb +71 -0
- data/spec/models/payout_spec.rb +53 -0
- data/spec/models/rsk_balance_spec.rb +47 -0
- data/spec/models/validate_checkout_request_spec.rb +59 -0
- data/spec/models/validate_checkout_response_spec.rb +41 -0
- data/spec/models/wallet_balance_spec.rb +65 -0
- data/spec/spec_helper.rb +111 -0
- metadata +180 -49
- data/docs/Erc20PaymentsApi.md +0 -334
- data/docs/EthAddress.md +0 -8
- data/docs/EthNetwork.md +0 -9
- data/docs/PaginatedWalletOperations.md +0 -8
- data/docs/PaginatedWallets.md +0 -8
- data/docs/Wallet.md +0 -13
- data/docs/WalletCreateInput.md +0 -9
- data/docs/WalletCreateOutput.md +0 -10
- data/docs/WalletInputs.md +0 -11
- data/docs/WalletOperation.md +0 -11
- data/docs/WalletOperationInputs.md +0 -10
- data/docs/WalletOperationOutput.md +0 -8
- data/docs/WalletRefundOperationInput.md +0 -7
- data/docs/WalletSettleOperationInput.md +0 -8
- data/lib/bleumi_pay_sdk_ruby/api/erc20_payments_api.rb +0 -482
- data/lib/bleumi_pay_sdk_ruby/models/eth_address.rb +0 -208
@@ -0,0 +1,157 @@
|
|
1
|
+
=begin
|
2
|
+
#Bleumi Pay API
|
3
|
+
|
4
|
+
#A simple and powerful REST API to integrate ERC-20, Ethereum, xDai payments and/or payouts into your business or application
|
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.2
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'cgi'
|
14
|
+
|
15
|
+
module BleumiPay
|
16
|
+
class PayoutsApi
|
17
|
+
attr_accessor :api_client
|
18
|
+
|
19
|
+
def initialize(api_client = ApiClient.default)
|
20
|
+
@api_client = api_client
|
21
|
+
end
|
22
|
+
# Create a payout.
|
23
|
+
# @param create_payout_request [CreatePayoutRequest] Request body - used to specify payout creation parameters.
|
24
|
+
# @param [Hash] opts the optional parameters
|
25
|
+
# @option opts [Chain] :chain Ethereum network in which payment is to be created. Please refer documentation for Supported Networks
|
26
|
+
# @return [CreatePayoutResponse]
|
27
|
+
def create_payout(create_payout_request, opts = {})
|
28
|
+
data, _status_code, _headers = create_payout_with_http_info(create_payout_request, opts)
|
29
|
+
data
|
30
|
+
end
|
31
|
+
|
32
|
+
# Create a payout.
|
33
|
+
# @param create_payout_request [CreatePayoutRequest] Request body - used to specify payout creation parameters.
|
34
|
+
# @param [Hash] opts the optional parameters
|
35
|
+
# @option opts [Chain] :chain Ethereum network in which payment is to be created. Please refer documentation for Supported Networks
|
36
|
+
# @return [Array<(CreatePayoutResponse, Integer, Hash)>] CreatePayoutResponse data, response status code and response headers
|
37
|
+
def create_payout_with_http_info(create_payout_request, opts = {})
|
38
|
+
if @api_client.config.debugging
|
39
|
+
@api_client.config.logger.debug 'Calling API: PayoutsApi.create_payout ...'
|
40
|
+
end
|
41
|
+
# verify the required parameter 'create_payout_request' is set
|
42
|
+
if @api_client.config.client_side_validation && create_payout_request.nil?
|
43
|
+
fail ArgumentError, "Missing the required parameter 'create_payout_request' when calling PayoutsApi.create_payout"
|
44
|
+
end
|
45
|
+
# resource path
|
46
|
+
local_var_path = '/v1/payout'
|
47
|
+
|
48
|
+
# query parameters
|
49
|
+
query_params = opts[:query_params] || {}
|
50
|
+
query_params[:'chain'] = opts[:'chain'] if !opts[:'chain'].nil?
|
51
|
+
|
52
|
+
# header parameters
|
53
|
+
header_params = opts[:header_params] || {}
|
54
|
+
# HTTP header 'Accept' (if needed)
|
55
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
56
|
+
# HTTP header 'Content-Type'
|
57
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
|
58
|
+
|
59
|
+
# form parameters
|
60
|
+
form_params = opts[:form_params] || {}
|
61
|
+
|
62
|
+
# http body (model)
|
63
|
+
post_body = opts[:body] || @api_client.object_to_http_body(create_payout_request)
|
64
|
+
|
65
|
+
# return_type
|
66
|
+
return_type = opts[:return_type] || 'CreatePayoutResponse'
|
67
|
+
|
68
|
+
# auth_names
|
69
|
+
auth_names = opts[:auth_names] || ['ApiKeyAuth']
|
70
|
+
|
71
|
+
new_options = opts.merge(
|
72
|
+
:header_params => header_params,
|
73
|
+
:query_params => query_params,
|
74
|
+
:form_params => form_params,
|
75
|
+
:body => post_body,
|
76
|
+
:auth_names => auth_names,
|
77
|
+
:return_type => return_type
|
78
|
+
)
|
79
|
+
|
80
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
|
81
|
+
if @api_client.config.debugging
|
82
|
+
@api_client.config.logger.debug "API called: PayoutsApi#create_payout\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
83
|
+
end
|
84
|
+
return data, status_code, headers
|
85
|
+
end
|
86
|
+
|
87
|
+
# Returns a list of payouts
|
88
|
+
# @param [Hash] opts the optional parameters
|
89
|
+
# @option opts [String] :next_token Cursor to start results from
|
90
|
+
# @option opts [String] :sort_by Sort payments by
|
91
|
+
# @option opts [String] :start_at Get payouts from this timestamp (unix)
|
92
|
+
# @option opts [String] :end_at Get payouts till this timestamp (unix)
|
93
|
+
# @return [PaginatedPayoutItems]
|
94
|
+
def list_payouts(opts = {})
|
95
|
+
data, _status_code, _headers = list_payouts_with_http_info(opts)
|
96
|
+
data
|
97
|
+
end
|
98
|
+
|
99
|
+
# Returns a list of payouts
|
100
|
+
# @param [Hash] opts the optional parameters
|
101
|
+
# @option opts [String] :next_token Cursor to start results from
|
102
|
+
# @option opts [String] :sort_by Sort payments by
|
103
|
+
# @option opts [String] :start_at Get payouts from this timestamp (unix)
|
104
|
+
# @option opts [String] :end_at Get payouts till this timestamp (unix)
|
105
|
+
# @return [Array<(PaginatedPayoutItems, Integer, Hash)>] PaginatedPayoutItems data, response status code and response headers
|
106
|
+
def list_payouts_with_http_info(opts = {})
|
107
|
+
if @api_client.config.debugging
|
108
|
+
@api_client.config.logger.debug 'Calling API: PayoutsApi.list_payouts ...'
|
109
|
+
end
|
110
|
+
allowable_values = ["createdAt", "updatedAt"]
|
111
|
+
if @api_client.config.client_side_validation && opts[:'sort_by'] && !allowable_values.include?(opts[:'sort_by'])
|
112
|
+
fail ArgumentError, "invalid value for \"sort_by\", must be one of #{allowable_values}"
|
113
|
+
end
|
114
|
+
# resource path
|
115
|
+
local_var_path = '/v1/payout'
|
116
|
+
|
117
|
+
# query parameters
|
118
|
+
query_params = opts[:query_params] || {}
|
119
|
+
query_params[:'nextToken'] = opts[:'next_token'] if !opts[:'next_token'].nil?
|
120
|
+
query_params[:'sortBy'] = opts[:'sort_by'] if !opts[:'sort_by'].nil?
|
121
|
+
query_params[:'startAt'] = opts[:'start_at'] if !opts[:'start_at'].nil?
|
122
|
+
query_params[:'endAt'] = opts[:'end_at'] if !opts[:'end_at'].nil?
|
123
|
+
|
124
|
+
# header parameters
|
125
|
+
header_params = opts[:header_params] || {}
|
126
|
+
# HTTP header 'Accept' (if needed)
|
127
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
128
|
+
|
129
|
+
# form parameters
|
130
|
+
form_params = opts[:form_params] || {}
|
131
|
+
|
132
|
+
# http body (model)
|
133
|
+
post_body = opts[:body]
|
134
|
+
|
135
|
+
# return_type
|
136
|
+
return_type = opts[:return_type] || 'PaginatedPayoutItems'
|
137
|
+
|
138
|
+
# auth_names
|
139
|
+
auth_names = opts[:auth_names] || ['ApiKeyAuth']
|
140
|
+
|
141
|
+
new_options = opts.merge(
|
142
|
+
:header_params => header_params,
|
143
|
+
:query_params => query_params,
|
144
|
+
:form_params => form_params,
|
145
|
+
:body => post_body,
|
146
|
+
:auth_names => auth_names,
|
147
|
+
:return_type => return_type
|
148
|
+
)
|
149
|
+
|
150
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
151
|
+
if @api_client.config.debugging
|
152
|
+
@api_client.config.logger.debug "API called: PayoutsApi#list_payouts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
153
|
+
end
|
154
|
+
return data, status_code, headers
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
@@ -0,0 +1,288 @@
|
|
1
|
+
=begin
|
2
|
+
#Bleumi Pay API
|
3
|
+
|
4
|
+
#A simple and powerful REST API to integrate ERC-20, Ethereum, xDai payments and/or payouts into your business or application
|
5
|
+
|
6
|
+
Contact: info@bleumi.com
|
7
|
+
|
8
|
+
=end
|
9
|
+
module BleumiPay
|
10
|
+
class RequestValidator
|
11
|
+
|
12
|
+
def self.default
|
13
|
+
@@default ||= RequestValidator.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def eth_address?(str)
|
17
|
+
# We use !! to convert the return value to a boolean
|
18
|
+
!!(str =~ /^0x[a-fA-F0-9]{40}$/)
|
19
|
+
end
|
20
|
+
|
21
|
+
def algo_address?(str)
|
22
|
+
# We use !! to convert the return value to a boolean
|
23
|
+
!!(str =~ /^[A-Z2-7+=*]{58}$/)
|
24
|
+
end
|
25
|
+
|
26
|
+
def algo_token?(str)
|
27
|
+
# We use !! to convert the return value to a boolean
|
28
|
+
!!(str =~ /^[0-9]*$/)
|
29
|
+
end
|
30
|
+
|
31
|
+
def is_not_empty(str)
|
32
|
+
if (str == nil || str == "") then
|
33
|
+
return false
|
34
|
+
end
|
35
|
+
return true
|
36
|
+
end
|
37
|
+
|
38
|
+
def check_eth_addr(name, input)
|
39
|
+
if !((eth_address?(input))||(input == "ETH")||(input == "XDAI")||(input == "XDAIT")) then
|
40
|
+
return "`#{name}` is not a valid Ethereum address"
|
41
|
+
end
|
42
|
+
return nil
|
43
|
+
end
|
44
|
+
|
45
|
+
def check_rsk_addr(name, input)
|
46
|
+
if !((eth_address?(input))||(input == "RBTC")) then
|
47
|
+
return "`#{name}` is not a valid RSK address"
|
48
|
+
end
|
49
|
+
return nil
|
50
|
+
end
|
51
|
+
|
52
|
+
def check_alg_addr(name, input, is_token)
|
53
|
+
if (is_token)
|
54
|
+
if !((algo_token?(input))||(input == "ALGO")) then
|
55
|
+
return "`#{name}` is not a valid Algorand token"
|
56
|
+
end
|
57
|
+
else
|
58
|
+
if !(algo_address?(input)) then
|
59
|
+
return "`#{name}` is not a valid Algorand address"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
return nil
|
63
|
+
end
|
64
|
+
|
65
|
+
def is_algo_network(chain)
|
66
|
+
return ((chain == "alg_mainnet")||(chain == "alg_testnet"))
|
67
|
+
end
|
68
|
+
|
69
|
+
def is_rsk_network(chain)
|
70
|
+
return ((chain == "rsk")||(chain == "rsk_testnet"))
|
71
|
+
end
|
72
|
+
|
73
|
+
def check_req_param(name, input)
|
74
|
+
if (input == nil || input == "")
|
75
|
+
return "Missing required parameter `#{name}`"
|
76
|
+
end
|
77
|
+
return nil
|
78
|
+
end
|
79
|
+
|
80
|
+
def check_network_addr(name, input, chain, mandatory, is_token)
|
81
|
+
if mandatory then
|
82
|
+
msg = check_req_param(name, input)
|
83
|
+
if is_not_empty(msg) then
|
84
|
+
return msg
|
85
|
+
end
|
86
|
+
end
|
87
|
+
if is_not_empty(input) then
|
88
|
+
msg = nil
|
89
|
+
if is_algo_network(chain) then
|
90
|
+
msg = check_alg_addr(name, input, is_token)
|
91
|
+
elsif is_rsk_network(chain) then
|
92
|
+
msg = check_rsk_addr(name, input)
|
93
|
+
else
|
94
|
+
msg = check_eth_addr(name, input)
|
95
|
+
end
|
96
|
+
if is_not_empty(msg) then
|
97
|
+
return msg
|
98
|
+
end
|
99
|
+
end
|
100
|
+
return nil
|
101
|
+
end
|
102
|
+
|
103
|
+
def validate_create_payment_request(params, chain)
|
104
|
+
# check if chain is provided
|
105
|
+
msg = check_req_param("Chain", chain)
|
106
|
+
if is_not_empty(msg) then
|
107
|
+
return msg
|
108
|
+
end
|
109
|
+
# check if buyer_address is valid address in the network
|
110
|
+
msg = check_network_addr("BuyerAddress", params.buyer_address, chain, mandatory=true, is_token=false)
|
111
|
+
if is_not_empty(msg) then
|
112
|
+
return msg
|
113
|
+
end
|
114
|
+
# check if transfer_address is valid address in the network
|
115
|
+
msg = check_network_addr("TransferAddress", params.transfer_address, chain, mandatory=true, is_token=false)
|
116
|
+
if is_not_empty(msg) then
|
117
|
+
return msg
|
118
|
+
end
|
119
|
+
|
120
|
+
# check if token is valid address in the network (if provided)
|
121
|
+
if is_not_empty(params.token) then
|
122
|
+
msg = check_network_addr("Token", params.token, chain, mandatory=false, is_token=true)
|
123
|
+
if is_not_empty(msg) then
|
124
|
+
return msg
|
125
|
+
end
|
126
|
+
end
|
127
|
+
return nil
|
128
|
+
end
|
129
|
+
|
130
|
+
def validate_refund_payment_request(params, chain)
|
131
|
+
# check if chain is provided
|
132
|
+
msg = check_req_param("Chain", chain)
|
133
|
+
if is_not_empty(msg) then
|
134
|
+
return msg
|
135
|
+
end
|
136
|
+
# check if token is valid address in the network
|
137
|
+
msg = check_network_addr("Token", params.token, chain, mandatory=true, is_token=true)
|
138
|
+
if is_not_empty(msg) then
|
139
|
+
return msg
|
140
|
+
end
|
141
|
+
return nil
|
142
|
+
end
|
143
|
+
|
144
|
+
def validate_settle_payment_request(params, chain)
|
145
|
+
# check if chain is provided
|
146
|
+
msg = check_req_param("Chain", chain)
|
147
|
+
if is_not_empty(msg) then
|
148
|
+
return msg
|
149
|
+
end
|
150
|
+
# check if token is valid address in the network
|
151
|
+
msg = check_network_addr("Token", params.token, chain, mandatory=true, is_token=true)
|
152
|
+
if is_not_empty(msg) then
|
153
|
+
return msg
|
154
|
+
end
|
155
|
+
# check if amount to settle is provided
|
156
|
+
msg = check_req_param("Amount", params.amount)
|
157
|
+
if is_not_empty(msg) then
|
158
|
+
return msg
|
159
|
+
end
|
160
|
+
return nil
|
161
|
+
end
|
162
|
+
|
163
|
+
def validate_create_checkout_url_request(params)
|
164
|
+
# check if id is provided while creating checkout url
|
165
|
+
msg = check_req_param("Id", params.id)
|
166
|
+
if is_not_empty(msg) then
|
167
|
+
return msg
|
168
|
+
end
|
169
|
+
|
170
|
+
# check if currency is provided while creating checkout url
|
171
|
+
msg = check_req_param("Currency", params.currency)
|
172
|
+
if is_not_empty(msg) then
|
173
|
+
return msg
|
174
|
+
end
|
175
|
+
|
176
|
+
# check if amount is provided while creating checkout url
|
177
|
+
msg = check_req_param("Amount", params.amount)
|
178
|
+
if is_not_empty(msg) then
|
179
|
+
return msg
|
180
|
+
end
|
181
|
+
|
182
|
+
# check if cancel_url is provided while creating checkout url
|
183
|
+
msg = check_req_param("CancelUrl", params.cancel_url)
|
184
|
+
if is_not_empty(msg) then
|
185
|
+
return msg
|
186
|
+
end
|
187
|
+
|
188
|
+
# check if success_url is provided while creating checkout url
|
189
|
+
msg = check_req_param("SuccessUrl", params.success_url)
|
190
|
+
if is_not_empty(msg) then
|
191
|
+
return msg
|
192
|
+
end
|
193
|
+
|
194
|
+
# check if token is valid address in the network (if provided)
|
195
|
+
if is_not_empty(params.token) then
|
196
|
+
|
197
|
+
# check if chain is provided in the request, when token is provided, this is required
|
198
|
+
msg = check_req_param("Chain", params.chain)
|
199
|
+
if is_not_empty(msg) then
|
200
|
+
return msg
|
201
|
+
end
|
202
|
+
|
203
|
+
# check if token is valid address in the network (if provided)
|
204
|
+
msg = check_network_addr("Token", params.token, params.chain, mandatory=false, is_token=true)
|
205
|
+
if is_not_empty(msg) then
|
206
|
+
return msg
|
207
|
+
end
|
208
|
+
|
209
|
+
# check if buyer_address is valid address in the network (if provided)
|
210
|
+
if is_not_empty(params.buyer_address) then
|
211
|
+
msg = check_network_addr("BuyerAddress", params.buyer_address, params.chain, mandatory=false, is_token=false)
|
212
|
+
if is_not_empty(msg) then
|
213
|
+
return msg
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
217
|
+
return nil
|
218
|
+
end
|
219
|
+
|
220
|
+
def validate_checkout_payment_params(params)
|
221
|
+
|
222
|
+
# check if hmac_alg is provided while creating checkout payment parameters request
|
223
|
+
msg = check_req_param("HmacAlg", params.hmac_alg)
|
224
|
+
if is_not_empty(msg) then
|
225
|
+
return msg
|
226
|
+
end
|
227
|
+
|
228
|
+
# check if hmac_input is provided while creating checkout payment parameters request
|
229
|
+
msg = check_req_param("HmacInput", params.hmac_input)
|
230
|
+
if is_not_empty(msg) then
|
231
|
+
return msg
|
232
|
+
end
|
233
|
+
|
234
|
+
# check if hmac_key_id is provided while creating checkout payment parameters request
|
235
|
+
msg = check_req_param("HmacKeyId", params.hmac_key_id)
|
236
|
+
if is_not_empty(msg) then
|
237
|
+
return msg
|
238
|
+
end
|
239
|
+
|
240
|
+
# check if hmac_value is provided while creating checkout payment parameters request
|
241
|
+
msg = check_req_param("HmacValue", params.hmac_value)
|
242
|
+
if is_not_empty(msg) then
|
243
|
+
return msg
|
244
|
+
end
|
245
|
+
return nil
|
246
|
+
end
|
247
|
+
|
248
|
+
def validate_create_payout_request(params, chain)
|
249
|
+
msg = check_req_param("Chain", chain)
|
250
|
+
if is_not_empty(msg) then
|
251
|
+
return msg
|
252
|
+
end
|
253
|
+
# check if token is valid address in the network
|
254
|
+
msg = check_network_addr("Token", params.token, chain, mandatory=true, is_token=true)
|
255
|
+
if is_not_empty(msg) then
|
256
|
+
return msg
|
257
|
+
end
|
258
|
+
|
259
|
+
payouts = params.payouts
|
260
|
+
if payouts.length == 0 then
|
261
|
+
return "Payouts not defined."
|
262
|
+
end
|
263
|
+
|
264
|
+
for payout in payouts
|
265
|
+
# check if payout.transfer_address is valid address in the network
|
266
|
+
msg = check_network_addr("TransferAddress", payout.transfer_address, chain, mandatory=true, is_token=false)
|
267
|
+
if is_not_empty(msg) then
|
268
|
+
return msg
|
269
|
+
end
|
270
|
+
|
271
|
+
# check if payout.amount is provided for payout
|
272
|
+
msg = check_req_param("Amount", payout.amount)
|
273
|
+
if is_not_empty(msg) then
|
274
|
+
return msg
|
275
|
+
end
|
276
|
+
|
277
|
+
if is_algo_network(chain) then
|
278
|
+
# check if payout.authorization is provided for Algorand payout
|
279
|
+
msg = check_req_param("Authorization", payout.authorization)
|
280
|
+
if is_not_empty(msg) then
|
281
|
+
return msg
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|
285
|
+
return nil
|
286
|
+
end
|
287
|
+
end
|
288
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
=begin
|
2
|
-
#Bleumi Pay API
|
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 ERC-20, Ethereum, xDai, Algorand payments and/or payouts into your business or application
|
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.2
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -30,7 +30,7 @@ module BleumiPay
|
|
30
30
|
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
|
31
31
|
def initialize(config = Configuration.default)
|
32
32
|
@config = config
|
33
|
-
@user_agent = "
|
33
|
+
@user_agent = "bleumi_pay_sdk_ruby/#{VERSION}/ruby"
|
34
34
|
@default_headers = {
|
35
35
|
'Content-Type' => 'application/json',
|
36
36
|
'User-Agent' => @user_agent
|
@@ -269,11 +269,13 @@ module BleumiPay
|
|
269
269
|
tempfile.write(chunk)
|
270
270
|
end
|
271
271
|
request.on_complete do |response|
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
272
|
+
if tempfile
|
273
|
+
tempfile.close
|
274
|
+
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
|
275
|
+
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
|
276
|
+
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
|
277
|
+
"explicitly with `tempfile.delete`"
|
278
|
+
end
|
277
279
|
end
|
278
280
|
end
|
279
281
|
|