# `Pact.Builders.RequestBuilder`

Builder for `Request` objects. Normally created via `Pact.Builders.PactBuilder`.

# `body2`

```elixir
@spec body2(
  builder :: Pact.Native.PactConsumer.RequestBuilder.t(),
  body :: String.t(),
  content_type :: String.t()
) :: Pact.Native.PactConsumer.RequestBuilder.t()
```

Specify a body literal with content type. This does not allow using patterns.

# `body`

```elixir
@spec body(
  builder :: Pact.Native.PactConsumer.RequestBuilder.t(),
  value :: String.t()
) ::
  Pact.Native.PactConsumer.RequestBuilder.t()
```

Specify a body literal. This does not allow using patterns.

# `body_matching2`

```elixir
@spec body_matching2(
  builder :: Pact.Native.PactConsumer.RequestBuilder.t(),
  body :: Pact.Patterns.string_pattern(),
  content_type :: String.t()
) :: Pact.Native.PactConsumer.RequestBuilder.t()
```

Specify a text body matching the given pattern with a content type.

# `body_matching`

```elixir
@spec body_matching(
  builder :: Pact.Native.PactConsumer.RequestBuilder.t(),
  body :: Pact.Patterns.string_pattern()
) :: Pact.Native.PactConsumer.RequestBuilder.t()
```

Specify a text body (text/plain) matching the given pattern.

# `build`

```elixir
@spec build(buider :: Pact.Native.PactConsumer.RequestBuilder.t()) ::
  Pact.Native.PactConsumer.Request.t()
```

Build the specified `Request` object.

# `build_v4`

```elixir
@spec build_v4(buider :: Pact.Native.PactConsumer.RequestBuilder.t()) ::
  Pact.Native.PactConsumer.HttpRequest.t()
```

Build the specified `Request` object in V4 format.

# `content_type`

```elixir
@spec content_type(
  builder :: Pact.Native.PactConsumer.RequestBuilder.t(),
  value :: String.t()
) ::
  Pact.Native.PactConsumer.RequestBuilder.t()
```

Set the `Content-Type` header.

# `contents`

```elixir
@spec contents(
  builder :: Pact.Native.PactConsumer.RequestBuilder.t(),
  content_type :: String.t(),
  definition :: term()
) :: Pact.Native.PactConsumer.RequestBuilder.t()
```

Set the request body using the JSON data. If the body is being supplied by a plugin, this is what is sent to the plugin to setup the body.

# `default`

```elixir
@spec default() :: Pact.Native.PactConsumer.RequestBuilder.t()
```

Creates and returns a new request builder with default settings.

# `delete`

```elixir
@spec delete(buider :: Pact.Native.PactConsumer.RequestBuilder.t()) ::
  Pact.Native.PactConsumer.RequestBuilder.t()
```

Set the HTTP method to `DELETE`.

# `get`

```elixir
@spec get(buider :: Pact.Native.PactConsumer.RequestBuilder.t()) ::
  Pact.Native.PactConsumer.RequestBuilder.t()
```

Set the HTTP method to `GET`. This is the default, so we don't actually care.

# `header`

```elixir
@spec header(
  builder :: Pact.Native.PactConsumer.RequestBuilder.t(),
  name :: String.t(),
  value :: Pact.Patterns.string_pattern()
) :: Pact.Native.PactConsumer.RequestBuilder.t()
```

Specify a header pattern.

# `header_from_provider_state`

```elixir
@spec header_from_provider_state(
  builder :: Pact.Native.PactConsumer.RequestBuilder.t(),
  name :: String.t(),
  expression :: String.t(),
  value :: Pact.Patterns.string_pattern()
) :: Pact.Native.PactConsumer.RequestBuilder.t()
```

Specify a header pattern and a generator from provider state.

# `html`

```elixir
@spec html(builder :: Pact.Native.PactConsumer.RequestBuilder.t()) ::
  Pact.Native.PactConsumer.RequestBuilder.t()
```

Set the `Content-Type` header to `text/html`.

# `json_body`

```elixir
@spec json_body(
  builder :: Pact.Native.PactConsumer.RequestBuilder.t(),
  body :: Pact.Patterns.json_pattern()
) :: Pact.Native.PactConsumer.RequestBuilder.t()
```

Specify the body as `JsonPattern`, possibly including special matching rules.

# `json_utf8`

```elixir
@spec json_utf8(builder :: Pact.Native.PactConsumer.RequestBuilder.t()) ::
  Pact.Native.PactConsumer.RequestBuilder.t()
```

Set the `Content-Type` header to `application/json; charset=utf-8`,
with enough flexibility to cover common variations.

# `method`

```elixir
@spec method(
  buider :: Pact.Native.PactConsumer.RequestBuilder.t(),
  method :: String.t()
) ::
  Pact.Native.PactConsumer.RequestBuilder.t()
```

Specify the request method. Defaults to `"GET"`.

# `path`

```elixir
@spec path(buider :: Pact.Native.PactConsumer.RequestBuilder.t(), path :: String.t()) ::
  Pact.Native.PactConsumer.RequestBuilder.t()
```

Specify the request path. Defaults to `"/"`.

# `path_from_provider_state`

```elixir
@spec path_from_provider_state(
  buider :: Pact.Native.PactConsumer.RequestBuilder.t(),
  expression :: String.t(),
  path :: String.t()
) :: Pact.Native.PactConsumer.RequestBuilder.t()
```

Specify the request path with generators. Defaults to `"/"`.

# `post`

```elixir
@spec post(buider :: Pact.Native.PactConsumer.RequestBuilder.t()) ::
  Pact.Native.PactConsumer.RequestBuilder.t()
```

Set the HTTP method to `POST`.

# `put`

```elixir
@spec put(buider :: Pact.Native.PactConsumer.RequestBuilder.t()) ::
  Pact.Native.PactConsumer.RequestBuilder.t()
```

Set the HTTP method to `PUT`.

# `query_param`

```elixir
@spec query_param(
  buider :: Pact.Native.PactConsumer.RequestBuilder.t(),
  key :: String.t(),
  value :: String.t()
) :: Pact.Native.PactConsumer.RequestBuilder.t()
```

Specify a query parameter. You may pass either a single value or a list of values to represent a repeated parameter.
To pass multiple parameters with the same name, call `query_param` more than once with the same `key`.

---

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