cryptopay-ruby 0.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +27 -15
  3. data/bin/console +2 -1
  4. data/cryptopay.gemspec +7 -7
  5. data/lib/cryptopay/api/coin_withdrawals.rb +7 -2
  6. data/lib/cryptopay/api/coins.rb +30 -0
  7. data/lib/cryptopay/client.rb +3 -1
  8. data/lib/cryptopay/models/account.rb +4 -0
  9. data/lib/cryptopay/models/account_list_result.rb +14 -2
  10. data/lib/cryptopay/models/channel.rb +20 -0
  11. data/lib/cryptopay/models/channel_params.rb +11 -0
  12. data/lib/cryptopay/models/channel_payment.rb +20 -0
  13. data/lib/cryptopay/models/channel_payment_callback.rb +0 -4
  14. data/lib/cryptopay/models/channel_update_params.rb +2 -0
  15. data/lib/cryptopay/models/channels_config.rb +64 -0
  16. data/lib/cryptopay/models/coin.rb +94 -0
  17. data/lib/cryptopay/models/coin_destination_tag.rb +72 -0
  18. data/lib/cryptopay/models/coin_list_result.rb +70 -0
  19. data/lib/cryptopay/models/coin_network.rb +128 -0
  20. data/lib/cryptopay/models/coin_withdrawal.rb +20 -0
  21. data/lib/cryptopay/models/coin_withdrawal_callback.rb +0 -4
  22. data/lib/cryptopay/models/coin_withdrawal_params.rb +14 -1
  23. data/lib/cryptopay/models/coin_withdrawals_config.rb +64 -0
  24. data/lib/cryptopay/models/customer.rb +12 -4
  25. data/lib/cryptopay/models/customer_address.rb +83 -0
  26. data/lib/cryptopay/models/customer_params.rb +11 -5
  27. data/lib/cryptopay/models/customer_update_params.rb +14 -6
  28. data/lib/cryptopay/models/exchange_transfer.rb +6 -0
  29. data/lib/cryptopay/models/exchange_transfer_params.rb +6 -0
  30. data/lib/cryptopay/models/invoice.rb +10 -1
  31. data/lib/cryptopay/models/invoice_callback.rb +0 -2
  32. data/lib/cryptopay/models/invoice_params.rb +8 -1
  33. data/lib/cryptopay/models/invoice_recalculation_params.rb +1 -1
  34. data/lib/cryptopay/models/invoice_refund.rb +9 -0
  35. data/lib/cryptopay/models/invoices_config.rb +64 -0
  36. data/lib/cryptopay/models/network_fee.rb +10 -2
  37. data/lib/cryptopay/models/risk_params.rb +1 -1
  38. data/lib/cryptopay/models/risk_type.rb +18 -0
  39. data/lib/cryptopay/models/transaction.rb +13 -0
  40. data/lib/cryptopay/require.rb +10 -0
  41. data/lib/cryptopay/version.rb +1 -1
  42. data/lib/cryptopay.rb +8 -9
  43. metadata +41 -31
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-generated file
4
+ # DO NOT EDIT
5
+
6
+ module Cryptopay
7
+ class Coin
8
+ ENCODER = Encoder.new(
9
+ name: 'Cryptopay::Coin',
10
+ attribute_map: {
11
+ 'currency': :currency,
12
+ 'name': :name,
13
+ 'logo_url': :logo_url,
14
+ 'networks': :networks
15
+ },
16
+ types: {
17
+ 'currency': :String,
18
+ 'name': :String,
19
+ 'logo_url': :String,
20
+ 'networks': :'Array<CoinNetwork>'
21
+ },
22
+ nullables: []
23
+ )
24
+ private_constant :ENCODER
25
+
26
+ # Initializes the object
27
+ # @param [Hash] attributes Model attributes in the form of hash
28
+ def initialize(attributes = {})
29
+ @attributes = ENCODER.sanitize(attributes)
30
+ end
31
+
32
+ def currency
33
+ @attributes[:currency]
34
+ end
35
+
36
+ def name
37
+ @attributes[:name]
38
+ end
39
+
40
+ def logo_url
41
+ @attributes[:logo_url]
42
+ end
43
+
44
+ def networks
45
+ @attributes[:networks]
46
+ end
47
+
48
+ # Show invalid properties with the reasons. Usually used together with valid?
49
+ # @return Array for valid properties with the reasons
50
+ def invalid_properties
51
+ properties = []
52
+
53
+ properties.push('invalid value for "currency", currency cannot be nil.') if currency.nil?
54
+
55
+ properties.push('invalid value for "name", name cannot be nil.') if name.nil?
56
+
57
+ properties.push('invalid value for "logo_url", logo_url cannot be nil.') if logo_url.nil?
58
+
59
+ properties.push('invalid value for "networks", networks cannot be nil.') if networks.nil?
60
+
61
+ networks&.each_with_index do |item, index|
62
+ item.invalid_properties.each do |prop|
63
+ properties.push("invalid value for \"networks.#{index}\": #{prop}")
64
+ end
65
+ end
66
+
67
+ properties
68
+ end
69
+
70
+ # Check to see if the all the properties in the model are valid
71
+ # @return true if the model is valid
72
+ def valid?
73
+ invalid_properties.empty?
74
+ end
75
+
76
+ # Builds the object from hash
77
+ # @param [Hash] attributes Model attributes in the form of hash
78
+ # @return [Cryptopay::Coin] Returns the model itself
79
+ def self.build_from_hash(data)
80
+ attributes = ENCODER.build_from_hash(data)
81
+ new(attributes)
82
+ end
83
+
84
+ # Returns the object in the form of hash
85
+ # @return [Hash] Returns the object in the form of hash
86
+ def to_hash
87
+ ENCODER.to_hash(@attributes)
88
+ end
89
+
90
+ def inspect
91
+ "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-generated file
4
+ # DO NOT EDIT
5
+
6
+ module Cryptopay
7
+ class CoinDestinationTag
8
+ ENCODER = Encoder.new(
9
+ name: 'Cryptopay::CoinDestinationTag',
10
+ attribute_map: {
11
+ 'required': :required,
12
+ 'name': :name
13
+ },
14
+ types: {
15
+ 'required': :Boolean,
16
+ 'name': :String
17
+ },
18
+ nullables: []
19
+ )
20
+ private_constant :ENCODER
21
+
22
+ # Initializes the object
23
+ # @param [Hash] attributes Model attributes in the form of hash
24
+ def initialize(attributes = {})
25
+ @attributes = ENCODER.sanitize(attributes)
26
+ end
27
+
28
+ def required
29
+ @attributes[:required]
30
+ end
31
+
32
+ def name
33
+ @attributes[:name]
34
+ end
35
+
36
+ # Show invalid properties with the reasons. Usually used together with valid?
37
+ # @return Array for valid properties with the reasons
38
+ def invalid_properties
39
+ properties = []
40
+
41
+ properties.push('invalid value for "required", required cannot be nil.') if required.nil?
42
+
43
+ properties.push('invalid value for "name", name cannot be nil.') if name.nil?
44
+
45
+ properties
46
+ end
47
+
48
+ # Check to see if the all the properties in the model are valid
49
+ # @return true if the model is valid
50
+ def valid?
51
+ invalid_properties.empty?
52
+ end
53
+
54
+ # Builds the object from hash
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ # @return [Cryptopay::CoinDestinationTag] Returns the model itself
57
+ def self.build_from_hash(data)
58
+ attributes = ENCODER.build_from_hash(data)
59
+ new(attributes)
60
+ end
61
+
62
+ # Returns the object in the form of hash
63
+ # @return [Hash] Returns the object in the form of hash
64
+ def to_hash
65
+ ENCODER.to_hash(@attributes)
66
+ end
67
+
68
+ def inspect
69
+ "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-generated file
4
+ # DO NOT EDIT
5
+
6
+ module Cryptopay
7
+ class CoinListResult
8
+ ENCODER = Encoder.new(
9
+ name: 'Cryptopay::CoinListResult',
10
+ attribute_map: {
11
+ 'data': :data
12
+ },
13
+ types: {
14
+ 'data': :'Array<Coin>'
15
+ },
16
+ nullables: []
17
+ )
18
+ private_constant :ENCODER
19
+
20
+ # Initializes the object
21
+ # @param [Hash] attributes Model attributes in the form of hash
22
+ def initialize(attributes = {})
23
+ @attributes = ENCODER.sanitize(attributes)
24
+ end
25
+
26
+ def data
27
+ @attributes[:data]
28
+ end
29
+
30
+ # Show invalid properties with the reasons. Usually used together with valid?
31
+ # @return Array for valid properties with the reasons
32
+ def invalid_properties
33
+ properties = []
34
+
35
+ properties.push('invalid value for "data", data cannot be nil.') if data.nil?
36
+
37
+ data&.each_with_index do |item, index|
38
+ item.invalid_properties.each do |prop|
39
+ properties.push("invalid value for \"data.#{index}\": #{prop}")
40
+ end
41
+ end
42
+
43
+ properties
44
+ end
45
+
46
+ # Check to see if the all the properties in the model are valid
47
+ # @return true if the model is valid
48
+ def valid?
49
+ invalid_properties.empty?
50
+ end
51
+
52
+ # Builds the object from hash
53
+ # @param [Hash] attributes Model attributes in the form of hash
54
+ # @return [Cryptopay::CoinListResult] Returns the model itself
55
+ def self.build_from_hash(data)
56
+ attributes = ENCODER.build_from_hash(data)
57
+ new(attributes)
58
+ end
59
+
60
+ # Returns the object in the form of hash
61
+ # @return [Hash] Returns the object in the form of hash
62
+ def to_hash
63
+ ENCODER.to_hash(@attributes)
64
+ end
65
+
66
+ def inspect
67
+ "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,128 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-generated file
4
+ # DO NOT EDIT
5
+
6
+ module Cryptopay
7
+ class CoinNetwork
8
+ ENCODER = Encoder.new(
9
+ name: 'Cryptopay::CoinNetwork',
10
+ attribute_map: {
11
+ 'network': :network,
12
+ 'name': :name,
13
+ 'precision': :precision,
14
+ 'destination_tag': :destination_tag,
15
+ 'invoices': :invoices,
16
+ 'channels': :channels,
17
+ 'coin_withdrawals': :coin_withdrawals
18
+ },
19
+ types: {
20
+ 'network': :String,
21
+ 'name': :String,
22
+ 'precision': :Integer,
23
+ 'destination_tag': :CoinDestinationTag,
24
+ 'invoices': :InvoicesConfig,
25
+ 'channels': :ChannelsConfig,
26
+ 'coin_withdrawals': :CoinWithdrawalsConfig
27
+ },
28
+ nullables: [
29
+ :destination_tag
30
+ ]
31
+ )
32
+ private_constant :ENCODER
33
+
34
+ # Initializes the object
35
+ # @param [Hash] attributes Model attributes in the form of hash
36
+ def initialize(attributes = {})
37
+ @attributes = ENCODER.sanitize(attributes)
38
+ end
39
+
40
+ def network
41
+ @attributes[:network]
42
+ end
43
+
44
+ def name
45
+ @attributes[:name]
46
+ end
47
+
48
+ def precision
49
+ @attributes[:precision]
50
+ end
51
+
52
+ def destination_tag
53
+ @attributes[:destination_tag]
54
+ end
55
+
56
+ def invoices
57
+ @attributes[:invoices]
58
+ end
59
+
60
+ def channels
61
+ @attributes[:channels]
62
+ end
63
+
64
+ def coin_withdrawals
65
+ @attributes[:coin_withdrawals]
66
+ end
67
+
68
+ # Show invalid properties with the reasons. Usually used together with valid?
69
+ # @return Array for valid properties with the reasons
70
+ def invalid_properties
71
+ properties = []
72
+
73
+ properties.push('invalid value for "network", network cannot be nil.') if network.nil?
74
+
75
+ properties.push('invalid value for "name", name cannot be nil.') if name.nil?
76
+
77
+ properties.push('invalid value for "precision", precision cannot be nil.') if precision.nil?
78
+
79
+ destination_tag&.invalid_properties&.each do |prop|
80
+ properties.push("invalid value for \"destination_tag\": #{prop}")
81
+ end
82
+
83
+ properties.push('invalid value for "invoices", invoices cannot be nil.') if invoices.nil?
84
+
85
+ invoices&.invalid_properties&.each do |prop|
86
+ properties.push("invalid value for \"invoices\": #{prop}")
87
+ end
88
+
89
+ properties.push('invalid value for "channels", channels cannot be nil.') if channels.nil?
90
+
91
+ channels&.invalid_properties&.each do |prop|
92
+ properties.push("invalid value for \"channels\": #{prop}")
93
+ end
94
+
95
+ properties.push('invalid value for "coin_withdrawals", coin_withdrawals cannot be nil.') if coin_withdrawals.nil?
96
+
97
+ coin_withdrawals&.invalid_properties&.each do |prop|
98
+ properties.push("invalid value for \"coin_withdrawals\": #{prop}")
99
+ end
100
+
101
+ properties
102
+ end
103
+
104
+ # Check to see if the all the properties in the model are valid
105
+ # @return true if the model is valid
106
+ def valid?
107
+ invalid_properties.empty?
108
+ end
109
+
110
+ # Builds the object from hash
111
+ # @param [Hash] attributes Model attributes in the form of hash
112
+ # @return [Cryptopay::CoinNetwork] Returns the model itself
113
+ def self.build_from_hash(data)
114
+ attributes = ENCODER.build_from_hash(data)
115
+ new(attributes)
116
+ end
117
+
118
+ # Returns the object in the form of hash
119
+ # @return [Hash] Returns the object in the form of hash
120
+ def to_hash
121
+ ENCODER.to_hash(@attributes)
122
+ end
123
+
124
+ def inspect
125
+ "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
126
+ end
127
+ end
128
+ end
@@ -12,6 +12,7 @@ module Cryptopay
12
12
  'custom_id': :custom_id,
13
13
  'customer_id': :customer_id,
14
14
  'address': :address,
15
+ 'network': :network,
15
16
  'txid': :txid,
16
17
  'status': :status,
17
18
  'charged_amount': :charged_amount,
@@ -31,6 +32,7 @@ module Cryptopay
31
32
  'custom_id': :String,
32
33
  'customer_id': :String,
33
34
  'address': :String,
35
+ 'network': :String,
34
36
  'txid': :String,
35
37
  'status': :CoinWithdrawalStatus,
36
38
  'charged_amount': :Decimal,
@@ -60,22 +62,32 @@ module Cryptopay
60
62
  @attributes = ENCODER.sanitize(attributes)
61
63
  end
62
64
 
65
+ # Coin withdrawal ID
63
66
  def id
64
67
  @attributes[:id]
65
68
  end
66
69
 
70
+ # Payment reference ID in your system
67
71
  def custom_id
68
72
  @attributes[:custom_id]
69
73
  end
70
74
 
75
+ # The reference ID of your customer
71
76
  def customer_id
72
77
  @attributes[:customer_id]
73
78
  end
74
79
 
80
+ # Recipient's cryptocurrency wallet address
75
81
  def address
76
82
  @attributes[:address]
77
83
  end
78
84
 
85
+ # Cryptocurrency network
86
+ def network
87
+ @attributes[:network]
88
+ end
89
+
90
+ # Cryptocurrency transaction ID on the blockchain
79
91
  def txid
80
92
  @attributes[:txid]
81
93
  end
@@ -84,22 +96,27 @@ module Cryptopay
84
96
  @attributes[:status]
85
97
  end
86
98
 
99
+ # Payment amount. Amount charged from your account
87
100
  def charged_amount
88
101
  @attributes[:charged_amount]
89
102
  end
90
103
 
104
+ # Account currency the payment has been sent from
91
105
  def charged_currency
92
106
  @attributes[:charged_currency]
93
107
  end
94
108
 
109
+ # Cryptocurrency transaction amount. Exact amount received by a recipient
95
110
  def received_amount
96
111
  @attributes[:received_amount]
97
112
  end
98
113
 
114
+ # Cryptocurrency type
99
115
  def received_currency
100
116
  @attributes[:received_currency]
101
117
  end
102
118
 
119
+ # Network fee amount
103
120
  def network_fee
104
121
  @attributes[:network_fee]
105
122
  end
@@ -124,6 +141,7 @@ module Cryptopay
124
141
  @attributes[:risk]
125
142
  end
126
143
 
144
+ # Coin withdrawal creation date and time
127
145
  def created_at
128
146
  @attributes[:created_at]
129
147
  end
@@ -135,6 +153,8 @@ module Cryptopay
135
153
 
136
154
  properties.push('invalid value for "address", address cannot be nil.') if address.nil?
137
155
 
156
+ properties.push('invalid value for "network", network cannot be nil.') if network.nil?
157
+
138
158
  properties.push('invalid value for "status", status cannot be nil.') if status.nil?
139
159
 
140
160
  if !status.nil? && !%w[new pending on_hold processing sent completed failed cancelled].include?(status)
@@ -46,10 +46,6 @@ module Cryptopay
46
46
 
47
47
  properties.push('invalid value for "type", type cannot be nil.') if type.nil?
48
48
 
49
- if !type.nil? && !['CoinWithdrawal'].include?(type)
50
- properties.push('invalid value for type, must be one of "CoinWithdrawal"')
51
- end
52
-
53
49
  properties.push('invalid value for "event", event cannot be nil.') if event.nil?
54
50
 
55
51
  if !event.nil? && !%w[created status_changed].include?(event)
@@ -11,6 +11,7 @@ module Cryptopay
11
11
  'address': :address,
12
12
  'charged_currency': :charged_currency,
13
13
  'received_currency': :received_currency,
14
+ 'network': :network,
14
15
  'charged_amount': :charged_amount,
15
16
  'charged_amount_to_send': :charged_amount_to_send,
16
17
  'received_amount': :received_amount,
@@ -23,6 +24,7 @@ module Cryptopay
23
24
  'address': :String,
24
25
  'charged_currency': :String,
25
26
  'received_currency': :String,
27
+ 'network': :String,
26
28
  'charged_amount': :Decimal,
27
29
  'charged_amount_to_send': :Decimal,
28
30
  'received_amount': :Decimal,
@@ -45,26 +47,37 @@ module Cryptopay
45
47
  @attributes = ENCODER.sanitize(attributes)
46
48
  end
47
49
 
50
+ # A recipient's cryptocurrency wallet address
48
51
  def address
49
52
  @attributes[:address]
50
53
  end
51
54
 
55
+ # An account currency to send a transaction from
52
56
  def charged_currency
53
57
  @attributes[:charged_currency]
54
58
  end
55
59
 
60
+ # Cryptocurrency type
56
61
  def received_currency
57
62
  @attributes[:received_currency]
58
63
  end
59
64
 
65
+ # Cryptocurrency network
66
+ def network
67
+ @attributes[:network]
68
+ end
69
+
70
+ # All applicable fees will be deducted from this amount before processing a transaction instead of adding them on top it
60
71
  def charged_amount
61
72
  @attributes[:charged_amount]
62
73
  end
63
74
 
75
+ # An exact transaction amount to send. All applicable fees will be added on top of this amount and debited from your account
64
76
  def charged_amount_to_send
65
77
  @attributes[:charged_amount_to_send]
66
78
  end
67
79
 
80
+ # 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
68
81
  def received_amount
69
82
  @attributes[:received_amount]
70
83
  end
@@ -83,7 +96,7 @@ module Cryptopay
83
96
  @attributes[:network_fee_level]
84
97
  end
85
98
 
86
- # Set `true` by default. Set `false` for two-step withdrawal and commit it within 30 seconds
99
+ # Is `false` if omitted. Set `true` to turn off two-step withdrawal. Set `false` for two-step withdrawal and commit it within 30 seconds
87
100
  def force_commit
88
101
  @attributes[:force_commit]
89
102
  end
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-generated file
4
+ # DO NOT EDIT
5
+
6
+ module Cryptopay
7
+ class CoinWithdrawalsConfig
8
+ ENCODER = Encoder.new(
9
+ name: 'Cryptopay::CoinWithdrawalsConfig',
10
+ attribute_map: {
11
+ 'enabled': :enabled
12
+ },
13
+ types: {
14
+ 'enabled': :Boolean
15
+ },
16
+ nullables: []
17
+ )
18
+ private_constant :ENCODER
19
+
20
+ # Initializes the object
21
+ # @param [Hash] attributes Model attributes in the form of hash
22
+ def initialize(attributes = {})
23
+ @attributes = ENCODER.sanitize(attributes)
24
+ end
25
+
26
+ def enabled
27
+ @attributes[:enabled]
28
+ end
29
+
30
+ # Show invalid properties with the reasons. Usually used together with valid?
31
+ # @return Array for valid properties with the reasons
32
+ def invalid_properties
33
+ properties = []
34
+
35
+ properties.push('invalid value for "enabled", enabled cannot be nil.') if enabled.nil?
36
+
37
+ properties
38
+ end
39
+
40
+ # Check to see if the all the properties in the model are valid
41
+ # @return true if the model is valid
42
+ def valid?
43
+ invalid_properties.empty?
44
+ end
45
+
46
+ # Builds the object from hash
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ # @return [Cryptopay::CoinWithdrawalsConfig] Returns the model itself
49
+ def self.build_from_hash(data)
50
+ attributes = ENCODER.build_from_hash(data)
51
+ new(attributes)
52
+ end
53
+
54
+ # Returns the object in the form of hash
55
+ # @return [Hash] Returns the object in the form of hash
56
+ def to_hash
57
+ ENCODER.to_hash(@attributes)
58
+ end
59
+
60
+ def inspect
61
+ "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
62
+ end
63
+ end
64
+ 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': :Object
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,6 +51,14 @@ 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 "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
61
+
54
62
  properties
55
63
  end
56
64