# `Unicom360.Balance`
[🔗](https://github.com/TechRode-Solution-Limited/unicom360-elixir/blob/v0.1.0/lib/unicom360/balance.ex#L1)

Account balances (`POST /api/v1/json/balance` and `/balance/all`), and the struct
`get/2` returns (canonical name `Balance`).

    {:ok, %Unicom360.Balance{balance: balance}} = Unicom360.Balance.get(client)
    {:ok, whatsapp} = Unicom360.Balance.get(client, bundle_type: "WHATSAPP")
    {:ok, %Unicom360.Balances{balances: balances}} = Unicom360.Balance.all(client)

Balances are `Decimal`s, exactly as the gateway sent them. Bundle types: `"SMS"` (the
default), `"SMS_INTERNATIONAL"`, `"EMAIL"` and `"WHATSAPP"`.

Fields of `%Unicom360.Balance{}`: `message`, `balance` (a `Decimal`), `bundle_type`,
`client_id`, `client_name`, `raw` and `extra`.

# `t`

```elixir
@type t() :: %Unicom360.Balance{
  balance: Decimal.t() | nil,
  bundle_type: String.t() | nil,
  client_id: String.t() | nil,
  client_name: String.t() | nil,
  extra: map(),
  message: String.t() | nil,
  raw: map()
}
```

# `all`

```elixir
@spec all(Unicom360.Client.t(), keyword()) ::
  {:ok, Unicom360.Balances.t()} | {:error, Unicom360.Error.t()}
```

Every balance, as a map from bundle type to `Decimal`.

Options: `:timeout` (ms per attempt) and `:max_retries`.

# `all!`

```elixir
@spec all!(Unicom360.Client.t(), keyword()) :: Unicom360.Balances.t()
```

Like `all/2`, but returns the balances or raises `Unicom360.Error`.

# `email`

```elixir
@spec email() :: String.t()
```

The email bundle type.

# `get`

```elixir
@spec get(Unicom360.Client.t(), keyword()) ::
  {:ok, t()} | {:error, Unicom360.Error.t()}
```

One balance: the SMS bundle, or the bundle given as `bundle_type:`.

Options: `:bundle_type`, `:timeout` (ms per attempt) and `:max_retries`. A refusal (for
example `code: "CLIENT_NOT_FOUND"`) is an `:api_error` with no `api_reference`.

# `get!`

```elixir
@spec get!(Unicom360.Client.t(), keyword()) :: t()
```

Like `get/2`, but returns the balance or raises `Unicom360.Error`.

# `sms`

```elixir
@spec sms() :: String.t()
```

The SMS bundle type.

# `sms_international`

```elixir
@spec sms_international() :: String.t()
```

The international SMS bundle type.

# `whatsapp`

```elixir
@spec whatsapp() :: String.t()
```

The WhatsApp bundle type.

---

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