MishkaPay.Usage.Cancellation (Mishka Pay v0.0.1)

Copy Markdown View Source

Takes back one usage report sent by mistake, with MishkaPay.cancel_usage/1: the meter then counts it as if it was never reported. A guarded_struct.

What the caller gives:

  • :provider, :tenant: which provider, with whose keys.
  • :event_name: the meter's event name the report was sent under.
  • :usage_id: the report's id, the :id of the MishkaPay.Usage that MishkaPay.report_usage/1 answered (made from its :reference).

What the provider fills in: :status, :pending while it takes the report out of the count, :complete once it has.

A provider takes a report back only for a while after it came in (Stripe: 24 hours). After that, report the same value again below zero to correct the count.

Summary

Types

t()

The struct that builder/1 returns.

Functions

A sample %MishkaPay.Usage.Cancellation{} populated from defaults + type-based fallbacks.

Types

t()

@type t() :: %MishkaPay.Usage.Cancellation{
  event_name: String.t(),
  provider: String.t(),
  status: (:pending | :complete) | nil,
  tenant: term() | nil,
  usage_id: String.t()
}

The struct that builder/1 returns.

FieldTypeRequiredDefaultDescriptionDerives
:providerString.t()yessanitize(trim) validate(not_nil_value, string, not_empty)
:tenantterm() | nilno
:event_nameString.t()yessanitize(trim) validate(not_nil_value, string, not_empty, max_len=100)
:usage_idString.t()yessanitize(trim) validate(not_nil_value, string, not_empty, max_len=100)
:status:pending | :complete | nilnovalidate(enum=Atom[pending::complete])

Functions

builder(attrs_or_input, error \\ false)

enforce_keys()

enforce_keys(field)

example()

A sample %MishkaPay.Usage.Cancellation{} populated from defaults + type-based fallbacks.

keys()

keys(field)