Class: Bitbot::Trader::Providers::Bitstamp::HttpClient
- Inherits:
-
Object
- Object
- Bitbot::Trader::Providers::Bitstamp::HttpClient
- Defined in:
- lib/bitbot/trader/providers/bitstamp/http_client.rb
Overview
Bitstamp specific http client
Constant Summary collapse
- HOST =
"https://www.bitstamp.net/api/"
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
private
Return connection.
-
#password ⇒ String
readonly
private
API passsword.
-
#username ⇒ String
readonly
private
API username.
Class Method Summary collapse
-
.build(options) ⇒ HttpClient
private
Build a new HttpClient object.
-
.make_connection ⇒ Faraday
private
Creates a new faraday connection object.
Instance Method Summary collapse
-
#initialize(connection, username, password) ⇒ undefined
constructor
private
Initializes HttpClient object.
-
#post(path, options = {}) ⇒ Hash
private
Sends post request to given path.
Constructor Details
#initialize(connection, username, password) ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes HttpClient object
75 76 77 78 79 |
# File 'lib/bitbot/trader/providers/bitstamp/http_client.rb', line 75 def initialize(connection, username, password) @connection = connection @username = username @password = password end |
Instance Attribute Details
#connection ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return connection
47 48 49 |
# File 'lib/bitbot/trader/providers/bitstamp/http_client.rb', line 47 def connection @connection end |
#password ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
API passsword
63 64 65 |
# File 'lib/bitbot/trader/providers/bitstamp/http_client.rb', line 63 def password @password end |
#username ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
API username
55 56 57 |
# File 'lib/bitbot/trader/providers/bitstamp/http_client.rb', line 55 def username @username end |
Class Method Details
.build(options) ⇒ HttpClient
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Build a new HttpClient object
23 24 25 26 27 28 29 |
# File 'lib/bitbot/trader/providers/bitstamp/http_client.rb', line 23 def self.build() username = .fetch(:username) password = .fetch(:password) connection = make_connection new(connection, username, password) end |
.make_connection ⇒ Faraday
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Creates a new faraday connection object
37 38 39 |
# File 'lib/bitbot/trader/providers/bitstamp/http_client.rb', line 37 def self.make_connection Faraday.new(url: HOST) end |
Instance Method Details
#post(path, options = {}) ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Sends post request to given path
92 93 94 95 96 |
# File 'lib/bitbot/trader/providers/bitstamp/http_client.rb', line 92 def post(path, = {}) = .merge(user: @username, password: @password) result = @connection.post("#{path}/", ).body JSON.parse(result) end |