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

Contract that every HTTP client implementation must satisfy.

In production, `Rapyd.HTTP.Client` fulfills this contract.  In tests,
a `Mox` mock can be injected via the `http_client:` option on
`Rapyd.new/1`:

    Mox.defmock(MockHTTP, for: Rapyd.HTTP.Behaviour)

    client = Rapyd.new!(
      access_key: "key",
      secret_key: "secret",
      http_client: MockHTTP
    )

# `request`

```elixir
@callback request(
  client :: Rapyd.Client.t(),
  method :: :get | :post | :put | :patch | :delete,
  path :: String.t(),
  body :: map() | list() | nil,
  opts :: keyword()
) :: {:ok, term()} | {:error, Rapyd.Error.t()}
```

Execute a signed HTTP request against the Rapyd API.

* `client`  — `%Rapyd.Client{}` carrying credentials and config
* `method`  — `:get | :post | :put | :patch | :delete`
* `path`    — API path starting with `/`, e.g. `"/v1/payments"`
* `body`    — JSON-serialisable map / list, or `nil` for bodyless requests
* `opts`    — reserved for future use; pass `[]`

Returns `{:ok, data}` where `data` is the decoded `"data"` field from the
Rapyd envelope, or `{:error, %Rapyd.Error{}}`.

---

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