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

Copy Markdown View Source

Makes a module the mishka_pay:event:process listener that syncs the provider object an event is about into a resource of a site-managed kind (MishkaPay.Ash.Object.Spec): a product.updated into the :product resource, an invoice.paid into the :invoice one.

defmodule MyApp.Pay.ProductSync do
  use MishkaPay.Ash.Object.Listener, resource: MyApp.Pay.Product, kind: :product
end

MishkaPay.Ash.Resource makes one for each resource that listens (listen? true), as <Resource>.MishkaPayListener. An event about another object is left alone, and so is one from a provider that cannot read this kind at all (a PayPal CATALOG.PRODUCT.CREATED: Mishka Pay has no PayPal catalog); an object the provider fails to give fails the event, so the inbox tries it again later.