Module: Bitstamp::Net
- Defined in:
- lib/bitstamp/net.rb
Constant Summary collapse
- HTTPI_ADAPTER =
:net_http
Class Method Summary collapse
- .delete(path, options = {}) ⇒ Object
- .get(path, options = {}) ⇒ Object
- .nonce_parameter ⇒ Object
- .patch(path, options = {}) ⇒ Object
- .post(path, options = {}) ⇒ Object
- .req(verb, path, options = {}) ⇒ Object
- .to_uri(path) ⇒ Object
Class Method Details
.delete(path, options = {}) ⇒ Object
44 45 46 |
# File 'lib/bitstamp/net.rb', line 44 def self.delete(path, ={}) self.req(:delete, path, ) end |
.get(path, options = {}) ⇒ Object
32 33 34 |
# File 'lib/bitstamp/net.rb', line 32 def self.get(path, ={}) self.req(:get, path, ) end |
.nonce_parameter ⇒ Object
28 29 30 |
# File 'lib/bitstamp/net.rb', line 28 def self.nonce_parameter Bitstamp.nonce_parameter end |
.patch(path, options = {}) ⇒ Object
40 41 42 |
# File 'lib/bitstamp/net.rb', line 40 def self.patch(path, ={}) self.req(:patch, path, ) end |
.post(path, options = {}) ⇒ Object
36 37 38 |
# File 'lib/bitstamp/net.rb', line 36 def self.post(path, ={}) self.req(:post, path, ) end |
.req(verb, path, options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/bitstamp/net.rb', line 9 def self.req(verb, path, ={}) r = HTTPI::Request.new(self.to_uri(path)) if Bitstamp.conn_timeout r.open_timeout = Bitstamp.conn_timeout r.read_timeout = Bitstamp.conn_timeout end if Bitstamp.configured? [:key] = Bitstamp.key [:nonce] = self.nonce_parameter [:signature] = HMAC::SHA256.hexdigest(Bitstamp.secret, [:nonce]+Bitstamp.client_id.to_s+[:key]).upcase end r.body = HTTPI.request(verb, r, HTTPI_ADAPTER) end |
.to_uri(path) ⇒ Object
5 6 7 |
# File 'lib/bitstamp/net.rb', line 5 def self.to_uri(path) return "https://www.bitstamp.net/api#{path}/" end |