Behaviour that Codat.HTTP.Client satisfies, exposed for mocking in tests.
In your application tests you can swap the real HTTP client for Mox:
# test/test_helper.exs
Mox.defmock(Codat.MockHTTP, for: Codat.HTTP.Behaviour)
# in a test
Codat.MockHTTP
|> expect(:get, fn _config, "/companies", _opts ->
{:ok, %{"results" => [], "pageNumber" => 1, "pageSize" => 100, "totalResults" => 0}}
end)Configure the adapter per-config:
config = Codat.Config.new(http_adapter: Codat.MockHTTP)
Summary
Types
@type response() :: {:ok, map() | list() | binary() | nil} | {:error, Codat.Error.t()}
Callbacks
@callback delete(Codat.Config.t(), String.t(), keyword()) :: response()
@callback get(Codat.Config.t(), String.t(), keyword()) :: response()