# `DocuSign.RequestBuilder`
[🔗](https://github.com/neilberkman/docusign_elixir/blob/v3.5.1/lib/docusign/request_builder.ex#L5)

Helper functions for building Req requests

# `add_optional_params`

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

Add optional parameters to a request

### Parameters

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

### Special Parameters

- `:headers` - A map of custom headers to add to the request. These will be merged
  with the default headers. This is useful for DocuSign-specific headers like
  `X-DocuSign-Edit` which are required for certain operations on locked envelopes.

### Returns

Map

### Examples

    # Add custom headers for locked envelope operations
    optional_params = %{body: :body}
    opts = [
      body: envelope_data,
      headers: %{"X-DocuSign-Edit" => ~s({"LockToken": "abc123", "LockDurationInSeconds": "600"})}
    ]
    add_optional_params(request, optional_params, opts)

# `add_param`

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

Add non-optional parameters to a 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.

This handles cases where POST, PATCH and PUT requests require a body
even when it's empty.

### Parameters

- `request` (Map) - Collected request options

### Returns

Map

# `evaluate_response`

```elixir
@spec evaluate_response({:ok, Req.Response.t()} | {:error, any()}, [
  {integer(), any()}
]) ::
  {:ok, any()} | {:error, Req.Response.t()}
```

Handle the response for a Req request.

### Parameters

- `response` (Req.Response.t) - The response object

### Returns

{:ok, any()} on success
{:error, Req.Response.t} 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*
