class ZaifWrapper::Client::ZaifPrivateApi
Public Class Methods
new(api_key, api_secret)
click to toggle source
# File lib/zaif_wrapper/client.rb, line 66 def initialize(api_key, api_secret) @api_key = api_key @api_secret = api_secret end
Public Instance Methods
check(method_name, body)
click to toggle source
# File lib/zaif_wrapper/client.rb, line 89 def check(method_name, body) case method_name when 'trade' then raise "Required parameters are missing" if body["currency_pair"].nil? || body["action"].nil? || body["price"].nil? || body["amount"].nil? when 'cancel_order' then raise "Required parameters are missing" if body["order_id"].nil? when 'withdraw' then raise "Required parameters are missing" if body["currency"].nil? || body["address"].nil? || body["amount"].nil? when 'deposit_history' then raise "Required parameters are missing" if body["currency"].nil? when 'withdraw_history' then raise "Required parameters are missing" if body["currency"].nil? end end
method_missing(name, *args)
click to toggle source
# File lib/zaif_wrapper/client.rb, line 71 def method_missing(name, *args) if PRIVATE_METHODS.include?(name.to_s) klass = class << self; self end klass.class_eval do define_method(name) do |body = {}| check(name, body) body.store("method", name.to_s) post_request(body, PRIVATE_REQUEST_URL_BASE) end end if args.length == 1 __send__(name, args[0]) else __send__(name) end end end