class Cwallet::Wallet::APIClient

Constants

CALLBACK_DIGEST

Public Class Methods

callback_signing_public_key() click to toggle source
# File lib/cwallet/wallet/api_client.rb, line 726
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__), 'cpub.pub'))
  @@callback_signing_public_key = OpenSSL::PKey::RSA.new(File.read(path))
end
create_user(params) click to toggle source

Users

# File lib/cwallet/wallet/api_client.rb, line 83
def self.create_user(params)
  req = Net::HTTP::Post.new("/v2/user")
  req.body = params.to_json
  req['Content-Type'] = 'application/json'
  req['User-Agent'] = "cwallet/ruby/#{Cwallet::Wallet::VERSION}"

  uri = URI.parse(params[:api_url] || Cwallet::Wallet::BASE_API_URL)
  conn = Net::HTTP.new(uri.host, uri.port)
  conn.use_ssl = true
  resp = conn.request(req)

  User.new(self, JSON.parse(resp.body)['data'])
end
verify_callback(body, signature) click to toggle source
# File lib/cwallet/wallet/api_client.rb, line 719
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

Public Instance Methods

account(account_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/cwallet/wallet/api_client.rb, line 145
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/cwallet/wallet/api_client.rb, line 136
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/cwallet/wallet/api_client.rb, line 233
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/cwallet/wallet/api_client.rb, line 242
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/cwallet/wallet/api_client.rb, line 224
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/cwallet/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/cwallet/wallet/api_client.rb, line 115
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/cwallet/wallet/api_client.rb, line 371
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/cwallet/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/cwallet/wallet/api_client.rb, line 733
def callback_signing_public_key
  Cwallet::Wallet::APIClient.callback_signing_public_key
end
cancel_request(account_id, transaction_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/cwallet/wallet/api_client.rb, line 332
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/cwallet/wallet/api_client.rb, line 610
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/cwallet/wallet/api_client.rb, line 632
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/cwallet/wallet/api_client.rb, line 601
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/cwallet/wallet/api_client.rb, line 382
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/cwallet/wallet/api_client.rb, line 466
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/cwallet/wallet/api_client.rb, line 423
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/cwallet/wallet/api_client.rb, line 509
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/cwallet/wallet/api_client.rb, line 341
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/cwallet/wallet/api_client.rb, line 172
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/cwallet/wallet/api_client.rb, line 251
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/cwallet/wallet/api_client.rb, line 619
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/cwallet/wallet/api_client.rb, line 641
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/cwallet/wallet/api_client.rb, line 572
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/cwallet/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/cwallet/wallet/api_client.rb, line 106
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/cwallet/wallet/api_client.rb, line 706
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/cwallet/wallet/api_client.rb, line 190
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/cwallet/wallet/api_client.rb, line 453
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/cwallet/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/cwallet/wallet/api_client.rb, line 653
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/cwallet/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/cwallet/wallet/api_client.rb, line 362
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/cwallet/wallet/api_client.rb, line 353
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/cwallet/wallet/api_client.rb, line 444
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/cwallet/wallet/api_client.rb, line 435
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/cwallet/wallet/api_client.rb, line 403
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/cwallet/wallet/api_client.rb, line 394
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/cwallet/wallet/api_client.rb, line 487
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/cwallet/wallet/api_client.rb, line 478
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/cwallet/wallet/api_client.rb, line 542
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/cwallet/wallet/api_client.rb, line 211
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/cwallet/wallet/api_client.rb, line 202
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/cwallet/wallet/api_client.rb, line 563
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/cwallet/wallet/api_client.rb, line 554
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/cwallet/wallet/api_client.rb, line 530
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/cwallet/wallet/api_client.rb, line 521
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/cwallet/wallet/api_client.rb, line 694
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/cwallet/wallet/api_client.rb, line 154
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/cwallet/wallet/api_client.rb, line 682
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/cwallet/wallet/api_client.rb, line 585
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/cwallet/wallet/api_client.rb, line 309
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/cwallet/wallet/api_client.rb, line 323
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/cwallet/wallet/api_client.rb, line 412
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/cwallet/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/cwallet/wallet/api_client.rb, line 281
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/cwallet/wallet/api_client.rb, line 163
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/cwallet/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/cwallet/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/cwallet/wallet/api_client.rb, line 272
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/cwallet/wallet/api_client.rb, line 263
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/cwallet/wallet/api_client.rb, line 295
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/cwallet/wallet/api_client.rb, line 181
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/cwallet/wallet/api_client.rb, line 124
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
# File lib/cwallet/wallet/api_client.rb, line 97
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/cwallet/wallet/api_client.rb, line 737
def verify_callback(body, signature)
  Cwallet::Wallet::APIClient.verify_callback(body, signature)
end
withdraw(account_id, params = {}) { |out, resp| ... } click to toggle source
# File lib/cwallet/wallet/api_client.rb, line 496
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/cwallet/wallet/api_client.rb, line 743
def determine_currency_pair(params)
  Cwallet::Util.determine_currency_pair(params)
end