Class: Peatio::ManagementAPIv1::Client

Inherits:
ManagementAPIv1::Client
  • Object
show all
Defined in:
lib/peatio/management_api_v1/client.rb

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



6
7
8
# 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

Instance Method Details

#create_deposit(request_params = {}) ⇒ Object



22
23
24
25
26
27
28
# 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 = {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# 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