cryptopay-ruby 1.0.0 → 2.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: 565560b9bd60b4439f410a759ef4c51fce1104e29b887a5a70f579f583a96a7a
4
- data.tar.gz: a48fe75139c6244dc20fa430633329d7015debd3760bcb38d48e6fa350bf3593
3
+ metadata.gz: fb93a5d512a5c50963761dae68e58c82f02d97ac0b645f3a9850ed0c098d30a0
4
+ data.tar.gz: 0b2590bd8ddebe472f255fd777214fb095f182b28ba05ea993df4217b10dcf98
5
5
  SHA512:
6
- metadata.gz: 3c2bac187a5dfc48dcef7691025ac33dd4bf79dd6235f8429f5c827a90e5b4b18ed7a80d6cdb1cdebce6d1974b707aed284a79ca796a8251056113ca1b0e305a
7
- data.tar.gz: 4d836911974b0d7a971d5898c678a245e69f0b1b5f4b70aa8977738fbcd68712902161c8da06323b4a280bcf663dd1fbb536efc9031874aedd03b7ce49d915e6
6
+ metadata.gz: 502490fdeb6d82851be75a541838219ee3058de3836ee1abb8381b8fe3df1236cc71e8149d27f38fb76907fd1f777ea9fab1a596d3efec5a0a3b2e8574d87660
7
+ data.tar.gz: 3aaaa5115bee1d8983a756bd59425e656ce7a1f1607fbd324803c09e1cbccd3aa897f021f71992e8fa0286c1724a6cad7b3b20aa51d413b20be97c73b63666aa
data/README.md CHANGED
@@ -265,7 +265,7 @@ Customer objects allow you to reject High-Risk transactions automatically, and t
265
265
 
266
266
  ```ruby
267
267
  params = Cryptopay::CustomerParams.new(
268
- id: 'e2abd0899bada2814e6f6aa08aae61f8',
268
+ id: '500b71259c48d4e212693a21e0d10c60',
269
269
  currency: 'EUR'
270
270
  )
271
271
 
@@ -295,11 +295,15 @@ p result # => <CustomerResult data=...>
295
295
 
296
296
 
297
297
  ```ruby
298
- customer_id = "CUSTOMER-123"
298
+ customer_id = 'CUSTOMER-123'
299
299
  params = Cryptopay::CustomerUpdateParams.new(
300
- refund_addresses: {
301
- 'BTC' => '2N9wPGx67zdSeAbXi15qHgoZ9Hb9Uxhd2uQ'
302
- }
300
+ addresses: [
301
+ Cryptopay::CustomerAddress.new(
302
+ address: '2N9wPGx67zdSeAbXi15qHgoZ9Hb9Uxhd2uQ',
303
+ currency: 'BTC',
304
+ network: 'bitcoin'
305
+ )
306
+ ]
303
307
  )
304
308
 
305
309
  result = client.customers.update(customer_id, params)
data/bin/console CHANGED
@@ -3,9 +3,10 @@
3
3
 
4
4
  require 'bundler/setup'
5
5
  require 'dotenv/load'
6
- require 'cryptopay'
7
6
  require 'pry-byebug'
8
7
 
8
+ require 'cryptopay'
9
+
9
10
  client = Cryptopay::Client.new do |config|
10
11
  config.api_url = Cryptopay::SANDBOX
11
12
  config.api_key = ENV.fetch('API_KEY')
@@ -10,12 +10,12 @@ module Cryptopay
10
10
  attribute_map: {
11
11
  'id': :id,
12
12
  'currency': :currency,
13
- 'refund_addresses': :refund_addresses
13
+ 'addresses': :addresses
14
14
  },
15
15
  types: {
16
16
  'id': :String,
17
17
  'currency': :String,
18
- 'refund_addresses': :'Hash<String, String>'
18
+ 'addresses': :'Array<CustomerAddress>'
19
19
  },
20
20
  nullables: []
21
21
  )
@@ -38,8 +38,8 @@ module Cryptopay
38
38
  end
39
39
 
40
40
  # The list of refund addresses where Cryptopay will refund High-Risk transactions to
41
- def refund_addresses
42
- @attributes[:refund_addresses]
41
+ def addresses
42
+ @attributes[:addresses]
43
43
  end
44
44
 
45
45
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -51,7 +51,13 @@ module Cryptopay
51
51
 
52
52
  properties.push('invalid value for "currency", currency cannot be nil.') if currency.nil?
53
53
 
54
- properties.push('invalid value for "refund_addresses", refund_addresses cannot be nil.') if refund_addresses.nil?
54
+ properties.push('invalid value for "addresses", addresses cannot be nil.') if addresses.nil?
55
+
56
+ addresses&.each_with_index do |item, index|
57
+ item.invalid_properties.each do |prop|
58
+ properties.push("invalid value for \"addresses.#{index}\": #{prop}")
59
+ end
60
+ end
55
61
 
56
62
  properties
57
63
  end
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-generated file
4
+ # DO NOT EDIT
5
+
6
+ module Cryptopay
7
+ class CustomerAddress
8
+ ENCODER = Encoder.new(
9
+ name: 'Cryptopay::CustomerAddress',
10
+ attribute_map: {
11
+ 'address': :address,
12
+ 'currency': :currency,
13
+ 'network': :network
14
+ },
15
+ types: {
16
+ 'address': :String,
17
+ 'currency': :String,
18
+ 'network': :String
19
+ },
20
+ nullables: []
21
+ )
22
+ private_constant :ENCODER
23
+
24
+ # Initializes the object
25
+ # @param [Hash] attributes Model attributes in the form of hash
26
+ def initialize(attributes = {})
27
+ @attributes = ENCODER.sanitize(attributes)
28
+ end
29
+
30
+ # Cryptocurrency address
31
+ def address
32
+ @attributes[:address]
33
+ end
34
+
35
+ # Cryptocurrency name
36
+ def currency
37
+ @attributes[:currency]
38
+ end
39
+
40
+ # Cryptocurrency network
41
+ def network
42
+ @attributes[:network]
43
+ end
44
+
45
+ # Show invalid properties with the reasons. Usually used together with valid?
46
+ # @return Array for valid properties with the reasons
47
+ def invalid_properties
48
+ properties = []
49
+
50
+ properties.push('invalid value for "address", address cannot be nil.') if address.nil?
51
+
52
+ properties.push('invalid value for "currency", currency cannot be nil.') if currency.nil?
53
+
54
+ properties.push('invalid value for "network", network cannot be nil.') if network.nil?
55
+
56
+ properties
57
+ end
58
+
59
+ # Check to see if the all the properties in the model are valid
60
+ # @return true if the model is valid
61
+ def valid?
62
+ invalid_properties.empty?
63
+ end
64
+
65
+ # Builds the object from hash
66
+ # @param [Hash] attributes Model attributes in the form of hash
67
+ # @return [Cryptopay::CustomerAddress] Returns the model itself
68
+ def self.build_from_hash(data)
69
+ attributes = ENCODER.build_from_hash(data)
70
+ new(attributes)
71
+ end
72
+
73
+ # Returns the object in the form of hash
74
+ # @return [Hash] Returns the object in the form of hash
75
+ def to_hash
76
+ ENCODER.to_hash(@attributes)
77
+ end
78
+
79
+ def inspect
80
+ "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
81
+ end
82
+ end
83
+ end
@@ -10,12 +10,12 @@ module Cryptopay
10
10
  attribute_map: {
11
11
  'id': :id,
12
12
  'currency': :currency,
13
- 'refund_addresses': :refund_addresses
13
+ 'addresses': :addresses
14
14
  },
15
15
  types: {
16
16
  'id': :String,
17
17
  'currency': :String,
18
- 'refund_addresses': :'Hash<String, String>'
18
+ 'addresses': :'Array<CustomerAddress>'
19
19
  },
20
20
  nullables: []
21
21
  )
@@ -37,9 +37,9 @@ module Cryptopay
37
37
  @attributes[:currency]
38
38
  end
39
39
 
40
- # This object allows you to specify 1 cryptocurrency address for each type of supported cryptocurrencies i.e. BTC, ETH, XRP, LTC and BCH. In case Cryptopay detects a High-Risk transaction, such transaction will not be processed. Instead, it will be sent to the address specified for respective cryptocurrency. If you do not specify any addresses here, High-Risk payments will be put on hold
41
- def refund_addresses
42
- @attributes[:refund_addresses]
40
+ # This array allows you to specify 1 cryptocurrency address for each type of supported cryptocurrencies i.e. BTC, ETH, XRP, LTC and BCH. In case Cryptopay detects a High-Risk transaction, such transaction will not be processed. Instead, it will be sent to the address specified for respective cryptocurrency. If you do not specify any addresses here, High-Risk payments will be put on hold
41
+ def addresses
42
+ @attributes[:addresses]
43
43
  end
44
44
 
45
45
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -51,6 +51,12 @@ module Cryptopay
51
51
 
52
52
  properties.push('invalid value for "currency", currency cannot be nil.') if currency.nil?
53
53
 
54
+ addresses&.each_with_index do |item, index|
55
+ item.invalid_properties.each do |prop|
56
+ properties.push("invalid value for \"addresses.#{index}\": #{prop}")
57
+ end
58
+ end
59
+
54
60
  properties
55
61
  end
56
62
 
@@ -9,11 +9,11 @@ module Cryptopay
9
9
  name: 'Cryptopay::CustomerUpdateParams',
10
10
  attribute_map: {
11
11
  'currency': :currency,
12
- 'refund_addresses': :refund_addresses
12
+ 'addresses': :addresses
13
13
  },
14
14
  types: {
15
15
  'currency': :String,
16
- 'refund_addresses': :'Hash<String, String>'
16
+ 'addresses': :'Array<CustomerAddress>'
17
17
  },
18
18
  nullables: []
19
19
  )
@@ -30,15 +30,23 @@ module Cryptopay
30
30
  @attributes[:currency]
31
31
  end
32
32
 
33
- # This object allows you to specify 1 cryptocurrency address for each type of supported cryptocurrencies i.e. BTC, ETH, XRP, LTC and BCH. In case Cryptopay detects a High-Risk transaction, such transaction will not be processed. Instead, it will be sent to the address specified for respective cryptocurrency. If you do not specify any addresses here, High-Risk payments will be put on hold
34
- def refund_addresses
35
- @attributes[:refund_addresses]
33
+ # This array allows you to specify 1 cryptocurrency address for each type of supported cryptocurrencies i.e. BTC, ETH, XRP, LTC and BCH. In case Cryptopay detects a High-Risk transaction, such transaction will not be processed. Instead, it will be sent to the address specified for respective cryptocurrency. If you do not specify any addresses here, High-Risk payments will be put on hold
34
+ def addresses
35
+ @attributes[:addresses]
36
36
  end
37
37
 
38
38
  # Show invalid properties with the reasons. Usually used together with valid?
39
39
  # @return Array for valid properties with the reasons
40
40
  def invalid_properties
41
- []
41
+ properties = []
42
+
43
+ addresses&.each_with_index do |item, index|
44
+ item.invalid_properties.each do |prop|
45
+ properties.push("invalid value for \"addresses.#{index}\": #{prop}")
46
+ end
47
+ end
48
+
49
+ properties
42
50
  end
43
51
 
44
52
  # Check to see if the all the properties in the model are valid
@@ -34,6 +34,7 @@ require 'cryptopay/models/coin_withdrawal_result'
34
34
  require 'cryptopay/models/coin_withdrawal_status'
35
35
  require 'cryptopay/models/coin_withdrawals_config'
36
36
  require 'cryptopay/models/customer'
37
+ require 'cryptopay/models/customer_address'
37
38
  require 'cryptopay/models/customer_list_result'
38
39
  require 'cryptopay/models/customer_params'
39
40
  require 'cryptopay/models/customer_result'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cryptopay
4
- VERSION = '1.0.0'
4
+ VERSION = '2.0.0'
5
5
  end
data/lib/cryptopay.rb CHANGED
@@ -2,23 +2,22 @@
2
2
 
3
3
  require 'base64'
4
4
  require 'cgi'
5
+ require 'date'
5
6
  require 'faraday'
6
7
  require 'json'
7
- require 'date'
8
8
  require 'time'
9
9
 
10
- # Common files
11
- require 'cryptopay/version'
12
- require 'cryptopay/encoder'
13
- require 'cryptopay/require'
14
- require 'cryptopay/config'
15
10
  require 'cryptopay/authentication'
16
- require 'cryptopay/connection'
17
- require 'cryptopay/types'
18
- require 'cryptopay/request'
19
11
  require 'cryptopay/callbacks'
20
12
  require 'cryptopay/client'
13
+ require 'cryptopay/config'
14
+ require 'cryptopay/connection'
15
+ require 'cryptopay/encoder'
21
16
  require 'cryptopay/errors'
17
+ require 'cryptopay/request'
18
+ require 'cryptopay/require'
19
+ require 'cryptopay/types'
20
+ require 'cryptopay/version'
22
21
 
23
22
  module Cryptopay
24
23
  PRODUCTION = 'https://business.cryptopay.me'
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: 1.0.0
4
+ version: 2.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: 2022-11-01 00:00:00.000000000 Z
11
+ date: 2022-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -192,6 +192,7 @@ files:
192
192
  - lib/cryptopay/models/coin_withdrawal_status.rb
193
193
  - lib/cryptopay/models/coin_withdrawals_config.rb
194
194
  - lib/cryptopay/models/customer.rb
195
+ - lib/cryptopay/models/customer_address.rb
195
196
  - lib/cryptopay/models/customer_list_result.rb
196
197
  - lib/cryptopay/models/customer_params.rb
197
198
  - lib/cryptopay/models/customer_result.rb
@@ -258,7 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
258
259
  - !ruby/object:Gem::Version
259
260
  version: '0'
260
261
  requirements: []
261
- rubygems_version: 3.0.3
262
+ rubygems_version: 3.0.3.1
262
263
  signing_key:
263
264
  specification_version: 4
264
265
  summary: The official Ruby gem for the Cryptopay API