Documentation
¶
Overview ¶
Package entmapping provides some builders to assist in the type mapping between Stripe + the external generic definitions in pkg/catalog and pkg/entitlements and the internal ent generated types not intended for external use, but rather as a helper for the Openlane core application
Index ¶
- func ApplyStripePrice[T OrgPriceSetter[T]](b T, p *stripe.Price) T
- func ApplyStripeProduct[T OrgProductSetter[T]](b T, p *stripe.Product) T
- func ApplyStripeSubscription[T OrgSubscriptionSetter[T]](b T, sub *stripe.Subscription) T
- func ApplyStripeSubscriptionItem[T OrgModuleSetter[T]](ctx context.Context, b T, item *stripe.SubscriptionItem, ...) T
- func GetProductMetadata(ctx context.Context, product *stripe.Product, ...) map[string]string
- func PopulatePricesForOrganizationCustomer(o *entitlements.OrganizationCustomer, useSandbox bool) *entitlements.OrganizationCustomer
- func StripePriceToOrgPrice(p *stripe.Price) *ent.OrgPrice
- func StripeProductToOrgProduct(p *stripe.Product) *ent.OrgProduct
- func StripeSubscriptionItemToOrgModule(item *stripe.SubscriptionItem) *ent.OrgModule
- func StripeSubscriptionToOrgSubscription(sub *stripe.Subscription) *ent.OrgSubscription
- type OrgModuleSetter
- type OrgPriceSetter
- type OrgProductSetter
- type OrgSubscriptionSetter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyStripePrice ¶
func ApplyStripePrice[T OrgPriceSetter[T]](b T, p *stripe.Price) T
ApplyStripePrice sets fields on the provided ent builder from the stripe.Price
func ApplyStripeProduct ¶
func ApplyStripeProduct[T OrgProductSetter[T]](b T, p *stripe.Product) T
ApplyStripeProduct sets fields on the provided ent builder from the stripe.Product
func ApplyStripeSubscription ¶
func ApplyStripeSubscription[T OrgSubscriptionSetter[T]](b T, sub *stripe.Subscription) T
ApplyStripeSubscription sets fields on the ent builder from the stripe.Subscription and customer info
func ApplyStripeSubscriptionItem ¶
func ApplyStripeSubscriptionItem[T OrgModuleSetter[T]](ctx context.Context, b T, item *stripe.SubscriptionItem, client *entitlements.StripeClient, status string) T
ApplyStripeSubscriptionItem sets fields on the ent builder from the stripe.SubscriptionItem
func GetProductMetadata ¶ added in v0.30.10
func GetProductMetadata(ctx context.Context, product *stripe.Product, client *entitlements.StripeClient) map[string]string
GetProductMetadata retrieves the metadata for a Stripe product, either from the provided product object or by fetching the full product details using the Stripe client.
func PopulatePricesForOrganizationCustomer ¶
func PopulatePricesForOrganizationCustomer(o *entitlements.OrganizationCustomer, useSandbox bool) *entitlements.OrganizationCustomer
PopulatePricesForOrganizationCustomer sets Prices on the OrganizationCustomer and returns it.
func StripePriceToOrgPrice ¶
StripePriceToOrgPrice converts a stripe.Price to an OrgPrice
func StripeProductToOrgProduct ¶
func StripeProductToOrgProduct(p *stripe.Product) *ent.OrgProduct
StripeProductToOrgProduct converts a stripe.Product to an OrgProduct
func StripeSubscriptionItemToOrgModule ¶
func StripeSubscriptionItemToOrgModule(item *stripe.SubscriptionItem) *ent.OrgModule
StripeSubscriptionItemToOrgModule converts a stripe.SubscriptionItem to an OrgModule
func StripeSubscriptionToOrgSubscription ¶
func StripeSubscriptionToOrgSubscription(sub *stripe.Subscription) *ent.OrgSubscription
StripeSubscriptionToOrgSubscription converts a stripe.Subscription and OrganizationCustomer info to an OrgSubscription.
Types ¶
type OrgModuleSetter ¶
type OrgModuleSetter[T any] interface { SetModule(models.OrgModule) T SetPrice(models.Price) T SetStripePriceID(string) T SetStatus(string) T SetVisibility(string) T SetModuleLookupKey(string) T SetActive(bool) T }
OrgModuleSetter defines the methods needed to set OrgModule fields on ent builders
type OrgPriceSetter ¶
type OrgPriceSetter[T any] interface { SetStripePriceID(string) T SetPrice(models.Price) T SetStatus(string) T SetActive(bool) T SetProductID(string) T }
OrgPriceSetter defines the methods needed to set OrgPrice fields on ent builders. It uses a generic type parameter so that the concrete builder type is returned from each setter, enabling call chaining.
type OrgProductSetter ¶
type OrgProductSetter[T any] interface { SetModule(string) T SetStripeProductID(string) T SetStatus(string) T SetActive(bool) T SetPriceID(string) T }
OrgProductSetter defines the methods needed to set OrgProduct fields on ent builders
type OrgSubscriptionSetter ¶
type OrgSubscriptionSetter[T any] interface { SetStripeSubscriptionID(string) T SetStripeSubscriptionStatus(string) T SetActive(bool) T SetProductPrice(models.Price) T SetTrialExpiresAt(time.Time) T SetDaysUntilDue(string) T SetFeatures([]string) T SetFeatureLookupKeys([]string) T }
OrgSubscriptionSetter defines the methods needed to set OrgSubscription fields on ent builders