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

Copy Markdown View Source

What a meter counted for one customer over a window of time, read with MishkaPay.usage_summary/6. A guarded_struct the provider fills in.

  • :provider, :meter_id, :customer_id: whose usage, on which meter.
  • :value: the usage the meter's aggregation gives for the window (a sum, a count or the last value), as the provider reports it; 0 when nothing was reported.
  • :from, :to: the window the provider counted, :to not included. A provider may widen the window asked for to its own boundaries, such as whole minutes at Stripe.

A provider counts usage a little after it is reported, so a report made a moment ago may not be in the value yet.

Summary

Types

t()

The struct that builder/1 returns.

Functions

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

Types

t()

@type t() :: %MishkaPay.Usage.Summary{
  customer_id: String.t() | nil,
  from: DateTime.t() | nil,
  meter_id: String.t() | nil,
  provider: String.t() | nil,
  to: DateTime.t() | nil,
  value: number() | nil
}

The struct that builder/1 returns.

FieldTypeRequiredDefaultDescriptionDerives
:providerString.t() | nilnovalidate(string)
:meter_idString.t() | nilnovalidate(string)
:customer_idString.t() | nilnovalidate(string)
:valuenumber() | nilno0
:fromDateTime.t() | nilnovalidate(struct)
:toDateTime.t() | nilnovalidate(struct)

Functions

builder(attrs_or_input, error \\ false)

enforce_keys()

enforce_keys(field)

example()

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

keys()

keys(field)