cryptopay-ruby 2.0.0 → 2.2.0
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/.github/workflows/ci.yml +6 -1
- data/.rubocop.yml +6 -0
- data/README.md +51 -10
- data/lib/cryptopay/api/coin_withdrawals.rb +1 -0
- data/lib/cryptopay/api/invoices.rb +2 -0
- data/lib/cryptopay/api/subscriptions.rb +99 -0
- data/lib/cryptopay/client.rb +3 -2
- data/lib/cryptopay/models/account.rb +8 -8
- data/lib/cryptopay/models/account_list_result.rb +8 -8
- data/lib/cryptopay/models/beneficiary.rb +97 -0
- data/lib/cryptopay/models/beneficiary_address.rb +113 -0
- data/lib/cryptopay/models/beneficiary_type.rb +18 -0
- data/lib/cryptopay/models/callback.rb +3 -1
- data/lib/cryptopay/models/channel.rb +8 -8
- data/lib/cryptopay/models/channel_list_result.rb +8 -8
- data/lib/cryptopay/models/channel_params.rb +8 -8
- data/lib/cryptopay/models/channel_payment.rb +8 -8
- data/lib/cryptopay/models/channel_payment_callback.rb +8 -8
- data/lib/cryptopay/models/channel_payment_list_result.rb +8 -8
- data/lib/cryptopay/models/channel_payment_result.rb +8 -8
- data/lib/cryptopay/models/channel_result.rb +8 -8
- data/lib/cryptopay/models/channel_update_params.rb +8 -8
- data/lib/cryptopay/models/channels_config.rb +8 -8
- data/lib/cryptopay/models/coin.rb +8 -8
- data/lib/cryptopay/models/coin_destination_tag.rb +8 -8
- data/lib/cryptopay/models/coin_list_result.rb +8 -8
- data/lib/cryptopay/models/coin_network.rb +8 -8
- data/lib/cryptopay/models/coin_withdrawal.rb +8 -8
- data/lib/cryptopay/models/coin_withdrawal_callback.rb +8 -8
- data/lib/cryptopay/models/coin_withdrawal_list_result.rb +8 -8
- data/lib/cryptopay/models/coin_withdrawal_params.rb +30 -13
- data/lib/cryptopay/models/coin_withdrawal_result.rb +8 -8
- data/lib/cryptopay/models/coin_withdrawals_config.rb +8 -8
- data/lib/cryptopay/models/customer.rb +8 -8
- data/lib/cryptopay/models/customer_address.rb +8 -8
- data/lib/cryptopay/models/customer_list_result.rb +8 -8
- data/lib/cryptopay/models/customer_params.rb +8 -8
- data/lib/cryptopay/models/customer_result.rb +8 -8
- data/lib/cryptopay/models/customer_update_params.rb +8 -8
- data/lib/cryptopay/models/exchange.rb +8 -8
- data/lib/cryptopay/models/exchange_transfer.rb +8 -8
- data/lib/cryptopay/models/exchange_transfer_params.rb +8 -8
- data/lib/cryptopay/models/exchange_transfer_result.rb +8 -8
- data/lib/cryptopay/models/invoice.rb +15 -8
- data/lib/cryptopay/models/invoice_callback.rb +8 -8
- data/lib/cryptopay/models/invoice_list_result.rb +8 -8
- data/lib/cryptopay/models/invoice_params.rb +17 -10
- data/lib/cryptopay/models/invoice_recalculation.rb +8 -8
- data/lib/cryptopay/models/invoice_recalculation_params.rb +8 -8
- data/lib/cryptopay/models/invoice_recalculation_result.rb +8 -8
- data/lib/cryptopay/models/invoice_refund.rb +8 -8
- data/lib/cryptopay/models/invoice_refund_list_result.rb +8 -8
- data/lib/cryptopay/models/invoice_refund_params.rb +8 -8
- data/lib/cryptopay/models/invoice_refund_result.rb +8 -8
- data/lib/cryptopay/models/invoice_result.rb +8 -8
- data/lib/cryptopay/models/invoice_transaction.rb +8 -8
- data/lib/cryptopay/models/invoices_config.rb +8 -8
- data/lib/cryptopay/models/network_fee.rb +8 -8
- data/lib/cryptopay/models/network_fee_list_result.rb +8 -8
- data/lib/cryptopay/models/pagination.rb +8 -8
- data/lib/cryptopay/models/rate.rb +8 -8
- data/lib/cryptopay/models/rate_result.rb +8 -8
- data/lib/cryptopay/models/rates_result.rb +8 -8
- data/lib/cryptopay/models/risk.rb +8 -8
- data/lib/cryptopay/models/risk_params.rb +8 -8
- data/lib/cryptopay/models/risk_result.rb +8 -8
- data/lib/cryptopay/models/subscription.rb +222 -0
- data/lib/cryptopay/models/subscription_callback.rb +88 -0
- data/lib/cryptopay/models/subscription_callback_event.rb +18 -0
- data/lib/cryptopay/models/subscription_list_result.rb +82 -0
- data/lib/cryptopay/models/subscription_params.rb +159 -0
- data/lib/cryptopay/models/subscription_period.rb +20 -0
- data/lib/cryptopay/models/subscription_result.rb +68 -0
- data/lib/cryptopay/models/subscription_status.rb +18 -0
- data/lib/cryptopay/models/transaction.rb +8 -8
- data/lib/cryptopay/models/transaction_list_result.rb +8 -8
- data/lib/cryptopay/require.rb +12 -4
- data/lib/cryptopay/version.rb +1 -1
- metadata +18 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b7b5b9797e07653c96e6c8e9e89838d4ad67db7d4c31df93971c78697125446
|
4
|
+
data.tar.gz: ad3a36fae0973cde9845e898b4ad6f4eb795957af856d8cfadb95215a2e1dfff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84f5d30d964c10af04fff1f1a77e83b28352b42faaf63f2862b2a2a47fe81238b4545be53e95c14ef8a11f1823a1344913ad7cf9fa01dfbb3424109ab0ffce64
|
7
|
+
data.tar.gz: ff88be658db23f44d892a60aa1a9da21efa9631f42a222d1f34934f8c42211fc4b4c748f826cf51a0071f19a7910106739895f5a5dd24aac334658a781291194
|
data/.github/workflows/ci.yml
CHANGED
data/.rubocop.yml
CHANGED
@@ -18,6 +18,9 @@ Style/GuardClause:
|
|
18
18
|
Style/Copyright:
|
19
19
|
Enabled: false
|
20
20
|
|
21
|
+
Style/DisableCopsWithinSourceCodeDirective:
|
22
|
+
Enabled: false
|
23
|
+
|
21
24
|
Style/Documentation:
|
22
25
|
Enabled: false
|
23
26
|
|
@@ -102,3 +105,6 @@ Metrics/MethodLength:
|
|
102
105
|
Naming/PredicateName:
|
103
106
|
Exclude:
|
104
107
|
- lib/cryptopay/models/**/*
|
108
|
+
|
109
|
+
Naming/VariableNumber:
|
110
|
+
AllowedIdentifiers: line_1, line_2
|
data/README.md
CHANGED
@@ -19,7 +19,7 @@ For more information, please visit [Cryptopay API docs](https://developers.crypt
|
|
19
19
|
* [ExchangeTransfers](#exchangetransfers)
|
20
20
|
* [Invoices](#invoices)
|
21
21
|
* [Rates](#rates)
|
22
|
-
* [
|
22
|
+
* [Subscriptions](#subscriptions)
|
23
23
|
* [Transactions](#transactions)
|
24
24
|
* [Callbacks](#callbacks)
|
25
25
|
* [Development](#development)
|
@@ -468,22 +468,63 @@ result = client.rates.retrieve(base_currency, quote_currency)
|
|
468
468
|
p result # => <RateResult data=...>
|
469
469
|
```
|
470
470
|
|
471
|
-
###
|
471
|
+
### Subscriptions
|
472
472
|
|
473
|
-
[Risks API docs](https://developers.cryptopay.me/guides/risks)
|
474
473
|
|
475
|
-
####
|
474
|
+
#### Cancel a subscription
|
476
475
|
|
477
476
|
|
478
477
|
```ruby
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
478
|
+
subscription_id = 'de37fb63-986b-4f83-bf9f-612734316fdc'
|
479
|
+
|
480
|
+
result = client.subscriptions.cancel(subscription_id)
|
481
|
+
p result # => <SubscriptionResult data=...>
|
482
|
+
```
|
483
|
+
|
484
|
+
#### Create a subscription
|
485
|
+
|
486
|
+
|
487
|
+
```ruby
|
488
|
+
params = Cryptopay::SubscriptionParams.new(
|
489
|
+
name: 'Subscription name',
|
490
|
+
amount: '100.0',
|
491
|
+
currency: 'EUR',
|
492
|
+
period: 'month',
|
493
|
+
period_quantity: 3,
|
494
|
+
payer_email: 'user@example.com',
|
495
|
+
starts_at: Time.now.utc + 7 * 24 * 3600
|
483
496
|
)
|
484
497
|
|
485
|
-
result = client.
|
486
|
-
p result # => <
|
498
|
+
result = client.subscriptions.create(params)
|
499
|
+
p result # => <SubscriptionResult data=...>
|
500
|
+
```
|
501
|
+
|
502
|
+
#### List subscriptions
|
503
|
+
|
504
|
+
|
505
|
+
```ruby
|
506
|
+
result = client.subscriptions.list
|
507
|
+
p result # => <SubscriptionListResult data=...>
|
508
|
+
```
|
509
|
+
|
510
|
+
#### Retrieve a subscription
|
511
|
+
|
512
|
+
|
513
|
+
```ruby
|
514
|
+
subscription_id = '64249ede-8969-4d5c-a042-806f9c3e7db3'
|
515
|
+
|
516
|
+
result = client.subscriptions.retrieve(subscription_id)
|
517
|
+
p result # => <SubscriptionResult data=...>
|
518
|
+
```
|
519
|
+
|
520
|
+
#### Retrieve a subscription by custom_id
|
521
|
+
|
522
|
+
|
523
|
+
```ruby
|
524
|
+
custom_id = 'PAYMENT-123'
|
525
|
+
|
526
|
+
result = client.subscriptions.retrieve_by_custom_id(custom_id)
|
527
|
+
p result # => <SubscriptionResult data=...>
|
487
528
|
```
|
488
529
|
|
489
530
|
### Transactions
|
@@ -26,6 +26,7 @@ module Cryptopay
|
|
26
26
|
end
|
27
27
|
|
28
28
|
# Create a withdrawal
|
29
|
+
# To create a withdrawal you need to use either `charged_amount`, `charged_amount_to_send` or `received_amount` parameters in your request body.
|
29
30
|
# @param coin_withdrawal_params [CoinWithdrawalParams]
|
30
31
|
# @param [Hash] opts the optional parameters
|
31
32
|
# @return [CoinWithdrawalResult]
|
@@ -88,6 +88,7 @@ module Cryptopay
|
|
88
88
|
# @param [Hash] opts the optional parameters
|
89
89
|
# @option opts [String] :customer_id The internal ID of your customer that the transaction relates to
|
90
90
|
# @option opts [String] :starting_after Pagination parameter. ID to start after
|
91
|
+
# @option opts [String] :subscription_id
|
91
92
|
# @return [InvoiceListResult]
|
92
93
|
def list(opts = {})
|
93
94
|
path = '/api/invoices'
|
@@ -95,6 +96,7 @@ module Cryptopay
|
|
95
96
|
query_params = {}
|
96
97
|
query_params[:customer_id] = opts[:customer_id] unless opts[:customer_id].nil?
|
97
98
|
query_params[:starting_after] = opts[:starting_after] unless opts[:starting_after].nil?
|
99
|
+
query_params[:subscription_id] = opts[:subscription_id] unless opts[:subscription_id].nil?
|
98
100
|
|
99
101
|
req = Request.new(
|
100
102
|
method: :get,
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Auto-generated file
|
4
|
+
# DO NOT EDIT
|
5
|
+
|
6
|
+
module Cryptopay
|
7
|
+
class Subscriptions
|
8
|
+
def initialize(connection)
|
9
|
+
@connection = connection
|
10
|
+
end
|
11
|
+
|
12
|
+
# Cancel a subscription
|
13
|
+
# @param subscription_id [String] Subscription ID
|
14
|
+
# @param [Hash] opts the optional parameters
|
15
|
+
# @return [SubscriptionResult]
|
16
|
+
def cancel(subscription_id, _opts = {})
|
17
|
+
path = '/api/subscriptions/{subscription_id}/cancel'
|
18
|
+
path = path.sub('{subscription_id}', CGI.escape(subscription_id.to_s))
|
19
|
+
|
20
|
+
req = Request.new(
|
21
|
+
method: :post,
|
22
|
+
path: path
|
23
|
+
)
|
24
|
+
|
25
|
+
connection.call(req, return_type: SubscriptionResult)
|
26
|
+
end
|
27
|
+
|
28
|
+
# Create a subscription
|
29
|
+
# @param subscription_params [SubscriptionParams]
|
30
|
+
# @param [Hash] opts the optional parameters
|
31
|
+
# @return [SubscriptionResult]
|
32
|
+
def create(subscription_params, _opts = {})
|
33
|
+
path = '/api/subscriptions'
|
34
|
+
|
35
|
+
req = Request.new(
|
36
|
+
method: :post,
|
37
|
+
path: path,
|
38
|
+
body_params: subscription_params
|
39
|
+
)
|
40
|
+
|
41
|
+
connection.call(req, return_type: SubscriptionResult)
|
42
|
+
end
|
43
|
+
|
44
|
+
# List subscriptions
|
45
|
+
# @param [Hash] opts the optional parameters
|
46
|
+
# @option opts [String] :starting_after Pagination parameter. ID to start after
|
47
|
+
# @return [SubscriptionListResult]
|
48
|
+
def list(opts = {})
|
49
|
+
path = '/api/subscriptions'
|
50
|
+
|
51
|
+
query_params = {}
|
52
|
+
query_params[:starting_after] = opts[:starting_after] unless opts[:starting_after].nil?
|
53
|
+
|
54
|
+
req = Request.new(
|
55
|
+
method: :get,
|
56
|
+
path: path,
|
57
|
+
query_params: query_params
|
58
|
+
)
|
59
|
+
|
60
|
+
connection.call(req, return_type: SubscriptionListResult)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Retrieve a subscription
|
64
|
+
# @param subscription_id [String] Subscription ID
|
65
|
+
# @param [Hash] opts the optional parameters
|
66
|
+
# @return [SubscriptionResult]
|
67
|
+
def retrieve(subscription_id, _opts = {})
|
68
|
+
path = '/api/subscriptions/{subscription_id}'
|
69
|
+
path = path.sub('{subscription_id}', CGI.escape(subscription_id.to_s))
|
70
|
+
|
71
|
+
req = Request.new(
|
72
|
+
method: :get,
|
73
|
+
path: path
|
74
|
+
)
|
75
|
+
|
76
|
+
connection.call(req, return_type: SubscriptionResult)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Retrieve a subscription by custom_id
|
80
|
+
# @param custom_id [String]
|
81
|
+
# @param [Hash] opts the optional parameters
|
82
|
+
# @return [SubscriptionResult]
|
83
|
+
def retrieve_by_custom_id(custom_id, _opts = {})
|
84
|
+
path = '/api/subscriptions/custom_id/{custom_id}'
|
85
|
+
path = path.sub('{custom_id}', CGI.escape(custom_id.to_s))
|
86
|
+
|
87
|
+
req = Request.new(
|
88
|
+
method: :get,
|
89
|
+
path: path
|
90
|
+
)
|
91
|
+
|
92
|
+
connection.call(req, return_type: SubscriptionResult)
|
93
|
+
end
|
94
|
+
|
95
|
+
private
|
96
|
+
|
97
|
+
attr_reader :connection
|
98
|
+
end
|
99
|
+
end
|
data/lib/cryptopay/client.rb
CHANGED
@@ -12,7 +12,8 @@ module Cryptopay
|
|
12
12
|
:customers,
|
13
13
|
:risks,
|
14
14
|
:callbacks,
|
15
|
-
:coins
|
15
|
+
:coins,
|
16
|
+
:subscriptions
|
16
17
|
|
17
18
|
def initialize(&block)
|
18
19
|
config = Config.new(&block)
|
@@ -34,8 +35,8 @@ module Cryptopay
|
|
34
35
|
@transactions = Transactions.new(connection)
|
35
36
|
@exchange_transfers = ExchangeTransfers.new(connection)
|
36
37
|
@customers = Customers.new(connection)
|
37
|
-
@risks = Risks.new(connection)
|
38
38
|
@coins = Coins.new(connection)
|
39
|
+
@subscriptions = Subscriptions.new(connection)
|
39
40
|
end
|
40
41
|
end
|
41
42
|
end
|
@@ -23,6 +23,14 @@ module Cryptopay
|
|
23
23
|
)
|
24
24
|
private_constant :ENCODER
|
25
25
|
|
26
|
+
# Builds the object from hash
|
27
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
28
|
+
# @return [Cryptopay::Account] Returns the model itself
|
29
|
+
def self.build_from_hash(data)
|
30
|
+
attributes = ENCODER.build_from_hash(data)
|
31
|
+
new(attributes)
|
32
|
+
end
|
33
|
+
|
26
34
|
# Initializes the object
|
27
35
|
# @param [Hash] attributes Model attributes in the form of hash
|
28
36
|
def initialize(attributes = {})
|
@@ -71,14 +79,6 @@ module Cryptopay
|
|
71
79
|
invalid_properties.empty?
|
72
80
|
end
|
73
81
|
|
74
|
-
# Builds the object from hash
|
75
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
76
|
-
# @return [Cryptopay::Account] Returns the model itself
|
77
|
-
def self.build_from_hash(data)
|
78
|
-
attributes = ENCODER.build_from_hash(data)
|
79
|
-
new(attributes)
|
80
|
-
end
|
81
|
-
|
82
82
|
# Returns the object in the form of hash
|
83
83
|
# @return [Hash] Returns the object in the form of hash
|
84
84
|
def to_hash
|
@@ -19,6 +19,14 @@ module Cryptopay
|
|
19
19
|
)
|
20
20
|
private_constant :ENCODER
|
21
21
|
|
22
|
+
# Builds the object from hash
|
23
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
24
|
+
# @return [Cryptopay::AccountListResult] Returns the model itself
|
25
|
+
def self.build_from_hash(data)
|
26
|
+
attributes = ENCODER.build_from_hash(data)
|
27
|
+
new(attributes)
|
28
|
+
end
|
29
|
+
|
22
30
|
# Initializes the object
|
23
31
|
# @param [Hash] attributes Model attributes in the form of hash
|
24
32
|
def initialize(attributes = {})
|
@@ -61,14 +69,6 @@ module Cryptopay
|
|
61
69
|
invalid_properties.empty?
|
62
70
|
end
|
63
71
|
|
64
|
-
# Builds the object from hash
|
65
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
66
|
-
# @return [Cryptopay::AccountListResult] Returns the model itself
|
67
|
-
def self.build_from_hash(data)
|
68
|
-
attributes = ENCODER.build_from_hash(data)
|
69
|
-
new(attributes)
|
70
|
-
end
|
71
|
-
|
72
72
|
# Returns the object in the form of hash
|
73
73
|
# @return [Hash] Returns the object in the form of hash
|
74
74
|
def to_hash
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Auto-generated file
|
4
|
+
# DO NOT EDIT
|
5
|
+
|
6
|
+
module Cryptopay
|
7
|
+
# Beneficiary information.
|
8
|
+
class Beneficiary
|
9
|
+
ENCODER = Encoder.new(
|
10
|
+
name: 'Cryptopay::Beneficiary',
|
11
|
+
attribute_map: {
|
12
|
+
'type': :type,
|
13
|
+
'name': :name,
|
14
|
+
'address': :address
|
15
|
+
},
|
16
|
+
types: {
|
17
|
+
'type': :BeneficiaryType,
|
18
|
+
'name': :String,
|
19
|
+
'address': :BeneficiaryAddress
|
20
|
+
},
|
21
|
+
nullables: []
|
22
|
+
)
|
23
|
+
private_constant :ENCODER
|
24
|
+
|
25
|
+
# Builds the object from hash
|
26
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
27
|
+
# @return [Cryptopay::Beneficiary] Returns the model itself
|
28
|
+
def self.build_from_hash(data)
|
29
|
+
attributes = ENCODER.build_from_hash(data)
|
30
|
+
new(attributes)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Initializes the object
|
34
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
35
|
+
def initialize(attributes = {})
|
36
|
+
@attributes = ENCODER.sanitize(attributes)
|
37
|
+
end
|
38
|
+
|
39
|
+
def type
|
40
|
+
@attributes[:type]
|
41
|
+
end
|
42
|
+
|
43
|
+
# The registered name of the company for a `legal_person` or the full name for a `natural_person`.
|
44
|
+
def name
|
45
|
+
@attributes[:name]
|
46
|
+
end
|
47
|
+
|
48
|
+
def address
|
49
|
+
@attributes[:address]
|
50
|
+
end
|
51
|
+
|
52
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
53
|
+
# @return Array for valid properties with the reasons
|
54
|
+
def invalid_properties
|
55
|
+
properties = []
|
56
|
+
|
57
|
+
properties.push('invalid value for "type", type cannot be nil.') if type.nil?
|
58
|
+
|
59
|
+
if !type.nil? && !%w[natural_person legal_person].include?(type)
|
60
|
+
properties.push('invalid value for type, must be one of "natural_person", "legal_person"')
|
61
|
+
end
|
62
|
+
|
63
|
+
properties.push('invalid value for "name", name cannot be nil.') if name.nil?
|
64
|
+
|
65
|
+
if name.to_s.length > 100
|
66
|
+
properties.push('invalid value for "name", the character length must be smaller than or equal to 100.')
|
67
|
+
end
|
68
|
+
|
69
|
+
pattern = Regexp.new(/^[a-zA-Z0-9\s-]+$/)
|
70
|
+
properties.push("invalid value for \"name\", must conform to the pattern #{pattern}.") if name !~ pattern
|
71
|
+
|
72
|
+
properties.push('invalid value for "address", address cannot be nil.') if address.nil?
|
73
|
+
|
74
|
+
address&.invalid_properties&.each do |prop|
|
75
|
+
properties.push("invalid value for \"address\": #{prop}")
|
76
|
+
end
|
77
|
+
|
78
|
+
properties
|
79
|
+
end
|
80
|
+
|
81
|
+
# Check to see if the all the properties in the model are valid
|
82
|
+
# @return true if the model is valid
|
83
|
+
def valid?
|
84
|
+
invalid_properties.empty?
|
85
|
+
end
|
86
|
+
|
87
|
+
# Returns the object in the form of hash
|
88
|
+
# @return [Hash] Returns the object in the form of hash
|
89
|
+
def to_hash
|
90
|
+
ENCODER.to_hash(@attributes)
|
91
|
+
end
|
92
|
+
|
93
|
+
def inspect
|
94
|
+
"#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Auto-generated file
|
4
|
+
# DO NOT EDIT
|
5
|
+
|
6
|
+
module Cryptopay
|
7
|
+
class BeneficiaryAddress
|
8
|
+
ENCODER = Encoder.new(
|
9
|
+
name: 'Cryptopay::BeneficiaryAddress',
|
10
|
+
attribute_map: {
|
11
|
+
'country': :country,
|
12
|
+
'city': :city,
|
13
|
+
'line_1': :line_1,
|
14
|
+
'line_2': :line_2,
|
15
|
+
'post_code': :post_code
|
16
|
+
},
|
17
|
+
types: {
|
18
|
+
'country': :String,
|
19
|
+
'city': :String,
|
20
|
+
'line_1': :String,
|
21
|
+
'line_2': :String,
|
22
|
+
'post_code': :String
|
23
|
+
},
|
24
|
+
nullables: []
|
25
|
+
)
|
26
|
+
private_constant :ENCODER
|
27
|
+
|
28
|
+
# Builds the object from hash
|
29
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
30
|
+
# @return [Cryptopay::BeneficiaryAddress] Returns the model itself
|
31
|
+
def self.build_from_hash(data)
|
32
|
+
attributes = ENCODER.build_from_hash(data)
|
33
|
+
new(attributes)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Initializes the object
|
37
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
38
|
+
def initialize(attributes = {})
|
39
|
+
@attributes = ENCODER.sanitize(attributes)
|
40
|
+
end
|
41
|
+
|
42
|
+
# The 2-letter ISO country code of the address.
|
43
|
+
def country
|
44
|
+
@attributes[:country]
|
45
|
+
end
|
46
|
+
|
47
|
+
# The city of the address.
|
48
|
+
def city
|
49
|
+
@attributes[:city]
|
50
|
+
end
|
51
|
+
|
52
|
+
# First line of the address.
|
53
|
+
def line_1
|
54
|
+
@attributes[:line_1]
|
55
|
+
end
|
56
|
+
|
57
|
+
# Second line of the address.
|
58
|
+
def line_2
|
59
|
+
@attributes[:line_2]
|
60
|
+
end
|
61
|
+
|
62
|
+
# Postal code of the address.
|
63
|
+
def post_code
|
64
|
+
@attributes[:post_code]
|
65
|
+
end
|
66
|
+
|
67
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
68
|
+
# @return Array for valid properties with the reasons
|
69
|
+
def invalid_properties
|
70
|
+
properties = []
|
71
|
+
|
72
|
+
properties.push('invalid value for "country", country cannot be nil.') if country.nil?
|
73
|
+
|
74
|
+
if country.to_s.length > 2
|
75
|
+
properties.push('invalid value for "country", the character length must be smaller than or equal to 2.')
|
76
|
+
end
|
77
|
+
|
78
|
+
if !city.nil? && city.to_s.length > 35
|
79
|
+
properties.push('invalid value for "city", the character length must be smaller than or equal to 35.')
|
80
|
+
end
|
81
|
+
|
82
|
+
if !line_1.nil? && line_1.to_s.length > 70
|
83
|
+
properties.push('invalid value for "line_1", the character length must be smaller than or equal to 70.')
|
84
|
+
end
|
85
|
+
|
86
|
+
if !line_2.nil? && line_2.to_s.length > 70
|
87
|
+
properties.push('invalid value for "line_2", the character length must be smaller than or equal to 70.')
|
88
|
+
end
|
89
|
+
|
90
|
+
if !post_code.nil? && post_code.to_s.length > 16
|
91
|
+
properties.push('invalid value for "post_code", the character length must be smaller than or equal to 16.')
|
92
|
+
end
|
93
|
+
|
94
|
+
properties
|
95
|
+
end
|
96
|
+
|
97
|
+
# Check to see if the all the properties in the model are valid
|
98
|
+
# @return true if the model is valid
|
99
|
+
def valid?
|
100
|
+
invalid_properties.empty?
|
101
|
+
end
|
102
|
+
|
103
|
+
# Returns the object in the form of hash
|
104
|
+
# @return [Hash] Returns the object in the form of hash
|
105
|
+
def to_hash
|
106
|
+
ENCODER.to_hash(@attributes)
|
107
|
+
end
|
108
|
+
|
109
|
+
def inspect
|
110
|
+
"#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Auto-generated file
|
4
|
+
# DO NOT EDIT
|
5
|
+
|
6
|
+
module Cryptopay
|
7
|
+
module BeneficiaryType
|
8
|
+
NATURAL_PERSON = 'natural_person'
|
9
|
+
LEGAL_PERSON = 'legal_person'
|
10
|
+
|
11
|
+
# Builds the enum from string
|
12
|
+
# @param [String] The enum value in the form of the string
|
13
|
+
# @return [String] The enum value
|
14
|
+
def self.build_from_hash(value)
|
15
|
+
value
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -10,7 +10,7 @@ module Cryptopay
|
|
10
10
|
|
11
11
|
# Builds the object
|
12
12
|
# @param [Mixed] Data to be matched against the list of oneOf items
|
13
|
-
# @return [Cryptopay::ChannelPaymentCallback, Cryptopay::CoinWithdrawalCallback, Cryptopay::InvoiceCallback, nil] Returns the model or nil
|
13
|
+
# @return [Cryptopay::ChannelPaymentCallback, Cryptopay::CoinWithdrawalCallback, Cryptopay::InvoiceCallback, Cryptopay::SubscriptionCallback, nil] Returns the model or nil
|
14
14
|
def self.build_from_hash(data)
|
15
15
|
case data[DISCRIMINATOR_NAME]
|
16
16
|
when 'ChannelPayment'
|
@@ -19,6 +19,8 @@ module Cryptopay
|
|
19
19
|
CoinWithdrawalCallback.build_from_hash(data)
|
20
20
|
when 'Invoice'
|
21
21
|
InvoiceCallback.build_from_hash(data)
|
22
|
+
when 'Subscription'
|
23
|
+
SubscriptionCallback.build_from_hash(data)
|
22
24
|
end
|
23
25
|
end
|
24
26
|
end
|
@@ -45,6 +45,14 @@ module Cryptopay
|
|
45
45
|
)
|
46
46
|
private_constant :ENCODER
|
47
47
|
|
48
|
+
# Builds the object from hash
|
49
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
50
|
+
# @return [Cryptopay::Channel] Returns the model itself
|
51
|
+
def self.build_from_hash(data)
|
52
|
+
attributes = ENCODER.build_from_hash(data)
|
53
|
+
new(attributes)
|
54
|
+
end
|
55
|
+
|
48
56
|
# Initializes the object
|
49
57
|
# @param [Hash] attributes Model attributes in the form of hash
|
50
58
|
def initialize(attributes = {})
|
@@ -155,14 +163,6 @@ module Cryptopay
|
|
155
163
|
invalid_properties.empty?
|
156
164
|
end
|
157
165
|
|
158
|
-
# Builds the object from hash
|
159
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
160
|
-
# @return [Cryptopay::Channel] Returns the model itself
|
161
|
-
def self.build_from_hash(data)
|
162
|
-
attributes = ENCODER.build_from_hash(data)
|
163
|
-
new(attributes)
|
164
|
-
end
|
165
|
-
|
166
166
|
# Returns the object in the form of hash
|
167
167
|
# @return [Hash] Returns the object in the form of hash
|
168
168
|
def to_hash
|
@@ -19,6 +19,14 @@ module Cryptopay
|
|
19
19
|
)
|
20
20
|
private_constant :ENCODER
|
21
21
|
|
22
|
+
# Builds the object from hash
|
23
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
24
|
+
# @return [Cryptopay::ChannelListResult] Returns the model itself
|
25
|
+
def self.build_from_hash(data)
|
26
|
+
attributes = ENCODER.build_from_hash(data)
|
27
|
+
new(attributes)
|
28
|
+
end
|
29
|
+
|
22
30
|
# Initializes the object
|
23
31
|
# @param [Hash] attributes Model attributes in the form of hash
|
24
32
|
def initialize(attributes = {})
|
@@ -61,14 +69,6 @@ module Cryptopay
|
|
61
69
|
invalid_properties.empty?
|
62
70
|
end
|
63
71
|
|
64
|
-
# Builds the object from hash
|
65
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
66
|
-
# @return [Cryptopay::ChannelListResult] Returns the model itself
|
67
|
-
def self.build_from_hash(data)
|
68
|
-
attributes = ENCODER.build_from_hash(data)
|
69
|
-
new(attributes)
|
70
|
-
end
|
71
|
-
|
72
72
|
# Returns the object in the form of hash
|
73
73
|
# @return [Hash] Returns the object in the form of hash
|
74
74
|
def to_hash
|
@@ -29,6 +29,14 @@ module Cryptopay
|
|
29
29
|
)
|
30
30
|
private_constant :ENCODER
|
31
31
|
|
32
|
+
# Builds the object from hash
|
33
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
34
|
+
# @return [Cryptopay::ChannelParams] Returns the model itself
|
35
|
+
def self.build_from_hash(data)
|
36
|
+
attributes = ENCODER.build_from_hash(data)
|
37
|
+
new(attributes)
|
38
|
+
end
|
39
|
+
|
32
40
|
# Initializes the object
|
33
41
|
# @param [Hash] attributes Model attributes in the form of hash
|
34
42
|
def initialize(attributes = {})
|
@@ -92,14 +100,6 @@ module Cryptopay
|
|
92
100
|
invalid_properties.empty?
|
93
101
|
end
|
94
102
|
|
95
|
-
# Builds the object from hash
|
96
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
97
|
-
# @return [Cryptopay::ChannelParams] Returns the model itself
|
98
|
-
def self.build_from_hash(data)
|
99
|
-
attributes = ENCODER.build_from_hash(data)
|
100
|
-
new(attributes)
|
101
|
-
end
|
102
|
-
|
103
103
|
# Returns the object in the form of hash
|
104
104
|
# @return [Hash] Returns the object in the form of hash
|
105
105
|
def to_hash
|