cryptopay-ruby 0.1.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.
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,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-generated file
4
+ # DO NOT EDIT
5
+
6
+ module Cryptopay
7
+ class RatesResult
8
+ ENCODER = Encoder.new(
9
+ name: 'Cryptopay::RatesResult',
10
+ attribute_map: {
11
+ 'data': :data
12
+ },
13
+ types: {
14
+ 'data': :'Hash<String, Rate>'
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
+ 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::RatesResult] 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,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-generated file
4
+ # DO NOT EDIT
5
+
6
+ module Cryptopay
7
+ # Transaction risk level details
8
+ class Risk
9
+ ENCODER = Encoder.new(
10
+ name: 'Cryptopay::Risk',
11
+ attribute_map: {
12
+ 'score': :score,
13
+ 'level': :level,
14
+ 'resource_name': :resource_name,
15
+ 'resource_category': :resource_category
16
+ },
17
+ types: {
18
+ 'score': :Float,
19
+ 'level': :RiskLevel,
20
+ 'resource_name': :String,
21
+ 'resource_category': :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
+ # Transaction risk score
34
+ def score
35
+ @attributes[:score]
36
+ end
37
+
38
+ def level
39
+ @attributes[:level]
40
+ end
41
+
42
+ # A resource name the transaction has been received from
43
+ def resource_name
44
+ @attributes[:resource_name]
45
+ end
46
+
47
+ # A resource category the transaction has been received from
48
+ def resource_category
49
+ @attributes[:resource_category]
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 "score", score cannot be nil.') if score.nil?
58
+
59
+ properties.push('invalid value for "level", level cannot be nil.') if level.nil?
60
+
61
+ if !level.nil? && !%w[low medium high].include?(level)
62
+ properties.push('invalid value for level, must be one of "low", "medium", "high"')
63
+ end
64
+
65
+ properties.push('invalid value for "resource_name", resource_name cannot be nil.') if resource_name.nil?
66
+
67
+ if resource_category.nil?
68
+ properties.push('invalid value for "resource_category", resource_category cannot be nil.')
69
+ end
70
+
71
+ properties
72
+ end
73
+
74
+ # Check to see if the all the properties in the model are valid
75
+ # @return true if the model is valid
76
+ def valid?
77
+ invalid_properties.empty?
78
+ end
79
+
80
+ # Builds the object from hash
81
+ # @param [Hash] attributes Model attributes in the form of hash
82
+ # @return [Cryptopay::Risk] Returns the model itself
83
+ def self.build_from_hash(data)
84
+ attributes = ENCODER.build_from_hash(data)
85
+ new(attributes)
86
+ end
87
+
88
+ # Returns the object in the form of hash
89
+ # @return [Hash] Returns the object in the form of hash
90
+ def to_hash
91
+ ENCODER.to_hash(@attributes)
92
+ end
93
+
94
+ def inspect
95
+ "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-generated file
4
+ # DO NOT EDIT
5
+
6
+ module Cryptopay
7
+ module RiskLevel
8
+ LOW = 'low'
9
+ MEDIUM = 'medium'
10
+ HIGH = 'high'
11
+
12
+ # Builds the enum from string
13
+ # @param [String] The enum value in the form of the string
14
+ # @return [String] The enum value
15
+ def self.build_from_hash(value)
16
+ value
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-generated file
4
+ # DO NOT EDIT
5
+
6
+ module Cryptopay
7
+ class RiskParams
8
+ ENCODER = Encoder.new(
9
+ name: 'Cryptopay::RiskParams',
10
+ attribute_map: {
11
+ 'address': :address,
12
+ 'currency': :currency,
13
+ 'type': :type
14
+ },
15
+ types: {
16
+ 'address': :String,
17
+ 'currency': :String,
18
+ 'type': :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 symbol
36
+ def currency
37
+ @attributes[:currency]
38
+ end
39
+
40
+ def type
41
+ @attributes[:type]
42
+ end
43
+
44
+ # Show invalid properties with the reasons. Usually used together with valid?
45
+ # @return Array for valid properties with the reasons
46
+ def invalid_properties
47
+ properties = []
48
+
49
+ properties.push('invalid value for "address", address cannot be nil.') if address.nil?
50
+
51
+ properties.push('invalid value for "currency", currency cannot be nil.') if currency.nil?
52
+
53
+ properties.push('invalid value for "type", type cannot be nil.') if type.nil?
54
+
55
+ if !type.nil? && !%w[source_of_funds destination_of_funds].include?(type)
56
+ properties.push('invalid value for type, must be one of "source_of_funds", "destination_of_funds"')
57
+ end
58
+
59
+ properties
60
+ end
61
+
62
+ # Check to see if the all the properties in the model are valid
63
+ # @return true if the model is valid
64
+ def valid?
65
+ invalid_properties.empty?
66
+ end
67
+
68
+ # Builds the object from hash
69
+ # @param [Hash] attributes Model attributes in the form of hash
70
+ # @return [Cryptopay::RiskParams] Returns the model itself
71
+ def self.build_from_hash(data)
72
+ attributes = ENCODER.build_from_hash(data)
73
+ new(attributes)
74
+ end
75
+
76
+ # Returns the object in the form of hash
77
+ # @return [Hash] Returns the object in the form of hash
78
+ def to_hash
79
+ ENCODER.to_hash(@attributes)
80
+ end
81
+
82
+ def inspect
83
+ "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
84
+ end
85
+ end
86
+ 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 RiskResult
8
+ ENCODER = Encoder.new(
9
+ name: 'Cryptopay::RiskResult',
10
+ attribute_map: {
11
+ 'data': :data
12
+ },
13
+ types: {
14
+ 'data': :Risk
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::RiskResult] 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,174 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-generated file
4
+ # DO NOT EDIT
5
+
6
+ module Cryptopay
7
+ class Transaction
8
+ ENCODER = Encoder.new(
9
+ name: 'Cryptopay::Transaction',
10
+ attribute_map: {
11
+ 'id': :id,
12
+ 'custom_id': :custom_id,
13
+ 'customer_id': :customer_id,
14
+ 'amount': :amount,
15
+ 'currency': :currency,
16
+ 'balance': :balance,
17
+ 'fee': :fee,
18
+ 'fee_currency': :fee_currency,
19
+ 'reference_id': :reference_id,
20
+ 'reference_type': :reference_type,
21
+ 'description': :description,
22
+ 'status': :status,
23
+ 'status_context': :status_context,
24
+ 'risk': :risk,
25
+ 'created_at': :created_at
26
+ },
27
+ types: {
28
+ 'id': :String,
29
+ 'custom_id': :String,
30
+ 'customer_id': :String,
31
+ 'amount': :Decimal,
32
+ 'currency': :String,
33
+ 'balance': :Decimal,
34
+ 'fee': :Decimal,
35
+ 'fee_currency': :String,
36
+ 'reference_id': :String,
37
+ 'reference_type': :TransactionReferenceType,
38
+ 'description': :String,
39
+ 'status': :String,
40
+ 'status_context': :String,
41
+ 'risk': :Risk,
42
+ 'created_at': :Time
43
+ },
44
+ nullables: %i[
45
+ custom_id
46
+ customer_id
47
+ description
48
+ status
49
+ status_context
50
+ ]
51
+ )
52
+ private_constant :ENCODER
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ @attributes = ENCODER.sanitize(attributes)
58
+ end
59
+
60
+ def id
61
+ @attributes[:id]
62
+ end
63
+
64
+ def custom_id
65
+ @attributes[:custom_id]
66
+ end
67
+
68
+ def customer_id
69
+ @attributes[:customer_id]
70
+ end
71
+
72
+ def amount
73
+ @attributes[:amount]
74
+ end
75
+
76
+ def currency
77
+ @attributes[:currency]
78
+ end
79
+
80
+ def balance
81
+ @attributes[:balance]
82
+ end
83
+
84
+ def fee
85
+ @attributes[:fee]
86
+ end
87
+
88
+ def fee_currency
89
+ @attributes[:fee_currency]
90
+ end
91
+
92
+ def reference_id
93
+ @attributes[:reference_id]
94
+ end
95
+
96
+ def reference_type
97
+ @attributes[:reference_type]
98
+ end
99
+
100
+ def description
101
+ @attributes[:description]
102
+ end
103
+
104
+ def status
105
+ @attributes[:status]
106
+ end
107
+
108
+ def status_context
109
+ @attributes[:status_context]
110
+ end
111
+
112
+ def risk
113
+ @attributes[:risk]
114
+ end
115
+
116
+ def created_at
117
+ @attributes[:created_at]
118
+ end
119
+
120
+ # Show invalid properties with the reasons. Usually used together with valid?
121
+ # @return Array for valid properties with the reasons
122
+ def invalid_properties
123
+ properties = []
124
+
125
+ properties.push('invalid value for "id", id cannot be nil.') if id.nil?
126
+
127
+ properties.push('invalid value for "amount", amount cannot be nil.') if amount.nil?
128
+
129
+ properties.push('invalid value for "currency", currency cannot be nil.') if currency.nil?
130
+
131
+ properties.push('invalid value for "balance", balance cannot be nil.') if balance.nil?
132
+
133
+ properties.push('invalid value for "reference_id", reference_id cannot be nil.') if reference_id.nil?
134
+
135
+ properties.push('invalid value for "reference_type", reference_type cannot be nil.') if reference_type.nil?
136
+
137
+ if !reference_type.nil? && !%w[BankDeposit BankWithdrawal ChannelPayment CoinDeposit CoinWithdrawal ExchangeTransfer Invoice InvoiceRefund ManualBalanceTransaction].include?(reference_type)
138
+ properties.push('invalid value for reference_type, must be one of "BankDeposit", "BankWithdrawal", "ChannelPayment", "CoinDeposit", "CoinWithdrawal", "ExchangeTransfer", "Invoice", "InvoiceRefund", "ManualBalanceTransaction"')
139
+ end
140
+
141
+ risk&.invalid_properties&.each do |prop|
142
+ properties.push("invalid value for \"risk\": #{prop}")
143
+ end
144
+
145
+ properties.push('invalid value for "created_at", created_at cannot be nil.') if created_at.nil?
146
+
147
+ properties
148
+ end
149
+
150
+ # Check to see if the all the properties in the model are valid
151
+ # @return true if the model is valid
152
+ def valid?
153
+ invalid_properties.empty?
154
+ end
155
+
156
+ # Builds the object from hash
157
+ # @param [Hash] attributes Model attributes in the form of hash
158
+ # @return [Cryptopay::Transaction] Returns the model itself
159
+ def self.build_from_hash(data)
160
+ attributes = ENCODER.build_from_hash(data)
161
+ new(attributes)
162
+ end
163
+
164
+ # Returns the object in the form of hash
165
+ # @return [Hash] Returns the object in the form of hash
166
+ def to_hash
167
+ ENCODER.to_hash(@attributes)
168
+ end
169
+
170
+ def inspect
171
+ "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
172
+ end
173
+ end
174
+ 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 TransactionListResult
8
+ ENCODER = Encoder.new(
9
+ name: 'Cryptopay::TransactionListResult',
10
+ attribute_map: {
11
+ 'data': :data,
12
+ 'meta': :meta
13
+ },
14
+ types: {
15
+ 'data': :'Array<Transaction>',
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::TransactionListResult] 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,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Auto-generated file
4
+ # DO NOT EDIT
5
+
6
+ module Cryptopay
7
+ module TransactionReferenceType
8
+ BANK_DEPOSIT = 'BankDeposit'
9
+ BANK_WITHDRAWAL = 'BankWithdrawal'
10
+ CHANNEL_PAYMENT = 'ChannelPayment'
11
+ COIN_DEPOSIT = 'CoinDeposit'
12
+ COIN_WITHDRAWAL = 'CoinWithdrawal'
13
+ EXCHANGE_TRANSFER = 'ExchangeTransfer'
14
+ INVOICE = 'Invoice'
15
+ INVOICE_REFUND = 'InvoiceRefund'
16
+ MANUAL_BALANCE_TRANSACTION = 'ManualBalanceTransaction'
17
+
18
+ # Builds the enum from string
19
+ # @param [String] The enum value in the form of the string
20
+ # @return [String] The enum value
21
+ def self.build_from_hash(value)
22
+ value
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cryptopay
4
+ class Request
5
+ attr_reader :method, :path, :body, :date, :headers, :content_type
6
+
7
+ DEFAULT_HEADERS = {
8
+ 'Accept' => 'application/json',
9
+ 'User-Agent' => "Cryptopay Ruby v#{VERSION}"
10
+ }.freeze
11
+
12
+ CONTENT_TYPE = 'application/json'
13
+
14
+ def initialize(method:, path:, query_params: {}, body_params: {})
15
+ @method = method
16
+ @path = prepare_query(path, query_params)
17
+ @body = prepare_body(body_params.to_hash)
18
+ @date = Time.now.httpdate
19
+ @content_type = CONTENT_TYPE
20
+ @headers = DEFAULT_HEADERS.merge(Date: date, 'Content-Type': @content_type)
21
+ end
22
+
23
+ def add_header(key, value)
24
+ @headers = headers.merge(key => value)
25
+ end
26
+
27
+ private
28
+
29
+ def prepare_query(path, params)
30
+ return path if params.empty?
31
+
32
+ query = encode_query(params)
33
+ [path, query].join('?')
34
+ end
35
+
36
+ def prepare_body(params)
37
+ return if params.empty?
38
+
39
+ params.to_json
40
+ end
41
+
42
+ def encode_query(params)
43
+ Faraday::NestedParamsEncoder.encode(params)
44
+ end
45
+ end
46
+ end