Subscription Addon Diff Package
This package implements functionality to apply and restore subscription addons to subscription specifications.
Core Components
Diffable Interface (diff.go)
The central interface for objects that can be both applied to and removed from a subscription specification:
GetApplies(): Returns operations that will be applied to the specificationGetRestores(): Returns operations that will be applied to revert changes
Addon Operations (addon.go)
Handles the conversion of subscription addons into diffable objects that can modify subscription specifications:
GetDiffableFromAddon(): Creates a diffable object from a subscription addondiffable: Wrapper for apply and restore implementations for a singleSubscriptionAddonInstance
Application Logic (apply.go)
Algorithm for applying subscription addon rate cards to subscription specifications. A specification for it is as follows:
- Given a
SubscriptionAddon,SubscriptionAddonInstancescan be created. - Given a
SubscriptionAddonInstanceand aSubscriptionView, theSubscriptionAddonRateCardscan be matched to theSubscriptionView's items.
Then, for each SubscriptionAddonRateCard:
- During the Addon's entire cadence, the RateCard has to be present: either as a modification on an existing item, or as a new item.
- The RateCard's contents should always be effective
SubscriptionAddonInstnce.Quantitytimes: if quantity is 0, the RateCard should not be present.
The merging logic of two RateCards is defined in the
subscriptionaddonpackage, not here.
If the above are met for each SubscriptionAddonRateCard of each SubscriptionAddonInstance, then the SubscriptionAddon has been applied to the SubscriptionSpec.
Usage
This package is meant to be internal to subscription.