MishkaPay.Ash.Object.Spec (Mishka Pay v0.0.1)

Copy Markdown View Source

What the provider objects a site manages from its admin keep and do, kind by kind: products, prices, coupons, promotion codes, payment links and one-off bills (the :product, :price, :coupon, :promotion_code, :payment_link and :invoice kinds of MishkaPay.Ash.Resource). Each kind names the provider object its webhook events are about, how to read one again, the row it writes from the provider's answer, and the MishkaPay call of each of its actions. MishkaPay.Ash.Object.Change and MishkaPay.Ash.Object.Listener run them.

Summary

Functions

The row's attributes from the provider's object.

The MishkaPay call of an action: :add makes the object from the action's input, the others act on the row's object. input holds the action's arguments set, with :provider, :tenant and, on a row, :id.

The provider capability that reads a kind's object: a provider without it cannot give one, so an event about such an object is not for this kind.

Reads one object of kind again from its provider.

The :sync argument that names the object: :product_id, :invoice_id...

The kinds of provider objects a site manages from its admin.

The provider's name of the object a kind keeps, as its webhook events name it.

Functions

attributes(product)

@spec attributes(struct()) :: map()

The row's attributes from the provider's object.

call(atom1, atom2, input)

@spec call(atom(), atom(), map()) :: {:ok, struct()} | :ok | {:error, term()}

The MishkaPay call of an action: :add makes the object from the action's input, the others act on the row's object. input holds the action's arguments set, with :provider, :tenant and, on a row, :id.

capability(kind)

@spec capability(atom()) :: MishkaPay.Provider.capability()

The provider capability that reads a kind's object: a provider without it cannot give one, so an event about such an object is not for this kind.

fetch(atom, provider, id, tenant)

@spec fetch(atom(), String.t(), String.t(), term()) ::
  {:ok, struct()} | {:error, term()}

Reads one object of kind again from its provider.

id_argument(atom)

@spec id_argument(atom()) :: atom()

The :sync argument that names the object: :product_id, :invoice_id...

kinds()

@spec kinds() :: [atom()]

The kinds of provider objects a site manages from its admin.

object(kind)

@spec object(atom()) :: String.t()

The provider's name of the object a kind keeps, as its webhook events name it.