module Shapeshift::Api
Constants
- VERSION
Public Class Methods
coins()
click to toggle source
# File lib/shapeshift/api.rb, line 7 def self.coins get 'getcoins' end
quote(amount_to, from_symbol, to_symbol = 'btc')
click to toggle source
# File lib/shapeshift/api.rb, line 20 def self.quote amount_to, from_symbol, to_symbol = 'btc' post 'sendamount', {amount: amount_to, pair: pair(from_symbol, to_symbol)} end
rate(from_symbol, to_symbol = 'btc')
click to toggle source
minimum, limit - measured in from_symbol rate = from_symbol / to_symbol minerFee - measured in to_symbol
# File lib/shapeshift/api.rb, line 16 def self.rate from_symbol, to_symbol = 'btc' get "marketinfo/#{pair(from_symbol, to_symbol)}" end
sendamount(amount_to, address_to, from_symbol, to_symbol = 'btc')
click to toggle source
{“success”=>{“orderId”=>“23902010-5280-499c-8065-50ff3fc9f24a”, “pair”=>“eth_gnt”, “withdrawal”=>“0xd7170547046adc91b5cdf39bc04ad70e95d0a825”, “withdrawalAmount”=>“30”, “deposit”=>“0x553beec262e0ab11dfe43f7d60dc1f51f03e4398”, “depositAmount”=>“0.02696698”, “expiration”=>1512726449980, “quotedRate”=>“1557.46037437”, “maxLimit”=>11.57075248, “apiPubKey”=>“shapeshift”, “minerFee”=>“12”}}
# File lib/shapeshift/api.rb, line 30 def self.sendamount amount_to, address_to, from_symbol, to_symbol = 'btc' post 'sendamount', {amount: amount_to, withdrawal: address_to, pair: pair(from_symbol, to_symbol)} end
status(address)
click to toggle source
{“status”=>“no_deposits”, “address”=>“0x553beec262e0ab11dfe43f7d60dc1f51f03e4398”}
# File lib/shapeshift/api.rb, line 35 def self.status address get "txStat/#{URI::encode_www_form_component address}" end
Private Class Methods
get(method_args)
click to toggle source
# File lib/shapeshift/api.rb, line 46 def self.get method_args url = URI.parse("https://shapeshift.io/#{method_args}") req = Net::HTTP::Get.new url r = Net::HTTP.start(url.hostname, url.port, use_ssl: true, connect_timeout: 10, read_timeout: 20 ) {|http| http.request(req) } JSON.parse(r.body) end
pair(from_symbol, to_symbol)
click to toggle source
# File lib/shapeshift/api.rb, line 42 def self.pair from_symbol, to_symbol "#{from_symbol.to_s.downcase}_#{to_symbol.to_s.downcase}" end
post(method, args)
click to toggle source
# File lib/shapeshift/api.rb, line 60 def self.post method, args url = URI.parse("https://shapeshift.io/#{method}") req = Net::HTTP::Post.new url req.form_data = args r = Net::HTTP.start(url.hostname, url.port, use_ssl: true, connect_timeout: 10, read_timeout: 120 ) {|http| http.request(req) } JSON.parse(r.body) end