Class: Jahuty::Api::Client
- Inherits:
-
Object
- Object
- Jahuty::Api::Client
- Defined in:
- lib/jahuty/api/client.rb
Overview
Handles HTTP requests and responses.
Constant Summary collapse
- HEADERS =
{ 'Accept' => 'application/json;q=0.9,*/*;q=0.8', 'Accept-Encoding' => 'gzip, deflate', 'Content-Type' => 'application/json; charset=utf-8', 'User-Agent' => "Jahuty Ruby SDK v#{::Jahuty::VERSION}" }.freeze
Instance Method Summary collapse
-
#initialize(api_key:) ⇒ Client
constructor
A new instance of Client.
- #send(request) ⇒ Object
Constructor Details
#initialize(api_key:) ⇒ Client
Returns a new instance of Client.
16 17 18 |
# File 'lib/jahuty/api/client.rb', line 16 def initialize(api_key:) @api_key = api_key end |
Instance Method Details
#send(request) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/jahuty/api/client.rb', line 20 def send(request) @client ||= Faraday.new(url: ::Jahuty::BASE_URI, headers: headers) # Cnvert the action's string method to Faraday's verb-based methods. @client.send( request.method.to_sym, request.path, request.params ) end |