# `Codat.HTTP.Behaviour`
[🔗](https://github.com/iamkanishka/codat.git/blob/v1.0.0/lib/codat/http/behaviour.ex#L1)

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)

# `response`

```elixir
@type response() :: {:ok, map() | list() | binary() | nil} | {:error, Codat.Error.t()}
```

# `delete`

```elixir
@callback delete(Codat.Config.t(), String.t(), keyword()) :: response()
```

# `get`

```elixir
@callback get(Codat.Config.t(), String.t(), keyword()) :: response()
```

# `patch`

```elixir
@callback patch(Codat.Config.t(), String.t(), map() | list(), keyword()) :: response()
```

# `post`

```elixir
@callback post(Codat.Config.t(), String.t(), map() | list(), keyword()) :: response()
```

# `put`

```elixir
@callback put(Codat.Config.t(), String.t(), map() | list(), keyword()) :: response()
```

---

*Consult [api-reference.md](api-reference.md) for complete listing*
