Class: InfaktApiClient::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/infakt_api_client/client.rb

Overview

Client class for interacting with the inFakt API Manages HTTP communication and authentication with the API endpoints

Constant Summary collapse

HTTP_OK =

Add HTTP status constants for better readability

200
HTTP_UNAUTHORIZED =
401
HTTP_NOT_FOUND =
404

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



12
13
14
15
16
# File 'lib/infakt_api_client/client.rb', line 12

def initialize
  @connection = Faraday.new(url: InfaktApiClient.configuration.api_endpoint) do |faraday|
    configure_connection(faraday)
  end
end

Instance Method Details

#user_detailsObject



18
19
20
21
22
23
# File 'lib/infakt_api_client/client.rb', line 18

def user_details
  response = @connection.get("account/details.json")
  handle_response(response) do |data|
    User.new(data)
  end
end