# `KapsoEx.WhatsApp.Flows`
[🔗](https://github.com/rocket4ce/kapso_ex/blob/v0.1.0/lib/kapso_ex/whatsapp/flows.ex#L1)

WhatsApp Flows through Meta's Graph API shapes (proxied by Kapso).

`KapsoEx.Platform.Flows` offers a higher level API on top of this: flow
versions, data endpoints and encryption setup.

Flow-ID endpoints need a context so Kapso can pick the connection: pass
`phone_number_id:` or `business_account_id:` in `params`.

# `result`

```elixir
@type result() :: {:ok, map()} | {:error, KapsoEx.Error.t()}
```

# `create`

```elixir
@spec create(KapsoEx.Client.t(), String.t(), map() | keyword()) :: result()
```

Creates a flow in a WhatsApp Business Account.

Attributes: `name` and `categories` (required), `clone_flow_id`,
`endpoint_uri`, `flow_json` (a JSON string) and `publish`.

# `create_for_phone_number`

```elixir
@spec create_for_phone_number(KapsoEx.Client.t(), String.t(), map() | keyword()) ::
  result()
```

Creates a flow for a phone number. Attributes as in `create/3`.

# `delete`

```elixir
@spec delete(KapsoEx.Client.t(), String.t(), map() | keyword()) :: result()
```

Deletes a draft flow. This cannot be undone.

# `deprecate`

```elixir
@spec deprecate(KapsoEx.Client.t(), String.t(), map() | keyword()) :: result()
```

Deprecates a published flow.

# `get`

```elixir
@spec get(KapsoEx.Client.t(), String.t(), map() | keyword()) :: result()
```

Gets a flow. `fields` defaults to
`"id,name,status,categories,validation_errors,json_version,data_api_version,endpoint_uri,preview"`.

    Flows.get(client, flow_id, phone_number_id: "647015955153740")

# `get_assets`

```elixir
@spec get_assets(KapsoEx.Client.t(), String.t(), map() | keyword()) :: result()
```

Lists the flow's assets, with download URLs for the flow JSON.

# `list`

```elixir
@spec list(KapsoEx.Client.t(), String.t(), map() | keyword()) :: result()
```

Lists the flows of a WhatsApp Business Account.

# `list_for_phone_number`

```elixir
@spec list_for_phone_number(KapsoEx.Client.t(), String.t(), map() | keyword()) ::
  result()
```

Lists the flows available to a phone number.

# `publish`

```elixir
@spec publish(KapsoEx.Client.t(), String.t(), map() | keyword()) :: result()
```

Publishes a flow. This cannot be undone.

# `update`

```elixir
@spec update(KapsoEx.Client.t(), String.t(), map() | keyword(), map() | keyword()) ::
  result()
```

Updates flow metadata: `name`, `categories`, `endpoint_uri` or
`application_id`.

# `upload_json`

```elixir
@spec upload_json(
  KapsoEx.Client.t(),
  String.t(),
  String.t() | map(),
  map() | keyword()
) :: result()
```

Uploads the flow JSON (max 10 MB). `flow_json` is a JSON string or a map,
which is encoded for you.

---

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