class Jahuty::Api::Client

Handles HTTP requests and responses.

Constants

HEADERS

Public Class Methods

new(api_key:) click to toggle source
# File lib/jahuty/api/client.rb, line 16
def initialize(api_key:)
  @api_key  = api_key
end

Public Instance Methods

send(request) click to toggle source
# 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

Private Instance Methods

headers() click to toggle source
# File lib/jahuty/api/client.rb, line 33
def headers
  { 'Authorization' => "Bearer #{@api_key}" }.merge(HEADERS)
end