Current section
Files
Jump to
Current section
Files
lib/hyperswitch/client.ex
defmodule Hyperswitch.Client do
## Types
@type method :: :get | :post | :delete
@type headers :: nil | [{binary(), binary()}]
@type path :: binary()
@type params :: nil | keyword()
@type body :: nil | map()
@type error :: (message :: binary()) | {code :: binary(), message :: binary()}
@type response(t) :: {:ok, t} | {:error, error()}
@type response :: response(map())
@type request :: %{
required(:method) => method(),
optional(:headers) => headers(),
required(:path) => path(),
optional(:params) => params(),
optional(:body) => params()
}
## Behaviours
@callback request(request()) :: response()
## Public functions
@spec request(request()) :: response()
def request(request) when is_map(request) do
impl().request(request)
end
## Private functions
defp impl do
Application.get_env(:hyperswitch, :http_client, Hyperswitch.Clients.Req)
end
end