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.
- checksums.yaml +7 -0
- data/.github/workflows/ci.yml +36 -0
- data/.gitignore +38 -0
- data/.rspec +2 -0
- data/.rubocop.yml +104 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +521 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/cryptopay.gemspec +40 -0
- data/lib/cryptopay/api/accounts.rb +51 -0
- data/lib/cryptopay/api/channels.rb +142 -0
- data/lib/cryptopay/api/coin_withdrawals.rb +115 -0
- data/lib/cryptopay/api/customers.rb +85 -0
- data/lib/cryptopay/api/exchange_transfers.rb +64 -0
- data/lib/cryptopay/api/invoices.rb +163 -0
- data/lib/cryptopay/api/rates.rb +50 -0
- data/lib/cryptopay/api/risks.rb +32 -0
- data/lib/cryptopay/api/transactions.rb +47 -0
- data/lib/cryptopay/authentication.rb +30 -0
- data/lib/cryptopay/callbacks.rb +38 -0
- data/lib/cryptopay/client.rb +39 -0
- data/lib/cryptopay/config.rb +48 -0
- data/lib/cryptopay/connection.rb +48 -0
- data/lib/cryptopay/encoder.rb +113 -0
- data/lib/cryptopay/errors.rb +32 -0
- data/lib/cryptopay/models/account.rb +88 -0
- data/lib/cryptopay/models/account_list_result.rb +70 -0
- data/lib/cryptopay/models/callback.rb +25 -0
- data/lib/cryptopay/models/channel.rb +156 -0
- data/lib/cryptopay/models/channel_list_result.rb +82 -0
- data/lib/cryptopay/models/channel_params.rb +102 -0
- data/lib/cryptopay/models/channel_payment.rb +216 -0
- data/lib/cryptopay/models/channel_payment_callback.rb +92 -0
- data/lib/cryptopay/models/channel_payment_callback_event.rb +21 -0
- data/lib/cryptopay/models/channel_payment_list_result.rb +82 -0
- data/lib/cryptopay/models/channel_payment_result.rb +68 -0
- data/lib/cryptopay/models/channel_payment_status.rb +21 -0
- data/lib/cryptopay/models/channel_payment_status_context.rb +18 -0
- data/lib/cryptopay/models/channel_result.rb +68 -0
- data/lib/cryptopay/models/channel_status.rb +18 -0
- data/lib/cryptopay/models/channel_update_params.rb +85 -0
- data/lib/cryptopay/models/coin_withdrawal.rb +205 -0
- data/lib/cryptopay/models/coin_withdrawal_callback.rb +92 -0
- data/lib/cryptopay/models/coin_withdrawal_callback_event.rb +18 -0
- data/lib/cryptopay/models/coin_withdrawal_list_result.rb +82 -0
- data/lib/cryptopay/models/coin_withdrawal_params.rb +135 -0
- data/lib/cryptopay/models/coin_withdrawal_result.rb +68 -0
- data/lib/cryptopay/models/coin_withdrawal_status.rb +24 -0
- data/lib/cryptopay/models/customer.rb +81 -0
- data/lib/cryptopay/models/customer_list_result.rb +82 -0
- data/lib/cryptopay/models/customer_params.rb +81 -0
- data/lib/cryptopay/models/customer_result.rb +68 -0
- data/lib/cryptopay/models/customer_update_params.rb +68 -0
- data/lib/cryptopay/models/exchange.rb +89 -0
- data/lib/cryptopay/models/exchange_transfer.rb +116 -0
- data/lib/cryptopay/models/exchange_transfer_params.rb +101 -0
- data/lib/cryptopay/models/exchange_transfer_result.rb +68 -0
- data/lib/cryptopay/models/invoice.rb +276 -0
- data/lib/cryptopay/models/invoice_callback.rb +90 -0
- data/lib/cryptopay/models/invoice_callback_event.rb +22 -0
- data/lib/cryptopay/models/invoice_list_result.rb +82 -0
- data/lib/cryptopay/models/invoice_params.rb +131 -0
- data/lib/cryptopay/models/invoice_recalculation.rb +178 -0
- data/lib/cryptopay/models/invoice_recalculation_params.rb +61 -0
- data/lib/cryptopay/models/invoice_recalculation_result.rb +68 -0
- data/lib/cryptopay/models/invoice_refund.rb +154 -0
- data/lib/cryptopay/models/invoice_refund_list_result.rb +70 -0
- data/lib/cryptopay/models/invoice_refund_params.rb +61 -0
- data/lib/cryptopay/models/invoice_refund_result.rb +68 -0
- data/lib/cryptopay/models/invoice_result.rb +68 -0
- data/lib/cryptopay/models/invoice_status.rb +21 -0
- data/lib/cryptopay/models/invoice_status_context.rb +20 -0
- data/lib/cryptopay/models/invoice_transaction.rb +76 -0
- data/lib/cryptopay/models/network_fee.rb +84 -0
- data/lib/cryptopay/models/network_fee_level.rb +19 -0
- data/lib/cryptopay/models/network_fee_list_result.rb +70 -0
- data/lib/cryptopay/models/pagination.rb +72 -0
- data/lib/cryptopay/models/rate.rb +74 -0
- data/lib/cryptopay/models/rate_result.rb +68 -0
- data/lib/cryptopay/models/rates_result.rb +64 -0
- data/lib/cryptopay/models/risk.rb +98 -0
- data/lib/cryptopay/models/risk_level.rb +19 -0
- data/lib/cryptopay/models/risk_params.rb +86 -0
- data/lib/cryptopay/models/risk_result.rb +68 -0
- data/lib/cryptopay/models/transaction.rb +174 -0
- data/lib/cryptopay/models/transaction_list_result.rb +82 -0
- data/lib/cryptopay/models/transaction_reference_type.rb +25 -0
- data/lib/cryptopay/request.rb +46 -0
- data/lib/cryptopay/require.rb +79 -0
- data/lib/cryptopay/types.rb +11 -0
- data/lib/cryptopay/version.rb +5 -0
- data/lib/cryptopay.rb +26 -0
- metadata +256 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Cryptopay
|
|
4
|
+
class Authentication
|
|
5
|
+
def initialize(api_key:, api_secret:)
|
|
6
|
+
@api_key = api_key
|
|
7
|
+
@api_secret = api_secret
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def sign(request)
|
|
11
|
+
signature_string = [
|
|
12
|
+
request.method.to_s.upcase,
|
|
13
|
+
request.body.nil? ? '' : Digest::MD5.hexdigest(request.body),
|
|
14
|
+
request.content_type,
|
|
15
|
+
request.date,
|
|
16
|
+
request.path
|
|
17
|
+
].join("\n")
|
|
18
|
+
|
|
19
|
+
signature = Base64.strict_encode64(OpenSSL::HMAC.digest('sha1', api_secret, signature_string))
|
|
20
|
+
|
|
21
|
+
request.add_header('Authorization', "HMAC #{api_key}:#{signature}")
|
|
22
|
+
|
|
23
|
+
request
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
attr_reader :api_key, :api_secret
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Cryptopay
|
|
4
|
+
class Callbacks
|
|
5
|
+
def initialize(secret)
|
|
6
|
+
@secret = secret
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# Verifies callback body and builds Callback object
|
|
10
|
+
# @param body [String] Raw request body string
|
|
11
|
+
# @param signature [String] Value of the X-Cryptopay-Signature header
|
|
12
|
+
# @return [Object] Callback
|
|
13
|
+
def verify(body, signature)
|
|
14
|
+
expected_signature = OpenSSL::HMAC.hexdigest('SHA256', secret, body)
|
|
15
|
+
|
|
16
|
+
equals = secure_compare(signature, expected_signature)
|
|
17
|
+
raise(SignatureVerificationError, 'Signature mismatch') unless equals
|
|
18
|
+
|
|
19
|
+
data = JSON.parse(body, symbolize_names: true)
|
|
20
|
+
Callback.build_from_hash(data)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
attr_reader :secret
|
|
26
|
+
|
|
27
|
+
# Constant-time comparison algorithm to prevent timing attacks
|
|
28
|
+
def secure_compare(str1, str2)
|
|
29
|
+
return false if str1.empty? || str2.empty? || str1.bytesize != str2.bytesize
|
|
30
|
+
|
|
31
|
+
l = str1.unpack("C#{str1.bytesize}")
|
|
32
|
+
|
|
33
|
+
res = 0
|
|
34
|
+
str2.each_byte { |byte| res |= byte ^ l.shift }
|
|
35
|
+
res.zero?
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Cryptopay
|
|
4
|
+
class Client
|
|
5
|
+
attr_reader :invoices,
|
|
6
|
+
:rates,
|
|
7
|
+
:coin_withdrawals,
|
|
8
|
+
:channels,
|
|
9
|
+
:accounts,
|
|
10
|
+
:transactions,
|
|
11
|
+
:exchange_transfers,
|
|
12
|
+
:customers,
|
|
13
|
+
:risks,
|
|
14
|
+
:callbacks
|
|
15
|
+
|
|
16
|
+
def initialize(&block)
|
|
17
|
+
config = Config.new(&block)
|
|
18
|
+
connection = Connection.new(config)
|
|
19
|
+
|
|
20
|
+
setup_apis(connection)
|
|
21
|
+
|
|
22
|
+
@callbacks = Callbacks.new(config.callback_secret)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
def setup_apis(connection)
|
|
28
|
+
@invoices = Invoices.new(connection)
|
|
29
|
+
@rates = Rates.new(connection)
|
|
30
|
+
@coin_withdrawals = CoinWithdrawals.new(connection)
|
|
31
|
+
@channels = Channels.new(connection)
|
|
32
|
+
@accounts = Accounts.new(connection)
|
|
33
|
+
@transactions = Transactions.new(connection)
|
|
34
|
+
@exchange_transfers = ExchangeTransfers.new(connection)
|
|
35
|
+
@customers = Customers.new(connection)
|
|
36
|
+
@risks = Risks.new(connection)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Cryptopay
|
|
4
|
+
class Config
|
|
5
|
+
# Cryptopay API Base URL
|
|
6
|
+
attr_accessor :api_url
|
|
7
|
+
|
|
8
|
+
# Cryptopay API Key
|
|
9
|
+
attr_accessor :api_key
|
|
10
|
+
|
|
11
|
+
# Cryptopay API Secret
|
|
12
|
+
attr_accessor :api_secret
|
|
13
|
+
|
|
14
|
+
# Cryptopay callback secret
|
|
15
|
+
attr_accessor :callback_secret
|
|
16
|
+
|
|
17
|
+
# Optional proc yeilding the Faraday builder
|
|
18
|
+
attr_accessor :faraday_builder
|
|
19
|
+
|
|
20
|
+
# The Faraday adapter to be used. Net::HTTP by default
|
|
21
|
+
attr_accessor :faraday_adapter
|
|
22
|
+
|
|
23
|
+
def initialize
|
|
24
|
+
yield(self)
|
|
25
|
+
|
|
26
|
+
validate!
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def validate!
|
|
32
|
+
errors = validate
|
|
33
|
+
return if errors.empty?
|
|
34
|
+
|
|
35
|
+
raise(ArgumentError, errors.join("\n"))
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def validate
|
|
39
|
+
errors = []
|
|
40
|
+
|
|
41
|
+
errors << 'Missing "api_url" in Cryptopay config' if api_url.nil?
|
|
42
|
+
errors << 'Missing "api_key" in Cryptopay config' if api_key.nil?
|
|
43
|
+
errors << 'Missing "api_secret" in Cryptopay config' if api_secret.nil?
|
|
44
|
+
|
|
45
|
+
errors
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Cryptopay
|
|
4
|
+
class Connection
|
|
5
|
+
def initialize(config)
|
|
6
|
+
@config = config
|
|
7
|
+
@auth = Authentication.new(api_key: config.api_key, api_secret: config.api_secret)
|
|
8
|
+
@faraday = setup_faraday
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def call(req, return_type:)
|
|
12
|
+
auth.sign(req)
|
|
13
|
+
|
|
14
|
+
res = run_request(req)
|
|
15
|
+
body = JSON.parse(res.body, symbolize_names: true)
|
|
16
|
+
|
|
17
|
+
return_type.build_from_hash(body)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
attr_reader :config, :auth, :faraday
|
|
23
|
+
|
|
24
|
+
def run_request(req)
|
|
25
|
+
res = faraday.run_request(req.method, req.path, req.body, req.headers)
|
|
26
|
+
check_error(res)
|
|
27
|
+
rescue Faraday::Error => e
|
|
28
|
+
raise(ConnectionError, e)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def setup_faraday
|
|
32
|
+
adapter = config.faraday_adapter || Faraday.default_adapter
|
|
33
|
+
|
|
34
|
+
@connection = Faraday.new(url: config.api_url) do |f|
|
|
35
|
+
config.faraday_builder&.call(f)
|
|
36
|
+
|
|
37
|
+
f.adapter(*adapter)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def check_error(res)
|
|
42
|
+
error = Error.from_response(res)
|
|
43
|
+
raise(error) if error
|
|
44
|
+
|
|
45
|
+
res
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Cryptopay
|
|
4
|
+
class Encoder
|
|
5
|
+
def initialize(name:, attribute_map:, types:, nullables:)
|
|
6
|
+
@name = name
|
|
7
|
+
@attribute_map = attribute_map
|
|
8
|
+
@types = types
|
|
9
|
+
@nullables = nullables
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def sanitize(attributes)
|
|
13
|
+
attributes.each_with_object({}) do |(k, v), h|
|
|
14
|
+
unless attribute_map.key?(k.to_sym)
|
|
15
|
+
raise(
|
|
16
|
+
ArgumentError,
|
|
17
|
+
"`#{k}` is not a valid attribute in `#{name}`. " \
|
|
18
|
+
"Please check the name to make sure it's valid. List of attributes: " + attribute_map.keys.inspect
|
|
19
|
+
)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
h[k.to_sym] = v
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def build_from_hash(data)
|
|
27
|
+
types.each_with_object({}) do |(key, type), attributes|
|
|
28
|
+
value = data[attribute_map[key]]
|
|
29
|
+
|
|
30
|
+
if value.nil?
|
|
31
|
+
attributes[key] = nil if nullables.include?(key)
|
|
32
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
33
|
+
attributes[key] = value.map { |v| _deserialize(Regexp.last_match(1), v) }
|
|
34
|
+
else
|
|
35
|
+
attributes[key] = _deserialize(type, value)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def to_hash(attributes)
|
|
41
|
+
attribute_map.each_with_object({}) do |(attr, param), hash|
|
|
42
|
+
value = attributes[attr]
|
|
43
|
+
if value.nil?
|
|
44
|
+
nullable = nullables.include?(attr)
|
|
45
|
+
|
|
46
|
+
# Skip non-nullable attributes with nil values
|
|
47
|
+
next unless nullable
|
|
48
|
+
|
|
49
|
+
# Skip nullable attributes which was not explicitly set
|
|
50
|
+
next unless attributes.key?(attr)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
hash[param] = _to_hash(value)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
private
|
|
58
|
+
|
|
59
|
+
def _deserialize(type, value)
|
|
60
|
+
case type.to_sym
|
|
61
|
+
when :Time
|
|
62
|
+
Time.parse(value)
|
|
63
|
+
when :Date
|
|
64
|
+
Date.parse(value)
|
|
65
|
+
when :String
|
|
66
|
+
value.to_s
|
|
67
|
+
when :Integer
|
|
68
|
+
value.to_i
|
|
69
|
+
when :Float
|
|
70
|
+
value.to_f
|
|
71
|
+
when :Boolean
|
|
72
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
73
|
+
true
|
|
74
|
+
else
|
|
75
|
+
false
|
|
76
|
+
end
|
|
77
|
+
when :Object
|
|
78
|
+
# generic object (usually a Hash), return directly
|
|
79
|
+
value
|
|
80
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
81
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
82
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
83
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
84
|
+
k_type = Regexp.last_match[:k_type]
|
|
85
|
+
v_type = Regexp.last_match[:v_type]
|
|
86
|
+
{}.tap do |hash|
|
|
87
|
+
value.each do |k, v|
|
|
88
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
else
|
|
92
|
+
klass = Cryptopay.const_get(type)
|
|
93
|
+
klass.build_from_hash(value)
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def _to_hash(value)
|
|
98
|
+
if value.is_a?(Array)
|
|
99
|
+
value.compact.map { |v| _to_hash(v) }
|
|
100
|
+
elsif value.is_a?(Hash)
|
|
101
|
+
{}.tap do |hash|
|
|
102
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
103
|
+
end
|
|
104
|
+
elsif value.respond_to?(:to_hash)
|
|
105
|
+
value.to_hash
|
|
106
|
+
else
|
|
107
|
+
value
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
attr_reader :name, :attribute_map, :types, :nullables
|
|
112
|
+
end
|
|
113
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Cryptopay
|
|
4
|
+
class Error < StandardError
|
|
5
|
+
def self.from_response(res)
|
|
6
|
+
case res.status
|
|
7
|
+
when 400..499
|
|
8
|
+
ClientError.from_response(res)
|
|
9
|
+
when 500..599
|
|
10
|
+
ServerError.from_response(res)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class ClientError < Error
|
|
16
|
+
def self.from_response(res)
|
|
17
|
+
new("Status #{res.status}: #{res.body}")
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
class ServerError < Error
|
|
22
|
+
def self.from_response(res)
|
|
23
|
+
new("Status #{res.status}: #{res.body}")
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
class ConnectionError < Error
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
class SignatureVerificationError < Error
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Auto-generated file
|
|
4
|
+
# DO NOT EDIT
|
|
5
|
+
|
|
6
|
+
module Cryptopay
|
|
7
|
+
class Account
|
|
8
|
+
ENCODER = Encoder.new(
|
|
9
|
+
name: 'Cryptopay::Account',
|
|
10
|
+
attribute_map: {
|
|
11
|
+
'id': :id,
|
|
12
|
+
'currency': :currency,
|
|
13
|
+
'balance': :balance,
|
|
14
|
+
'project_id': :project_id
|
|
15
|
+
},
|
|
16
|
+
types: {
|
|
17
|
+
'id': :String,
|
|
18
|
+
'currency': :String,
|
|
19
|
+
'balance': :Decimal,
|
|
20
|
+
'project_id': :String
|
|
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 id
|
|
33
|
+
@attributes[:id]
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def currency
|
|
37
|
+
@attributes[:currency]
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def balance
|
|
41
|
+
@attributes[:balance]
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def project_id
|
|
45
|
+
@attributes[:project_id]
|
|
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 "id", id cannot be nil.') if id.nil?
|
|
54
|
+
|
|
55
|
+
properties.push('invalid value for "currency", currency cannot be nil.') if currency.nil?
|
|
56
|
+
|
|
57
|
+
properties.push('invalid value for "balance", balance cannot be nil.') if balance.nil?
|
|
58
|
+
|
|
59
|
+
properties.push('invalid value for "project_id", project_id cannot be nil.') if project_id.nil?
|
|
60
|
+
|
|
61
|
+
properties
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Check to see if the all the properties in the model are valid
|
|
65
|
+
# @return true if the model is valid
|
|
66
|
+
def valid?
|
|
67
|
+
invalid_properties.empty?
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Builds the object from hash
|
|
71
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
72
|
+
# @return [Cryptopay::Account] Returns the model itself
|
|
73
|
+
def self.build_from_hash(data)
|
|
74
|
+
attributes = ENCODER.build_from_hash(data)
|
|
75
|
+
new(attributes)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Returns the object in the form of hash
|
|
79
|
+
# @return [Hash] Returns the object in the form of hash
|
|
80
|
+
def to_hash
|
|
81
|
+
ENCODER.to_hash(@attributes)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def inspect
|
|
85
|
+
"#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
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 AccountListResult
|
|
8
|
+
ENCODER = Encoder.new(
|
|
9
|
+
name: 'Cryptopay::AccountListResult',
|
|
10
|
+
attribute_map: {
|
|
11
|
+
'data': :data
|
|
12
|
+
},
|
|
13
|
+
types: {
|
|
14
|
+
'data': :'Array<Account>'
|
|
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::AccountListResult] 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,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Auto-generated file
|
|
4
|
+
# DO NOT EDIT
|
|
5
|
+
|
|
6
|
+
module Cryptopay
|
|
7
|
+
module Callback
|
|
8
|
+
DISCRIMINATOR_NAME = :type
|
|
9
|
+
private_constant :DISCRIMINATOR_NAME
|
|
10
|
+
|
|
11
|
+
# Builds the object
|
|
12
|
+
# @param [Mixed] Data to be matched against the list of oneOf items
|
|
13
|
+
# @return [Cryptopay::ChannelPaymentCallback, Cryptopay::CoinWithdrawalCallback, Cryptopay::InvoiceCallback, nil] Returns the model or nil
|
|
14
|
+
def self.build_from_hash(data)
|
|
15
|
+
case data[DISCRIMINATOR_NAME]
|
|
16
|
+
when 'ChannelPayment'
|
|
17
|
+
ChannelPaymentCallback.build_from_hash(data)
|
|
18
|
+
when 'CoinWithdrawal'
|
|
19
|
+
CoinWithdrawalCallback.build_from_hash(data)
|
|
20
|
+
when 'Invoice'
|
|
21
|
+
InvoiceCallback.build_from_hash(data)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Auto-generated file
|
|
4
|
+
# DO NOT EDIT
|
|
5
|
+
|
|
6
|
+
module Cryptopay
|
|
7
|
+
class Channel
|
|
8
|
+
ENCODER = Encoder.new(
|
|
9
|
+
name: 'Cryptopay::Channel',
|
|
10
|
+
attribute_map: {
|
|
11
|
+
'id': :id,
|
|
12
|
+
'status': :status,
|
|
13
|
+
'name': :name,
|
|
14
|
+
'description': :description,
|
|
15
|
+
'pay_currency': :pay_currency,
|
|
16
|
+
'receiver_currency': :receiver_currency,
|
|
17
|
+
'address': :address,
|
|
18
|
+
'project_id': :project_id,
|
|
19
|
+
'custom_id': :custom_id,
|
|
20
|
+
'customer_id': :customer_id,
|
|
21
|
+
'uri': :uri,
|
|
22
|
+
'hosted_page_url': :hosted_page_url
|
|
23
|
+
},
|
|
24
|
+
types: {
|
|
25
|
+
'id': :String,
|
|
26
|
+
'status': :ChannelStatus,
|
|
27
|
+
'name': :String,
|
|
28
|
+
'description': :String,
|
|
29
|
+
'pay_currency': :String,
|
|
30
|
+
'receiver_currency': :String,
|
|
31
|
+
'address': :String,
|
|
32
|
+
'project_id': :String,
|
|
33
|
+
'custom_id': :String,
|
|
34
|
+
'customer_id': :String,
|
|
35
|
+
'uri': :String,
|
|
36
|
+
'hosted_page_url': :String
|
|
37
|
+
},
|
|
38
|
+
nullables: %i[
|
|
39
|
+
description
|
|
40
|
+
custom_id
|
|
41
|
+
customer_id
|
|
42
|
+
]
|
|
43
|
+
)
|
|
44
|
+
private_constant :ENCODER
|
|
45
|
+
|
|
46
|
+
# Initializes the object
|
|
47
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
48
|
+
def initialize(attributes = {})
|
|
49
|
+
@attributes = ENCODER.sanitize(attributes)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def id
|
|
53
|
+
@attributes[:id]
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def status
|
|
57
|
+
@attributes[:status]
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def name
|
|
61
|
+
@attributes[:name]
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def description
|
|
65
|
+
@attributes[:description]
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def pay_currency
|
|
69
|
+
@attributes[:pay_currency]
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def receiver_currency
|
|
73
|
+
@attributes[:receiver_currency]
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def address
|
|
77
|
+
@attributes[:address]
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def project_id
|
|
81
|
+
@attributes[:project_id]
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def custom_id
|
|
85
|
+
@attributes[:custom_id]
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def customer_id
|
|
89
|
+
@attributes[:customer_id]
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def uri
|
|
93
|
+
@attributes[:uri]
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def hosted_page_url
|
|
97
|
+
@attributes[:hosted_page_url]
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
101
|
+
# @return Array for valid properties with the reasons
|
|
102
|
+
def invalid_properties
|
|
103
|
+
properties = []
|
|
104
|
+
|
|
105
|
+
properties.push('invalid value for "id", id cannot be nil.') if id.nil?
|
|
106
|
+
|
|
107
|
+
properties.push('invalid value for "status", status cannot be nil.') if status.nil?
|
|
108
|
+
|
|
109
|
+
if !status.nil? && !%w[enabled disabled].include?(status)
|
|
110
|
+
properties.push('invalid value for status, must be one of "enabled", "disabled"')
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
properties.push('invalid value for "name", name cannot be nil.') if name.nil?
|
|
114
|
+
|
|
115
|
+
properties.push('invalid value for "pay_currency", pay_currency cannot be nil.') if pay_currency.nil?
|
|
116
|
+
|
|
117
|
+
if receiver_currency.nil?
|
|
118
|
+
properties.push('invalid value for "receiver_currency", receiver_currency cannot be nil.')
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
properties.push('invalid value for "address", address cannot be nil.') if address.nil?
|
|
122
|
+
|
|
123
|
+
properties.push('invalid value for "project_id", project_id cannot be nil.') if project_id.nil?
|
|
124
|
+
|
|
125
|
+
properties.push('invalid value for "uri", uri cannot be nil.') if uri.nil?
|
|
126
|
+
|
|
127
|
+
properties.push('invalid value for "hosted_page_url", hosted_page_url cannot be nil.') if hosted_page_url.nil?
|
|
128
|
+
|
|
129
|
+
properties
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# Check to see if the all the properties in the model are valid
|
|
133
|
+
# @return true if the model is valid
|
|
134
|
+
def valid?
|
|
135
|
+
invalid_properties.empty?
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# Builds the object from hash
|
|
139
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
140
|
+
# @return [Cryptopay::Channel] Returns the model itself
|
|
141
|
+
def self.build_from_hash(data)
|
|
142
|
+
attributes = ENCODER.build_from_hash(data)
|
|
143
|
+
new(attributes)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# Returns the object in the form of hash
|
|
147
|
+
# @return [Hash] Returns the object in the form of hash
|
|
148
|
+
def to_hash
|
|
149
|
+
ENCODER.to_hash(@attributes)
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def inspect
|
|
153
|
+
"#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash)
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
end
|