Accrue.Entitlements.Account (accrue v1.5.0)

Copy Markdown View Source

Durable, owner-stable entitlement identity.

Hosts authenticate and supply the opaque owner identity before calling this boundary. The resulting UUID is not derived from the owner and is suitable for future rail-specific account binding.

Summary

Functions

Builds the owner-identity changeset and maps the database uniqueness authority.

Fetches or creates the single durable account for an authenticated owner identity.

Types

t()

@type t() :: %Accrue.Entitlements.Account{
  __meta__: term(),
  id: term(),
  inserted_at: term(),
  owner_id: term(),
  owner_type: term(),
  revision: term(),
  updated_at: term()
}

Functions

changeset(account_or_changeset, attrs \\ %{})

@spec changeset(t() | Ecto.Changeset.t(), map()) :: Ecto.Changeset.t()

Builds the owner-identity changeset and maps the database uniqueness authority.

fetch_or_create(repo, owner_type, owner_id)

@spec fetch_or_create(Ecto.Repo.t(), String.t(), String.t()) ::
  {:ok, t()} | {:error, Ecto.Changeset.t()}

Fetches or creates the single durable account for an authenticated owner identity.