Local write/read/resolve helpers for Braintree discount mappings.
Summary
Types
@type resolve_error() :: :not_found | :inactive | :expired | :max_redemptions_reached | Accrue.Error.DiscountMappingInvalid.t() | term()
Functions
@spec get_discount_mapping( String.t(), keyword() ) :: {:ok, Accrue.Billing.DiscountMapping.t()} | {:error, :not_found}
@spec record_discount_mapping_redemption( String.t() | Accrue.Billing.DiscountMapping.t(), keyword() ) :: {:ok, Accrue.Billing.DiscountMapping.t()} | {:error, :not_found | :max_redemptions_reached | term()}
@spec release_discount_mapping_reservation( String.t() | Accrue.Billing.DiscountMapping.t(), keyword() ) :: {:ok, Accrue.Billing.DiscountMapping.t()} | {:error, :not_found | term()}
@spec reserve_discount_mapping(String.t(), non_neg_integer(), keyword()) :: {:ok, %{ mapping: Accrue.Billing.DiscountMapping.t(), amount_off_minor: non_neg_integer(), estimated_total_minor: non_neg_integer() }} | {:error, resolve_error()}
@spec resolve_discount_mapping(String.t(), non_neg_integer(), keyword()) :: {:ok, %{ mapping: Accrue.Billing.DiscountMapping.t(), amount_off_minor: non_neg_integer(), estimated_total_minor: non_neg_integer() }} | {:error, resolve_error()}
@spec upsert_discount_mapping(String.t(), map()) :: {:ok, Accrue.Billing.DiscountMapping.t()} | {:error, Ecto.Changeset.t() | term()}
@spec upsert_discount_mapping!(String.t(), map()) :: Accrue.Billing.DiscountMapping.t()