import { Billing } from "polar-accounts/src/Billing" ; export interface Discount { readonly interval : Billing . Interval ; readonly plan : Billing . V2PlanLevel ; readonly before : number ; readonly after : number ; } const DISCOUNTS = [ ] ; export interface DiscountMap { [ key ] : Discount ; } export class Discounts { constructor ( private delegate = { } ) { } public get ( interval , plan ) { const key = Discounts . key ( interval , plan ) ; return this . delegate [ key ] || undefined ; } private static key ( interval , plan ) { return `${ interval }:${ plan }` ; } public static create ( ) { const backing = { } ; for ( const discount of DISCOUNTS ) { const key = this . key ( discount . interval , discount . plan ) ; backing [ key ] = discount ; } return new Discounts ( backing ) ; } }