# `KapsoEx.Platform.Funding`
[🔗](https://github.com/rocket4ce/kapso_ex/blob/v0.1.0/lib/kapso_ex/platform/funding.ex#L1)

[WhatsApp funding and usage](https://docs.kapso.ai/docs/platform/whatsapp-funding)
for Tech Providers with managed billing: funding status per WhatsApp
Business Account (WABA) and portfolio, recorded charges, and stopping
funding.

Usage amounts are in micro USD (`customer_charge_micro_usd`).

# `result`

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

# `time`

```elixir
@type time() :: DateTime.t() | String.t()
```

# `ensure_account_funding`

```elixir
@spec ensure_account_funding(KapsoEx.Client.t(), String.t(), String.t()) :: result()
```

Verifies an external multi-partner solution account with Meta and ensures
Kapso funds it, without waiting for Meta's webhook. Call it after
Embedded Signup completes.

# `get_account_funding`

```elixir
@spec get_account_funding(KapsoEx.Client.t(), String.t()) :: result()
```

Gets the funding status of a WABA.

# `get_account_usage`

```elixir
@spec get_account_usage(KapsoEx.Client.t(), String.t(), time(), time()) :: result()
```

Gets the charges recorded for a WABA between `start_time` and `end_time`.

# `get_funding_operation`

```elixir
@spec get_funding_operation(KapsoEx.Client.t(), String.t(), String.t()) :: result()
```

Gets the status of a funding revocation operation.

# `get_portfolio_usage`

```elixir
@spec get_portfolio_usage(KapsoEx.Client.t(), String.t(), time(), time()) :: result()
```

Gets the charges recorded across a portfolio's accounts between `start_time` and `end_time`.

# `list_portfolio_accounts`

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

Lists the WABAs of a business portfolio with their funding status. Params: `limit`, `before`, `after`.

# `revoke_portfolio_funding`

```elixir
@spec revoke_portfolio_funding(KapsoEx.Client.t(), String.t(), String.t()) :: result()
```

Queues an asynchronous stop of Kapso funding for a portfolio.

`idempotency_key` (1-255 bytes) must be stable per logical request:
reuse it when retrying after a network failure to get the original
operation back. Follow it with `get_funding_operation/3`.

---

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