Class: BitFlyer::Api::PrivateReader
- Defined in:
- lib/bit_flyer/api/private_reader.rb
Constant Summary collapse
- CURRENCY_CODE =
'JPY'
Constants inherited from Base
Instance Method Summary collapse
-
#balancehistory(count = 100, before = nil, after = nil) ⇒ Object
残高履歴.
-
#executions(product_code = '', count = nil, before = nil, after = nil) ⇒ Object
約定の一覧を取得 パラメータ product_code: マーケットの一覧で取得できる product_code または alias のいずれかを指定してください。 count, before, after: ページ形式 を参照してください。.
-
#initialize(key, secret) ⇒ PrivateReader
constructor
A new instance of PrivateReader.
Constructor Details
#initialize(key, secret) ⇒ PrivateReader
Returns a new instance of PrivateReader.
10 11 12 13 |
# File 'lib/bit_flyer/api/private_reader.rb', line 10 def initialize(key, secret) @key = key @secret = secret end |
Instance Method Details
#balancehistory(count = 100, before = nil, after = nil) ⇒ Object
残高履歴
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/bit_flyer/api/private_reader.rb', line 47 def balancehistory(count = 100, before = nil, after = nil) = Time.now.to_i.to_s uri = URI.parse(BASE_URL) uri.path = "/v1/me/getbalancehistory" query_string = {} query_string[:currency_code] = CURRENCY_CODE query_string[:count] = count if count.present? query_string[:before] = before unless before.nil? query_string[:after] = after unless after.nil? uri.query = query_string.to_param request_uri = uri.request_uri text = + 'GET' + request_uri sign = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha256"), @secret, text) response = connect.get do |req| req.url request_uri req.headers = { "ACCESS-KEY" => @key, "ACCESS-TIMESTAMP" => , "ACCESS-SIGN" => sign } end response.body end |
#executions(product_code = '', count = nil, before = nil, after = nil) ⇒ Object
約定の一覧を取得パラメータproduct_code: マーケットの一覧で取得できる product_code または alias のいずれかを指定してください。count, before, after: ページ形式 を参照してください。
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/bit_flyer/api/private_reader.rb', line 20 def executions(product_code = '', count = nil, before = nil, after = nil) = Time.now.to_i.to_s uri = URI.parse(BASE_URL) uri.path = "/v1/me/getexecutions" query_string = {} query_string[:product_code] = product_code if product_code.present? query_string[:count] = count if count.present? query_string[:before] = before unless before.nil? query_string[:after] = after unless after.nil? uri.query = query_string.to_param uri_path = query_string.count >= 1 ? uri.request_uri : uri.path text = + 'GET' + uri_path sign = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha256"), @secret, text) response = connect.get do |req| req.url uri_path req.headers = { "ACCESS-KEY" => @key, "ACCESS-TIMESTAMP" => , "ACCESS-SIGN" => sign } end response.body end |