Sha256: 7ebe9cc311cf8d5aeb4869d6acb08cdf5fcc2812ab123f10af8b0fbb9de723d3
Contents?: true
Size: 1019 Bytes
Versions: 1
Compression:
Stored size: 1019 Bytes
Contents
require 'httparty' module Bitstampede class Net attr_reader :client def initialize(client) @client = client end def secret client.secret end def key client.key end def post(endpoint, options={}) map_response(raw_post(endpoint, options)) end private def url_for(endpoint) base_url + endpoint + '/' end def base_url 'https://www.bitstamp.net/api/' end def auth_options { user: key, password: secret } end # For some crazy reason, bitstamp is returning ruby hash strings rather than # JSON objects right now ಠ_ಠ I'm just going to gsub '=>' to ':' to 'solve' # it for now. Not thrilled with this. def map_response(wish_this_were_reliably_json) wish_this_were_reliably_json.gsub('=>', ':') end def raw_post(endpoint, options) HTTParty.post(url_for(endpoint), body: options.merge(auth_options)).to_s.tap {|r| STDOUT.puts r} end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bitstampede-0.1.6 | lib/bitstampede/net.rb |