class MaxExchangeApi::PrivateApi

Public Class Methods

new(access_key, secret_key, config: nil) click to toggle source
Calls superclass method MaxExchangeApi::BaseApi::new
# File lib/max_exchange_api/private_api.rb, line 9
def initialize(access_key, secret_key, config: nil)
  super(config: config)

  @access_key = access_key
  @secret_key = secret_key
end

Public Instance Methods

account(currency) click to toggle source
# File lib/max_exchange_api/private_api.rb, line 54
def account(currency)
  send_request(:get, "/members/accounts/#{currency}", {})
end
accounts() click to toggle source
# File lib/max_exchange_api/private_api.rb, line 50
def accounts
  send_request(:get, '/members/accounts', {})
end
cancel_order!(order_id, use_client_id: false) click to toggle source
# File lib/max_exchange_api/private_api.rb, line 207
def cancel_order!(order_id, use_client_id: false)
  id_params_key = use_client_id ? :client_oid : :id
  send_request(:post, '/order/delete', id_params_key => order_id)
end
cancel_orders!(market: nil, side: nil, group_id: nil) click to toggle source
# File lib/max_exchange_api/private_api.rb, line 203
def cancel_orders!(market: nil, side: nil, group_id: nil)
  send_request(:post, '/orders/clear', market: market, side: side, group_id: group_id)
end
create_deposit_addresses!(currency) click to toggle source
# File lib/max_exchange_api/private_api.rb, line 90
def create_deposit_addresses!(currency)
  send_request(:post, '/deposit_addresses', currency: currency)
end
create_order!(market, side, volume, price: nil, client_oid: nil, stop_price: nil, ord_type: nil, group_id: nil) click to toggle source
# File lib/max_exchange_api/private_api.rb, line 212
def create_order!(market, side, volume, price: nil, client_oid: nil, stop_price: nil, ord_type: nil, group_id: nil)
  send_request(
    :post,
    '/orders',
    market: market,
    side: side,
    volume: volume,
    price: price,
    client_oid: client_oid,
    stop_price: stop_price,
    ord_type: ord_type,
    group_id: group_id,
  )
end
create_orders!(market, orders, group_id: nil) click to toggle source
# File lib/max_exchange_api/private_api.rb, line 227
def create_orders!(market, orders, group_id: nil)
  send_request(:post, '/orders/multi/onebyone', market: market, orders: orders, group_id: group_id)
end
create_withdrawal!(currency, withdraw_address_id, amount) click to toggle source
# File lib/max_exchange_api/private_api.rb, line 126
def create_withdrawal!(currency, withdraw_address_id, amount)
  send_request(:post, '/withdrawal', currency: currency, withdraw_address_uuid: withdraw_address_id, amount: amount)
end
deposit(transaction_id) click to toggle source
# File lib/max_exchange_api/private_api.rb, line 74
def deposit(transaction_id)
  send_request(:get, '/deposit', txid: transaction_id)
end
deposit_addresses(currency: nil, pagination: nil, page: 1, limit: 50, offset: 0) click to toggle source
# File lib/max_exchange_api/private_api.rb, line 78
def deposit_addresses(currency: nil, pagination: nil, page: 1, limit: 50, offset: 0)
  send_request(
    :get,
    '/deposit_addresses',
    currency: currency,
    pagination: pagination,
    page: page,
    limit: limit,
    offset: offset,
  )
end
deposits(currency, from: nil, to: nil, state: nil, pagination: nil, page: 1, limit: 50, offset: 0) click to toggle source
# File lib/max_exchange_api/private_api.rb, line 58
def deposits(currency, from: nil, to: nil, state: nil, pagination: nil, page: 1, limit: 50,
             offset: 0)
  send_request(
    :get,
    '/deposits',
    currency: currency,
    from: from,
    to: to,
    state: state,
    pagination: pagination,
    page: page,
    limit: limit,
    offset: offset,
  )
end
internal_transfer(internal_transfer_id) click to toggle source
# File lib/max_exchange_api/private_api.rb, line 146
def internal_transfer(internal_transfer_id)
  send_request(:get, '/internal_transfer', uuid: internal_transfer_id)
end
internal_transfers(currency: nil, side: 'in', from: nil, to: nil, pagination: nil, page: 1, limit: 50, offset: 0) click to toggle source
# File lib/max_exchange_api/private_api.rb, line 130
def internal_transfers(currency: nil, side: 'in', from: nil, to: nil, pagination: nil, page: 1, limit: 50,
                       offset: 0)
  send_request(
    :get,
    '/internal_transfers',
    currency: currency,
    side: side,
    from: from,
    to: to,
    pagination: pagination,
    page: page,
    limit: limit,
    offset: offset,
  )
end
max_rewards_yesterday() click to toggle source
# File lib/max_exchange_api/private_api.rb, line 179
def max_rewards_yesterday
  send_request(:get, '/max_rewards/yesterday', {})
end
me() click to toggle source
# File lib/max_exchange_api/private_api.rb, line 42
def me
  send_request(:get, '/members/me', {})
end
member_profile() click to toggle source
# File lib/max_exchange_api/private_api.rb, line 38
def member_profile
  send_request(:get, '/members/profile', {})
end
my_trades(market, timestamp: nil, from: nil, to: nil, order_by: 'desc', pagination: true, page: 1, limit: 50, offset: 0) click to toggle source
# File lib/max_exchange_api/private_api.rb, line 21
def my_trades(market, timestamp: nil, from: nil, to: nil, order_by: 'desc', pagination: true, page: 1, limit: 50,
              offset: 0)
  send_request(
    :get,
    '/trades/my',
    market: market,
    timestamp: timestamp,
    from: from,
    to: to,
    order_by: order_by,
    pagination: pagination,
    page: page,
    limit: limit,
    offset: offset,
  )
end
my_trades_of_order(order_id, use_client_id: false) click to toggle source
# File lib/max_exchange_api/private_api.rb, line 16
def my_trades_of_order(order_id, use_client_id: false)
  id_params_key = use_client_id ? :client_oid : :id
  send_request(:get, '/trades/my/of_order', id_params_key => order_id)
end
order(order_id, use_client_id: false) click to toggle source
# File lib/max_exchange_api/private_api.rb, line 198
def order(order_id, use_client_id: false)
  id_params_key = use_client_id ? :client_oid : :id
  send_request(:get, '/order', id_params_key => order_id)
end
orders(market, state: nil, order_by: 'asc', group_id: nil, pagination: nil, page: 1, limit: 50, offset: 0) click to toggle source
# File lib/max_exchange_api/private_api.rb, line 183
def orders(market, state: nil, order_by: 'asc', group_id: nil, pagination: nil, page: 1, limit: 50, offset: 0)
  send_request(
    :get,
    '/orders',
    market: market,
    state: state,
    order_by: order_by,
    group_id: group_id,
    pagination: pagination,
    page: page,
    limit: limit,
    offset: offset,
  )
end
rewards(reward_type: nil, currency: nil, from: nil, to: nil, pagination: nil, page: 1, limit: 50, offset: 0) click to toggle source
# File lib/max_exchange_api/private_api.rb, line 150
def rewards(reward_type: nil, currency: nil, from: nil, to: nil, pagination: nil, page: 1, limit: 50, offset: 0)
  path = reward_type ? "/rewards/#{reward_type}" : '/rewards'
  send_request(
    :get,
    path,
    currency: currency,
    from: from,
    to: to,
    pagination: pagination,
    page: page,
    limit: limit,
    offset: offset,
  )
end
vip_level() click to toggle source
# File lib/max_exchange_api/private_api.rb, line 46
def vip_level
  send_request(:get, '/members/vip_level', {})
end
withdraw_addresses(currency, pagination: nil, page: 1, limit: 50, offset: 0) click to toggle source
# File lib/max_exchange_api/private_api.rb, line 94
def withdraw_addresses(currency, pagination: nil, page: 1, limit: 50, offset: 0)
  send_request(
    :get,
    '/withdraw_addresses',
    currency: currency,
    pagination: pagination,
    page: page,
    limit: limit,
    offset: offset,
  )
end
withdrawal(withdraw_id) click to toggle source
# File lib/max_exchange_api/private_api.rb, line 106
def withdrawal(withdraw_id)
  send_request(:get, '/withdrawal', uuid: withdraw_id)
end
withdrawals(currency, from: nil, to: nil, state: nil, pagination: nil, page: 1, limit: 50, offset: 0) click to toggle source
# File lib/max_exchange_api/private_api.rb, line 110
def withdrawals(currency, from: nil, to: nil, state: nil, pagination: nil, page: 1, limit: 50,
                offset: 0)
  send_request(
    :get,
    '/withdrawals',
    currency: currency,
    from: from,
    to: to,
    state: state,
    pagination: pagination,
    page: page,
    limit: limit,
    offset: offset,
  )
end
yields(currency: nil, from: nil, to: nil, pagination: nil, page: 1, limit: 50, offset: 0) click to toggle source
# File lib/max_exchange_api/private_api.rb, line 165
def yields(currency: nil, from: nil, to: nil, pagination: nil, page: 1, limit: 50, offset: 0)
  send_request(
    :get,
    '/yields',
    currency: currency,
    from: from,
    to: to,
    pagination: pagination,
    page: page,
    limit: limit,
    offset: offset,
  )
end

Protected Instance Methods

send_request(method, path, query) click to toggle source
Calls superclass method MaxExchangeApi::BaseApi#send_request
# File lib/max_exchange_api/private_api.rb, line 233
def send_request(method, path, query)
  query = query.compact
  query.merge!(path: "/api/v2#{path}", nonce: (Time.now.to_f * 1000).to_i)
  return super(method, path, Helper.gen_headers(query, @access_key, @secret_key), query)
end