class Coinbase::Wallet::APIClient

Constants

CALLBACK_DIGEST

Public Class Methods

callback_signing_public_key() click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 712
def self.callback_signing_public_key
  @@callback_signing_public_key ||= nil
  return @@callback_signing_public_key if @@callback_signing_public_key
  path = File.expand_path(File.join(File.dirname(__FILE__), 'coinbase-callback.pub'))
  @@callback_signing_public_key = OpenSSL::PKey::RSA.new(File.read(path))
end
verify_callback(body, signature) click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 705
def self.verify_callback(body, signature)
  return false unless callback_signing_public_key
  callback_signing_public_key.verify(CALLBACK_DIGEST, signature.unpack("m0")[0], body)
rescue OpenSSL::PKey::RSAError, ArgumentError
  false
end
whitelisted_certificates() click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 727
def self.whitelisted_certificates
  path = File.expand_path(File.join(File.dirname(__FILE__), 'ca-coinbase.crt'))

  certs = [ [] ]
  File.readlines(path).each do |line|
    next if ["\n","#"].include?(line[0])
    certs.last << line
    certs << [] if line == "-----END CERTIFICATE-----\n"
  end

  result = OpenSSL::X509::Store.new

  certs.each do |lines|
    next if lines.empty?
    cert = OpenSSL::X509::Certificate.new(lines.join)
    result.add_cert(cert)
  end

  result
end

Public Instance Methods

account(account_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 131
def account(account_id, params = {})
  out = nil
  get("/v2/accounts/#{account_id}", params) do |resp|
    out = Account.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
accounts(params = {}) { |out, resp| ... } click to toggle source

Accounts

# File lib/coinbase/wallet/api_client.rb, line 122
def accounts(params = {})
  out = nil
  get("/v2/accounts", params) do |resp|
    out = resp.data.map { |item| Account.new(self, item) }
    yield(out, resp) if block_given?
  end
  out
end
address(account_id, address_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 219
def address(account_id, address_id, params = {})
  out = nil
  get("/v2/accounts/#{account_id}/addresses/#{address_id}", params) do |resp|
    out = Address.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
address_transactions(account_id, address_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 228
def address_transactions(account_id, address_id, params = {})
  out = nil
  get("/v2/accounts/#{account_id}/addresses/#{address_id}/transactions", params) do |resp|
    out = resp.data.map { |item| Transaction.new(self, item) }
    yield(out, resp) if block_given?
  end
  out
end
addresses(account_id, params = {}) { |out, resp| ... } click to toggle source

Addresses

# File lib/coinbase/wallet/api_client.rb, line 210
def addresses(account_id, params = {})
  out = nil
  get("/v2/accounts/#{account_id}/addresses", params) do |resp|
    out = resp.data.map { |item| Address.new(self, item) }
    yield(out, resp) if block_given?
  end
  out
end
auth_headers(method, path, body) click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 4
def auth_headers(method, path, body)
  raise NotImplementedError, "APIClient is not intended to be used directly"
end
auth_info(params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 101
def auth_info(params = {})
  out = nil
  get("/v2/user/auth", params) do |resp|
    out = APIObject.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
buy(account_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 357
def buy(account_id, params = {})
  raise APIError, "Missing parameter: 'amount' or 'total'" unless params.include? :amount or params.include? :total

  out = nil
  post("/v2/accounts/#{account_id}/buys", params) do |resp|
    out = Transfer.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
buy_price(params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 29
def buy_price(params = {})
  out = nil
  pair = determine_currency_pair(params)

  get("/v2/prices/#{pair}/buy", params) do |resp|
    out = APIObject.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
callback_signing_public_key() click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 719
def callback_signing_public_key
  Coinbase::Wallet::APIClient.callback_signing_public_key
end
cancel_request(account_id, transaction_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 318
def cancel_request(account_id, transaction_id, params = {})
  out = nil
  delete("/v2/accounts/#{account_id}/transactions/#{transaction_id}", params) do |resp|
    out = APIObject.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
checkout(checkout_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 596
def checkout(checkout_id, params = {})
  out = nil
  get("/v2/checkouts/#{checkout_id}", params) do |resp|
    out = Checkout.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
checkout_orders(checkout_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 618
def checkout_orders(checkout_id, params = {})
  out = nil
  get("/v2/checkouts/#{checkout_id}/orders", params) do |resp|
    out = resp.data.map { |item| Order.new(self, item) }
    yield(out, resp) if block_given?
  end
  out
end
checkouts(params = {}) { |out, resp| ... } click to toggle source

Checkouts

# File lib/coinbase/wallet/api_client.rb, line 587
def checkouts(params = {})
  out = nil
  get("/v2/checkouts", params) do |resp|
    out = resp.data.map { |item| Checkout.new(self, item) }
    yield(out, resp) if block_given?
  end
  out
end
commit_buy(account_id, transaction_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 368
def commit_buy(account_id, transaction_id, params = {})
  out = nil
  post("/v2/accounts/#{account_id}/buys/#{transaction_id}/commit", params) do |resp|
    out = Transfer.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
commit_deposit(account_id, transaction_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 452
def commit_deposit(account_id, transaction_id, params = {})
  out = nil
  post("/v2/accounts/#{account_id}/deposits/#{transaction_id}/commit", params) do |resp|
    out = APIObject.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
commit_sell(account_id, transaction_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 409
def commit_sell(account_id, transaction_id, params = {})
  out = nil
  post("/v2/accounts/#{account_id}/sells/#{transaction_id}/commit", params) do |resp|
    out = Transfer.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
commit_withdrawal(account_id, transaction_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 495
def commit_withdrawal(account_id, transaction_id, params = {})
  out = nil
  post("/v2/accounts/#{account_id}/withdrawals/#{transaction_id}/commit", params) do |resp|
    out = APIObject.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
complete_request(account_id, transaction_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 327
def complete_request(account_id, transaction_id, params = {})
  out = nil
  post("/v2/accounts/#{account_id}/transactions/#{transaction_id}/complete", params) do |resp|
    out = APIObject.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
create_account(params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 158
def create_account(params = {})
  out = nil
  post("/v2/accounts", params) do |resp|
    out = Account.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
create_address(account_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 237
def create_address(account_id, params = {})
  out = nil
  post("/v2/accounts/#{account_id}/addresses", params) do |resp|
    out = Address.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
create_checkout(params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 605
def create_checkout(params = {})
  [ :amount, :currency, :name ].each do |param|
    fail APIError, "Missing parameter: #{param}" unless params.include? param
  end

  out = nil
  post("/v2/checkouts", params) do |resp|
    out = Checkout.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
create_checkout_order(checkout_id, params={}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 627
def create_checkout_order(checkout_id, params={})
  out = nil
  post("/v2/checkouts/#{checkout_id}/orders", params) do |resp|
    out = Order.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
create_order(params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 558
def create_order(params = {})
  [ :amount, :currency, :name ].each do |param|
    fail APIError, "Missing parameter: #{param}" unless params.include? param
  end

  out = nil
  post("/v2/orders", params) do |resp|
    out = Order.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
currencies(params = {}) { |out, resp| ... } click to toggle source

Market Data

# File lib/coinbase/wallet/api_client.rb, line 11
def currencies(params = {})
  out = nil
  get("/v2/currencies", params) do |resp|
    out = resp.data.map { |item| APIObject.new(self, item) }
    yield(out, resp) if block_given?
  end
  out
end
current_user(params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 92
def current_user(params = {})
  out = nil
  get("/v2/user", params) do |resp|
    out = CurrentUser.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
delete(path, params) { |resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 692
def delete(path, params)
  headers = {}
  if params.has_key? :two_factor_token
    headers['CB-2FA-TOKEN'] = params[:two_factor_token]
    params.delete(:two_factor_token)
  end

  http_verb('DELETE', path, nil, headers) do |resp|
    yield(resp)
  end
end
delete_account(account_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 176
def delete_account(account_id, params = {})
  out = nil
  delete("/v2/accounts/#{account_id}", params) do |resp|
    out = APIObject.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
deposit(account_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 439
def deposit(account_id, params = {})
  [ :amount ].each do |param|
    raise APIError, "Missing parameter: #{param}" unless params.include? param
  end

  out = nil
  post("/v2/accounts/#{account_id}/deposits", params) do |resp|
    out = Transfer.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
exchange_rates(params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 20
def exchange_rates(params = {})
  out = nil
  get("/v2/exchange-rates", params) do |resp|
    out = APIObject.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
get(path, params) { |resp| ... } click to toggle source

HTTP Stuff

# File lib/coinbase/wallet/api_client.rb, line 639
def get(path, params)
  uri = path
  if params.count > 0
    uri += "?#{URI.encode_www_form(params)}"
  end

  headers = {}
  if params.has_key? :two_factor_token
    headers['CB-2FA-TOKEN'] = params[:two_factor_token]
    params.delete(:two_factor_token)
  end

  http_verb('GET', uri, nil, headers) do |resp|
    if params[:fetch_all] == true &&
      resp.body.has_key?('pagination') &&
      resp.body['pagination']['next_uri'] != nil
        params[:starting_after] = resp.body['data'].last['id']
        get(path, params) do |page|
          body = resp.body
          body['data'] += page.data
          resp.body = body
          yield(resp)
        end
    else
      yield(resp)
    end
  end
end
historic_prices(params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 62
def historic_prices(params = {})
  out = nil
  get("/v2/prices/historic", params) do |resp|
    out = APIObject.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
list_buy(account_id, transaction_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 348
def list_buy(account_id, transaction_id, params = {})
  out = nil
  get("/v2/accounts/#{account_id}/buys/#{transaction_id}", params) do |resp|
    out = Transfer.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
list_buys(account_id, params={}) { |out, resp| ... } click to toggle source

Buys

# File lib/coinbase/wallet/api_client.rb, line 339
def list_buys(account_id, params={})
  out = nil
  get("/v2/accounts/#{account_id}/buys", params) do |resp|
    out = resp.data.map { |item| Transfer.new(self, item) }
    yield(out, resp) if block_given?
  end
  out
end
list_deposit(account_id, transaction_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 430
def list_deposit(account_id, transaction_id, params = {})
  out = nil
  get("/v2/accounts/#{account_id}/deposits/#{transaction_id}", params) do |resp|
    out = Transfer.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
list_deposits(account_id, params={}) { |out, resp| ... } click to toggle source

Deposits

# File lib/coinbase/wallet/api_client.rb, line 421
def list_deposits(account_id, params={})
  out = nil
  get("/v2/accounts/#{account_id}/deposits", params) do |resp|
    out = resp.data.map { |item| Transfer.new(self, item) }
    yield(out, resp) if block_given?
  end
  out
end
list_sell(account_id, transaction_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 389
def list_sell(account_id, transaction_id, params = {})
  out = nil
  get("/v2/accounts/#{account_id}/sells/#{transaction_id}", params) do |resp|
    out = Transfer.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
list_sells(account_id, params = {}) { |out, resp| ... } click to toggle source

Sells

# File lib/coinbase/wallet/api_client.rb, line 380
def list_sells(account_id, params = {})
  out = nil
  get("/v2/accounts/#{account_id}/sells", params) do |resp|
    out = resp.data.map { |item| Transfer.new(self, item) }
    yield(out, resp) if block_given?
  end
  out
end
list_withdrawal(account_id, transaction_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 473
def list_withdrawal(account_id, transaction_id, params = {})
  out = nil
  get("/v2/accounts/#{account_id}/withdrawals/#{transaction_id}", params) do |resp|
    out = Transfer.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
list_withdrawals(account_id, params={}) { |out, resp| ... } click to toggle source

withdrawals

# File lib/coinbase/wallet/api_client.rb, line 464
def list_withdrawals(account_id, params={})
  out = nil
  get("/v2/accounts/#{account_id}/withdrawals", params) do |resp|
    out = resp.data.map { |item| Transfer.new(self, item) }
    yield(out, resp) if block_given?
  end
  out
end
merchant(merchant_id, params = {}) { |out, resp| ... } click to toggle source

Merchants

# File lib/coinbase/wallet/api_client.rb, line 528
def merchant(merchant_id, params = {})
  out = nil
  get("/v2/merchants/#{merchant_id}", params) do |resp|
    out = APIObject.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
notification(notification_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 197
def notification(notification_id, params = {})
  out = nil
  get("/v2/notifications/#{notification_id}", params) do |resp|
    out = APIObject.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
notifications(params = {}) { |out, resp| ... } click to toggle source

Notifications

# File lib/coinbase/wallet/api_client.rb, line 188
def notifications(params = {})
  out = nil
  get("/v2/notifications", params) do |resp|
    out = resp.data.map { |item| APIObject.new(self, item) }
    yield(out, resp) if block_given?
  end
  out
end
order(order_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 549
def order(order_id, params = {})
  out = nil
  get("/v2/orders/#{order_id}", params) do |resp|
    out = Order.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
orders(params = {}) { |out, resp| ... } click to toggle source

Orders

# File lib/coinbase/wallet/api_client.rb, line 540
def orders(params = {})
  out = nil
  get("/v2/orders", params) do |resp|
    out = resp.data.map { |item| Order.new(self, item) }
    yield(out, resp) if block_given?
  end
  out
end
payment_method(payment_method_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 516
def payment_method(payment_method_id, params = {})
  out = nil
  get("/v2/payment-methods/#{payment_method_id}", params) do |resp|
    out = APIObject.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
payment_methods(params = {}) { |out, resp| ... } click to toggle source

Payment Methods

# File lib/coinbase/wallet/api_client.rb, line 507
def payment_methods(params = {})
  out = nil
  get("/v2/payment-methods", params) do |resp|
    out = resp.data.map { |item| APIObject.new(self, item) }
    yield(out, resp) if block_given?
  end
  out
end
post(path, params) { |resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 680
def post(path, params)
  headers = {}
  if params.has_key? :two_factor_token
    headers['CB-2FA-TOKEN'] = params[:two_factor_token]
    params.delete(:two_factor_token)
  end

  http_verb('POST', path, params.to_json, headers) do |resp|
    yield(resp)
  end
end
primary_account(params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 140
def primary_account(params = {})
  out = nil
  get("/v2/accounts/primary", params) do |resp|
    out = Account.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
put(path, params) { |resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 668
def put(path, params)
  headers = {}
  if params.has_key? :two_factor_token
    headers['CB-2FA-TOKEN'] = params[:two_factor_token]
    params.delete(:two_factor_token)
  end

  http_verb('PUT', path, params.to_json, headers) do |resp|
    yield(resp)
  end
end
refund_order(order_id, params={}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 571
def refund_order(order_id, params={})
  [ :currency ].each do |param|
    fail APIError, "Missing parameter: #{param}" unless params.include? param
  end

  out = nil
  post("/v2/orders/#{order_id}/refund", params) do |resp|
    out = Order.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
request(account_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 295
def request(account_id, params = {})
  [ :to, :amount, :currency ].each do |param|
    raise APIError, "Missing parameter: #{param}" unless params.include? param
  end
  params['type'] = 'request'

  out = nil
  post("/v2/accounts/#{account_id}/transactions", params) do |resp|
    out = Request.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
resend_request(account_id, transaction_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 309
def resend_request(account_id, transaction_id, params = {})
  out = nil
  post("/v2/accounts/#{account_id}/transactions/#{transaction_id}/resend", params) do |resp|
    out = APIObject.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
sell(account_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 398
def sell(account_id, params = {})
  raise APIError, "Missing parameter: 'amount' or 'total'" unless params.include? :amount or params.include? :total

  out = nil
  post("/v2/accounts/#{account_id}/sells", params) do |resp|
    out = Transfer.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
sell_price(params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 40
def sell_price(params = {})
  out = nil
  pair = determine_currency_pair(params)

  get("/v2/prices/#{pair}/sell", params) do |resp|
    out = APIObject.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
send(account_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 267
def send(account_id, params = {})
  [ :to, :amount ].each do |param|
    raise APIError, "Missing parameter: #{param}" unless params.include? param
  end
  params['type'] = 'send'

  out = nil
  post("/v2/accounts/#{account_id}/transactions", params) do |resp|
    out = Transaction.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
set_primary_account(account_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 149
def set_primary_account(account_id, params = {})
  out = nil
  post("/v2/accounts/#{account_id}/primary", params) do |resp|
    out = Account.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
spot_price(params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 51
def spot_price(params = {})
  out = nil
  pair = determine_currency_pair(params)

  get("/v2/prices/#{pair}/spot", params) do |resp|
    out = APIObject.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
time(params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 71
def time(params = {})
  out = nil
  get("/v2/time", params) do |resp|
    out = APIObject.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
transaction(account_id, transaction_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 258
def transaction(account_id, transaction_id, params = {})
  out = nil
  get("/v2/accounts/#{account_id}/transactions/#{transaction_id}", params) do |resp|
    out = Transaction.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
transactions(account_id, params = {}) { |out, resp| ... } click to toggle source

Transactions

# File lib/coinbase/wallet/api_client.rb, line 249
def transactions(account_id, params = {})
  out = nil
  get("/v2/accounts/#{account_id}/transactions", params) do |resp|
    out = resp.data.map { |item| Transaction.new(self, item) }
    yield(out, resp) if block_given?
  end
  out
end
transfer(account_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 281
def transfer(account_id, params = {})
  [ :to, :amount ].each do |param|
    raise APIError, "Missing parameter: #{param}" unless params.include? param
  end
  params['type'] = 'transfer'

  out = nil
  post("/v2/accounts/#{account_id}/transactions", params) do |resp|
    out = Transaction.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
update_account(account_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 167
def update_account(account_id, params = {})
  out = nil
  put("/v2/accounts/#{account_id}", params) do |resp|
    out = Account.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
update_current_user(params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 110
def update_current_user(params = {})
  out = nil
  put("/v2/user", params) do |resp|
    out = CurrentUser.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
user(user_id, params = {}) { |out, resp| ... } click to toggle source

Users

# File lib/coinbase/wallet/api_client.rb, line 83
def user(user_id, params = {})
  out = nil
  get("/v2/users/#{user_id}", params) do |resp|
    out = User.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end
verify_callback(body, signature) click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 723
def verify_callback(body, signature)
  Coinbase::Wallet::APIClient.verify_callback(body, signature)
end
withdraw(account_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 482
def withdraw(account_id, params = {})
  [ :amount ].each do |param|
    raise APIError, "Missing parameter: #{param}" unless params.include? param
  end

  out = nil
  post("/v2/accounts/#{account_id}/withdrawals", params) do |resp|
    out = Transfer.new(self, resp.data)
    yield(out, resp) if block_given?
  end
  out
end

Private Instance Methods

determine_currency_pair(params) click to toggle source
# File lib/coinbase/wallet/api_client.rb, line 750
def determine_currency_pair(params)
  Coinbase::Util.determine_currency_pair(params)
end