Class: PeatioAPI::Client
- Inherits:
-
Object
- Object
- PeatioAPI::Client
- Defined in:
- lib/peatio_api/client.rb,
lib/peatio_api/client/version.rb
Direct Known Subclasses
Constant Summary collapse
- VERSION =
'0.0.3'
Instance Attribute Summary collapse
-
#auth ⇒ Object
readonly
Returns the value of attribute auth.
Instance Method Summary collapse
- #get(path, params = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #post(path, params = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 |
# File 'lib/peatio_api/client.rb', line 10 def initialize(={}) .symbolize_keys! setup_auth_keys @endpoint = [:endpoint] || 'https://peatio.com' end |
Instance Attribute Details
#auth ⇒ Object (readonly)
Returns the value of attribute auth.
8 9 10 |
# File 'lib/peatio_api/client.rb', line 8 def auth @auth end |
Instance Method Details
#get(path, params = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/peatio_api/client.rb', line 16 def get(path, params={}) uri = URI("#{@endpoint}#{path}") # sign on all requests, even those to public API signed_params = @auth.signed_params 'GET', path, params uri.query = URI.encode_www_form signed_params parse Net::HTTP.get_response(uri) end |
#post(path, params = {}) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/peatio_api/client.rb', line 26 def post(path, params={}) uri = URI("#{@endpoint}#{path}") Net::HTTP.new(uri.hostname, uri.port).start do |http| params = @auth.signed_params 'POST', path, params parse http.request_post(path, params.to_query) end end |