# `Ory.RequestBuilder`

Helper functions for building Tesla requests

# `response_mapping`

```elixir
@type response_mapping() :: [{status_code(), false | %{} | module()}]
```

# `status_code`

```elixir
@type status_code() :: :default | 100..599
```

# `add_optional_params`

```elixir
@spec add_optional_params(map(), %{optional(atom()) =&gt; atom()}, keyword()) :: map()
```

Add optional parameters to the request.

### Parameters

- `request` (Map) - Collected request options
- `definitions` (Map) - Map of parameter name to parameter location.
- `options` (KeywordList) - The provided optional parameters

### Returns

Map

# `add_param`

```elixir
@spec add_param(map(), atom(), atom(), any()) :: map()
```

Add non-optional parameters to the request.

### Parameters

- `request` (Map) - Collected request options
- `location` (atom) - Where to put the parameter
- `key` (atom) - The name of the parameter
- `value` (any) - The value of the parameter

### Returns

Map

# `ensure_body`

```elixir
@spec ensure_body(map()) :: map()
```

This function ensures that the `body` parameter is always set.

When using Tesla with the `httpc` adapter (the default adapter), there is a
bug where POST, PATCH and PUT requests will fail if the body is empty.

### Parameters

- `request` (Map) - Collected request options

### Returns

Map

# `evaluate_response`

```elixir
@spec evaluate_response(Tesla.Env.result(), response_mapping()) ::
  {:ok, struct() | [struct()] | Tesla.Env.t()} | {:error, Tesla.Env.t() | any()}
```

Evaluate the response from a Tesla request.
Decode the response for a Tesla request.

### Parameters

- `result` (Tesla.Env.result()): The response from Tesla.request/2.
- `mapping` ([{http_status, struct}]): The mapping for status to struct for decoding.

### Returns

- `{:ok, struct}`, {:ok, [struct]} or `{:ok, Tesla.Env.t()}` on success
- `{:error, term}` on failure

# `method`

```elixir
@spec method(map(), atom()) :: map()
```

Specify the request `method` when building a request.

Does not override the `method` if one has already been specified.

### Parameters

- `request` (Map) - Collected request options
- `method` (atom) - Request method

### Returns

Map

# `url`

```elixir
@spec url(map(), String.t()) :: map()
```

Specify the request URL when building a request.

Does not override the `url` if one has already been specified.

### Parameters

- `request` (Map) - Collected request options
- `url` (String) - Request URL

### Returns

Map

---

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