# `PaperTiger.Connect`
[🔗](https://github.com/EnaiaInc/paper_tiger/blob/v1.2.2/lib/paper_tiger/connect.ex#L1)

Request-scoped helpers for Stripe Connect behavior.

Stripe's `Stripe-Account` header is per request. PaperTiger models that by
storing the connected account ID in the process dictionary for the duration
of a request, then using it as part of the ETS storage namespace for normal
resources. Platform-owned resources can temporarily opt back into the base
namespace with `without_account/1`.

# `account_id`

```elixir
@type account_id() :: String.t()
```

# `storage_namespace`

```elixir
@type storage_namespace() :: pid() | :global | {pid() | :global, account_id()}
```

# `account_id?`

```elixir
@spec account_id?(term()) :: boolean()
```

Returns true when an ID looks like a Stripe connected account ID.

# `clear_account`

```elixir
@spec clear_account() :: :ok
```

Clears any connected account from the current process.

# `current_account`

```elixir
@spec current_account() :: account_id() | nil
```

Returns the connected account ID for the current request, if any.

# `put_account`

```elixir
@spec put_account(account_id()) :: :ok
```

Sets the connected account for the current process.

# `storage_namespace`

```elixir
@spec storage_namespace() :: storage_namespace()
```

Returns the storage namespace for the current sandbox + connected account.

# `storage_namespace`

```elixir
@spec storage_namespace(pid() | :global) :: storage_namespace()
```

Returns the storage namespace for a base sandbox namespace.

# `with_account`

```elixir
@spec with_account(account_id() | nil, (-&gt; result)) :: result when result: term()
```

Runs `fun` with the given connected account ID in the process dictionary.

# `without_account`

```elixir
@spec without_account((-&gt; result)) :: result when result: term()
```

Runs `fun` in platform scope even if the request is account-scoped.

---

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