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:idof theMishkaPay.UsagethatMishkaPay.report_usage/1answered (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
Functions
A sample %MishkaPay.Usage.Cancellation{} populated from defaults + type-based fallbacks.
Types
@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.
| Field | Type | Required | Default | Description | Derives |
|---|---|---|---|---|---|
:provider | String.t() | yes | sanitize(trim) validate(not_nil_value, string, not_empty) | ||
:tenant | term() | nil | no | |||
:event_name | String.t() | yes | sanitize(trim) validate(not_nil_value, string, not_empty, max_len=100) | ||
:usage_id | String.t() | yes | sanitize(trim) validate(not_nil_value, string, not_empty, max_len=100) | ||
:status | :pending | :complete | nil | no | validate(enum=Atom[pending::complete]) |