cryptopay-ruby 2.1.0 → 3.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 18a89097b66be19ae3889c0c2279574f5b2aa917d6d66a5ace4547cd2877538b
4
- data.tar.gz: b259cd7c0ef3ebe5e8457118533e3abeb5bd2c033f14b549657c7fcc844015dd
3
+ metadata.gz: ef84c8ae3650cba4ab5f4fce1e22df6e9762b9dce8cfda0671fb141eee38efc5
4
+ data.tar.gz: f740121751b90551e1caa0108fac4fab7570b9c8e08b8c2714e9dae6b42fb34d
5
5
  SHA512:
6
- metadata.gz: 7f4a1fa54fd517d1288a386e115ac2634293c95d0fb1af44e1e4f6af51671d215a42dd51bb4fc5fce201533f3992703a5104e24ef378830e67dfc4bafe704c67
7
- data.tar.gz: 411446bfe02bbf5ccac2c906524451bce90c0348ade8da2751038cf8abb707ca916426ed041bc1a8509a835a5473c20e594c3d4e5b0cd1b73c05b2bb344ee8c4
6
+ metadata.gz: 8833dd9bdba6ba96d906d3cb945e320cabeb7a94a625aa8eba15f0c501af05dd396e44678077246f2d6d7eaf9acb93b9d9552d65dc138c9234c26d86e4eb01c5
7
+ data.tar.gz: 50d32b002e455292b9ec8f3a47961fe92829862d9cec35ebed1f80decadb6940f016ad62eedff175bc3c182af7d93e6279982e89fbc5497babb70821dd72665a
data/.rubocop.yml CHANGED
@@ -105,3 +105,6 @@ Metrics/MethodLength:
105
105
  Naming/PredicateName:
106
106
  Exclude:
107
107
  - lib/cryptopay/models/**/*
108
+
109
+ Naming/VariableNumber:
110
+ AllowedIdentifiers: line_1, line_2
data/README.md CHANGED
@@ -19,7 +19,6 @@ For more information, please visit [Cryptopay API docs](https://developers.crypt
19
19
  * [ExchangeTransfers](#exchangetransfers)
20
20
  * [Invoices](#invoices)
21
21
  * [Rates](#rates)
22
- * [Risks](#risks)
23
22
  * [Subscriptions](#subscriptions)
24
23
  * [Transactions](#transactions)
25
24
  * [Callbacks](#callbacks)
@@ -205,6 +204,19 @@ params = Cryptopay::CoinWithdrawalParams.new(
205
204
  force_commit: true
206
205
  )
207
206
 
207
+ result = client.coin_withdrawals.create(params)
208
+ p result # => <CoinWithdrawalResult data=...>
209
+ # New amounts example
210
+ params = Cryptopay::CoinWithdrawalParams.new(
211
+ address: '2Mz3bcjSVHG8uQJpNjmCxp24VdTjwaqmFcJ',
212
+ amount: '100.0',
213
+ amount_currency: 'EUR',
214
+ received_currency: 'BTC',
215
+ amount_includes_processing_fee: true,
216
+ amount_includes_network_fee: true,
217
+ force_commit: true
218
+ )
219
+
208
220
  result = client.coin_withdrawals.create(params)
209
221
  p result # => <CoinWithdrawalResult data=...>
210
222
  ```
@@ -403,9 +415,8 @@ p result # => <InvoiceRecalculationResult data=...>
403
415
 
404
416
  ```ruby
405
417
  invoice_id = '7e274430-e20f-4321-8748-20824287ae44'
406
- invoice_refund_params = Cryptopay::InvoiceRefundParams.new(address: '0xf3532c1fd002665ec54d46a50787e0c69c76cd44')
407
418
 
408
- result = client.invoices.create_refund(invoice_id, invoice_refund_params)
419
+ result = client.invoices.create_refund(invoice_id)
409
420
  p result # => <InvoiceRefundResult data=...>
410
421
  ```
411
422
 
@@ -469,24 +480,6 @@ result = client.rates.retrieve(base_currency, quote_currency)
469
480
  p result # => <RateResult data=...>
470
481
  ```
471
482
 
472
- ### Risks
473
-
474
- [Risks API docs](https://developers.cryptopay.me/guides/risks)
475
-
476
- #### Score a coin address
477
-
478
-
479
- ```ruby
480
- params = Cryptopay::RiskParams.new(
481
- address: '2N9wPGx67zdSeAbXi15qHgoZ9Hb9Uxhd2uQ',
482
- currency: 'BTC',
483
- type: 'source_of_funds'
484
- )
485
-
486
- result = client.risks.score(params)
487
- p result # => <RiskResult data=...>
488
- ```
489
-
490
483
  ### Subscriptions
491
484
 
492
485
 
@@ -26,6 +26,7 @@ module Cryptopay
26
26
  end
27
27
 
28
28
  # Create a withdrawal
29
+ # To create a withdrawal you must provide either the legacy amount fields (&#x60;charged_amount&#x60;, &#x60;charged_amount_to_send&#x60;, &#x60;received_amount&#x60;) or the new amount fields (&#x60;amount&#x60;, &#x60;amount_currency&#x60;, &#x60;amount_includes_processing_fee&#x60;, &#x60;amount_includes_network_fee&#x60;). Mixing legacy and new amount fields in one request is not allowed.
29
30
  # @param coin_withdrawal_params [CoinWithdrawalParams]
30
31
  # @param [Hash] opts the optional parameters
31
32
  # @return [CoinWithdrawalResult]
@@ -65,19 +65,19 @@ module Cryptopay
65
65
  end
66
66
 
67
67
  # Create invoice refund
68
- # This endpoint allows you to create invoice refunds.
68
+ # This endpoint allows you to create invoice refunds to your cryptocurrency account.
69
69
  # @param invoice_id [String] Invoice ID
70
- # @param invoice_refund_params [InvoiceRefundParams]
71
70
  # @param [Hash] opts the optional parameters
71
+ # @option opts [Object] :body
72
72
  # @return [InvoiceRefundResult]
73
- def create_refund(invoice_id, invoice_refund_params, _opts = {})
73
+ def create_refund(invoice_id, opts = {})
74
74
  path = '/api/invoices/{invoice_id}/refunds'
75
75
  path = path.sub('{invoice_id}', CGI.escape(invoice_id.to_s))
76
76
 
77
77
  req = Request.new(
78
78
  method: :post,
79
79
  path: path,
80
- body_params: invoice_refund_params
80
+ body_params: opts[:body] || {}
81
81
  )
82
82
 
83
83
  connection.call(req, return_type: InvoiceRefundResult)
@@ -26,7 +26,7 @@ module Cryptopay
26
26
 
27
27
  private
28
28
 
29
- def setup_apis(connection) # rubocop:disable Metrics/MethodLength
29
+ def setup_apis(connection)
30
30
  @invoices = Invoices.new(connection)
31
31
  @rates = Rates.new(connection)
32
32
  @coin_withdrawals = CoinWithdrawals.new(connection)
@@ -35,7 +35,6 @@ module Cryptopay
35
35
  @transactions = Transactions.new(connection)
36
36
  @exchange_transfers = ExchangeTransfers.new(connection)
37
37
  @customers = Customers.new(connection)
38
- @risks = Risks.new(connection)
39
38
  @coins = Coins.new(connection)
40
39
  @subscriptions = Subscriptions.new(connection)
41
40
  end
@@ -0,0 +1,92 @@
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`. Note that only following symbols will be stored, regardless of the input value: letters of any language, digits `0-9`, symbols `&` `!` `,` `.` `-` and single spaces. Symbols `\\`, `/`, newlines and tabs will be replaced with spaces. Everything else will be removed, including double spaces and spaces in the end.
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
+ address&.invalid_properties&.each do |prop|
70
+ properties.push("invalid value for \"address\": #{prop}")
71
+ end
72
+
73
+ properties
74
+ end
75
+
76
+ # Check to see if the all the properties in the model are valid
77
+ # @return true if the model is valid
78
+ def valid?
79
+ invalid_properties.empty?
80
+ end
81
+
82
+ # Returns the object in the form of hash
83
+ # @return [Hash] Returns the object in the form of hash
84
+ def to_hash
85
+ ENCODER.to_hash(@attributes)
86
+ end
87
+
88
+ def inspect
89
+ "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
90
+ end
91
+ end
92
+ end
@@ -0,0 +1,111 @@
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
+ if !country.nil? && country.to_s.length > 2
73
+ properties.push('invalid value for "country", the character length must be smaller than or equal to 2.')
74
+ end
75
+
76
+ if !city.nil? && city.to_s.length > 35
77
+ properties.push('invalid value for "city", the character length must be smaller than or equal to 35.')
78
+ end
79
+
80
+ if !line_1.nil? && line_1.to_s.length > 70
81
+ properties.push('invalid value for "line_1", the character length must be smaller than or equal to 70.')
82
+ end
83
+
84
+ if !line_2.nil? && line_2.to_s.length > 70
85
+ properties.push('invalid value for "line_2", the character length must be smaller than or equal to 70.')
86
+ end
87
+
88
+ if !post_code.nil? && post_code.to_s.length > 16
89
+ properties.push('invalid value for "post_code", the character length must be smaller than or equal to 16.')
90
+ end
91
+
92
+ properties
93
+ end
94
+
95
+ # Check to see if the all the properties in the model are valid
96
+ # @return true if the model is valid
97
+ def valid?
98
+ invalid_properties.empty?
99
+ end
100
+
101
+ # Returns the object in the form of hash
102
+ # @return [Hash] Returns the object in the form of hash
103
+ def to_hash
104
+ ENCODER.to_hash(@attributes)
105
+ end
106
+
107
+ def inspect
108
+ "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
109
+ end
110
+ end
111
+ 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
@@ -18,7 +18,13 @@ module Cryptopay
18
18
  'custom_id': :custom_id,
19
19
  'customer_id': :customer_id,
20
20
  'network_fee_level': :network_fee_level,
21
- 'force_commit': :force_commit
21
+ 'force_commit': :force_commit,
22
+ 'travel_rule_compliant': :travel_rule_compliant,
23
+ 'beneficiary': :beneficiary,
24
+ 'amount': :amount,
25
+ 'amount_currency': :amount_currency,
26
+ 'amount_includes_processing_fee': :amount_includes_processing_fee,
27
+ 'amount_includes_network_fee': :amount_includes_network_fee
22
28
  },
23
29
  types: {
24
30
  'address': :String,
@@ -31,7 +37,13 @@ module Cryptopay
31
37
  'custom_id': :String,
32
38
  'customer_id': :String,
33
39
  'network_fee_level': :NetworkFeeLevel,
34
- 'force_commit': :Boolean
40
+ 'force_commit': :Boolean,
41
+ 'travel_rule_compliant': :Boolean,
42
+ 'beneficiary': :Beneficiary,
43
+ 'amount': :Decimal,
44
+ 'amount_currency': :String,
45
+ 'amount_includes_processing_fee': :Boolean,
46
+ 'amount_includes_network_fee': :Boolean
35
47
  },
36
48
  nullables: %i[
37
49
  charged_amount
@@ -75,17 +87,17 @@ module Cryptopay
75
87
  @attributes[:network]
76
88
  end
77
89
 
78
- # All applicable fees will be deducted from this amount before processing a transaction instead of adding them on top it
90
+ # The exact amount to debit from your account in `charged_currency`. All applicable fees will be deducted from this amount before processing a transaction instead of adding them on top it.
79
91
  def charged_amount
80
92
  @attributes[:charged_amount]
81
93
  end
82
94
 
83
- # An exact transaction amount to send. All applicable fees will be added on top of this amount and debited from your account
95
+ # The exact transaction amount to send in `charged_currency`. All applicable fees will be added on top of this amount and debited from your account.
84
96
  def charged_amount_to_send
85
97
  @attributes[:charged_amount_to_send]
86
98
  end
87
99
 
88
- # An exact transaction amount to send. All applicable fees will be added on top of this amount and debited from your account. Use this parameter if you want to send a transaction from cryptocurrency accounts only
100
+ # The exact transaction amount to send in `received_currency`. All applicable fees will be added on top of this amount and debited from your account.
89
101
  def received_amount
90
102
  @attributes[:received_amount]
91
103
  end
@@ -109,6 +121,35 @@ module Cryptopay
109
121
  @attributes[:force_commit]
110
122
  end
111
123
 
124
+ # Is `false` if omitted. Set `true` to turn on beneficiary data validations
125
+ def travel_rule_compliant
126
+ @attributes[:travel_rule_compliant]
127
+ end
128
+
129
+ def beneficiary
130
+ @attributes[:beneficiary]
131
+ end
132
+
133
+ # Transaction amount for new calculation
134
+ def amount
135
+ @attributes[:amount]
136
+ end
137
+
138
+ # An currency of the transaction amount
139
+ def amount_currency
140
+ @attributes[:amount_currency]
141
+ end
142
+
143
+ # Whether the amount includes processing fee
144
+ def amount_includes_processing_fee
145
+ @attributes[:amount_includes_processing_fee]
146
+ end
147
+
148
+ # Whether the amount includes network fee
149
+ def amount_includes_network_fee
150
+ @attributes[:amount_includes_network_fee]
151
+ end
152
+
112
153
  # Show invalid properties with the reasons. Usually used together with valid?
113
154
  # @return Array for valid properties with the reasons
114
155
  def invalid_properties
@@ -126,6 +167,10 @@ module Cryptopay
126
167
  properties.push('invalid value for network_fee_level, must be one of "fast", "average", "slow"')
127
168
  end
128
169
 
170
+ beneficiary&.invalid_properties&.each do |prop|
171
+ properties.push("invalid value for \"beneficiary\": #{prop}")
172
+ end
173
+
129
174
  properties
130
175
  end
131
176
 
@@ -6,6 +6,9 @@
6
6
  # Models
7
7
  require 'cryptopay/models/account'
8
8
  require 'cryptopay/models/account_list_result'
9
+ require 'cryptopay/models/beneficiary'
10
+ require 'cryptopay/models/beneficiary_address'
11
+ require 'cryptopay/models/beneficiary_type'
9
12
  require 'cryptopay/models/callback'
10
13
  require 'cryptopay/models/channel'
11
14
  require 'cryptopay/models/channel_list_result'
@@ -53,7 +56,6 @@ require 'cryptopay/models/invoice_recalculation_params'
53
56
  require 'cryptopay/models/invoice_recalculation_result'
54
57
  require 'cryptopay/models/invoice_refund'
55
58
  require 'cryptopay/models/invoice_refund_list_result'
56
- require 'cryptopay/models/invoice_refund_params'
57
59
  require 'cryptopay/models/invoice_refund_result'
58
60
  require 'cryptopay/models/invoice_result'
59
61
  require 'cryptopay/models/invoice_status'
@@ -69,9 +71,6 @@ require 'cryptopay/models/rate_result'
69
71
  require 'cryptopay/models/rates_result'
70
72
  require 'cryptopay/models/risk'
71
73
  require 'cryptopay/models/risk_level'
72
- require 'cryptopay/models/risk_params'
73
- require 'cryptopay/models/risk_result'
74
- require 'cryptopay/models/risk_type'
75
74
  require 'cryptopay/models/subscription'
76
75
  require 'cryptopay/models/subscription_callback'
77
76
  require 'cryptopay/models/subscription_callback_event'
@@ -93,6 +92,5 @@ require 'cryptopay/api/customers'
93
92
  require 'cryptopay/api/exchange_transfers'
94
93
  require 'cryptopay/api/invoices'
95
94
  require 'cryptopay/api/rates'
96
- require 'cryptopay/api/risks'
97
95
  require 'cryptopay/api/subscriptions'
98
96
  require 'cryptopay/api/transactions'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cryptopay
4
- VERSION = '2.1.0'
4
+ VERSION = '3.0.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cryptopay-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cryptopay
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-18 00:00:00.000000000 Z
11
+ date: 2025-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -165,6 +165,9 @@ files:
165
165
  - lib/cryptopay/errors.rb
166
166
  - lib/cryptopay/models/account.rb
167
167
  - lib/cryptopay/models/account_list_result.rb
168
+ - lib/cryptopay/models/beneficiary.rb
169
+ - lib/cryptopay/models/beneficiary_address.rb
170
+ - lib/cryptopay/models/beneficiary_type.rb
168
171
  - lib/cryptopay/models/callback.rb
169
172
  - lib/cryptopay/models/channel.rb
170
173
  - lib/cryptopay/models/channel_list_result.rb
@@ -268,7 +271,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
268
271
  - !ruby/object:Gem::Version
269
272
  version: '0'
270
273
  requirements: []
271
- rubygems_version: 3.3.20
274
+ rubygems_version: 3.3.26
272
275
  signing_key:
273
276
  specification_version: 4
274
277
  summary: The official Ruby gem for the Cryptopay API