cryptopay-ruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ci.yml +36 -0
  3. data/.gitignore +38 -0
  4. data/.rspec +2 -0
  5. data/.rubocop.yml +104 -0
  6. data/Gemfile +8 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +521 -0
  9. data/Rakefile +8 -0
  10. data/bin/console +15 -0
  11. data/cryptopay.gemspec +40 -0
  12. data/lib/cryptopay/api/accounts.rb +51 -0
  13. data/lib/cryptopay/api/channels.rb +142 -0
  14. data/lib/cryptopay/api/coin_withdrawals.rb +115 -0
  15. data/lib/cryptopay/api/customers.rb +85 -0
  16. data/lib/cryptopay/api/exchange_transfers.rb +64 -0
  17. data/lib/cryptopay/api/invoices.rb +163 -0
  18. data/lib/cryptopay/api/rates.rb +50 -0
  19. data/lib/cryptopay/api/risks.rb +32 -0
  20. data/lib/cryptopay/api/transactions.rb +47 -0
  21. data/lib/cryptopay/authentication.rb +30 -0
  22. data/lib/cryptopay/callbacks.rb +38 -0
  23. data/lib/cryptopay/client.rb +39 -0
  24. data/lib/cryptopay/config.rb +48 -0
  25. data/lib/cryptopay/connection.rb +48 -0
  26. data/lib/cryptopay/encoder.rb +113 -0
  27. data/lib/cryptopay/errors.rb +32 -0
  28. data/lib/cryptopay/models/account.rb +88 -0
  29. data/lib/cryptopay/models/account_list_result.rb +70 -0
  30. data/lib/cryptopay/models/callback.rb +25 -0
  31. data/lib/cryptopay/models/channel.rb +156 -0
  32. data/lib/cryptopay/models/channel_list_result.rb +82 -0
  33. data/lib/cryptopay/models/channel_params.rb +102 -0
  34. data/lib/cryptopay/models/channel_payment.rb +216 -0
  35. data/lib/cryptopay/models/channel_payment_callback.rb +92 -0
  36. data/lib/cryptopay/models/channel_payment_callback_event.rb +21 -0
  37. data/lib/cryptopay/models/channel_payment_list_result.rb +82 -0
  38. data/lib/cryptopay/models/channel_payment_result.rb +68 -0
  39. data/lib/cryptopay/models/channel_payment_status.rb +21 -0
  40. data/lib/cryptopay/models/channel_payment_status_context.rb +18 -0
  41. data/lib/cryptopay/models/channel_result.rb +68 -0
  42. data/lib/cryptopay/models/channel_status.rb +18 -0
  43. data/lib/cryptopay/models/channel_update_params.rb +85 -0
  44. data/lib/cryptopay/models/coin_withdrawal.rb +205 -0
  45. data/lib/cryptopay/models/coin_withdrawal_callback.rb +92 -0
  46. data/lib/cryptopay/models/coin_withdrawal_callback_event.rb +18 -0
  47. data/lib/cryptopay/models/coin_withdrawal_list_result.rb +82 -0
  48. data/lib/cryptopay/models/coin_withdrawal_params.rb +135 -0
  49. data/lib/cryptopay/models/coin_withdrawal_result.rb +68 -0
  50. data/lib/cryptopay/models/coin_withdrawal_status.rb +24 -0
  51. data/lib/cryptopay/models/customer.rb +81 -0
  52. data/lib/cryptopay/models/customer_list_result.rb +82 -0
  53. data/lib/cryptopay/models/customer_params.rb +81 -0
  54. data/lib/cryptopay/models/customer_result.rb +68 -0
  55. data/lib/cryptopay/models/customer_update_params.rb +68 -0
  56. data/lib/cryptopay/models/exchange.rb +89 -0
  57. data/lib/cryptopay/models/exchange_transfer.rb +116 -0
  58. data/lib/cryptopay/models/exchange_transfer_params.rb +101 -0
  59. data/lib/cryptopay/models/exchange_transfer_result.rb +68 -0
  60. data/lib/cryptopay/models/invoice.rb +276 -0
  61. data/lib/cryptopay/models/invoice_callback.rb +90 -0
  62. data/lib/cryptopay/models/invoice_callback_event.rb +22 -0
  63. data/lib/cryptopay/models/invoice_list_result.rb +82 -0
  64. data/lib/cryptopay/models/invoice_params.rb +131 -0
  65. data/lib/cryptopay/models/invoice_recalculation.rb +178 -0
  66. data/lib/cryptopay/models/invoice_recalculation_params.rb +61 -0
  67. data/lib/cryptopay/models/invoice_recalculation_result.rb +68 -0
  68. data/lib/cryptopay/models/invoice_refund.rb +154 -0
  69. data/lib/cryptopay/models/invoice_refund_list_result.rb +70 -0
  70. data/lib/cryptopay/models/invoice_refund_params.rb +61 -0
  71. data/lib/cryptopay/models/invoice_refund_result.rb +68 -0
  72. data/lib/cryptopay/models/invoice_result.rb +68 -0
  73. data/lib/cryptopay/models/invoice_status.rb +21 -0
  74. data/lib/cryptopay/models/invoice_status_context.rb +20 -0
  75. data/lib/cryptopay/models/invoice_transaction.rb +76 -0
  76. data/lib/cryptopay/models/network_fee.rb +84 -0
  77. data/lib/cryptopay/models/network_fee_level.rb +19 -0
  78. data/lib/cryptopay/models/network_fee_list_result.rb +70 -0
  79. data/lib/cryptopay/models/pagination.rb +72 -0
  80. data/lib/cryptopay/models/rate.rb +74 -0
  81. data/lib/cryptopay/models/rate_result.rb +68 -0
  82. data/lib/cryptopay/models/rates_result.rb +64 -0
  83. data/lib/cryptopay/models/risk.rb +98 -0
  84. data/lib/cryptopay/models/risk_level.rb +19 -0
  85. data/lib/cryptopay/models/risk_params.rb +86 -0
  86. data/lib/cryptopay/models/risk_result.rb +68 -0
  87. data/lib/cryptopay/models/transaction.rb +174 -0
  88. data/lib/cryptopay/models/transaction_list_result.rb +82 -0
  89. data/lib/cryptopay/models/transaction_reference_type.rb +25 -0
  90. data/lib/cryptopay/request.rb +46 -0
  91. data/lib/cryptopay/require.rb +79 -0
  92. data/lib/cryptopay/types.rb +11 -0
  93. data/lib/cryptopay/version.rb +5 -0
  94. data/lib/cryptopay.rb +26 -0
  95. metadata +256 -0
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-generated file
4
+ # DO NOT EDIT
5
+
6
+ module Cryptopay
7
+ class CoinWithdrawalResult
8
+ ENCODER = Encoder.new(
9
+ name: 'Cryptopay::CoinWithdrawalResult',
10
+ attribute_map: {
11
+ 'data': :data
12
+ },
13
+ types: {
14
+ 'data': :CoinWithdrawal
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&.invalid_properties&.each do |prop|
38
+ properties.push("invalid value for \"data\": #{prop}")
39
+ end
40
+
41
+ properties
42
+ end
43
+
44
+ # Check to see if the all the properties in the model are valid
45
+ # @return true if the model is valid
46
+ def valid?
47
+ invalid_properties.empty?
48
+ end
49
+
50
+ # Builds the object from hash
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ # @return [Cryptopay::CoinWithdrawalResult] Returns the model itself
53
+ def self.build_from_hash(data)
54
+ attributes = ENCODER.build_from_hash(data)
55
+ new(attributes)
56
+ end
57
+
58
+ # Returns the object in the form of hash
59
+ # @return [Hash] Returns the object in the form of hash
60
+ def to_hash
61
+ ENCODER.to_hash(@attributes)
62
+ end
63
+
64
+ def inspect
65
+ "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-generated file
4
+ # DO NOT EDIT
5
+
6
+ module Cryptopay
7
+ module CoinWithdrawalStatus
8
+ NEW = 'new'
9
+ PENDING = 'pending'
10
+ ON_HOLD = 'on_hold'
11
+ PROCESSING = 'processing'
12
+ SENT = 'sent'
13
+ COMPLETED = 'completed'
14
+ FAILED = 'failed'
15
+ CANCELLED = 'cancelled'
16
+
17
+ # Builds the enum from string
18
+ # @param [String] The enum value in the form of the string
19
+ # @return [String] The enum value
20
+ def self.build_from_hash(value)
21
+ value
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-generated file
4
+ # DO NOT EDIT
5
+
6
+ module Cryptopay
7
+ class Customer
8
+ ENCODER = Encoder.new(
9
+ name: 'Cryptopay::Customer',
10
+ attribute_map: {
11
+ 'id': :id,
12
+ 'currency': :currency,
13
+ 'refund_addresses': :refund_addresses
14
+ },
15
+ types: {
16
+ 'id': :String,
17
+ 'currency': :String,
18
+ 'refund_addresses': :Object
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
+ # The customer's reference ID in your system
31
+ def id
32
+ @attributes[:id]
33
+ end
34
+
35
+ # The customer's currency in your system
36
+ def currency
37
+ @attributes[:currency]
38
+ end
39
+
40
+ # The list of refund addresses where Cryptopay will refund High-Risk transactions to
41
+ def refund_addresses
42
+ @attributes[:refund_addresses]
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 "id", id cannot be nil.') if id.nil?
51
+
52
+ properties.push('invalid value for "currency", currency cannot be nil.') if currency.nil?
53
+
54
+ properties
55
+ end
56
+
57
+ # Check to see if the all the properties in the model are valid
58
+ # @return true if the model is valid
59
+ def valid?
60
+ invalid_properties.empty?
61
+ end
62
+
63
+ # Builds the object from hash
64
+ # @param [Hash] attributes Model attributes in the form of hash
65
+ # @return [Cryptopay::Customer] Returns the model itself
66
+ def self.build_from_hash(data)
67
+ attributes = ENCODER.build_from_hash(data)
68
+ new(attributes)
69
+ end
70
+
71
+ # Returns the object in the form of hash
72
+ # @return [Hash] Returns the object in the form of hash
73
+ def to_hash
74
+ ENCODER.to_hash(@attributes)
75
+ end
76
+
77
+ def inspect
78
+ "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,82 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-generated file
4
+ # DO NOT EDIT
5
+
6
+ module Cryptopay
7
+ class CustomerListResult
8
+ ENCODER = Encoder.new(
9
+ name: 'Cryptopay::CustomerListResult',
10
+ attribute_map: {
11
+ 'data': :data,
12
+ 'meta': :meta
13
+ },
14
+ types: {
15
+ 'data': :'Array<Customer>',
16
+ 'meta': :Pagination
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 data
29
+ @attributes[:data]
30
+ end
31
+
32
+ def meta
33
+ @attributes[:meta]
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 "data", data cannot be nil.') if data.nil?
42
+
43
+ data&.each_with_index do |item, index|
44
+ item.invalid_properties.each do |prop|
45
+ properties.push("invalid value for \"data.#{index}\": #{prop}")
46
+ end
47
+ end
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
+
55
+ properties
56
+ end
57
+
58
+ # Check to see if the all the properties in the model are valid
59
+ # @return true if the model is valid
60
+ def valid?
61
+ invalid_properties.empty?
62
+ end
63
+
64
+ # Builds the object from hash
65
+ # @param [Hash] attributes Model attributes in the form of hash
66
+ # @return [Cryptopay::CustomerListResult] 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
+ # Returns the object in the form of hash
73
+ # @return [Hash] Returns the object in the form of hash
74
+ def to_hash
75
+ ENCODER.to_hash(@attributes)
76
+ end
77
+
78
+ def inspect
79
+ "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-generated file
4
+ # DO NOT EDIT
5
+
6
+ module Cryptopay
7
+ class CustomerParams
8
+ ENCODER = Encoder.new(
9
+ name: 'Cryptopay::CustomerParams',
10
+ attribute_map: {
11
+ 'id': :id,
12
+ 'currency': :currency,
13
+ 'refund_addresses': :refund_addresses
14
+ },
15
+ types: {
16
+ 'id': :String,
17
+ 'currency': :String,
18
+ 'refund_addresses': :Object
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
+ # The customer's reference ID in your system
31
+ def id
32
+ @attributes[:id]
33
+ end
34
+
35
+ # The customer's currency in your system
36
+ def currency
37
+ @attributes[:currency]
38
+ end
39
+
40
+ # This object allows you 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]
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 "id", id cannot be nil.') if id.nil?
51
+
52
+ properties.push('invalid value for "currency", currency cannot be nil.') if currency.nil?
53
+
54
+ properties
55
+ end
56
+
57
+ # Check to see if the all the properties in the model are valid
58
+ # @return true if the model is valid
59
+ def valid?
60
+ invalid_properties.empty?
61
+ end
62
+
63
+ # Builds the object from hash
64
+ # @param [Hash] attributes Model attributes in the form of hash
65
+ # @return [Cryptopay::CustomerParams] Returns the model itself
66
+ def self.build_from_hash(data)
67
+ attributes = ENCODER.build_from_hash(data)
68
+ new(attributes)
69
+ end
70
+
71
+ # Returns the object in the form of hash
72
+ # @return [Hash] Returns the object in the form of hash
73
+ def to_hash
74
+ ENCODER.to_hash(@attributes)
75
+ end
76
+
77
+ def inspect
78
+ "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-generated file
4
+ # DO NOT EDIT
5
+
6
+ module Cryptopay
7
+ class CustomerResult
8
+ ENCODER = Encoder.new(
9
+ name: 'Cryptopay::CustomerResult',
10
+ attribute_map: {
11
+ 'data': :data
12
+ },
13
+ types: {
14
+ 'data': :Customer
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&.invalid_properties&.each do |prop|
38
+ properties.push("invalid value for \"data\": #{prop}")
39
+ end
40
+
41
+ properties
42
+ end
43
+
44
+ # Check to see if the all the properties in the model are valid
45
+ # @return true if the model is valid
46
+ def valid?
47
+ invalid_properties.empty?
48
+ end
49
+
50
+ # Builds the object from hash
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ # @return [Cryptopay::CustomerResult] Returns the model itself
53
+ def self.build_from_hash(data)
54
+ attributes = ENCODER.build_from_hash(data)
55
+ new(attributes)
56
+ end
57
+
58
+ # Returns the object in the form of hash
59
+ # @return [Hash] Returns the object in the form of hash
60
+ def to_hash
61
+ ENCODER.to_hash(@attributes)
62
+ end
63
+
64
+ def inspect
65
+ "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-generated file
4
+ # DO NOT EDIT
5
+
6
+ module Cryptopay
7
+ class CustomerUpdateParams
8
+ ENCODER = Encoder.new(
9
+ name: 'Cryptopay::CustomerUpdateParams',
10
+ attribute_map: {
11
+ 'currency': :currency,
12
+ 'refund_addresses': :refund_addresses
13
+ },
14
+ types: {
15
+ 'currency': :String,
16
+ 'refund_addresses': :Object
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
+ # The customer's currency in your system
29
+ def currency
30
+ @attributes[:currency]
31
+ end
32
+
33
+ # This object allows you 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]
36
+ end
37
+
38
+ # Show invalid properties with the reasons. Usually used together with valid?
39
+ # @return Array for valid properties with the reasons
40
+ def invalid_properties
41
+ []
42
+ end
43
+
44
+ # Check to see if the all the properties in the model are valid
45
+ # @return true if the model is valid
46
+ def valid?
47
+ invalid_properties.empty?
48
+ end
49
+
50
+ # Builds the object from hash
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ # @return [Cryptopay::CustomerUpdateParams] Returns the model itself
53
+ def self.build_from_hash(data)
54
+ attributes = ENCODER.build_from_hash(data)
55
+ new(attributes)
56
+ end
57
+
58
+ # Returns the object in the form of hash
59
+ # @return [Hash] Returns the object in the form of hash
60
+ def to_hash
61
+ ENCODER.to_hash(@attributes)
62
+ end
63
+
64
+ def inspect
65
+ "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-generated file
4
+ # DO NOT EDIT
5
+
6
+ module Cryptopay
7
+ # Exchange details
8
+ class Exchange
9
+ ENCODER = Encoder.new(
10
+ name: 'Cryptopay::Exchange',
11
+ attribute_map: {
12
+ 'pair': :pair,
13
+ 'rate': :rate,
14
+ 'fee': :fee,
15
+ 'fee_currency': :fee_currency
16
+ },
17
+ types: {
18
+ 'pair': :String,
19
+ 'rate': :Decimal,
20
+ 'fee': :Decimal,
21
+ 'fee_currency': :String
22
+ },
23
+ nullables: []
24
+ )
25
+ private_constant :ENCODER
26
+
27
+ # Initializes the object
28
+ # @param [Hash] attributes Model attributes in the form of hash
29
+ def initialize(attributes = {})
30
+ @attributes = ENCODER.sanitize(attributes)
31
+ end
32
+
33
+ # Currency pair
34
+ def pair
35
+ @attributes[:pair]
36
+ end
37
+
38
+ # Exchange rate
39
+ def rate
40
+ @attributes[:rate]
41
+ end
42
+
43
+ # Exchange fee
44
+ def fee
45
+ @attributes[:fee]
46
+ end
47
+
48
+ # Exchange fee currency
49
+ def fee_currency
50
+ @attributes[:fee_currency]
51
+ end
52
+
53
+ # Show invalid properties with the reasons. Usually used together with valid?
54
+ # @return Array for valid properties with the reasons
55
+ def invalid_properties
56
+ properties = []
57
+
58
+ properties.push('invalid value for "pair", pair cannot be nil.') if pair.nil?
59
+
60
+ properties.push('invalid value for "rate", rate cannot be nil.') if rate.nil?
61
+
62
+ properties
63
+ end
64
+
65
+ # Check to see if the all the properties in the model are valid
66
+ # @return true if the model is valid
67
+ def valid?
68
+ invalid_properties.empty?
69
+ end
70
+
71
+ # Builds the object from hash
72
+ # @param [Hash] attributes Model attributes in the form of hash
73
+ # @return [Cryptopay::Exchange] Returns the model itself
74
+ def self.build_from_hash(data)
75
+ attributes = ENCODER.build_from_hash(data)
76
+ new(attributes)
77
+ end
78
+
79
+ # Returns the object in the form of hash
80
+ # @return [Hash] Returns the object in the form of hash
81
+ def to_hash
82
+ ENCODER.to_hash(@attributes)
83
+ end
84
+
85
+ def inspect
86
+ "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,116 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-generated file
4
+ # DO NOT EDIT
5
+
6
+ module Cryptopay
7
+ class ExchangeTransfer
8
+ ENCODER = Encoder.new(
9
+ name: 'Cryptopay::ExchangeTransfer',
10
+ attribute_map: {
11
+ 'id': :id,
12
+ 'charged_amount': :charged_amount,
13
+ 'charged_currency': :charged_currency,
14
+ 'received_amount': :received_amount,
15
+ 'received_currency': :received_currency,
16
+ 'custom_id': :custom_id,
17
+ 'exchange': :exchange
18
+ },
19
+ types: {
20
+ 'id': :String,
21
+ 'charged_amount': :Decimal,
22
+ 'charged_currency': :String,
23
+ 'received_amount': :Decimal,
24
+ 'received_currency': :String,
25
+ 'custom_id': :String,
26
+ 'exchange': :Exchange
27
+ },
28
+ nullables: [
29
+ :custom_id
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 id
41
+ @attributes[:id]
42
+ end
43
+
44
+ def charged_amount
45
+ @attributes[:charged_amount]
46
+ end
47
+
48
+ def charged_currency
49
+ @attributes[:charged_currency]
50
+ end
51
+
52
+ def received_amount
53
+ @attributes[:received_amount]
54
+ end
55
+
56
+ def received_currency
57
+ @attributes[:received_currency]
58
+ end
59
+
60
+ def custom_id
61
+ @attributes[:custom_id]
62
+ end
63
+
64
+ def exchange
65
+ @attributes[:exchange]
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 "id", id cannot be nil.') if id.nil?
74
+
75
+ properties.push('invalid value for "charged_amount", charged_amount cannot be nil.') if charged_amount.nil?
76
+
77
+ properties.push('invalid value for "charged_currency", charged_currency cannot be nil.') if charged_currency.nil?
78
+
79
+ properties.push('invalid value for "received_amount", received_amount cannot be nil.') if received_amount.nil?
80
+
81
+ if received_currency.nil?
82
+ properties.push('invalid value for "received_currency", received_currency cannot be nil.')
83
+ end
84
+
85
+ exchange&.invalid_properties&.each do |prop|
86
+ properties.push("invalid value for \"exchange\": #{prop}")
87
+ end
88
+
89
+ properties
90
+ end
91
+
92
+ # Check to see if the all the properties in the model are valid
93
+ # @return true if the model is valid
94
+ def valid?
95
+ invalid_properties.empty?
96
+ end
97
+
98
+ # Builds the object from hash
99
+ # @param [Hash] attributes Model attributes in the form of hash
100
+ # @return [Cryptopay::ExchangeTransfer] Returns the model itself
101
+ def self.build_from_hash(data)
102
+ attributes = ENCODER.build_from_hash(data)
103
+ new(attributes)
104
+ end
105
+
106
+ # Returns the object in the form of hash
107
+ # @return [Hash] Returns the object in the form of hash
108
+ def to_hash
109
+ ENCODER.to_hash(@attributes)
110
+ end
111
+
112
+ def inspect
113
+ "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
114
+ end
115
+ end
116
+ end