# `Pact.Builders.ResponseBuilder`

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

# `body2`

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

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

# `body`

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

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

# `body_matching2`

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

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

# `body_matching`

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

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

# `build`

```elixir
@spec build(buider :: Pact.Native.PactConsumer.ResponseBuilder.t()) ::
  Pact.Native.PactConsumer.Response.t()
```

Build the specified `Response` object.

# `build_v4`

```elixir
@spec build_v4(buider :: Pact.Native.PactConsumer.ResponseBuilder.t()) ::
  Pact.Native.PactConsumer.HttpResponse.t()
```

Build the specified `Response` object in V4 format.

# `content_type`

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

Set the `Content-Type` header.

# `contents`

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

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

# `created`

```elixir
@spec created(buider :: Pact.Native.PactConsumer.ResponseBuilder.t()) ::
  Pact.Native.PactConsumer.ResponseBuilder.t()
```

Set the status code to `201 Created`.

# `default`

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

# `forbidden`

```elixir
@spec forbidden(buider :: Pact.Native.PactConsumer.ResponseBuilder.t()) ::
  Pact.Native.PactConsumer.ResponseBuilder.t()
```

Set the status code to `403 Forbidden`.

# `header`

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

Specify a header pattern.

# `header_from_provider_state`

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

Specify a header pattern and a generator from provider state.

# `html`

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

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

# `json_body`

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

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

# `json_utf8`

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

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

# `no_content`

```elixir
@spec no_content(buider :: Pact.Native.PactConsumer.ResponseBuilder.t()) ::
  Pact.Native.PactConsumer.ResponseBuilder.t()
```

Set the status code to `204 No Content`.

# `not_found`

```elixir
@spec not_found(buider :: Pact.Native.PactConsumer.ResponseBuilder.t()) ::
  Pact.Native.PactConsumer.ResponseBuilder.t()
```

Set the status code to `404 Not Found`.

# `ok`

```elixir
@spec ok(buider :: Pact.Native.PactConsumer.ResponseBuilder.t()) ::
  Pact.Native.PactConsumer.ResponseBuilder.t()
```

Set the status code to `200 OK`. (This is default.)

# `status`

```elixir
@spec status(
  buider :: Pact.Native.PactConsumer.ResponseBuilder.t(),
  status :: pos_integer()
) ::
  Pact.Native.PactConsumer.ResponseBuilder.t()
```

Set the status code for the response. Defaults to `200`.

# `unauthorized`

```elixir
@spec unauthorized(buider :: Pact.Native.PactConsumer.ResponseBuilder.t()) ::
  Pact.Native.PactConsumer.ResponseBuilder.t()
```

Set the status code to `401 Unauthorized`.

---

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