cryptopay-ruby 0.1.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +20 -12
  3. data/cryptopay.gemspec +7 -7
  4. data/lib/cryptopay/api/coin_withdrawals.rb +7 -2
  5. data/lib/cryptopay/api/coins.rb +30 -0
  6. data/lib/cryptopay/client.rb +3 -1
  7. data/lib/cryptopay/models/account.rb +4 -0
  8. data/lib/cryptopay/models/account_list_result.rb +14 -2
  9. data/lib/cryptopay/models/channel.rb +20 -0
  10. data/lib/cryptopay/models/channel_params.rb +11 -0
  11. data/lib/cryptopay/models/channel_payment.rb +20 -0
  12. data/lib/cryptopay/models/channel_payment_callback.rb +0 -4
  13. data/lib/cryptopay/models/channel_update_params.rb +2 -0
  14. data/lib/cryptopay/models/channels_config.rb +64 -0
  15. data/lib/cryptopay/models/coin.rb +94 -0
  16. data/lib/cryptopay/models/coin_destination_tag.rb +72 -0
  17. data/lib/cryptopay/models/coin_list_result.rb +70 -0
  18. data/lib/cryptopay/models/coin_network.rb +128 -0
  19. data/lib/cryptopay/models/coin_withdrawal.rb +20 -0
  20. data/lib/cryptopay/models/coin_withdrawal_callback.rb +0 -4
  21. data/lib/cryptopay/models/coin_withdrawal_params.rb +14 -1
  22. data/lib/cryptopay/models/coin_withdrawals_config.rb +64 -0
  23. data/lib/cryptopay/models/customer.rb +3 -1
  24. data/lib/cryptopay/models/customer_params.rb +2 -2
  25. data/lib/cryptopay/models/customer_update_params.rb +2 -2
  26. data/lib/cryptopay/models/exchange_transfer.rb +6 -0
  27. data/lib/cryptopay/models/exchange_transfer_params.rb +6 -0
  28. data/lib/cryptopay/models/invoice.rb +10 -1
  29. data/lib/cryptopay/models/invoice_callback.rb +0 -2
  30. data/lib/cryptopay/models/invoice_params.rb +8 -1
  31. data/lib/cryptopay/models/invoice_recalculation_params.rb +1 -1
  32. data/lib/cryptopay/models/invoice_refund.rb +9 -0
  33. data/lib/cryptopay/models/invoices_config.rb +64 -0
  34. data/lib/cryptopay/models/network_fee.rb +10 -2
  35. data/lib/cryptopay/models/risk_params.rb +1 -1
  36. data/lib/cryptopay/models/risk_type.rb +18 -0
  37. data/lib/cryptopay/models/transaction.rb +13 -0
  38. data/lib/cryptopay/require.rb +9 -0
  39. data/lib/cryptopay/version.rb +1 -1
  40. metadata +39 -30
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b9f9de99f5c3cbd724ea0c23f40cbcfddbe1e53e7421dd1ebc7e439f35f4ecc
4
- data.tar.gz: f1e875ecee66df1a7bfd860cebbc2ff21a5c6adc352b3d3ee2db716652def832
3
+ metadata.gz: 565560b9bd60b4439f410a759ef4c51fce1104e29b887a5a70f579f583a96a7a
4
+ data.tar.gz: a48fe75139c6244dc20fa430633329d7015debd3760bcb38d48e6fa350bf3593
5
5
  SHA512:
6
- metadata.gz: c7ada56d4edde325ad250fe6e169814a2873379870322b63095fb261e74a3899fcf85dadf209738658e6e19227cd1215c4202851955d5eee5a29b27e2476c9b7
7
- data.tar.gz: 1a83aba1a6d7aca51d87e9b71254b80bb1aa7fe8d41e23e2d8d17904adf9cf192535a364aafb64e09507aa1bcd1dffe00e1f45ae483933b4f94c41fe4c35a919
6
+ metadata.gz: 3c2bac187a5dfc48dcef7691025ac33dd4bf79dd6235f8429f5c827a90e5b4b18ed7a80d6cdb1cdebce6d1974b707aed284a79ca796a8251056113ca1b0e305a
7
+ data.tar.gz: 4d836911974b0d7a971d5898c678a245e69f0b1b5f4b70aa8977738fbcd68712902161c8da06323b4a280bcf663dd1fbb536efc9031874aedd03b7ce49d915e6
data/README.md CHANGED
@@ -14,6 +14,7 @@ For more information, please visit [Cryptopay API docs](https://developers.crypt
14
14
  * [Accounts](#accounts)
15
15
  * [Channels](#channels)
16
16
  * [CoinWithdrawals](#coinwithdrawals)
17
+ * [Coins](#coins)
17
18
  * [Customers](#customers)
18
19
  * [ExchangeTransfers](#exchangetransfers)
19
20
  * [Invoices](#invoices)
@@ -67,7 +68,6 @@ end
67
68
 
68
69
  ### Accounts
69
70
 
70
- [Accounts API docs](https://developers.cryptopay.me/reference/accounts)
71
71
 
72
72
  #### List accounts
73
73
 
@@ -91,7 +91,7 @@ p result # => <TransactionListResult data=...>
91
91
 
92
92
  A channel is a static cryptocurrency address that may be assigned to each one of your customers.
93
93
 
94
- [Channels API docs](https://developers.cryptopay.me/reference/payment-channels)
94
+ [Channels API docs](https://developers.cryptopay.me/guides/channels)
95
95
 
96
96
  #### Create a channel
97
97
 
@@ -173,7 +173,7 @@ p result # => <ChannelResult data=...>
173
173
 
174
174
  In addition to accepting payments through the Cryptopay payment gateway, it is also possible to make payments to your customers in any of the cryptocurrency currently supported by Cryptopay. In Cryptopay, these payments are called “Coin Withdrawal”. The process of requesting coin withdrawal is almost the same for a customer in Cashier as the process of making a deposit with one exception - the customer will need to specify the address of the wallet he wants to send the cryptocurrency to.
175
175
 
176
- [Coin withdrawals API docs](https://developers.cryptopay.me/reference/coin-withdrawals)
176
+ [Coin withdrawals API docs](https://developers.cryptopay.me/guides/payouts)
177
177
 
178
178
  #### Commit a withdrawal
179
179
 
@@ -244,11 +244,21 @@ result = client.coin_withdrawals.retrieve_by_custom_id(custom_id)
244
244
  p result # => <CoinWithdrawalResult data=...>
245
245
  ```
246
246
 
247
+ ### Coins
248
+
249
+
250
+ #### List supported coins
251
+
252
+
253
+ ```ruby
254
+ result = client.coins.list
255
+ p result # => <CoinListResult data=...>
256
+ ```
257
+
247
258
  ### Customers
248
259
 
249
- Customer objects allow you to reject High-Risk transactions automatically, and to track multiple transactions, that are associated with the same customer
260
+ Customer objects allow you to reject High-Risk transactions automatically, and to track multiple transactions, that are associated with the same customer.
250
261
 
251
- [Customers API docs](https://developers.cryptopay.me/reference/customers)
252
262
 
253
263
  #### Create a customer
254
264
 
@@ -275,7 +285,7 @@ p result # => <CustomerListResult data=...>
275
285
 
276
286
 
277
287
  ```ruby
278
- customer_id = 'CUSTOMER-123'
288
+ customer_id = "CUSTOMER-123"
279
289
 
280
290
  result = client.customers.retrieve(customer_id)
281
291
  p result # => <CustomerResult data=...>
@@ -285,7 +295,7 @@ p result # => <CustomerResult data=...>
285
295
 
286
296
 
287
297
  ```ruby
288
- customer_id = 'CUSTOMER-123'
298
+ customer_id = "CUSTOMER-123"
289
299
  params = Cryptopay::CustomerUpdateParams.new(
290
300
  refund_addresses: {
291
301
  'BTC' => '2N9wPGx67zdSeAbXi15qHgoZ9Hb9Uxhd2uQ'
@@ -298,7 +308,6 @@ p result # => <CustomerResult data=...>
298
308
 
299
309
  ### ExchangeTransfers
300
310
 
301
- [Exchange transfers API docs](https://developers.cryptopay.me/reference/exchange)
302
311
 
303
312
  #### Commit an exchange transfer
304
313
 
@@ -346,7 +355,7 @@ p result # => <ExchangeTransferResult data=...>
346
355
 
347
356
  An invoice is a request for a cryptocurrency payment which contains a unique BTC, LTC, ETH or XRP address and the amount that has to be paid while the invoice is valid.
348
357
 
349
- [Invoices API docs](https://developers.cryptopay.me/reference/invoices)
358
+ [Invoices API docs](https://developers.cryptopay.me/guides/invoices)
350
359
 
351
360
  #### Commit invoice recalculation
352
361
 
@@ -435,7 +444,6 @@ p result # => <InvoiceResult data=...>
435
444
 
436
445
  ### Rates
437
446
 
438
- [Public rates API docs](https://developers.cryptopay.me/reference/public-rates)
439
447
 
440
448
  #### Retrieve all rates
441
449
 
@@ -458,7 +466,7 @@ p result # => <RateResult data=...>
458
466
 
459
467
  ### Risks
460
468
 
461
- [Risks API docs](https://developers.cryptopay.me/reference/risks)
469
+ [Risks API docs](https://developers.cryptopay.me/guides/risks)
462
470
 
463
471
  #### Score a coin address
464
472
 
@@ -476,7 +484,7 @@ p result # => <RiskResult data=...>
476
484
 
477
485
  ### Transactions
478
486
 
479
- [Transactions API docs](https://developers.cryptopay.me/reference/transactions)
487
+ [Transactions API docs](https://developers.cryptopay.me/guides/transactions)
480
488
 
481
489
  #### List transactions
482
490
 
data/cryptopay.gemspec CHANGED
@@ -30,11 +30,11 @@ Gem::Specification.new do |s|
30
30
 
31
31
  s.add_runtime_dependency('faraday', '~> 1.0', '>= 1.0.1')
32
32
 
33
- s.add_development_dependency('dotenv')
34
- s.add_development_dependency('pry-byebug')
35
- s.add_development_dependency('rake')
36
- s.add_development_dependency('rspec')
37
- s.add_development_dependency('rubocop')
38
- s.add_development_dependency('vcr')
39
- s.add_development_dependency('webmock')
33
+ s.add_development_dependency('dotenv', '~> 2.7')
34
+ s.add_development_dependency('pry-byebug', '~> 3.9')
35
+ s.add_development_dependency('rake', '~> 13.0')
36
+ s.add_development_dependency('rspec', '~> 3.11')
37
+ s.add_development_dependency('rubocop', '~> 1.25')
38
+ s.add_development_dependency('vcr', '~> 6.0')
39
+ s.add_development_dependency('webmock', '~> 3.14')
40
40
  end
@@ -64,13 +64,18 @@ module Cryptopay
64
64
 
65
65
  # List network fees
66
66
  # @param [Hash] opts the optional parameters
67
+ # @option opts [Boolean] :all_networks Is &#x60;false&#x60; if omitted. Set &#x60;true&#x60; to return network fees for all cryptocurrency networks
67
68
  # @return [NetworkFeeListResult]
68
- def list_network_fees(_opts = {})
69
+ def list_network_fees(opts = {})
69
70
  path = '/api/coin_withdrawals/network_fees'
70
71
 
72
+ query_params = {}
73
+ query_params[:all_networks] = opts[:all_networks] unless opts[:all_networks].nil?
74
+
71
75
  req = Request.new(
72
76
  method: :get,
73
- path: path
77
+ path: path,
78
+ query_params: query_params
74
79
  )
75
80
 
76
81
  connection.call(req, return_type: NetworkFeeListResult)
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-generated file
4
+ # DO NOT EDIT
5
+
6
+ module Cryptopay
7
+ class Coins
8
+ def initialize(connection)
9
+ @connection = connection
10
+ end
11
+
12
+ # List supported coins
13
+ # @param [Hash] opts the optional parameters
14
+ # @return [CoinListResult]
15
+ def list(_opts = {})
16
+ path = '/api/coins'
17
+
18
+ req = Request.new(
19
+ method: :get,
20
+ path: path
21
+ )
22
+
23
+ connection.call(req, return_type: CoinListResult)
24
+ end
25
+
26
+ private
27
+
28
+ attr_reader :connection
29
+ end
30
+ end
@@ -11,7 +11,8 @@ module Cryptopay
11
11
  :exchange_transfers,
12
12
  :customers,
13
13
  :risks,
14
- :callbacks
14
+ :callbacks,
15
+ :coins
15
16
 
16
17
  def initialize(&block)
17
18
  config = Config.new(&block)
@@ -34,6 +35,7 @@ module Cryptopay
34
35
  @exchange_transfers = ExchangeTransfers.new(connection)
35
36
  @customers = Customers.new(connection)
36
37
  @risks = Risks.new(connection)
38
+ @coins = Coins.new(connection)
37
39
  end
38
40
  end
39
41
  end
@@ -29,18 +29,22 @@ module Cryptopay
29
29
  @attributes = ENCODER.sanitize(attributes)
30
30
  end
31
31
 
32
+ # Account ID
32
33
  def id
33
34
  @attributes[:id]
34
35
  end
35
36
 
37
+ # Account currency
36
38
  def currency
37
39
  @attributes[:currency]
38
40
  end
39
41
 
42
+ # Account balance
40
43
  def balance
41
44
  @attributes[:balance]
42
45
  end
43
46
 
47
+ # Project ID which the account belongs to
44
48
  def project_id
45
49
  @attributes[:project_id]
46
50
  end
@@ -8,10 +8,12 @@ module Cryptopay
8
8
  ENCODER = Encoder.new(
9
9
  name: 'Cryptopay::AccountListResult',
10
10
  attribute_map: {
11
- 'data': :data
11
+ 'data': :data,
12
+ 'meta': :meta
12
13
  },
13
14
  types: {
14
- 'data': :'Array<Account>'
15
+ 'data': :'Array<Account>',
16
+ 'meta': :Pagination
15
17
  },
16
18
  nullables: []
17
19
  )
@@ -27,6 +29,10 @@ module Cryptopay
27
29
  @attributes[:data]
28
30
  end
29
31
 
32
+ def meta
33
+ @attributes[:meta]
34
+ end
35
+
30
36
  # Show invalid properties with the reasons. Usually used together with valid?
31
37
  # @return Array for valid properties with the reasons
32
38
  def invalid_properties
@@ -40,6 +46,12 @@ module Cryptopay
40
46
  end
41
47
  end
42
48
 
49
+ properties.push('invalid value for "meta", meta cannot be nil.') if meta.nil?
50
+
51
+ meta&.invalid_properties&.each do |prop|
52
+ properties.push("invalid value for \"meta\": #{prop}")
53
+ end
54
+
43
55
  properties
44
56
  end
45
57
 
@@ -15,6 +15,7 @@ module Cryptopay
15
15
  'pay_currency': :pay_currency,
16
16
  'receiver_currency': :receiver_currency,
17
17
  'address': :address,
18
+ 'network': :network,
18
19
  'project_id': :project_id,
19
20
  'custom_id': :custom_id,
20
21
  'customer_id': :customer_id,
@@ -29,6 +30,7 @@ module Cryptopay
29
30
  'pay_currency': :String,
30
31
  'receiver_currency': :String,
31
32
  'address': :String,
33
+ 'network': :String,
32
34
  'project_id': :String,
33
35
  'custom_id': :String,
34
36
  'customer_id': :String,
@@ -49,6 +51,7 @@ module Cryptopay
49
51
  @attributes = ENCODER.sanitize(attributes)
50
52
  end
51
53
 
54
+ # Channel ID
52
55
  def id
53
56
  @attributes[:id]
54
57
  end
@@ -57,42 +60,57 @@ module Cryptopay
57
60
  @attributes[:status]
58
61
  end
59
62
 
63
+ # Channel name
60
64
  def name
61
65
  @attributes[:name]
62
66
  end
63
67
 
68
+ # Channel description
64
69
  def description
65
70
  @attributes[:description]
66
71
  end
67
72
 
73
+ # The cryptocurrency which you want to accept
68
74
  def pay_currency
69
75
  @attributes[:pay_currency]
70
76
  end
71
77
 
78
+ # The currency which all incoming transactions will be converted to
72
79
  def receiver_currency
73
80
  @attributes[:receiver_currency]
74
81
  end
75
82
 
83
+ # Channel description
76
84
  def address
77
85
  @attributes[:address]
78
86
  end
79
87
 
88
+ # Cryptocurrency network
89
+ def network
90
+ @attributes[:network]
91
+ end
92
+
93
+ # Project ID
80
94
  def project_id
81
95
  @attributes[:project_id]
82
96
  end
83
97
 
98
+ # The channel reference ID in your system
84
99
  def custom_id
85
100
  @attributes[:custom_id]
86
101
  end
87
102
 
103
+ # The reference ID of your customer
88
104
  def customer_id
89
105
  @attributes[:customer_id]
90
106
  end
91
107
 
108
+ # Channel URI. May be used for generating a QR code
92
109
  def uri
93
110
  @attributes[:uri]
94
111
  end
95
112
 
113
+ # Channel hosted page that renders channel details
96
114
  def hosted_page_url
97
115
  @attributes[:hosted_page_url]
98
116
  end
@@ -120,6 +138,8 @@ module Cryptopay
120
138
 
121
139
  properties.push('invalid value for "address", address cannot be nil.') if address.nil?
122
140
 
141
+ properties.push('invalid value for "network", network cannot be nil.') if network.nil?
142
+
123
143
  properties.push('invalid value for "project_id", project_id cannot be nil.') if project_id.nil?
124
144
 
125
145
  properties.push('invalid value for "uri", uri cannot be nil.') if uri.nil?
@@ -11,6 +11,7 @@ module Cryptopay
11
11
  'name': :name,
12
12
  'description': :description,
13
13
  'pay_currency': :pay_currency,
14
+ 'network': :network,
14
15
  'receiver_currency': :receiver_currency,
15
16
  'custom_id': :custom_id,
16
17
  'customer_id': :customer_id
@@ -19,6 +20,7 @@ module Cryptopay
19
20
  'name': :String,
20
21
  'description': :String,
21
22
  'pay_currency': :String,
23
+ 'network': :String,
22
24
  'receiver_currency': :String,
23
25
  'custom_id': :String,
24
26
  'customer_id': :String
@@ -33,18 +35,27 @@ module Cryptopay
33
35
  @attributes = ENCODER.sanitize(attributes)
34
36
  end
35
37
 
38
+ # Channel name
36
39
  def name
37
40
  @attributes[:name]
38
41
  end
39
42
 
43
+ # Channel description
40
44
  def description
41
45
  @attributes[:description]
42
46
  end
43
47
 
48
+ # The cryptocurrency which you want to accept
44
49
  def pay_currency
45
50
  @attributes[:pay_currency]
46
51
  end
47
52
 
53
+ # Cryptocurrency network
54
+ def network
55
+ @attributes[:network]
56
+ end
57
+
58
+ # The currency which all incoming transactions will be converted to
48
59
  def receiver_currency
49
60
  @attributes[:receiver_currency]
50
61
  end
@@ -26,6 +26,7 @@ module Cryptopay
26
26
  'custom_id': :custom_id,
27
27
  'customer_id': :customer_id,
28
28
  'address': :address,
29
+ 'network': :network,
29
30
  'created_at': :created_at
30
31
  },
31
32
  types: {
@@ -47,6 +48,7 @@ module Cryptopay
47
48
  'custom_id': :String,
48
49
  'customer_id': :String,
49
50
  'address': :String,
51
+ 'network': :String,
50
52
  'created_at': :Time
51
53
  },
52
54
  nullables: %i[
@@ -65,38 +67,47 @@ module Cryptopay
65
67
  @attributes = ENCODER.sanitize(attributes)
66
68
  end
67
69
 
70
+ # Channel payment ID
68
71
  def id
69
72
  @attributes[:id]
70
73
  end
71
74
 
75
+ # Channel ID
72
76
  def channel_id
73
77
  @attributes[:channel_id]
74
78
  end
75
79
 
80
+ # Cryptocurrency transaction amount that was received
76
81
  def paid_amount
77
82
  @attributes[:paid_amount]
78
83
  end
79
84
 
85
+ # Cryptocurrency type
80
86
  def paid_currency
81
87
  @attributes[:paid_currency]
82
88
  end
83
89
 
90
+ # Amount credited to your Cryptopay account
84
91
  def received_amount
85
92
  @attributes[:received_amount]
86
93
  end
87
94
 
95
+ # Account currency
88
96
  def received_currency
89
97
  @attributes[:received_currency]
90
98
  end
91
99
 
100
+ # Processing fee
92
101
  def fee
93
102
  @attributes[:fee]
94
103
  end
95
104
 
105
+ # Processing fee currency
96
106
  def fee_currency
97
107
  @attributes[:fee_currency]
98
108
  end
99
109
 
110
+ # Cryptocurrency transaction ID on the blockchain
100
111
  def txid
101
112
  @attributes[:txid]
102
113
  end
@@ -125,18 +136,27 @@ module Cryptopay
125
136
  @attributes[:coin_withdrawal_id]
126
137
  end
127
138
 
139
+ # Channel payment custom_id value inherited from its parent channel
128
140
  def custom_id
129
141
  @attributes[:custom_id]
130
142
  end
131
143
 
144
+ # The reference ID of your customer
132
145
  def customer_id
133
146
  @attributes[:customer_id]
134
147
  end
135
148
 
149
+ # Channel cryptocurrency address
136
150
  def address
137
151
  @attributes[:address]
138
152
  end
139
153
 
154
+ # Cryptocurrency network
155
+ def network
156
+ @attributes[:network]
157
+ end
158
+
159
+ # Channel payment creation date and time
140
160
  def created_at
141
161
  @attributes[:created_at]
142
162
  end
@@ -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? && !['ChannelPayment'].include?(type)
50
- properties.push('invalid value for type, must be one of "ChannelPayment"')
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 on_hold completed refunded cancelled].include?(event)
@@ -29,10 +29,12 @@ module Cryptopay
29
29
  @attributes = ENCODER.sanitize(attributes)
30
30
  end
31
31
 
32
+ # Channel name
32
33
  def name
33
34
  @attributes[:name]
34
35
  end
35
36
 
37
+ # Channel description
36
38
  def description
37
39
  @attributes[:description]
38
40
  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 ChannelsConfig
8
+ ENCODER = Encoder.new(
9
+ name: 'Cryptopay::ChannelsConfig',
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::ChannelsConfig] 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
@@ -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