Class: WangluAPI::Client
- Defined in:
- lib/wanglu_api/client.rb,
lib/wanglu_api/client/version.rb
Direct Known Subclasses
Constant Summary collapse
- VERSION =
'0.0.8'
Instance Attribute Summary collapse
-
#auth ⇒ Object
readonly
Returns the value of attribute auth.
Instance Method Summary collapse
- #get(path, params = {}) ⇒ Object
- #get_public(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 15 |
# File 'lib/wanglu_api/client.rb', line 10 def initialize(={}) = .symbolize_keys setup_auth_keys @endpoint = [:endpoint] || 'https://exchange.wanglutech.com' @timeout = [:timeout] || 60 end |
Instance Attribute Details
#auth ⇒ Object (readonly)
Returns the value of attribute auth.
8 9 10 |
# File 'lib/wanglu_api/client.rb', line 8 def auth @auth end |
Instance Method Details
#get(path, params = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/wanglu_api/client.rb', line 26 def get(path, params={}) check_auth! uri = URI("#{@endpoint}#{path}") request(:get, path, @auth, params) do |http, signed_params| uri.query = URI.encode_www_form signed_params http.request_get(uri.request_uri) end end |
#get_public(path, params = {}) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/wanglu_api/client.rb', line 17 def get_public(path, params={}) uri = URI("#{@endpoint}#{path}") uri.query = URI.encode_www_form params request(:get, path, nil, params) do |http, _| http.request_get(uri.request_uri) end end |
#post(path, params = {}) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/wanglu_api/client.rb', line 37 def post(path, params={}) check_auth! request(:post, path, @auth, params) do |http, signed_params| http.request_post(path, signed_params.to_query) end end |