coinbase-sdk 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/coinbase/address.rb +20 -20
- data/lib/coinbase/asset.rb +76 -66
- data/lib/coinbase/balance.rb +10 -6
- data/lib/coinbase/client/api/assets_api.rb +91 -0
- data/lib/coinbase/client/api/balances_api.rb +97 -0
- data/lib/coinbase/client/api/external_addresses_api.rb +242 -0
- data/lib/coinbase/client/api/stake_api.rb +156 -6
- data/lib/coinbase/client/api/transfer_api.rb +114 -0
- data/lib/coinbase/client/models/fetch_staking_rewards200_response.rb +258 -0
- data/lib/coinbase/client/models/fetch_staking_rewards_request.rb +343 -0
- data/lib/coinbase/client/models/get_staking_context_request.rb +274 -0
- data/lib/coinbase/client/models/partial_eth_staking_context.rb +257 -0
- data/lib/coinbase/client/models/staking_context.rb +222 -0
- data/lib/coinbase/client/models/staking_context_context.rb +104 -0
- data/lib/coinbase/client/models/staking_reward.rb +308 -0
- data/lib/coinbase/client.rb +9 -0
- data/lib/coinbase/constants.rb +2 -27
- data/lib/coinbase/errors.rb +49 -64
- data/lib/coinbase/network.rb +6 -20
- data/lib/coinbase/wallet.rb +2 -2
- data/lib/coinbase.rb +8 -11
- metadata +13 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c52613ebb145609813f96508c0eff76721ee6afebf3f3207394dad4c91b51635
|
4
|
+
data.tar.gz: d7f86c6cfbc02b6dd8866717cc9a89439b81da9ae8838dc34855dd10bf9f3fa9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fa544e18af4ad42457ec8615e7a6e652fb15e1ae00cfa14924dcb86c53aab1ba90b21a8e1b7b29f193b1e0039d030cba1f45631b8dac23b287617105b88478b
|
7
|
+
data.tar.gz: 3625e897b9681e208cd921e8118275bd012996c17fb62fc235eac8624e6742ce18cff8d8177a1d379bfb5fa71ebec3db02a70d2bb683aeb067ccac7f89345945
|
data/lib/coinbase/address.rb
CHANGED
@@ -79,11 +79,13 @@ module Coinbase
|
|
79
79
|
# default address. If a String, interprets it as the address ID.
|
80
80
|
# @return [Coinbase::Transfer] The Transfer object.
|
81
81
|
def transfer(amount, asset_id, destination)
|
82
|
+
asset = Asset.fetch(network_id, asset_id)
|
83
|
+
|
82
84
|
destination_address, destination_network = destination_address_and_network(destination)
|
83
85
|
|
84
|
-
validate_can_transfer!(amount,
|
86
|
+
validate_can_transfer!(amount, asset, destination_network)
|
85
87
|
|
86
|
-
transfer = create_transfer(amount,
|
88
|
+
transfer = create_transfer(amount, asset, destination_address)
|
87
89
|
|
88
90
|
# If a server signer is managing keys, it will sign and broadcast the underlying transfer transaction out of band.
|
89
91
|
return transfer if Coinbase.use_server_signer?
|
@@ -98,9 +100,12 @@ module Coinbase
|
|
98
100
|
# @param to_asset_id [Symbol] The ID of the Asset to trade to. For Ether, :eth, :gwei, and :wei are supported.
|
99
101
|
# @return [Coinbase::Trade] The Trade object.
|
100
102
|
def trade(amount, from_asset_id, to_asset_id)
|
101
|
-
|
103
|
+
from_asset = Asset.fetch(network_id, from_asset_id)
|
104
|
+
to_asset = Asset.fetch(network_id, to_asset_id)
|
105
|
+
|
106
|
+
validate_can_trade!(amount, from_asset)
|
102
107
|
|
103
|
-
trade = create_trade(amount,
|
108
|
+
trade = create_trade(amount, from_asset, to_asset)
|
104
109
|
|
105
110
|
# NOTE: Trading does not yet support server signers at this point.
|
106
111
|
|
@@ -192,25 +197,23 @@ module Coinbase
|
|
192
197
|
[destination, network_id]
|
193
198
|
end
|
194
199
|
|
195
|
-
def validate_can_transfer!(amount,
|
200
|
+
def validate_can_transfer!(amount, asset, destination_network_id)
|
196
201
|
raise 'Cannot transfer from address without private key loaded' unless can_sign? || Coinbase.use_server_signer?
|
197
202
|
|
198
|
-
raise ArgumentError, "Unsupported asset: #{asset_id}" unless Coinbase::Asset.supported?(asset_id)
|
199
|
-
|
200
203
|
raise ArgumentError, 'Transfer must be on the same Network' unless destination_network_id == network_id
|
201
204
|
|
202
|
-
current_balance = balance(asset_id)
|
205
|
+
current_balance = balance(asset.asset_id)
|
203
206
|
|
204
207
|
return unless current_balance < amount
|
205
208
|
|
206
209
|
raise ArgumentError, "Insufficient funds: #{amount} requested, but only #{current_balance} available"
|
207
210
|
end
|
208
211
|
|
209
|
-
def create_transfer(amount,
|
212
|
+
def create_transfer(amount, asset, destination)
|
210
213
|
create_transfer_request = {
|
211
|
-
amount:
|
214
|
+
amount: asset.to_atomic_amount(amount).to_i.to_s,
|
212
215
|
network_id: network_id,
|
213
|
-
asset_id:
|
216
|
+
asset_id: asset.primary_denomination.to_s,
|
214
217
|
destination: destination
|
215
218
|
}
|
216
219
|
|
@@ -229,24 +232,21 @@ module Coinbase
|
|
229
232
|
Coinbase::Transfer.new(transfer_model)
|
230
233
|
end
|
231
234
|
|
232
|
-
def validate_can_trade!(amount,
|
235
|
+
def validate_can_trade!(amount, from_asset)
|
233
236
|
raise 'Cannot trade from address without private key loaded' unless can_sign?
|
234
237
|
|
235
|
-
|
236
|
-
raise ArgumentError, "Unsupported to asset: #{to_asset_id}" unless Coinbase::Asset.supported?(to_asset_id)
|
237
|
-
|
238
|
-
current_balance = balance(from_asset_id)
|
238
|
+
current_balance = balance(from_asset.asset_id)
|
239
239
|
|
240
240
|
return unless current_balance < amount
|
241
241
|
|
242
242
|
raise ArgumentError, "Insufficient funds: #{amount} requested, but only #{current_balance} available"
|
243
243
|
end
|
244
244
|
|
245
|
-
def create_trade(amount,
|
245
|
+
def create_trade(amount, from_asset, to_asset)
|
246
246
|
create_trade_request = {
|
247
|
-
amount:
|
248
|
-
from_asset_id:
|
249
|
-
to_asset_id:
|
247
|
+
amount: from_asset.to_atomic_amount(amount).to_i.to_s,
|
248
|
+
from_asset_id: from_asset.primary_denomination.to_s,
|
249
|
+
to_asset_id: to_asset.primary_denomination.to_s
|
250
250
|
}
|
251
251
|
|
252
252
|
trade_model = Coinbase.call_api do
|
data/lib/coinbase/asset.rb
CHANGED
@@ -3,98 +3,108 @@
|
|
3
3
|
module Coinbase
|
4
4
|
# A representation of an Asset.
|
5
5
|
class Asset
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
class << self
|
7
|
+
# Returns the primary denomination for the provided Asset ID.
|
8
|
+
# For assets with multiple denominations, e.g. eth can also be denominated in wei and gwei,
|
9
|
+
# this method will return the primary denomination.
|
10
|
+
# e.g. eth.
|
11
|
+
# @param asset_id [Symbol] The Asset ID
|
12
|
+
# @return [Symbol] The primary denomination for the Asset ID
|
13
|
+
def primary_denomination(asset_id)
|
14
|
+
return :eth if %i[wei gwei].include?(asset_id)
|
12
15
|
|
13
|
-
|
14
|
-
# @param amount [Integer, Float, BigDecimal] The amount to normalize
|
15
|
-
# @param asset_id [Symbol] The ID of the Asset being transferred
|
16
|
-
# @return [BigDecimal] The normalized amount in atomic units
|
17
|
-
def self.to_atomic_amount(amount, asset_id)
|
18
|
-
case asset_id
|
19
|
-
when :eth
|
20
|
-
amount * BigDecimal(Coinbase::WEI_PER_ETHER.to_s)
|
21
|
-
when :gwei
|
22
|
-
amount * BigDecimal(Coinbase::WEI_PER_GWEI.to_s)
|
23
|
-
when :usdc
|
24
|
-
amount * BigDecimal(Coinbase::ATOMIC_UNITS_PER_USDC.to_s)
|
25
|
-
when :weth
|
26
|
-
amount * BigDecimal(Coinbase::WEI_PER_ETHER)
|
27
|
-
else
|
28
|
-
amount
|
16
|
+
asset_id
|
29
17
|
end
|
30
|
-
end
|
31
18
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
19
|
+
def from_model(asset_model, asset_id: nil)
|
20
|
+
raise unless asset_model.is_a?(Coinbase::Client::Asset)
|
21
|
+
|
22
|
+
decimals = asset_model.decimals
|
23
|
+
|
24
|
+
# Handle the non-primary denomination case at the asset level.
|
25
|
+
# TODO: Push this logic down to the backend.
|
26
|
+
if asset_id && asset_id != Coinbase.to_sym(asset_model.asset_id)
|
27
|
+
case asset_id
|
28
|
+
when :gwei
|
29
|
+
decimals = GWEI_DECIMALS
|
30
|
+
when :wei
|
31
|
+
decimals = 0
|
32
|
+
else
|
33
|
+
raise ArgumentError, "Unsupported asset ID: #{asset_id}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
new(
|
38
|
+
network_id: Coinbase.to_sym(asset_model.network_id),
|
39
|
+
asset_id: asset_id || Coinbase.to_sym(asset_model.asset_id),
|
40
|
+
address_id: asset_model.contract_address,
|
41
|
+
decimals: decimals
|
42
|
+
)
|
49
43
|
end
|
50
|
-
end
|
51
44
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
45
|
+
# Fetches the Asset with the provided Asset ID.
|
46
|
+
# @param asset_id [Symbol] The Asset ID
|
47
|
+
# @return [Coinbase::Asset] The Asset
|
48
|
+
def fetch(network_id, asset_id)
|
49
|
+
asset_model = Coinbase.call_api do
|
50
|
+
assets_api.get_asset(
|
51
|
+
Coinbase.normalize_network(network_id),
|
52
|
+
primary_denomination(asset_id).to_s
|
53
|
+
)
|
54
|
+
end
|
60
55
|
|
61
|
-
|
62
|
-
|
56
|
+
from_model(asset_model, asset_id: asset_id)
|
57
|
+
end
|
63
58
|
|
64
|
-
|
65
|
-
raise unless asset_model.is_a?(Coinbase::Client::Asset)
|
59
|
+
private
|
66
60
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
address_id: asset_model.contract_address,
|
71
|
-
decimals: asset_model.decimals
|
72
|
-
)
|
61
|
+
def assets_api
|
62
|
+
Coinbase::Client::AssetsApi.new(Coinbase.configuration.api_client)
|
63
|
+
end
|
73
64
|
end
|
74
65
|
|
75
66
|
# Returns a new Asset object. Do not use this method. Instead, use the Asset constants defined in
|
76
67
|
# the Coinbase module.
|
77
68
|
# @param network_id [Symbol] The ID of the Network to which the Asset belongs
|
78
69
|
# @param asset_id [Symbol] The Asset ID
|
79
|
-
# @param display_name [String] (Optional) The Asset's display name
|
80
70
|
# @param address_id [String] (Optional) The Asset's address ID, if one exists
|
81
71
|
# @param decimals [Integer] (Optional) The number of decimal places the Asset uses
|
82
|
-
def initialize(network_id:, asset_id:,
|
72
|
+
def initialize(network_id:, asset_id:, decimals:, address_id: nil)
|
83
73
|
@network_id = network_id
|
84
74
|
@asset_id = asset_id
|
85
|
-
@display_name = display_name
|
86
75
|
@address_id = address_id
|
87
76
|
@decimals = decimals
|
88
77
|
end
|
89
78
|
|
90
|
-
attr_reader :network_id, :asset_id, :
|
79
|
+
attr_reader :network_id, :asset_id, :address_id, :decimals
|
80
|
+
|
81
|
+
# Converts the amount of the Asset from atomic to whole units.
|
82
|
+
# @param atomic_amount [Integer, Float, BigDecimal] The atomic amount to convert to whole units.
|
83
|
+
# @return [BigDecimal] The amount in whole units
|
84
|
+
def from_atomic_amount(atomic_amount)
|
85
|
+
BigDecimal(atomic_amount) / BigDecimal(10).power(decimals)
|
86
|
+
end
|
87
|
+
|
88
|
+
# Converts the amount of the Asset from whole to atomic units.
|
89
|
+
# @param whole_amount [Integer, Float, BigDecimal] The whole amount to convert to atomic units.
|
90
|
+
# @return [BigDecimal] The amount in atomic units
|
91
|
+
def to_atomic_amount(whole_amount)
|
92
|
+
whole_amount * BigDecimal(10).power(decimals)
|
93
|
+
end
|
94
|
+
|
95
|
+
# Returns the primary denomination for the Asset.
|
96
|
+
# For `gwei` and `wei` the primary denomination is `eth`.
|
97
|
+
# For all other assets, the primary denomination is the same asset ID.
|
98
|
+
# @return [Symbol] The primary denomination for the Asset
|
99
|
+
def primary_denomination
|
100
|
+
self.class.primary_denomination(asset_id)
|
101
|
+
end
|
91
102
|
|
92
103
|
# Returns a string representation of the Asset.
|
93
104
|
# @return [String] a string representation of the Asset
|
94
105
|
def to_s
|
95
|
-
"Coinbase::Asset{network_id: '#{network_id}', asset_id: '#{asset_id}',
|
96
|
-
|
97
|
-
(decimals.nil? ? '}' : ", decimals: '#{decimals}'}")
|
106
|
+
"Coinbase::Asset{network_id: '#{network_id}', asset_id: '#{asset_id}', decimals: '#{decimals}'" \
|
107
|
+
"#{address_id.nil? ? '' : ", address_id: '#{address_id}'"}}"
|
98
108
|
end
|
99
109
|
|
100
110
|
# Same as to_s.
|
data/lib/coinbase/balance.rb
CHANGED
@@ -7,9 +7,9 @@ module Coinbase
|
|
7
7
|
# @param balance_model [Coinbase::Client::Balance] The balance fetched from the API.
|
8
8
|
# @return [Balance] The converted Balance object.
|
9
9
|
def self.from_model(balance_model)
|
10
|
-
|
10
|
+
asset = Coinbase::Asset.from_model(balance_model.asset)
|
11
11
|
|
12
|
-
|
12
|
+
new(amount: asset.from_atomic_amount(balance_model.amount), asset: asset)
|
13
13
|
end
|
14
14
|
|
15
15
|
# Converts a Coinbase::Client::Balance model and asset ID to a Coinbase::Balance
|
@@ -19,8 +19,11 @@ module Coinbase
|
|
19
19
|
# @param asset_id [Symbol] The Asset ID of the denomination we want returned.
|
20
20
|
# @return [Balance] The converted Balance object.
|
21
21
|
def self.from_model_and_asset_id(balance_model, asset_id)
|
22
|
+
asset = Coinbase::Asset.from_model(balance_model.asset, asset_id: asset_id)
|
23
|
+
|
22
24
|
new(
|
23
|
-
amount:
|
25
|
+
amount: asset.from_atomic_amount(balance_model.amount),
|
26
|
+
asset: asset,
|
24
27
|
asset_id: asset_id
|
25
28
|
)
|
26
29
|
end
|
@@ -29,12 +32,13 @@ module Coinbase
|
|
29
32
|
# Balance.from_model_and_asset_id.
|
30
33
|
# @param amount [BigDecimal] The amount of the Asset
|
31
34
|
# @param asset_id [Symbol] The Asset ID
|
32
|
-
def initialize(amount:, asset_id:)
|
35
|
+
def initialize(amount:, asset:, asset_id: nil)
|
33
36
|
@amount = amount
|
34
|
-
@
|
37
|
+
@asset = asset
|
38
|
+
@asset_id = asset_id || asset.asset_id
|
35
39
|
end
|
36
40
|
|
37
|
-
attr_reader :amount, :asset_id
|
41
|
+
attr_reader :amount, :asset, :asset_id
|
38
42
|
|
39
43
|
# Returns a string representation of the Balance.
|
40
44
|
# @return [String] a string representation of the Balance
|
@@ -0,0 +1,91 @@
|
|
1
|
+
=begin
|
2
|
+
#Coinbase Platform API
|
3
|
+
|
4
|
+
#This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs.
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 0.0.1-alpha
|
7
|
+
Contact: yuga.cohler@coinbase.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
Generator version: 7.5.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'cgi'
|
14
|
+
|
15
|
+
module Coinbase::Client
|
16
|
+
class AssetsApi
|
17
|
+
attr_accessor :api_client
|
18
|
+
|
19
|
+
def initialize(api_client = ApiClient.default)
|
20
|
+
@api_client = api_client
|
21
|
+
end
|
22
|
+
# Get the asset for the specified asset ID.
|
23
|
+
# Get the asset for the specified asset ID.
|
24
|
+
# @param network_id [String] The ID of the blockchain network
|
25
|
+
# @param asset_id [String] The ID of the asset to fetch
|
26
|
+
# @param [Hash] opts the optional parameters
|
27
|
+
# @return [Asset]
|
28
|
+
def get_asset(network_id, asset_id, opts = {})
|
29
|
+
data, _status_code, _headers = get_asset_with_http_info(network_id, asset_id, opts)
|
30
|
+
data
|
31
|
+
end
|
32
|
+
|
33
|
+
# Get the asset for the specified asset ID.
|
34
|
+
# Get the asset for the specified asset ID.
|
35
|
+
# @param network_id [String] The ID of the blockchain network
|
36
|
+
# @param asset_id [String] The ID of the asset to fetch
|
37
|
+
# @param [Hash] opts the optional parameters
|
38
|
+
# @return [Array<(Asset, Integer, Hash)>] Asset data, response status code and response headers
|
39
|
+
def get_asset_with_http_info(network_id, asset_id, opts = {})
|
40
|
+
if @api_client.config.debugging
|
41
|
+
@api_client.config.logger.debug 'Calling API: AssetsApi.get_asset ...'
|
42
|
+
end
|
43
|
+
# verify the required parameter 'network_id' is set
|
44
|
+
if @api_client.config.client_side_validation && network_id.nil?
|
45
|
+
fail ArgumentError, "Missing the required parameter 'network_id' when calling AssetsApi.get_asset"
|
46
|
+
end
|
47
|
+
# verify the required parameter 'asset_id' is set
|
48
|
+
if @api_client.config.client_side_validation && asset_id.nil?
|
49
|
+
fail ArgumentError, "Missing the required parameter 'asset_id' when calling AssetsApi.get_asset"
|
50
|
+
end
|
51
|
+
# resource path
|
52
|
+
local_var_path = '/v1/networks/{network_id}/assets/{asset_id}'.sub('{' + 'network_id' + '}', CGI.escape(network_id.to_s)).sub('{' + 'asset_id' + '}', CGI.escape(asset_id.to_s))
|
53
|
+
|
54
|
+
# query parameters
|
55
|
+
query_params = opts[:query_params] || {}
|
56
|
+
|
57
|
+
# header parameters
|
58
|
+
header_params = opts[:header_params] || {}
|
59
|
+
# HTTP header 'Accept' (if needed)
|
60
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
61
|
+
|
62
|
+
# form parameters
|
63
|
+
form_params = opts[:form_params] || {}
|
64
|
+
|
65
|
+
# http body (model)
|
66
|
+
post_body = opts[:debug_body]
|
67
|
+
|
68
|
+
# return_type
|
69
|
+
return_type = opts[:debug_return_type] || 'Asset'
|
70
|
+
|
71
|
+
# auth_names
|
72
|
+
auth_names = opts[:debug_auth_names] || []
|
73
|
+
|
74
|
+
new_options = opts.merge(
|
75
|
+
:operation => :"AssetsApi.get_asset",
|
76
|
+
:header_params => header_params,
|
77
|
+
:query_params => query_params,
|
78
|
+
:form_params => form_params,
|
79
|
+
:body => post_body,
|
80
|
+
:auth_names => auth_names,
|
81
|
+
:return_type => return_type
|
82
|
+
)
|
83
|
+
|
84
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
85
|
+
if @api_client.config.debugging
|
86
|
+
@api_client.config.logger.debug "API called: AssetsApi#get_asset\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
87
|
+
end
|
88
|
+
return data, status_code, headers
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
=begin
|
2
|
+
#Coinbase Platform API
|
3
|
+
|
4
|
+
#This is the OpenAPI 3.0 specification for the Coinbase Platform APIs, used in conjunction with the Coinbase Platform SDKs.
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 0.0.1-alpha
|
7
|
+
Contact: yuga.cohler@coinbase.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
Generator version: 7.5.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'cgi'
|
14
|
+
|
15
|
+
module Coinbase::Client
|
16
|
+
class BalancesApi
|
17
|
+
attr_accessor :api_client
|
18
|
+
|
19
|
+
def initialize(api_client = ApiClient.default)
|
20
|
+
@api_client = api_client
|
21
|
+
end
|
22
|
+
# Get the balance of an asset in an external address
|
23
|
+
# Get the balance of an asset in an external address
|
24
|
+
# @param network_id [String] The ID of the blockchain network
|
25
|
+
# @param address_id [String] The ID of the address to fetch the balance for
|
26
|
+
# @param asset_id [String] The ID of the asset to fetch the balance for
|
27
|
+
# @param [Hash] opts the optional parameters
|
28
|
+
# @return [Balance]
|
29
|
+
def get_external_address_balance(network_id, address_id, asset_id, opts = {})
|
30
|
+
data, _status_code, _headers = get_external_address_balance_with_http_info(network_id, address_id, asset_id, opts)
|
31
|
+
data
|
32
|
+
end
|
33
|
+
|
34
|
+
# Get the balance of an asset in an external address
|
35
|
+
# Get the balance of an asset in an external address
|
36
|
+
# @param network_id [String] The ID of the blockchain network
|
37
|
+
# @param address_id [String] The ID of the address to fetch the balance for
|
38
|
+
# @param asset_id [String] The ID of the asset to fetch the balance for
|
39
|
+
# @param [Hash] opts the optional parameters
|
40
|
+
# @return [Array<(Balance, Integer, Hash)>] Balance data, response status code and response headers
|
41
|
+
def get_external_address_balance_with_http_info(network_id, address_id, asset_id, opts = {})
|
42
|
+
if @api_client.config.debugging
|
43
|
+
@api_client.config.logger.debug 'Calling API: BalancesApi.get_external_address_balance ...'
|
44
|
+
end
|
45
|
+
# verify the required parameter 'network_id' is set
|
46
|
+
if @api_client.config.client_side_validation && network_id.nil?
|
47
|
+
fail ArgumentError, "Missing the required parameter 'network_id' when calling BalancesApi.get_external_address_balance"
|
48
|
+
end
|
49
|
+
# verify the required parameter 'address_id' is set
|
50
|
+
if @api_client.config.client_side_validation && address_id.nil?
|
51
|
+
fail ArgumentError, "Missing the required parameter 'address_id' when calling BalancesApi.get_external_address_balance"
|
52
|
+
end
|
53
|
+
# verify the required parameter 'asset_id' is set
|
54
|
+
if @api_client.config.client_side_validation && asset_id.nil?
|
55
|
+
fail ArgumentError, "Missing the required parameter 'asset_id' when calling BalancesApi.get_external_address_balance"
|
56
|
+
end
|
57
|
+
# resource path
|
58
|
+
local_var_path = '/v1/networks/{network_id}/addresses/{address_id}/balances/{asset_id}'.sub('{' + 'network_id' + '}', CGI.escape(network_id.to_s)).sub('{' + 'address_id' + '}', CGI.escape(address_id.to_s)).sub('{' + 'asset_id' + '}', CGI.escape(asset_id.to_s))
|
59
|
+
|
60
|
+
# query parameters
|
61
|
+
query_params = opts[:query_params] || {}
|
62
|
+
|
63
|
+
# header parameters
|
64
|
+
header_params = opts[:header_params] || {}
|
65
|
+
# HTTP header 'Accept' (if needed)
|
66
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
67
|
+
|
68
|
+
# form parameters
|
69
|
+
form_params = opts[:form_params] || {}
|
70
|
+
|
71
|
+
# http body (model)
|
72
|
+
post_body = opts[:debug_body]
|
73
|
+
|
74
|
+
# return_type
|
75
|
+
return_type = opts[:debug_return_type] || 'Balance'
|
76
|
+
|
77
|
+
# auth_names
|
78
|
+
auth_names = opts[:debug_auth_names] || []
|
79
|
+
|
80
|
+
new_options = opts.merge(
|
81
|
+
:operation => :"BalancesApi.get_external_address_balance",
|
82
|
+
:header_params => header_params,
|
83
|
+
:query_params => query_params,
|
84
|
+
:form_params => form_params,
|
85
|
+
:body => post_body,
|
86
|
+
:auth_names => auth_names,
|
87
|
+
:return_type => return_type
|
88
|
+
)
|
89
|
+
|
90
|
+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
|
91
|
+
if @api_client.config.debugging
|
92
|
+
@api_client.config.logger.debug "API called: BalancesApi#get_external_address_balance\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
93
|
+
end
|
94
|
+
return data, status_code, headers
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|