# `MishkaPay.Ash.Resource.Kinds`
[🔗](https://github.com/mishka-group/mishka_pay/blob/v0.0.1/lib/mishka_pay/ash/__resource/kinds.ex#L6)

The shape of each kind of `MishkaPay.Ash.Resource`, in one place: its attributes, identities,
calculations and actions (with their arguments, changes and options), the code interface name
of each action, the listener that keeps it current and, for the inbox, its AshOban trigger.
`MishkaPay.Ash.Resource.ApplyKind` adds them to a host's resource with `Ash.Resource.Builder`,
skipping whatever the host defines itself.

# `action`

```elixir
@type action() :: {atom(), Ash.Resource.Actions.action_type(), keyword()}
```

# `attribute`

```elixir
@type attribute() :: {atom(), atom(), keyword()}
```

# `kind`

```elixir
@type kind() ::
  :inbox
  | :payment
  | :subscription
  | :customer
  | :dispute
  | :product
  | :price
  | :coupon
  | :promotion_code
  | :payment_link
  | :invoice
```

# `action_names`

```elixir
@spec action_names(kind()) :: [atom()]
```

The names of a kind's actions, in the order they are added.

# `actions`

```elixir
@spec actions(kind(), keyword()) :: [action()]
```

The actions of a kind, with `:resync` for every provider object's kind. `announce?: false`
builds their changes without the
`mishka_pay:<kind>:changed` event; `user:` names the `belongs_to_user` attribute, which a sync
writes from the owner and a customer's `:register` accepts.

# `attributes`

```elixir
@spec attributes(kind()) :: [attribute()]
```

The attributes of a kind, after its `:id` primary key and before its timestamps.

# `calculations`

```elixir
@spec calculations(kind()) :: [{atom(), atom(), term()}]
```

The calculations of a kind: its amounts as `Money`, and for a subscription `:active?` (gives
access now, as `MishkaPay.Ash.Subscribed` counts it by default), `:on_trial?` and `:canceling?`
(ends at the period's end), each usable in a filter or a sort.

# `forget_trigger`

```elixir
@spec forget_trigger(module(), pos_integer()) :: keyword()
```

The inbox's daily AshOban trigger that deletes processed events older than `days`.

# `identity`

```elixir
@spec identity(kind()) :: {atom(), [atom()]}
```

The identity that keeps each provider object (or event) once.

# `interface`

```elixir
@spec interface(atom()) :: atom()
```

The code interface name of an action. `receive` is an Elixir special form, so the inbox's
`:receive` is `receive_event`.

# `kinds`

```elixir
@spec kinds() :: [kind()]
```

Every kind.

# `listener`

```elixir
@spec listener(kind()) :: module()
```

The listener macro module that keeps a resource of the kind current from webhooks.

# `resync_trigger`

```elixir
@spec resync_trigger(module(), kind(), pos_integer()) :: keyword() | nil
```

The hourly AshOban trigger that reads again, with `:resync`, the rows of `kind` still open at
their provider and not read for `hours`; `nil` for a kind whose rows are never open.

# `trigger`

```elixir
@spec trigger(module()) :: keyword()
```

The inbox's AshOban trigger, as `oban do triggers do trigger :process ... end end` writes it.
Its worker and scheduler are named after the resource, so two inboxes never share them.

---

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