module Shapeshift
Constants
- VERSION
Public Class Methods
cancel(deposit_address)
click to toggle source
# File lib/shapeshift.rb, line 104 def self.cancel(deposit_address) url = "https://shapeshift.io/cancelpending" uri = URI.parse(url) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.request_uri, 'Content-Type' => 'application/json') request.body = { "address" => "#{deposit_address}" }.to_json response = http.request(request) end
coins()
click to toggle source
# File lib/shapeshift.rb, line 13 def self.coins coins = get("getcoins") all_coins = [] coins.each do |coin| all_coins << coin[1]['name'] end all_coins end
fixed(amount, wallet_address, coin_pair, return_address)
click to toggle source
# File lib/shapeshift.rb, line 73 def self.fixed(amount, wallet_address, coin_pair, return_address) url = "https://shapeshift.io/sendamount" uri = URI.parse(url) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.request_uri, 'Content-Type' => 'application/json') request.body = { "amount" => "#{amount}", "withdrawal" => "#{wallet_address}", "coin_pair" => "#{coin_pair}", "returnAddress" => "#{return_address}", "apiKey" => "db37c2139a497e6faded962d7b38b0511922accd69fd1574d7bc1108e0579cae2f71d439e545f4c18cda450228f1a3998244086d94fcacc7008bb75b80502d2d" # destTag = (Optional) Destination tag that you want appended to a Ripple payment to you # rsAddress = (Optional) For new NXT accounts to be funded, you supply this on NXT payment to you }.to_json response = http.request(request) end
get(path_name, value = nil)
click to toggle source
# File lib/shapeshift.rb, line 7 def self.get(path_name, value = nil) uri = URI("https://shapeshift.io/#{path_name}/#{value}") response = Net::HTTP.get(uri) check_response(response) end
limit(coin_pair)
click to toggle source
# File lib/shapeshift.rb, line 22 def self.limit(coin_pair) get("limit", coin_pair) end
market(coin_pair)
click to toggle source
# File lib/shapeshift.rb, line 26 def self.market(coin_pair) get("marketinfo", coin_pair) end
quote(amount, coin_pair)
click to toggle source
# File lib/shapeshift.rb, line 91 def self.quote(amount, coin_pair) url = "https://shapeshift.io/sendamount" uri = URI.parse(url) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.request_uri, 'Content-Type' => 'application/json') request.body = { "amount" => "#{amount}", "coin_pair" => "#{coin_pair}" }.to_json response = http.request(request) end
rate(coin_pair)
click to toggle source
# File lib/shapeshift.rb, line 30 def self.rate(coin_pair) get("rate", coin_pair) end
receipt(email, txid)
click to toggle source
# File lib/shapeshift.rb, line 60 def self.receipt(email, txid) url = "https://shapeshift.io/mail" uri = URI.parse(url) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.request_uri, 'Content-Type' => 'application/json') request.body = { "email" => "#{email}", "txid" => "#{txid}", }.to_json response = http.request(request) end
shift(wallet_address, coin_pair, return_address)
click to toggle source
# File lib/shapeshift.rb, line 42 def self.shift(wallet_address, coin_pair, return_address) url = "https://shapeshift.io/shift" uri = URI.parse(url) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.request_uri, 'Content-Type' => 'application/json') request.body = { "withdrawal" => "#{wallet_address}", "pair" => "#{coin_pair}", "returnAddress" => "#{return_address}", # destTag = (Optional) Destination tag that you want appended to a Ripple payment to you # rsAddress = (Optional) For new NXT accounts to be funded, you supply this on NXT payment to you "apiKey" => "db37c2139a497e6faded962d7b38b0511922accd69fd1574d7bc1108e0579cae2f71d439e545f4c18cda450228f1a3998244086d94fcacc7008bb75b80502d2d" }.to_json response = http.request(request) puts (response.body) end
status(deposit_address)
click to toggle source
# File lib/shapeshift.rb, line 34 def self.status(deposit_address) get("txStat", deposit_address) end
time_remaining(deposit_address)
click to toggle source
# File lib/shapeshift.rb, line 38 def self.time_remaining(deposit_address) get("timeremaining", deposit_address) end
Private Class Methods
check_response(response)
click to toggle source
# File lib/shapeshift.rb, line 118 def self.check_response(response) begin value = JSON.parse(response) rescue JSON::ParserError return puts "The API is not responding" end end