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 =

HTTP status constants for better readability

200
HTTP_CREATED =
201
HTTP_ACCEPTED =
202
HTTP_NO_CONTENT =
204
HTTP_BAD_REQUEST =
400
HTTP_UNAUTHORIZED =
401
HTTP_FORBIDDEN =
403
HTTP_NOT_FOUND =
404
HTTP_UNPROCESSABLE_ENTITY =
422
HTTP_TOO_MANY_REQUESTS =
429
HTTP_INTERNAL_SERVER_ERROR =
500
HTTP_SERVICE_UNAVAILABLE =
503

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



21
22
23
24
25
# File 'lib/infakt_api_client/client.rb', line 21

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

Instance Method Details

#user_detailsUser

Get user account details

Returns:

  • (User)

    User object with account details



29
30
31
32
33
34
# File 'lib/infakt_api_client/client.rb', line 29

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