Accrue.Billing.PromotionCodeProjection (accrue v0.3.0)

Copy Markdown View Source

Decomposes a processor promotion-code map (atom- or string-keyed) into a flat attrs map ready for Accrue.Billing.PromotionCode.changeset/2.

Mirrors Accrue.Billing.InvoiceProjection / SubscriptionProjection shape: handles dual atom/string keys, normalizes the full upstream object into jsonb-safe form for the data column, and resolves the nested coupon reference down to the coupon's processor_id string (the caller looks up the local coupon_id FK from that).

Summary

Types

decomposed()

@type decomposed() :: {:ok, map(), coupon_processor_id :: String.t() | nil}

Functions

decompose(stripe_promo)

@spec decompose(map()) :: decomposed()