Class: VaultOfSatoshi::API::Info
- Defined in:
- lib/vault_of_satoshi/api/info.rb
Constant Summary
Constants inherited from Base
Base::ALL_CURRENCIES, Base::CRYPTO_CURRENCIES, Base::FIAT_CURRENCIES
Instance Method Summary collapse
- #account ⇒ Object
- #balance(params = {}) ⇒ Object
- #currency(params = {}) ⇒ Object
-
#initialize(api_key, api_secret) ⇒ Info
constructor
A new instance of Info.
- #order_detail(params = {}) ⇒ Object
- #orderbook(params = {}) ⇒ Object
- #orders(params = {}) ⇒ Object
- #quote(params = {}) ⇒ Object
- #ticker(params = {}) ⇒ Object
- #wallet_address(params = {}) ⇒ Object
- #wallet_history(params = {}) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(api_key, api_secret) ⇒ Info
Returns a new instance of Info.
5 6 7 |
# File 'lib/vault_of_satoshi/api/info.rb', line 5 def initialize(api_key, api_secret) super end |
Instance Method Details
#account ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/vault_of_satoshi/api/info.rb', line 26 def account params = {nonce: nonce} endpoint = "/info/account" response = self.class.post(endpoint, body: params.to_param, headers: headers(endpoint, params)).parsed_response raise VaultOfSatoshi::API::Error.new(response["message"]) if response["status"] == "error" response["data"]["trade_fee"] = parse_data(response["data"]["trade_fee"], currency_objects: CRYPTO_CURRENCIES) response["data"]["monthly_volume"] = parse_data(response["data"]["monthly_volume"], currency_objects: CRYPTO_CURRENCIES) response["data"]["wallets"].each do |currency_code, wallet| response["data"]["wallets"][currency_code] = parse_data( wallet, currency_objects: [:balance, :daily_withdrawal_limit, :monthly_withdrawal_limit] ) end response["data"]["wallets"] = parse_data(response["data"]["wallets"]) parse_data(response["data"], unix_timestamps: [:created, :last_login]) end |
#balance(params = {}) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/vault_of_satoshi/api/info.rb', line 46 def balance(params = {}) params.slice!(:currency) params.merge!(nonce: nonce) endpoint = "/info/balance" response = self.class.post(endpoint, body: params.to_param, headers: headers(endpoint, params)).parsed_response raise VaultOfSatoshi::API::Error.new(response["message"]) if response["status"] == "error" if params[:currency] parse_currency_object(response["data"]) else parse_data(response["data"], currency_objects: ALL_CURRENCIES) end end |
#currency(params = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/vault_of_satoshi/api/info.rb', line 9 def currency(params = {}) params.slice!(:currency) params.merge!(nonce: nonce) endpoint = "/info/currency" response = self.class.post(endpoint, body: params.to_param, headers: headers(endpoint, params)).parsed_response raise VaultOfSatoshi::API::Error.new(response["message"]) if response["status"] == "error" if params[:currency] parse_data(response["data"], booleans: [:virtual, :tradeable]) else response["data"].map do |element| parse_data(element, booleans: [:virtual, :tradeable]) end end end |
#order_detail(params = {}) ⇒ Object
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/vault_of_satoshi/api/info.rb', line 159 def order_detail(params = {}) params.slice!(:order_id) params.merge!(nonce: nonce) endpoint = "/info/order_detail" response = self.class.post(endpoint, body: params.to_param, headers: headers(endpoint, params)).parsed_response raise VaultOfSatoshi::API::Error.new(response["message"]) if response["status"] == "error" = { microsecond_timestamps: :transaction_date, currency_objects: [:units_traded, :price, :fee, :total] } response["data"].map do |element| parse_data(element, ) end end |
#orderbook(params = {}) ⇒ Object
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/vault_of_satoshi/api/info.rb', line 122 def orderbook(params = {}) params.slice!(:order_currency, :payment_currency, :group_orders, :round, :count) params[:group_orders] = [1, "1", true, nil].include?(params[:group_orders]) ? 1 : 0 params.merge!(nonce: nonce) endpoint = "/info/orderbook" response = self.class.post(endpoint, body: params.to_param, headers: headers(endpoint, params)).parsed_response raise VaultOfSatoshi::API::Error.new(response["message"]) if response["status"] == "error" response["data"]["bids"].map! do |bid_object| parse_data(bid_object, currency_objects: [:price, :quantity]) end response["data"]["asks"].map! do |ask_object| parse_data(ask_object, currency_objects: [:price, :quantity]) end parse_data(response["data"], microsecond_timestamps: :timestamp) end |
#orders(params = {}) ⇒ Object
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/vault_of_satoshi/api/info.rb', line 140 def orders(params = {}) params.slice!(:count, :after, :open_only) params[:after] = date_input_to_microseconds(params[:after]) params.merge!(nonce: nonce) endpoint = "/info/orders" response = self.class.post(endpoint, body: params.to_param, headers: headers(endpoint, params)).parsed_response raise VaultOfSatoshi::API::Error.new(response["message"]) if response["status"] == "error" = { microsecond_timestamps: [:order_date, :date_completed], currency_objects: [:units, :units_remaining, :price, :fee, :total] } response["data"].map do |element| parse_data(element, ) end end |
#quote(params = {}) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/vault_of_satoshi/api/info.rb', line 108 def quote(params = {}) params.slice!(:type, :order_currency, :units, :payment_currency, :price) params[:units] = generate_currency_object(params[:units]) if params[:units] params[:price] = generate_currency_object(params[:price]) if params[:price] params.merge!(nonce: nonce) endpoint = "/info/quote" response = self.class.post(endpoint, body: params.to_param, headers: headers(endpoint, params)).parsed_response raise VaultOfSatoshi::API::Error.new(response["message"]) if response["status"] == "error" = {currency_objects: [:rate, :subtotal, :fee, :total]} parse_data(response["data"], ) end |
#ticker(params = {}) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/vault_of_satoshi/api/info.rb', line 90 def ticker(params = {}) params.slice!(:order_currency, :payment_currency) params.merge!(nonce: nonce) endpoint = "/info/ticker" response = self.class.post(endpoint, body: params.to_param, headers: headers(endpoint, params)).parsed_response raise VaultOfSatoshi::API::Error.new(response["message"]) if response["status"] == "error" = { unix_timestamps: :date, currency_objects: [ :opening_price, :closing_price, :min_price, :max_price, :average_price, :units_traded, :volume_1day, :volume_7day ] } parse_data(response["data"], ) end |
#wallet_address(params = {}) ⇒ Object
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/vault_of_satoshi/api/info.rb', line 61 def wallet_address(params = {}) params.slice!(:currency) params.merge!(nonce: nonce) endpoint = "/info/wallet_address" response = self.class.post(endpoint, body: params.to_param, headers: headers(endpoint, params)).parsed_response raise VaultOfSatoshi::API::Error.new(response["message"]) if response["status"] == "error" parse_data(response["data"]) end |
#wallet_history(params = {}) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/vault_of_satoshi/api/info.rb', line 72 def wallet_history(params = {}) params.slice!(:currency, :count, :after) params[:after] = date_input_to_microseconds(params[:after]) params.merge!(nonce: nonce) endpoint = "/info/wallet_history" response = self.class.post(endpoint, body: params.to_param, headers: headers(endpoint, params)).parsed_response raise VaultOfSatoshi::API::Error.new(response["message"]) if response["status"] == "error" = { currency_objects: :units, microsecond_timestamps: :transfer_date } response["data"].map do |element| parse_data(element, ) end end |