class Peatio::ManagementAPIv1::Client

Public Class Methods

new(*) click to toggle source
Calls superclass method
# File lib/peatio/management_api_v1/client.rb, line 6
def initialize(*)
  super ENV.fetch('PEATIO_ROOT_URL'), Rails.configuration.x.peatio_management_api_v1_configuration
end

Public Instance Methods

create_deposit(request_params = {}) click to toggle source
# File lib/peatio/management_api_v1/client.rb, line 22
def
  create_deposit(request_params = {})
  self.action = :write_deposits
  jwt = payload(request_params.slice(:uid, :currency, :amount))
            .yield_self { |payload| generate_jwt(payload) }
  request(:post, 'deposits/new', jwt, jwt: true)
end
create_withdraw(request_params = {}) click to toggle source
# File lib/peatio/management_api_v1/client.rb, line 10
def create_withdraw(request_params = {})
  self.action = :write_withdraws
  jwt = payload(request_params.slice(:uid, :tid, :rid, :currency, :amount, :action))
            .yield_self { |payload| generate_jwt(payload) }
            .yield_self do |jwt|
    action[:requires_barong_totp] ?
        Barong::ManagementAPIv1::Client.new.otp_sign(request_params.merge(jwt: jwt, account_uid: request_params[:uid])) : jwt
  end
  puts "Made it past barong signing" +jwt.to_s
  request(:post, 'withdraws/new', jwt, jwt: true)
end