# `Pact.Builders.MessageBuilder`

Asynchronous message interaction builder. Normally created via `Pact.Builders.PactBuilder.message_interaction`.

# `body`

```elixir
@spec body(
  builder :: Pact.Native.PactConsumer.MessageInteractionBuilder.t(),
  body :: binary() | [byte()],
  content_type :: String.t() | nil
) :: Pact.Native.PactConsumer.MessageInteractionBuilder.t()
```

Specify the message payload and content type

# `build`

```elixir
@spec build(builder :: Pact.Native.PactConsumer.MessageInteractionBuilder.t()) ::
  Pact.Native.PactConsumer.Interaction.t()
```

The interaction we've built

# `comment`

```elixir
@spec comment(
  builder :: Pact.Native.PactConsumer.MessageInteractionBuilder.t(),
  comment :: String.t()
) ::
  Pact.Native.PactConsumer.MessageInteractionBuilder.t()
```

Adds a text comment to this interaction. This allows to specify just a bit more information about the interaction. It has no functional impact, but can be displayed in the broker HTML page, and potentially in the test output.

# `given`

```elixir
@spec given(
  builder :: Pact.Native.PactConsumer.MessageInteractionBuilder.t(),
  given :: String.t()
) ::
  Pact.Native.PactConsumer.MessageInteractionBuilder.t()
```

Specify a "provider state" for this interaction. This is normally use to set up database fixtures when using a pact to test a provider.

# `given_with_params`

```elixir
@spec given_with_params(
  builder :: Pact.Native.PactConsumer.MessageInteractionBuilder.t(),
  given :: String.t(),
  params :: term()
) :: Pact.Native.PactConsumer.MessageInteractionBuilder.t()
```

Specify a "provider state" for this interaction with some defined parameters. This is normally use to set up database fixtures when using a pact to test a provider.

# `json_body`

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

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

# `new`

```elixir
@spec new(description :: String.t()) ::
  Pact.Native.PactConsumer.MessageInteractionBuilder.t()
```

Create a new message interaction builder, Description is the interaction description and interaction_type is the type of message (leave empty for the default type).

# `pending`

```elixir
@spec pending(
  builder :: Pact.Native.PactConsumer.MessageInteractionBuilder.t(),
  pending :: bool()
) ::
  Pact.Native.PactConsumer.MessageInteractionBuilder.t()
```

Sets this interaction as pending. This will permantly mark the interaction as pending in the Pact file, and it will not cause a verification failure.

# `test_name`

```elixir
@spec test_name(
  builder :: Pact.Native.PactConsumer.MessageInteractionBuilder.t(),
  name :: String.t()
) ::
  Pact.Native.PactConsumer.MessageInteractionBuilder.t()
```

Sets the test name for this interaction. This allows to specify just a bit more information about the interaction. It has no functional impact, but can be displayed in the broker HTML page, and potentially in the test output.

# `with_key`

```elixir
@spec with_key(
  buider :: Pact.Native.PactConsumer.MessageInteractionBuilder.t(),
  key :: String.t()
) ::
  Pact.Native.PactConsumer.MessageInteractionBuilder.t()
```

 Specify a unique key for this interaction. This key will be used to determine equality of the interaction, so must be unique.

---

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