Current section
Files
Jump to
Current section
Files
lib/foyer_api/connection.ex
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
# https://openapi-generator.tech
# Do not edit the class manually.
defmodule FoyerAPI.Connection do
@moduledoc """
Handle Tesla connections for FoyerAPI.
"""
use Tesla
# Add any middleware here (authentication)
plug(
Tesla.Middleware.BaseUrl,
Application.get_env(:foyer_api, :base_url, "https://api.foyer.ai")
)
plug(Tesla.Middleware.Headers, [{"user-agent", "Elixir"}])
plug(Tesla.Middleware.EncodeJson, engine: Poison)
@doc """
Configure a client connection using Bearer authentication.
## Parameters
- token (String): Token used for authentication
# Returns
Tesla.Env.client
"""
@spec new(String.t()) :: Tesla.Env.client()
def new(token) do
Tesla.client([
{Tesla.Middleware.BearerAuth, token: token}
])
end
@doc """
Configure an authless client connection
# Returns
Tesla.Env.client
"""
@spec new() :: Tesla.Env.client()
def new do
Tesla.client([])
end
end