Documentation
¶
Overview ¶
Package openmeter provides a Go client SDK for the OpenMeter API — usage metering and billing for AI and DevTool companies. It is generated from the OpenMeter TypeSpec definitions and exposes every operation as a method on a typed service hanging off Client (for example Client.Meters), with typed request and response models.
Construct a Client with New, passing the API base URL and a bearer token via WithToken:
om, err := openmeter.New(
"https://openmeter.cloud/api/v3",
openmeter.WithToken(os.Getenv("OPENMETER_API_KEY")),
)
Any non-2xx response is returned as an APIError carrying the HTTP status code and the RFC 7807 problem fields; unwrap it with errors.As or AsAPIError. Client-side validation failures such as an empty resource ID are reported before any request is sent and match ErrEmptyID via errors.Is.
Paginated list operations additionally provide ...All variants returning iter.Seq2 sequences that fetch pages lazily and yield each item together with an error.
Index ¶
- Variables
- func Bool(b bool) *bool
- func DecodeAPIError[T any](err error) (T, bool, error)
- func Int(i int) *int
- func Ptr[T any](v T) *T
- func String(s string) *string
- func Time(t time.Time) *time.Time
- type APIError
- type Addon
- type AddonFilter
- type AddonInstanceType
- type AddonListParams
- type AddonPagePaginatedResponse
- type AddonReference
- type AddonStatus
- type AddonsService
- func (s *AddonsService) Archive(ctx context.Context, addonID string) (*Addon, error)
- func (s *AddonsService) Create(ctx context.Context, request CreateAddonRequest) (*Addon, error)
- func (s *AddonsService) Delete(ctx context.Context, addonID string) error
- func (s *AddonsService) Get(ctx context.Context, addonID string) (*Addon, error)
- func (s *AddonsService) List(ctx context.Context, params AddonListParams) (*AddonPagePaginatedResponse, error)
- func (s *AddonsService) ListAll(ctx context.Context, params AddonListParams) iter.Seq2[Addon, error]
- func (s *AddonsService) Publish(ctx context.Context, addonID string) (*Addon, error)
- func (s *AddonsService) Update(ctx context.Context, addonID string, request UpsertAddonRequest) (*Addon, error)
- type Address
- type App
- type AppAction
- type AppActionRequest
- type AppActionType
- type AppCapability
- type AppCapabilityType
- type AppCatalogItem
- type AppCatalogItemListParams
- type AppCatalogItemPagePaginatedResponse
- type AppCustomerData
- type AppCustomerDataExternalInvoicing
- type AppCustomerDataExternalInvoicingInput
- type AppCustomerDataInput
- type AppCustomerDataStripe
- type AppCustomerDataStripeInput
- type AppExternalInvoicing
- type AppFilter
- type AppInstallMethods
- type AppListParams
- type AppPagePaginatedResponse
- type AppReconcileWebhookEventsActionRequest
- type AppReference
- type AppSandbox
- type AppStatus
- type AppStripe
- type AppStripeCheckoutSessionCustomTextParams
- type AppStripeCheckoutSessionCustomTextParamsAfterSubmit
- type AppStripeCheckoutSessionCustomTextParamsShippingAddress
- type AppStripeCheckoutSessionCustomTextParamsSubmit
- type AppStripeCheckoutSessionCustomTextParamsTermsOfServiceAcceptance
- type AppStripeCheckoutSessionMode
- type AppStripeCheckoutSessionUiMode
- type AppStripeCreateCheckoutSessionBillingAddressCollection
- type AppStripeCreateCheckoutSessionConsentCollection
- type AppStripeCreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreement
- type AppStripeCreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPosition
- type AppStripeCreateCheckoutSessionConsentCollectionPromotions
- type AppStripeCreateCheckoutSessionConsentCollectionTermsOfService
- type AppStripeCreateCheckoutSessionCustomerUpdate
- type AppStripeCreateCheckoutSessionCustomerUpdateBehavior
- type AppStripeCreateCheckoutSessionRedirectOnCompletion
- type AppStripeCreateCheckoutSessionRequestOptions
- type AppStripeCreateCheckoutSessionResult
- type AppStripeCreateCheckoutSessionTaxIDCollection
- type AppStripeCreateCheckoutSessionTaxIDCollectionRequired
- type AppStripeCreateCustomerPortalSessionOptions
- type AppStripeCreateCustomerPortalSessionResult
- type AppType
- type AppsService
- func (s *AppsService) ExecuteAction(ctx context.Context, appID string, request AppActionRequest) (*App, error)
- func (s *AppsService) Get(ctx context.Context, appID string) (*App, error)
- func (s *AppsService) GetCatalogItem(ctx context.Context, appType string) (*AppCatalogItem, error)
- func (s *AppsService) Install(ctx context.Context, request InstallAppRequest) (*InstallAppResponse, error)
- func (s *AppsService) List(ctx context.Context, params AppListParams) (*AppPagePaginatedResponse, error)
- func (s *AppsService) ListAll(ctx context.Context, params AppListParams) iter.Seq2[App, error]
- func (s *AppsService) ListCatalog(ctx context.Context, params AppCatalogItemListParams) (*AppCatalogItemPagePaginatedResponse, error)
- func (s *AppsService) ListCatalogAll(ctx context.Context, params AppCatalogItemListParams) iter.Seq2[AppCatalogItem, error]
- func (s *AppsService) Uninstall(ctx context.Context, appID string) error
- func (s *AppsService) Update(ctx context.Context, appID string, request UpdateAppRequest) (*App, error)
- type BillingCurrencyCode
- type BillingService
- func (s *BillingService) CreateProfile(ctx context.Context, request CreateBillingProfileRequest) (*Profile, error)
- func (s *BillingService) DeleteProfile(ctx context.Context, id string) error
- func (s *BillingService) GetProfile(ctx context.Context, id string) (*Profile, error)
- func (s *BillingService) ListProfiles(ctx context.Context, params ProfileListParams) (*ProfilePagePaginatedResponse, error)
- func (s *BillingService) ListProfilesAll(ctx context.Context, params ProfileListParams) iter.Seq2[Profile, error]
- func (s *BillingService) UpdateProfile(ctx context.Context, id string, request UpsertBillingProfileRequest) (*Profile, error)
- type BillingSubscription
- type BillingSubscriptionFilter
- type BillingSubscriptionListParams
- type BooleanFilter
- type Charge
- type ChargeCostBasis
- func ChargeCostBasisFromChargeCostBasisDynamic(value ChargeCostBasisDynamic) (ChargeCostBasis, error)
- func ChargeCostBasisFromChargeCostBasisManual(value ChargeCostBasisManual) (ChargeCostBasis, error)
- func ChargeCostBasisFromChargeCostBasisPinned(value ChargeCostBasisPinned) (ChargeCostBasis, error)
- func (u ChargeCostBasis) AsChargeCostBasisDynamic() (*ChargeCostBasisDynamic, error)
- func (u ChargeCostBasis) AsChargeCostBasisManual() (*ChargeCostBasisManual, error)
- func (u ChargeCostBasis) AsChargeCostBasisPinned() (*ChargeCostBasisPinned, error)
- func (u ChargeCostBasis) MarshalJSON() ([]byte, error)
- func (u *ChargeCostBasis) UnmarshalJSON(data []byte) error
- type ChargeCostBasisDynamic
- type ChargeCostBasisManual
- type ChargeCostBasisPinned
- type ChargeCostBasisType
- type ChargeFlatFee
- type ChargeFlatFeeDiscounts
- type ChargeFlatFeeSystemIntent
- type ChargePagePaginatedResponse
- type ChargeRealization
- type ChargeRealizationAmountDiscount
- type ChargeRealizationDetailedLine
- func ChargeRealizationDetailedLineFromChargeRealizationDetailedLineFlatFee(value ChargeRealizationDetailedLineFlatFee) (ChargeRealizationDetailedLine, error)
- func ChargeRealizationDetailedLineFromChargeRealizationDetailedLineUsageBased(value ChargeRealizationDetailedLineUsageBased) (ChargeRealizationDetailedLine, error)
- func (u ChargeRealizationDetailedLine) AsChargeRealizationDetailedLineFlatFee() (*ChargeRealizationDetailedLineFlatFee, error)
- func (u ChargeRealizationDetailedLine) AsChargeRealizationDetailedLineUsageBased() (*ChargeRealizationDetailedLineUsageBased, error)
- func (u ChargeRealizationDetailedLine) MarshalJSON() ([]byte, error)
- func (u *ChargeRealizationDetailedLine) UnmarshalJSON(data []byte) error
- type ChargeRealizationDetailedLineCategory
- type ChargeRealizationDetailedLineCreditApplied
- type ChargeRealizationDetailedLineFlatFee
- type ChargeRealizationDetailedLineUsageBased
- type ChargeRealizationInvoice
- type ChargeRealizationInvoiceOrReference
- func ChargeRealizationInvoiceOrReferenceFromChargeRealizationInvoice(value ChargeRealizationInvoice) (ChargeRealizationInvoiceOrReference, error)
- func ChargeRealizationInvoiceOrReferenceFromChargeRealizationInvoiceReference(value ChargeRealizationInvoiceReference) (ChargeRealizationInvoiceOrReference, error)
- func (u ChargeRealizationInvoiceOrReference) AsChargeRealizationInvoice() (*ChargeRealizationInvoice, error)
- func (u ChargeRealizationInvoiceOrReference) AsChargeRealizationInvoiceReference() (*ChargeRealizationInvoiceReference, error)
- func (u ChargeRealizationInvoiceOrReference) MarshalJSON() ([]byte, error)
- func (u *ChargeRealizationInvoiceOrReference) UnmarshalJSON(data []byte) error
- type ChargeRealizationInvoiceReference
- type ChargeRealizationPayment
- type ChargeRealizationPaymentStatus
- type ChargeRealizationType
- type ChargeReference
- type ChargeResolvedCostBasis
- type ChargeStatus
- type ChargeTotals
- type ChargeType
- type ChargeUsageBased
- type ChargeUsageBasedSystemIntent
- type ChargesExpand
- type ChargesService
- func (s *ChargesService) Get(ctx context.Context, chargeID string, params GetChargeParams) (*Charge, error)
- func (s *ChargesService) List(ctx context.Context, params ListChargesParams) (*ChargePagePaginatedResponse, error)
- func (s *ChargesService) ListAll(ctx context.Context, params ListChargesParams) iter.Seq2[Charge, error]
- type Client
- type ClosedPeriod
- type CollectionAlignment
- type CollectionMethod
- type CostBasis
- type CostBasisFilter
- type CostBasisListParams
- type CostBasisPagePaginatedResponse
- type CreateAddonRequest
- type CreateBillingProfileRequest
- type CreateChargeFlatFeeRequest
- type CreateChargeRequest
- func (u CreateChargeRequest) AsCreateChargeFlatFeeRequest() (*CreateChargeFlatFeeRequest, error)
- func (u CreateChargeRequest) AsCreateChargeUsageBasedRequest() (*CreateChargeUsageBasedRequest, error)
- func (u CreateChargeRequest) MarshalJSON() ([]byte, error)
- func (u *CreateChargeRequest) UnmarshalJSON(data []byte) error
- type CreateChargeUsageBasedRequest
- type CreateCostBasisRequest
- type CreateCreditAdjustmentRequest
- type CreateCreditGrantFilters
- type CreateCreditGrantPlanFilter
- type CreateCreditGrantPurchase
- type CreateCreditGrantRequest
- type CreateCurrencyCustomRequest
- type CreateCustomerRequest
- type CreateEntitlementBooleanRequest
- type CreateEntitlementMeteredRequest
- type CreateEntitlementRequest
- func CreateEntitlementRequestFromCreateEntitlementBooleanRequest(value CreateEntitlementBooleanRequest) (CreateEntitlementRequest, error)
- func CreateEntitlementRequestFromCreateEntitlementMeteredRequest(value CreateEntitlementMeteredRequest) (CreateEntitlementRequest, error)
- func CreateEntitlementRequestFromCreateEntitlementStaticRequest(value CreateEntitlementStaticRequest) (CreateEntitlementRequest, error)
- func (u CreateEntitlementRequest) AsCreateEntitlementBooleanRequest() (*CreateEntitlementBooleanRequest, error)
- func (u CreateEntitlementRequest) AsCreateEntitlementMeteredRequest() (*CreateEntitlementMeteredRequest, error)
- func (u CreateEntitlementRequest) AsCreateEntitlementStaticRequest() (*CreateEntitlementStaticRequest, error)
- func (u CreateEntitlementRequest) MarshalJSON() ([]byte, error)
- func (u *CreateEntitlementRequest) UnmarshalJSON(data []byte) error
- type CreateEntitlementStaticRequest
- type CreateFeatureRequest
- type CreateMeterRequest
- type CreateNotificationChannelRequest
- type CreatePlanAddonRequest
- type CreatePlanRequest
- type CreateSubscriptionAddonRequest
- type CreateTaxCodeRequest
- type CreateVersionFilter
- type CreditAdjustment
- type CreditAvailabilityPolicy
- type CreditBalance
- type CreditBalances
- type CreditFundingMethod
- type CreditGrant
- type CreditGrantFilter
- type CreditGrantFilters
- type CreditGrantInvoiceReference
- type CreditGrantInvoiceReferenceLine
- type CreditGrantListParams
- type CreditGrantPagePaginatedResponse
- type CreditGrantPlanFilter
- type CreditGrantPurchase
- type CreditGrantStatus
- type CreditGrantVoidPaymentAdjustment
- type CreditPurchasePaymentSettlementStatus
- type CreditTransaction
- type CreditTransactionAvailableBalance
- type CreditTransactionFilter
- type CreditTransactionListParams
- type CreditTransactionPaginatedResponse
- type CreditTransactionType
- type CurrenciesService
- func (s *CurrenciesService) CreateCostBasis(ctx context.Context, currencyID string, request CreateCostBasisRequest) (*CostBasis, error)
- func (s *CurrenciesService) CreateCustomCurrency(ctx context.Context, request CreateCurrencyCustomRequest) (*CurrencyCustom, error)
- func (s *CurrenciesService) GetCustomCurrency(ctx context.Context, currencyID string) (*CurrencyCustom, error)
- func (s *CurrenciesService) List(ctx context.Context, params CurrencyListParams) (*CurrencyPagePaginatedResponse, error)
- func (s *CurrenciesService) ListAll(ctx context.Context, params CurrencyListParams) iter.Seq2[Currency, error]
- func (s *CurrenciesService) ListCostBases(ctx context.Context, currencyID string, params CostBasisListParams) (*CostBasisPagePaginatedResponse, error)
- func (s *CurrenciesService) ListCostBasesAll(ctx context.Context, currencyID string, params CostBasisListParams) iter.Seq2[CostBasis, error]
- type Currency
- type CurrencyAmount
- type CurrencyCustom
- type CurrencyCustomReference
- type CurrencyExpand
- type CurrencyFiat
- type CurrencyFilter
- type CurrencyListParams
- type CurrencyPagePaginatedResponse
- type CurrencyType
- type CursorMeta
- type CursorMetaPage
- type CursorPageParams
- type CursorPaginationQueryPage
- type Customer
- type CustomerData
- type CustomerFilter
- type CustomerListParams
- type CustomerOrReference
- type CustomerPagePaginatedResponse
- type CustomerProfile
- type CustomerReference
- type CustomerStripeCreateCheckoutSessionRequest
- type CustomerStripeCreateCustomerPortalSessionRequest
- type CustomerUsageAttribution
- type CustomersBillingService
- func (s *CustomersBillingService) CreateStripeCheckoutSession(ctx context.Context, customerID string, ...) (*AppStripeCreateCheckoutSessionResult, error)
- func (s *CustomersBillingService) CreateStripePortalSession(ctx context.Context, customerID string, ...) (*AppStripeCreateCustomerPortalSessionResult, error)
- func (s *CustomersBillingService) Get(ctx context.Context, customerID string) (*CustomerData, error)
- func (s *CustomersBillingService) Update(ctx context.Context, customerID string, ...) (*CustomerData, error)
- func (s *CustomersBillingService) UpdateAppData(ctx context.Context, customerID string, request UpsertAppCustomerDataRequest) (*AppCustomerData, error)
- func (s *CustomersBillingService) UpdateProfile(ctx context.Context, customerID string, ...) (*CustomerProfile, error)
- type CustomersChargesService
- func (s *CustomersChargesService) Create(ctx context.Context, customerID string, request CreateChargeRequest) (*Charge, error)
- func (s *CustomersChargesService) Invoice(ctx context.Context, customerID string, request *InvoiceCustomerChargesInput) (*InvoiceCustomerChargesResult, error)
- func (s *CustomersChargesService) List(ctx context.Context, customerID string, params ListCustomerChargesParams) (*ChargePagePaginatedResponse, error)
- func (s *CustomersChargesService) ListAll(ctx context.Context, customerID string, params ListCustomerChargesParams) iter.Seq2[Charge, error]
- type CustomersCreditsAdjustmentsService
- type CustomersCreditsBalanceService
- type CustomersCreditsGrantsService
- func (s *CustomersCreditsGrantsService) Create(ctx context.Context, customerID string, request CreateCreditGrantRequest) (*CreditGrant, error)
- func (s *CustomersCreditsGrantsService) Get(ctx context.Context, customerID string, creditGrantID string) (*CreditGrant, error)
- func (s *CustomersCreditsGrantsService) List(ctx context.Context, customerID string, params CreditGrantListParams) (*CreditGrantPagePaginatedResponse, error)
- func (s *CustomersCreditsGrantsService) ListAll(ctx context.Context, customerID string, params CreditGrantListParams) iter.Seq2[CreditGrant, error]
- func (s *CustomersCreditsGrantsService) UpdateExternalSettlement(ctx context.Context, customerID string, creditGrantID string, ...) (*CreditGrant, error)
- func (s *CustomersCreditsGrantsService) Void(ctx context.Context, customerID string, creditGrantID string, ...) (*CreditGrant, error)
- type CustomersCreditsService
- type CustomersCreditsTransactionsService
- func (s *CustomersCreditsTransactionsService) List(ctx context.Context, customerID string, params CreditTransactionListParams) (*CreditTransactionPaginatedResponse, error)
- func (s *CustomersCreditsTransactionsService) ListAll(ctx context.Context, customerID string, params CreditTransactionListParams) iter.Seq2[CreditTransaction, error]
- type CustomersEntitlementsGrantsService
- func (s *CustomersEntitlementsGrantsService) Create(ctx context.Context, customerID string, entitlementID string, ...) (*EntitlementGrant, error)
- func (s *CustomersEntitlementsGrantsService) List(ctx context.Context, customerID string, entitlementID string, ...) (*EntitlementGrantPagePaginatedResponse, error)
- func (s *CustomersEntitlementsGrantsService) ListAll(ctx context.Context, customerID string, entitlementID string, ...) iter.Seq2[EntitlementGrant, error]
- type CustomersEntitlementsService
- func (s *CustomersEntitlementsService) Create(ctx context.Context, customerID string, request CreateEntitlementRequest) (*Entitlement, error)
- func (s *CustomersEntitlementsService) Delete(ctx context.Context, customerID string, entitlementID string) error
- func (s *CustomersEntitlementsService) Get(ctx context.Context, customerID string, entitlementID string) (*Entitlement, error)
- func (s *CustomersEntitlementsService) GetHistory(ctx context.Context, customerID string, entitlementID string, ...) (*EntitlementHistory, error)
- func (s *CustomersEntitlementsService) List(ctx context.Context, customerID string, params ListCustomerEntitlementsParams) (*EntitlementPagePaginatedResponse, error)
- func (s *CustomersEntitlementsService) ListAll(ctx context.Context, customerID string, params ListCustomerEntitlementsParams) iter.Seq2[Entitlement, error]
- func (s *CustomersEntitlementsService) Override(ctx context.Context, customerID string, entitlementID string, ...) (*Entitlement, error)
- func (s *CustomersEntitlementsService) ResetUsage(ctx context.Context, customerID string, entitlementID string, ...) error
- type CustomersService
- func (s *CustomersService) Create(ctx context.Context, request CreateCustomerRequest) (*Customer, error)
- func (s *CustomersService) Delete(ctx context.Context, customerID string) error
- func (s *CustomersService) Get(ctx context.Context, customerID string) (*Customer, error)
- func (s *CustomersService) List(ctx context.Context, params CustomerListParams) (*CustomerPagePaginatedResponse, error)
- func (s *CustomersService) ListAll(ctx context.Context, params CustomerListParams) iter.Seq2[Customer, error]
- func (s *CustomersService) Upsert(ctx context.Context, customerID string, request UpsertCustomerRequest) (*Customer, error)
- type DateTimeFilter
- type DefaultsService
- type Entitlement
- func (u Entitlement) AsEntitlementBoolean() (*EntitlementBoolean, error)
- func (u Entitlement) AsEntitlementMetered() (*EntitlementMetered, error)
- func (u Entitlement) AsEntitlementStatic() (*EntitlementStatic, error)
- func (u Entitlement) MarshalJSON() ([]byte, error)
- func (u *Entitlement) UnmarshalJSON(data []byte) error
- type EntitlementAccessCheckResult
- type EntitlementAccessExpand
- type EntitlementAccessQueryError
- type EntitlementAccessQueryErrorCode
- type EntitlementAccessQueryPage
- type EntitlementAccessQueryRequest
- type EntitlementAccessQueryRequestCustomers
- type EntitlementAccessQueryRequestFeatures
- type EntitlementAccessQueryResponse
- type EntitlementAccessQueryResult
- type EntitlementAccessQueryResultListParams
- type EntitlementAccessService
- type EntitlementAccessValue
- type EntitlementBalanceThresholdTriggeredV1Payload
- type EntitlementBoolean
- type EntitlementBurndownBalance
- type EntitlementBurndownGrantBalances
- type EntitlementBurndownSegment
- type EntitlementFeatureAccess
- type EntitlementFeatureAccessReason
- type EntitlementFeatureAccessReasonCode
- type EntitlementFeatureValueResult
- type EntitlementGrant
- type EntitlementGrantCreateRequest
- type EntitlementGrantPagePaginatedResponse
- type EntitlementGrantUsage
- type EntitlementHistory
- type EntitlementHistoryWindow
- type EntitlementHistoryWindowSize
- type EntitlementIssueAfterReset
- type EntitlementMeasureUsageFrom
- type EntitlementMeasureUsageFromPreset
- type EntitlementMetered
- type EntitlementPagePaginatedResponse
- type EntitlementStatic
- type EntitlementType
- type EntitlementUsagePeriodResetV1Payload
- type EntitlementValueResult
- type EntitlementsService
- func (s *EntitlementsService) Get(ctx context.Context, entitlementID string) (*Entitlement, error)
- func (s *EntitlementsService) GetCustomerAccess(ctx context.Context, customerID string, featureKey string) (*EntitlementAccessCheckResult, error)
- func (s *EntitlementsService) GetCustomerValue(ctx context.Context, customerID string, entitlementID string, ...) (*EntitlementValueResult, error)
- func (s *EntitlementsService) GetCustomerValueByFeatureKey(ctx context.Context, customerID string, featureKey string, ...) (*EntitlementFeatureValueResult, error)
- func (s *EntitlementsService) List(ctx context.Context, params ListEntitlementsParams) (*EntitlementPagePaginatedResponse, error)
- func (s *EntitlementsService) ListAll(ctx context.Context, params ListEntitlementsParams) iter.Seq2[Entitlement, error]
- func (s *EntitlementsService) ListCustomerAccess(ctx context.Context, customerID string) (*ListCustomerEntitlementAccessResponseData, error)
- type Event
- type EventInput
- type EventsService
- func (s *EventsService) IngestEvent(ctx context.Context, request EventInput) error
- func (s *EventsService) IngestEvents(ctx context.Context, request []EventInput) error
- func (s *EventsService) IngestEventsJSON(ctx context.Context, request OneOrMany[EventInput]) error
- func (s *EventsService) List(ctx context.Context, params IngestedEventListParams) (*IngestedEventPaginatedResponse, error)
- func (s *EventsService) ListAll(ctx context.Context, params IngestedEventListParams) iter.Seq2[IngestedEvent, error]
- type Feature
- type FeatureCostQueryResult
- type FeatureCostQueryRow
- type FeatureFilter
- type FeatureLLMTokenType
- type FeatureLLMUnitCost
- type FeatureLLMUnitCostPricing
- type FeatureListParams
- type FeatureManualUnitCost
- type FeatureMeterReference
- type FeatureMeterReferenceInput
- type FeatureOrReference
- type FeaturePagePaginatedResponse
- type FeatureReference
- type FeatureUnitCost
- type FeatureUnitCostType
- type FeaturesService
- func (s *FeaturesService) Create(ctx context.Context, request CreateFeatureRequest) (*Feature, error)
- func (s *FeaturesService) Delete(ctx context.Context, featureID string) error
- func (s *FeaturesService) Get(ctx context.Context, featureID string) (*Feature, error)
- func (s *FeaturesService) List(ctx context.Context, params FeatureListParams) (*FeaturePagePaginatedResponse, error)
- func (s *FeaturesService) ListAll(ctx context.Context, params FeatureListParams) iter.Seq2[Feature, error]
- func (s *FeaturesService) QueryCost(ctx context.Context, featureID string, request *MeterQueryRequest) (*FeatureCostQueryResult, error)
- func (s *FeaturesService) Update(ctx context.Context, featureID string, request UpdateFeatureRequest) (*Feature, error)
- type GetChargeParams
- type GetCustomerCreditBalanceFilter
- type GetCustomerCreditBalanceParams
- type GetCustomerEntitlementHistoryParams
- type GetCustomerEntitlementValueByFeatureKeyParams
- type GetCustomerEntitlementValueParams
- type GrantsService
- func (s *GrantsService) List(ctx context.Context, params ListGrantsParams) (*EntitlementGrantPagePaginatedResponse, error)
- func (s *GrantsService) ListAll(ctx context.Context, params ListGrantsParams) iter.Seq2[EntitlementGrant, error]
- func (s *GrantsService) Void(ctx context.Context, grantID string, params VoidGrantParams) error
- type IngestedEvent
- type IngestedEventFilter
- type IngestedEventListParams
- type IngestedEventPaginatedResponse
- type IngestedEventValidationError
- type InstallAppExternalInvoicing
- type InstallAppRequest
- func InstallAppRequestFromInstallAppExternalInvoicing(value InstallAppExternalInvoicing) (InstallAppRequest, error)
- func InstallAppRequestFromInstallAppSandbox(value InstallAppSandbox) (InstallAppRequest, error)
- func InstallAppRequestFromInstallAppStripeWithAPIKey(value InstallAppStripeWithAPIKey) (InstallAppRequest, error)
- func (u InstallAppRequest) AsInstallAppExternalInvoicing() (*InstallAppExternalInvoicing, error)
- func (u InstallAppRequest) AsInstallAppSandbox() (*InstallAppSandbox, error)
- func (u InstallAppRequest) AsInstallAppStripeWithAPIKey() (*InstallAppStripeWithAPIKey, error)
- func (u InstallAppRequest) MarshalJSON() ([]byte, error)
- func (u *InstallAppRequest) UnmarshalJSON(data []byte) error
- type InstallAppResponse
- func InstallAppResponseFromInstalledAppExternalInvoicing(value InstalledAppExternalInvoicing) (InstallAppResponse, error)
- func InstallAppResponseFromInstalledAppSandbox(value InstalledAppSandbox) (InstallAppResponse, error)
- func InstallAppResponseFromInstalledAppStripe(value InstalledAppStripe) (InstallAppResponse, error)
- func (u InstallAppResponse) AsInstalledAppExternalInvoicing() (*InstalledAppExternalInvoicing, error)
- func (u InstallAppResponse) AsInstalledAppSandbox() (*InstalledAppSandbox, error)
- func (u InstallAppResponse) AsInstalledAppStripe() (*InstalledAppStripe, error)
- func (u InstallAppResponse) MarshalJSON() ([]byte, error)
- func (u *InstallAppResponse) UnmarshalJSON(data []byte) error
- type InstallAppSandbox
- type InstallAppStripeWithAPIKey
- type InstalledAppExternalInvoicing
- type InstalledAppSandbox
- type InstalledAppStripe
- type Invoice
- type InvoiceAvailableActionDetails
- type InvoiceAvailableActions
- type InvoiceCreatedV1Payload
- type InvoiceCustomer
- type InvoiceCustomerChargesInput
- type InvoiceCustomerChargesResult
- type InvoiceDetailedLine
- type InvoiceDetailedLineCostCategory
- type InvoiceDiscountReason
- type InvoiceExternalReferences
- type InvoiceFilter
- type InvoiceLine
- type InvoiceLineAmountDiscount
- type InvoiceLineCreditsApplied
- type InvoiceLineDiscounts
- type InvoiceLineExternalReferences
- type InvoiceLineRateCard
- type InvoiceLineType
- type InvoiceLineUsageDiscount
- type InvoiceListParams
- type InvoicePagePaginatedResponse
- type InvoiceStandard
- type InvoiceStandardLine
- type InvoiceStandardStatus
- type InvoiceStatusDetails
- type InvoiceType
- type InvoiceUpdatedV1Payload
- type InvoiceUsageQuantityDetail
- type InvoiceWorkflow
- type InvoiceWorkflowAppsReferences
- type InvoiceWorkflowInvoicingSettings
- type InvoiceWorkflowSettings
- type InvoicesService
- func (s *InvoicesService) Advance(ctx context.Context, invoiceID string) (*Invoice, error)
- func (s *InvoicesService) Approve(ctx context.Context, invoiceID string) (*Invoice, error)
- func (s *InvoicesService) Delete(ctx context.Context, invoiceID string) error
- func (s *InvoicesService) Get(ctx context.Context, invoiceID string) (*Invoice, error)
- func (s *InvoicesService) List(ctx context.Context, params InvoiceListParams) (*InvoicePagePaginatedResponse, error)
- func (s *InvoicesService) ListAll(ctx context.Context, params InvoiceListParams) iter.Seq2[Invoice, error]
- func (s *InvoicesService) Retry(ctx context.Context, invoiceID string) (*Invoice, error)
- func (s *InvoicesService) SnapshotQuantities(ctx context.Context, invoiceID string) (*Invoice, error)
- func (s *InvoicesService) Update(ctx context.Context, invoiceID string, request UpdateInvoiceRequest) (*Invoice, error)
- type LLMCostModel
- type LLMCostModelPricing
- type LLMCostOverrideCreate
- type LLMCostPrice
- type LLMCostPriceSource
- type LLMCostProvider
- type LLMCostService
- func (s *LLMCostService) CreateOverride(ctx context.Context, request LLMCostOverrideCreate) (*LLMCostPrice, error)
- func (s *LLMCostService) DeleteOverride(ctx context.Context, priceID string) error
- func (s *LLMCostService) GetPrice(ctx context.Context, priceID string) (*LLMCostPrice, error)
- func (s *LLMCostService) ListOverrides(ctx context.Context, params ListLLMCostOverridesParams) (*PricePagePaginatedResponse, error)
- func (s *LLMCostService) ListOverridesAll(ctx context.Context, params ListLLMCostOverridesParams) iter.Seq2[LLMCostPrice, error]
- func (s *LLMCostService) ListPrices(ctx context.Context, params ListLLMCostPricesParams) (*PricePagePaginatedResponse, error)
- func (s *LLMCostService) ListPricesAll(ctx context.Context, params ListLLMCostPricesParams) iter.Seq2[LLMCostPrice, error]
- type LifecycleController
- type ListChargesFilter
- type ListChargesParams
- type ListCustomerChargesFilter
- type ListCustomerChargesParams
- type ListCustomerEntitlementAccessResponseData
- type ListCustomerEntitlementGrantsParams
- type ListCustomerEntitlementsFilter
- type ListCustomerEntitlementsParams
- type ListEntitlementsFilter
- type ListEntitlementsParams
- type ListEventsPage
- type ListGrantsFilter
- type ListGrantsParams
- type ListLLMCostOverridesFilter
- type ListLLMCostOverridesParams
- type ListLLMCostPricesFilter
- type ListLLMCostPricesParams
- type Meter
- type MeterAggregation
- type MeterFilter
- type MeterListParams
- type MeterPagePaginatedResponse
- type MeterQueryFilters
- type MeterQueryGranularity
- type MeterQueryRequest
- type MeterQueryResult
- type MeterQueryRow
- type MetersService
- func (s *MetersService) Create(ctx context.Context, request CreateMeterRequest) (*Meter, error)
- func (s *MetersService) Delete(ctx context.Context, meterID string) error
- func (s *MetersService) Get(ctx context.Context, meterID string) (*Meter, error)
- func (s *MetersService) List(ctx context.Context, params MeterListParams) (*MeterPagePaginatedResponse, error)
- func (s *MetersService) ListAll(ctx context.Context, params MeterListParams) iter.Seq2[Meter, error]
- func (s *MetersService) Query(ctx context.Context, meterID string, request MeterQueryRequest) (*MeterQueryResult, error)
- func (s *MetersService) QueryCSV(ctx context.Context, meterID string, request MeterQueryRequest) ([]byte, error)
- func (s *MetersService) QueryCSVStream(ctx context.Context, meterID string, request MeterQueryRequest) (io.ReadCloser, error)
- func (s *MetersService) Update(ctx context.Context, meterID string, request UpdateMeterRequest) (*Meter, error)
- type NotificationBalanceThreshold
- type NotificationBalanceThresholdType
- type NotificationChannel
- type NotificationChannelFilter
- type NotificationChannelListParams
- type NotificationChannelPagePaginatedResponse
- type NotificationChannelReference
- type NotificationChannelType
- type NotificationEvent
- type NotificationEventBalanceThresholdPayload
- type NotificationEventDeliveryAttempt
- type NotificationEventDeliveryAttemptResponse
- type NotificationEventDeliveryState
- type NotificationEventDeliveryStatus
- type NotificationEventFilter
- type NotificationEventInvoiceCreatedPayload
- type NotificationEventInvoiceUpdatedPayload
- type NotificationEventListParams
- type NotificationEventPagePaginatedResponse
- type NotificationEventPayload
- func NotificationEventPayloadFromNotificationEventBalanceThresholdPayload(value NotificationEventBalanceThresholdPayload) (NotificationEventPayload, error)
- func NotificationEventPayloadFromNotificationEventInvoiceCreatedPayload(value NotificationEventInvoiceCreatedPayload) (NotificationEventPayload, error)
- func NotificationEventPayloadFromNotificationEventInvoiceUpdatedPayload(value NotificationEventInvoiceUpdatedPayload) (NotificationEventPayload, error)
- func NotificationEventPayloadFromNotificationEventResetPayload(value NotificationEventResetPayload) (NotificationEventPayload, error)
- func (u NotificationEventPayload) AsNotificationEventBalanceThresholdPayload() (*NotificationEventBalanceThresholdPayload, error)
- func (u NotificationEventPayload) AsNotificationEventInvoiceCreatedPayload() (*NotificationEventInvoiceCreatedPayload, error)
- func (u NotificationEventPayload) AsNotificationEventInvoiceUpdatedPayload() (*NotificationEventInvoiceUpdatedPayload, error)
- func (u NotificationEventPayload) AsNotificationEventResetPayload() (*NotificationEventResetPayload, error)
- func (u NotificationEventPayload) MarshalJSON() ([]byte, error)
- func (u *NotificationEventPayload) UnmarshalJSON(data []byte) error
- type NotificationEventResetPayload
- type NotificationEventType
- type NotificationEventTypeDefinition
- type NotificationEventTypeSummary
- type NotificationEventTypeSummaryFilter
- type NotificationEventTypeSummaryListParams
- type NotificationEventTypeSummaryPaginatedResponse
- type NotificationEventV1Address
- type NotificationEventV1Alignment
- type NotificationEventV1App
- func NotificationEventV1AppFromNotificationEventV1CustomInvoicingApp(value NotificationEventV1CustomInvoicingApp) (NotificationEventV1App, error)
- func NotificationEventV1AppFromNotificationEventV1SandboxApp(value NotificationEventV1SandboxApp) (NotificationEventV1App, error)
- func NotificationEventV1AppFromNotificationEventV1StripeApp(value NotificationEventV1StripeApp) (NotificationEventV1App, error)
- func (u NotificationEventV1App) AsNotificationEventV1CustomInvoicingApp() (*NotificationEventV1CustomInvoicingApp, error)
- func (u NotificationEventV1App) AsNotificationEventV1SandboxApp() (*NotificationEventV1SandboxApp, error)
- func (u NotificationEventV1App) AsNotificationEventV1StripeApp() (*NotificationEventV1StripeApp, error)
- func (u NotificationEventV1App) MarshalJSON() ([]byte, error)
- func (u *NotificationEventV1App) UnmarshalJSON(data []byte) error
- type NotificationEventV1AppCapability
- type NotificationEventV1AppCapabilityType
- type NotificationEventV1AppStatus
- type NotificationEventV1AppType
- type NotificationEventV1BillingDiscountPercentage
- type NotificationEventV1BillingDiscountReason
- func NotificationEventV1BillingDiscountReasonFromNotificationEventV1DiscountReasonMaximumSpend(value NotificationEventV1DiscountReasonMaximumSpend) (NotificationEventV1BillingDiscountReason, error)
- func NotificationEventV1BillingDiscountReasonFromNotificationEventV1DiscountReasonRatecardPercentage(value NotificationEventV1DiscountReasonRatecardPercentage) (NotificationEventV1BillingDiscountReason, error)
- func NotificationEventV1BillingDiscountReasonFromNotificationEventV1DiscountReasonRatecardUsage(value NotificationEventV1DiscountReasonRatecardUsage) (NotificationEventV1BillingDiscountReason, error)
- func (u NotificationEventV1BillingDiscountReason) AsNotificationEventV1DiscountReasonMaximumSpend() (*NotificationEventV1DiscountReasonMaximumSpend, error)
- func (u NotificationEventV1BillingDiscountReason) AsNotificationEventV1DiscountReasonRatecardPercentage() (*NotificationEventV1DiscountReasonRatecardPercentage, error)
- func (u NotificationEventV1BillingDiscountReason) AsNotificationEventV1DiscountReasonRatecardUsage() (*NotificationEventV1DiscountReasonRatecardUsage, error)
- func (u NotificationEventV1BillingDiscountReason) MarshalJSON() ([]byte, error)
- func (u *NotificationEventV1BillingDiscountReason) UnmarshalJSON(data []byte) error
- type NotificationEventV1BillingDiscountUsage
- type NotificationEventV1BillingDiscounts
- type NotificationEventV1BillingInvoiceCustomerExtendedDetails
- type NotificationEventV1BillingParty
- type NotificationEventV1BillingPartyTaxIdentity
- type NotificationEventV1BillingProfileApps
- type NotificationEventV1BillingSettlementMode
- type NotificationEventV1BillingWorkflow
- type NotificationEventV1BillingWorkflowCollectionAlignment
- func NotificationEventV1BillingWorkflowCollectionAlignmentFromNotificationEventV1BillingWorkflowCollectionAlignmentAnchored(value NotificationEventV1BillingWorkflowCollectionAlignmentAnchored) (NotificationEventV1BillingWorkflowCollectionAlignment, error)
- func NotificationEventV1BillingWorkflowCollectionAlignmentFromNotificationEventV1BillingWorkflowCollectionAlignmentSubscription(value NotificationEventV1BillingWorkflowCollectionAlignmentSubscription) (NotificationEventV1BillingWorkflowCollectionAlignment, error)
- func (u NotificationEventV1BillingWorkflowCollectionAlignment) AsNotificationEventV1BillingWorkflowCollectionAlignmentAnchored() (*NotificationEventV1BillingWorkflowCollectionAlignmentAnchored, error)
- func (u NotificationEventV1BillingWorkflowCollectionAlignment) AsNotificationEventV1BillingWorkflowCollectionAlignmentSubscription() (*NotificationEventV1BillingWorkflowCollectionAlignmentSubscription, error)
- func (u NotificationEventV1BillingWorkflowCollectionAlignment) MarshalJSON() ([]byte, error)
- func (u *NotificationEventV1BillingWorkflowCollectionAlignment) UnmarshalJSON(data []byte) error
- type NotificationEventV1BillingWorkflowCollectionAlignmentAnchored
- type NotificationEventV1BillingWorkflowCollectionAlignmentSubscription
- type NotificationEventV1BillingWorkflowCollectionSettings
- type NotificationEventV1BillingWorkflowInvoicingSettings
- type NotificationEventV1BillingWorkflowInvoicingSubscriptionEndProrationMode
- type NotificationEventV1BillingWorkflowPaymentSettings
- type NotificationEventV1BillingWorkflowTaxSettings
- type NotificationEventV1CollectionMethod
- type NotificationEventV1CustomInvoicingApp
- type NotificationEventV1CustomInvoicingTaxConfig
- type NotificationEventV1Customer
- type NotificationEventV1CustomerUsageAttribution
- type NotificationEventV1DiscountReasonMaximumSpend
- type NotificationEventV1DiscountReasonRatecardPercentage
- type NotificationEventV1DiscountReasonRatecardUsage
- type NotificationEventV1DynamicPriceWithCommitments
- type NotificationEventV1EntitlementMetered
- type NotificationEventV1EntitlementValue
- type NotificationEventV1Feature
- type NotificationEventV1FeatureLLMUnitCost
- type NotificationEventV1FeatureLLMUnitCostPricing
- type NotificationEventV1FeatureManualUnitCost
- type NotificationEventV1FeatureUnitCost
- func NotificationEventV1FeatureUnitCostFromNotificationEventV1FeatureLLMUnitCost(value NotificationEventV1FeatureLLMUnitCost) (NotificationEventV1FeatureUnitCost, error)
- func NotificationEventV1FeatureUnitCostFromNotificationEventV1FeatureManualUnitCost(value NotificationEventV1FeatureManualUnitCost) (NotificationEventV1FeatureUnitCost, error)
- func (u NotificationEventV1FeatureUnitCost) AsNotificationEventV1FeatureLLMUnitCost() (*NotificationEventV1FeatureLLMUnitCost, error)
- func (u NotificationEventV1FeatureUnitCost) AsNotificationEventV1FeatureManualUnitCost() (*NotificationEventV1FeatureManualUnitCost, error)
- func (u NotificationEventV1FeatureUnitCost) MarshalJSON() ([]byte, error)
- func (u *NotificationEventV1FeatureUnitCost) UnmarshalJSON(data []byte) error
- type NotificationEventV1FilterString
- type NotificationEventV1FlatPrice
- type NotificationEventV1FlatPriceWithPaymentTerm
- type NotificationEventV1IDResource
- type NotificationEventV1InstallMethod
- type NotificationEventV1InvoiceAppExternalIds
- type NotificationEventV1InvoiceAvailableActionDetails
- type NotificationEventV1InvoiceAvailableActionInvoiceDetails
- type NotificationEventV1InvoiceAvailableActions
- type NotificationEventV1InvoiceDetailedLine
- type NotificationEventV1InvoiceDetailedLineCostCategory
- type NotificationEventV1InvoiceDetailedLineRateCard
- type NotificationEventV1InvoiceDocumentRef
- type NotificationEventV1InvoiceDocumentRefType
- type NotificationEventV1InvoiceLine
- type NotificationEventV1InvoiceLineAmountDiscount
- type NotificationEventV1InvoiceLineAppExternalIds
- type NotificationEventV1InvoiceLineCreditAllocation
- type NotificationEventV1InvoiceLineDiscounts
- type NotificationEventV1InvoiceLineManagedBy
- type NotificationEventV1InvoiceLineStatus
- type NotificationEventV1InvoiceLineSubscriptionReference
- type NotificationEventV1InvoiceLineTaxBehavior
- type NotificationEventV1InvoiceLineTaxItem
- type NotificationEventV1InvoiceLineUsageDiscount
- type NotificationEventV1InvoicePaymentTerms
- type NotificationEventV1InvoiceReference
- type NotificationEventV1InvoiceStatus
- type NotificationEventV1InvoiceStatusDetails
- type NotificationEventV1InvoiceTotals
- type NotificationEventV1InvoiceType
- type NotificationEventV1InvoiceUsageBasedRateCard
- type NotificationEventV1InvoiceWorkflowSettings
- type NotificationEventV1MarketplaceListing
- type NotificationEventV1PackagePriceWithCommitments
- type NotificationEventV1PaymentDueDate
- type NotificationEventV1PaymentTermDueDate
- type NotificationEventV1PaymentTermInstant
- type NotificationEventV1PaymentTerms
- func NotificationEventV1PaymentTermsFromNotificationEventV1PaymentTermDueDate(value NotificationEventV1PaymentTermDueDate) (NotificationEventV1PaymentTerms, error)
- func NotificationEventV1PaymentTermsFromNotificationEventV1PaymentTermInstant(value NotificationEventV1PaymentTermInstant) (NotificationEventV1PaymentTerms, error)
- func (u NotificationEventV1PaymentTerms) AsNotificationEventV1PaymentTermDueDate() (*NotificationEventV1PaymentTermDueDate, error)
- func (u NotificationEventV1PaymentTerms) AsNotificationEventV1PaymentTermInstant() (*NotificationEventV1PaymentTermInstant, error)
- func (u NotificationEventV1PaymentTerms) MarshalJSON() ([]byte, error)
- func (u *NotificationEventV1PaymentTerms) UnmarshalJSON(data []byte) error
- type NotificationEventV1Period
- type NotificationEventV1PlanReference
- type NotificationEventV1PricePaymentTerm
- type NotificationEventV1PriceTier
- type NotificationEventV1ProRatingConfig
- type NotificationEventV1ProRatingMode
- type NotificationEventV1RateCardUsageBasedPrice
- func NotificationEventV1RateCardUsageBasedPriceFromNotificationEventV1DynamicPriceWithCommitments(value NotificationEventV1DynamicPriceWithCommitments) (NotificationEventV1RateCardUsageBasedPrice, error)
- func NotificationEventV1RateCardUsageBasedPriceFromNotificationEventV1FlatPriceWithPaymentTerm(value NotificationEventV1FlatPriceWithPaymentTerm) (NotificationEventV1RateCardUsageBasedPrice, error)
- func NotificationEventV1RateCardUsageBasedPriceFromNotificationEventV1PackagePriceWithCommitments(value NotificationEventV1PackagePriceWithCommitments) (NotificationEventV1RateCardUsageBasedPrice, error)
- func NotificationEventV1RateCardUsageBasedPriceFromNotificationEventV1TieredPriceWithCommitments(value NotificationEventV1TieredPriceWithCommitments) (NotificationEventV1RateCardUsageBasedPrice, error)
- func NotificationEventV1RateCardUsageBasedPriceFromNotificationEventV1UnitPriceWithCommitments(value NotificationEventV1UnitPriceWithCommitments) (NotificationEventV1RateCardUsageBasedPrice, error)
- func (u NotificationEventV1RateCardUsageBasedPrice) AsNotificationEventV1DynamicPriceWithCommitments() (*NotificationEventV1DynamicPriceWithCommitments, error)
- func (u NotificationEventV1RateCardUsageBasedPrice) AsNotificationEventV1FlatPriceWithPaymentTerm() (*NotificationEventV1FlatPriceWithPaymentTerm, error)
- func (u NotificationEventV1RateCardUsageBasedPrice) AsNotificationEventV1PackagePriceWithCommitments() (*NotificationEventV1PackagePriceWithCommitments, error)
- func (u NotificationEventV1RateCardUsageBasedPrice) AsNotificationEventV1TieredPriceWithCommitments() (*NotificationEventV1TieredPriceWithCommitments, error)
- func (u NotificationEventV1RateCardUsageBasedPrice) AsNotificationEventV1UnitPriceWithCommitments() (*NotificationEventV1UnitPriceWithCommitments, error)
- func (u NotificationEventV1RateCardUsageBasedPrice) MarshalJSON() ([]byte, error)
- func (u *NotificationEventV1RateCardUsageBasedPrice) UnmarshalJSON(data []byte) error
- type NotificationEventV1RecurringPeriod
- type NotificationEventV1RecurringPeriodInterval
- type NotificationEventV1RecurringPeriodIntervalEnum
- type NotificationEventV1RecurringPeriodV2
- type NotificationEventV1RuleBalanceThresholdValue
- type NotificationEventV1RuleBalanceThresholdValueType
- type NotificationEventV1SandboxApp
- type NotificationEventV1StripeApp
- type NotificationEventV1StripeTaxConfig
- type NotificationEventV1Subject
- type NotificationEventV1Subscription
- type NotificationEventV1SubscriptionCostBasisMode
- type NotificationEventV1SubscriptionCostBasisPin
- type NotificationEventV1SubscriptionStatus
- type NotificationEventV1TaxBehavior
- type NotificationEventV1TaxConfig
- type NotificationEventV1TieredPriceMode
- type NotificationEventV1TieredPriceWithCommitments
- type NotificationEventV1UnitPrice
- type NotificationEventV1UnitPriceWithCommitments
- type NotificationEventV1ValidationIssue
- type NotificationEventV1ValidationIssueSeverity
- type NotificationRule
- func NotificationRuleFromNotificationRuleBalanceThreshold(value NotificationRuleBalanceThreshold) (NotificationRule, error)
- func NotificationRuleFromNotificationRuleEntitlementReset(value NotificationRuleEntitlementReset) (NotificationRule, error)
- func NotificationRuleFromNotificationRuleInvoiceCreated(value NotificationRuleInvoiceCreated) (NotificationRule, error)
- func NotificationRuleFromNotificationRuleInvoiceUpdated(value NotificationRuleInvoiceUpdated) (NotificationRule, error)
- func (u NotificationRule) AsNotificationRuleBalanceThreshold() (*NotificationRuleBalanceThreshold, error)
- func (u NotificationRule) AsNotificationRuleEntitlementReset() (*NotificationRuleEntitlementReset, error)
- func (u NotificationRule) AsNotificationRuleInvoiceCreated() (*NotificationRuleInvoiceCreated, error)
- func (u NotificationRule) AsNotificationRuleInvoiceUpdated() (*NotificationRuleInvoiceUpdated, error)
- func (u NotificationRule) MarshalJSON() ([]byte, error)
- func (u *NotificationRule) UnmarshalJSON(data []byte) error
- type NotificationRuleBalanceThreshold
- type NotificationRuleBalanceThresholdRequest
- type NotificationRuleEntitlementReset
- type NotificationRuleEntitlementResetRequest
- type NotificationRuleFilter
- type NotificationRuleInvoiceCreated
- type NotificationRuleInvoiceCreatedRequest
- type NotificationRuleInvoiceUpdated
- type NotificationRuleInvoiceUpdatedRequest
- type NotificationRuleListParams
- type NotificationRulePagePaginatedResponse
- type NotificationRuleReference
- type NotificationRuleRequest
- func NotificationRuleRequestFromNotificationRuleBalanceThresholdRequest(value NotificationRuleBalanceThresholdRequest) (NotificationRuleRequest, error)
- func NotificationRuleRequestFromNotificationRuleEntitlementResetRequest(value NotificationRuleEntitlementResetRequest) (NotificationRuleRequest, error)
- func NotificationRuleRequestFromNotificationRuleInvoiceCreatedRequest(value NotificationRuleInvoiceCreatedRequest) (NotificationRuleRequest, error)
- func NotificationRuleRequestFromNotificationRuleInvoiceUpdatedRequest(value NotificationRuleInvoiceUpdatedRequest) (NotificationRuleRequest, error)
- func (u NotificationRuleRequest) AsNotificationRuleBalanceThresholdRequest() (*NotificationRuleBalanceThresholdRequest, error)
- func (u NotificationRuleRequest) AsNotificationRuleEntitlementResetRequest() (*NotificationRuleEntitlementResetRequest, error)
- func (u NotificationRuleRequest) AsNotificationRuleInvoiceCreatedRequest() (*NotificationRuleInvoiceCreatedRequest, error)
- func (u NotificationRuleRequest) AsNotificationRuleInvoiceUpdatedRequest() (*NotificationRuleInvoiceUpdatedRequest, error)
- func (u NotificationRuleRequest) MarshalJSON() ([]byte, error)
- func (u *NotificationRuleRequest) UnmarshalJSON(data []byte) error
- type NotificationsService
- func (s *NotificationsService) CreateBillingChannel(ctx context.Context, request CreateNotificationChannelRequest) (*NotificationChannel, error)
- func (s *NotificationsService) CreateBillingRule(ctx context.Context, request NotificationRuleRequest) (*NotificationRule, error)
- func (s *NotificationsService) DeleteBillingChannel(ctx context.Context, notificationChannelID string) error
- func (s *NotificationsService) DeleteBillingRule(ctx context.Context, notificationRuleID string) error
- func (s *NotificationsService) GetBillingChannel(ctx context.Context, notificationChannelID string) (*NotificationChannel, error)
- func (s *NotificationsService) GetBillingEvent(ctx context.Context, notificationEventID string) (*NotificationEvent, error)
- func (s *NotificationsService) GetBillingEventType(ctx context.Context, notificationEventType string) (*NotificationEventTypeDefinition, error)
- func (s *NotificationsService) GetBillingRule(ctx context.Context, notificationRuleID string) (*NotificationRule, error)
- func (s *NotificationsService) ListBillingChannels(ctx context.Context, params NotificationChannelListParams) (*NotificationChannelPagePaginatedResponse, error)
- func (s *NotificationsService) ListBillingChannelsAll(ctx context.Context, params NotificationChannelListParams) iter.Seq2[NotificationChannel, error]
- func (s *NotificationsService) ListBillingEventTypes(ctx context.Context, params NotificationEventTypeSummaryListParams) (*NotificationEventTypeSummaryPaginatedResponse, error)
- func (s *NotificationsService) ListBillingEventTypesAll(ctx context.Context, params NotificationEventTypeSummaryListParams) iter.Seq2[NotificationEventTypeSummary, error]
- func (s *NotificationsService) ListBillingEvents(ctx context.Context, params NotificationEventListParams) (*NotificationEventPagePaginatedResponse, error)
- func (s *NotificationsService) ListBillingEventsAll(ctx context.Context, params NotificationEventListParams) iter.Seq2[NotificationEvent, error]
- func (s *NotificationsService) ListBillingRules(ctx context.Context, params NotificationRuleListParams) (*NotificationRulePagePaginatedResponse, error)
- func (s *NotificationsService) ListBillingRulesAll(ctx context.Context, params NotificationRuleListParams) iter.Seq2[NotificationRule, error]
- func (s *NotificationsService) ResendBillingEvent(ctx context.Context, notificationEventID string, ...) error
- func (s *NotificationsService) TestBillingRule(ctx context.Context, notificationRuleID string) (*NotificationEvent, error)
- func (s *NotificationsService) UpdateBillingChannel(ctx context.Context, notificationChannelID string, ...) (*NotificationChannel, error)
- func (s *NotificationsService) UpdateBillingRule(ctx context.Context, notificationRuleID string, ...) (*NotificationRule, error)
- type Nullable
- type Numeric
- type NumericFilter
- type OneOrMany
- type Option
- type OrganizationDefaultTaxCodes
- type PageMeta
- type PageParams
- type PaginatedMeta
- type Party
- type PartyAddresses
- type PartyTaxIdentity
- type Plan
- type PlanAddon
- type PlanAddonFilter
- type PlanAddonListParams
- type PlanAddonPagePaginatedResponse
- type PlanAddonsService
- func (s *PlanAddonsService) Create(ctx context.Context, planID string, request CreatePlanAddonRequest) (*PlanAddon, error)
- func (s *PlanAddonsService) Delete(ctx context.Context, planID string, planAddonID string) error
- func (s *PlanAddonsService) Get(ctx context.Context, planID string, planAddonID string) (*PlanAddon, error)
- func (s *PlanAddonsService) List(ctx context.Context, planID string, params PlanAddonListParams) (*PlanAddonPagePaginatedResponse, error)
- func (s *PlanAddonsService) ListAll(ctx context.Context, planID string, params PlanAddonListParams) iter.Seq2[PlanAddon, error]
- func (s *PlanAddonsService) Update(ctx context.Context, planID string, planAddonID string, ...) (*PlanAddon, error)
- type PlanFilter
- type PlanListParams
- type PlanPagePaginatedResponse
- type PlanPhase
- type PlanPhaseInput
- type PlanStatus
- type PlansService
- func (s *PlansService) Archive(ctx context.Context, planID string) (*Plan, error)
- func (s *PlansService) Create(ctx context.Context, request CreatePlanRequest) (*Plan, error)
- func (s *PlansService) Delete(ctx context.Context, planID string) error
- func (s *PlansService) Get(ctx context.Context, planID string) (*Plan, error)
- func (s *PlansService) List(ctx context.Context, params PlanListParams) (*PlanPagePaginatedResponse, error)
- func (s *PlansService) ListAll(ctx context.Context, params PlanListParams) iter.Seq2[Plan, error]
- func (s *PlansService) Publish(ctx context.Context, planID string) (*Plan, error)
- func (s *PlansService) Update(ctx context.Context, planID string, request UpsertPlanRequest) (*Plan, error)
- type Price
- func (u Price) AsPriceFlat() (*PriceFlat, error)
- func (u Price) AsPriceFree() (*PriceFree, error)
- func (u Price) AsPriceGraduated() (*PriceGraduated, error)
- func (u Price) AsPriceUnit() (*PriceUnit, error)
- func (u Price) AsPriceVolume() (*PriceVolume, error)
- func (u Price) MarshalJSON() ([]byte, error)
- func (u *Price) UnmarshalJSON(data []byte) error
- type PriceFlat
- type PriceFree
- type PriceGraduated
- type PricePagePaginatedResponse
- type PricePaymentTerm
- type PriceTier
- type PriceType
- type PriceUnit
- type PriceUsageBased
- func (u PriceUsageBased) AsPriceGraduated() (*PriceGraduated, error)
- func (u PriceUsageBased) AsPriceUnit() (*PriceUnit, error)
- func (u PriceUsageBased) AsPriceVolume() (*PriceVolume, error)
- func (u PriceUsageBased) MarshalJSON() ([]byte, error)
- func (u *PriceUsageBased) UnmarshalJSON(data []byte) error
- type PriceVolume
- type ProductCatalogValidationError
- type Profile
- type ProfileAppReferences
- type ProfileFilter
- type ProfileListParams
- type ProfilePagePaginatedResponse
- type ProfileReference
- type QueryFilterString
- type QueryFilterStringInput
- type QueryFilterStringMapItem
- type QueryFilterStringMapItemInput
- type RateCard
- type RateCardBooleanEntitlement
- type RateCardDiscounts
- type RateCardEntitlement
- func RateCardEntitlementFromRateCardBooleanEntitlement(value RateCardBooleanEntitlement) (RateCardEntitlement, error)
- func RateCardEntitlementFromRateCardMeteredEntitlement(value RateCardMeteredEntitlement) (RateCardEntitlement, error)
- func RateCardEntitlementFromRateCardStaticEntitlement(value RateCardStaticEntitlement) (RateCardEntitlement, error)
- func (u RateCardEntitlement) AsRateCardBooleanEntitlement() (*RateCardBooleanEntitlement, error)
- func (u RateCardEntitlement) AsRateCardMeteredEntitlement() (*RateCardMeteredEntitlement, error)
- func (u RateCardEntitlement) AsRateCardStaticEntitlement() (*RateCardStaticEntitlement, error)
- func (u RateCardEntitlement) MarshalJSON() ([]byte, error)
- func (u *RateCardEntitlement) UnmarshalJSON(data []byte) error
- type RateCardInput
- type RateCardMeteredEntitlement
- type RateCardProrationConfiguration
- type RateCardProrationMode
- type RateCardStaticEntitlement
- type RecurringPeriod
- type RecurringPeriodInput
- type ResendBillingNotificationEventRequest
- type ResetCustomerEntitlementUsageRequest
- type SettlementMode
- type Sort
- type SortOrder
- type SpendCommitments
- type StringExactFilter
- type StringFilter
- type SubscriptionAddon
- type SubscriptionAddonListParams
- type SubscriptionAddonPagePaginatedResponse
- type SubscriptionAddonRateCard
- type SubscriptionAddonTimelineSegment
- type SubscriptionAddonUpdate
- type SubscriptionBase
- type SubscriptionCancel
- type SubscriptionChange
- type SubscriptionChangeCustomer
- type SubscriptionChangePlan
- type SubscriptionChangeResponse
- type SubscriptionCostBasisMode
- type SubscriptionCostBasisPin
- type SubscriptionCreate
- type SubscriptionCreateTiming
- type SubscriptionCreateTimingEnum
- type SubscriptionCustomPlan
- type SubscriptionEdit
- type SubscriptionEditAddItem
- type SubscriptionEditAddPhase
- type SubscriptionEditOperation
- func SubscriptionEditOperationFromSubscriptionEditAddItem(value SubscriptionEditAddItem) (SubscriptionEditOperation, error)
- func SubscriptionEditOperationFromSubscriptionEditAddPhase(value SubscriptionEditAddPhase) (SubscriptionEditOperation, error)
- func SubscriptionEditOperationFromSubscriptionEditRemoveItem(value SubscriptionEditRemoveItem) (SubscriptionEditOperation, error)
- func SubscriptionEditOperationFromSubscriptionEditRemovePhase(value SubscriptionEditRemovePhase) (SubscriptionEditOperation, error)
- func SubscriptionEditOperationFromSubscriptionEditStretchPhase(value SubscriptionEditStretchPhase) (SubscriptionEditOperation, error)
- func SubscriptionEditOperationFromSubscriptionEditUnscheduleEdit(value SubscriptionEditUnscheduleEdit) (SubscriptionEditOperation, error)
- func (u SubscriptionEditOperation) AsSubscriptionEditAddItem() (*SubscriptionEditAddItem, error)
- func (u SubscriptionEditOperation) AsSubscriptionEditAddPhase() (*SubscriptionEditAddPhase, error)
- func (u SubscriptionEditOperation) AsSubscriptionEditRemoveItem() (*SubscriptionEditRemoveItem, error)
- func (u SubscriptionEditOperation) AsSubscriptionEditRemovePhase() (*SubscriptionEditRemovePhase, error)
- func (u SubscriptionEditOperation) AsSubscriptionEditStretchPhase() (*SubscriptionEditStretchPhase, error)
- func (u SubscriptionEditOperation) AsSubscriptionEditUnscheduleEdit() (*SubscriptionEditUnscheduleEdit, error)
- func (u SubscriptionEditOperation) MarshalJSON() ([]byte, error)
- func (u *SubscriptionEditOperation) UnmarshalJSON(data []byte) error
- type SubscriptionEditOperationType
- type SubscriptionEditRemoveItem
- type SubscriptionEditRemovePhase
- type SubscriptionEditStretchPhase
- type SubscriptionEditTiming
- type SubscriptionEditTimingEnum
- type SubscriptionEditUnscheduleEdit
- type SubscriptionItem
- type SubscriptionMigrate
- type SubscriptionMigrateResponse
- type SubscriptionOrReference
- func (u SubscriptionOrReference) AsBillingSubscription() (*BillingSubscription, error)
- func (u SubscriptionOrReference) AsSubscriptionReference() (*SubscriptionReference, error)
- func (u SubscriptionOrReference) MarshalJSON() ([]byte, error)
- func (u *SubscriptionOrReference) UnmarshalJSON(data []byte) error
- type SubscriptionPagePaginatedResponse
- type SubscriptionPhase
- type SubscriptionPhaseCreate
- type SubscriptionPlanReference
- type SubscriptionProRatingConfig
- type SubscriptionReference
- type SubscriptionReferencePhase
- type SubscriptionReferencePhaseItem
- type SubscriptionRemovePhaseShifting
- type SubscriptionStatus
- type SubscriptionsService
- func (s *SubscriptionsService) Cancel(ctx context.Context, subscriptionID string, request SubscriptionCancel) (*BillingSubscription, error)
- func (s *SubscriptionsService) Change(ctx context.Context, subscriptionID string, request SubscriptionChange) (*SubscriptionChangeResponse, error)
- func (s *SubscriptionsService) Create(ctx context.Context, request SubscriptionCreate) (*BillingSubscription, error)
- func (s *SubscriptionsService) CreateAddon(ctx context.Context, subscriptionID string, ...) (*SubscriptionAddon, error)
- func (s *SubscriptionsService) Edit(ctx context.Context, subscriptionID string, request SubscriptionEdit) (*BillingSubscription, error)
- func (s *SubscriptionsService) Get(ctx context.Context, subscriptionID string) (*BillingSubscription, error)
- func (s *SubscriptionsService) GetAddon(ctx context.Context, subscriptionID string, subscriptionAddonID string) (*SubscriptionAddon, error)
- func (s *SubscriptionsService) List(ctx context.Context, params BillingSubscriptionListParams) (*SubscriptionPagePaginatedResponse, error)
- func (s *SubscriptionsService) ListAddons(ctx context.Context, subscriptionID string, params SubscriptionAddonListParams) (*SubscriptionAddonPagePaginatedResponse, error)
- func (s *SubscriptionsService) ListAddonsAll(ctx context.Context, subscriptionID string, params SubscriptionAddonListParams) iter.Seq2[SubscriptionAddon, error]
- func (s *SubscriptionsService) ListAll(ctx context.Context, params BillingSubscriptionListParams) iter.Seq2[BillingSubscription, error]
- func (s *SubscriptionsService) Migrate(ctx context.Context, subscriptionID string, request SubscriptionMigrate) (*SubscriptionMigrateResponse, error)
- func (s *SubscriptionsService) Restore(ctx context.Context, subscriptionID string) (*BillingSubscription, error)
- func (s *SubscriptionsService) Unschedule(ctx context.Context, subscriptionID string) error
- func (s *SubscriptionsService) UnscheduleCancelation(ctx context.Context, subscriptionID string) (*BillingSubscription, error)
- func (s *SubscriptionsService) UpdateAddon(ctx context.Context, subscriptionID string, subscriptionAddonID string, ...) (*SubscriptionAddon, error)
- type Supplier
- type TaxBehavior
- type TaxCode
- type TaxCodeAppMapping
- type TaxCodeConfig
- type TaxCodeListParams
- type TaxCodePagePaginatedResponse
- type TaxCodeReference
- type TaxConfig
- type TaxConfigExternalInvoicing
- type TaxConfigStripe
- type TaxService
- func (s *TaxService) CreateCode(ctx context.Context, request CreateTaxCodeRequest) (*TaxCode, error)
- func (s *TaxService) DeleteCode(ctx context.Context, taxCodeID string) error
- func (s *TaxService) GetCode(ctx context.Context, taxCodeID string) (*TaxCode, error)
- func (s *TaxService) ListCodes(ctx context.Context, params TaxCodeListParams) (*TaxCodePagePaginatedResponse, error)
- func (s *TaxService) ListCodesAll(ctx context.Context, params TaxCodeListParams) iter.Seq2[TaxCode, error]
- func (s *TaxService) UpsertCode(ctx context.Context, taxCodeID string, request UpsertTaxCodeRequest) (*TaxCode, error)
- type Totals
- type UnitConfig
- type UnitConfigOperation
- type UnitConfigRoundingMode
- type UpdateAppExternalInvoicingRequest
- type UpdateAppRequest
- func UpdateAppRequestFromUpdateAppExternalInvoicingRequest(value UpdateAppExternalInvoicingRequest) (UpdateAppRequest, error)
- func UpdateAppRequestFromUpdateAppSandboxRequest(value UpdateAppSandboxRequest) (UpdateAppRequest, error)
- func UpdateAppRequestFromUpdateAppStripeRequest(value UpdateAppStripeRequest) (UpdateAppRequest, error)
- func (u UpdateAppRequest) AsUpdateAppExternalInvoicingRequest() (*UpdateAppExternalInvoicingRequest, error)
- func (u UpdateAppRequest) AsUpdateAppSandboxRequest() (*UpdateAppSandboxRequest, error)
- func (u UpdateAppRequest) AsUpdateAppStripeRequest() (*UpdateAppStripeRequest, error)
- func (u UpdateAppRequest) MarshalJSON() ([]byte, error)
- func (u *UpdateAppRequest) UnmarshalJSON(data []byte) error
- type UpdateAppSandboxRequest
- type UpdateAppStripeRequest
- type UpdateBillingInvoiceWorkflow
- type UpdateBillingInvoiceWorkflowInvoicingSettings
- type UpdateBillingNotificationChannelRequest
- type UpdateCreditGrantExternalSettlementRequest
- type UpdateFeatureRequest
- type UpdateInvoiceLine
- type UpdateInvoiceLineRateCard
- type UpdateInvoiceRequest
- type UpdateInvoiceStandardLine
- type UpdateInvoiceStandardRequest
- type UpdateInvoiceWorkflowSettings
- type UpdateMeterRequest
- type UpdateOrganizationDefaultTaxCodesRequest
- type UpsertAddonRequest
- type UpsertAppCustomerDataRequest
- type UpsertBillingProfileRequest
- type UpsertCustomerBillingDataRequest
- type UpsertCustomerBillingProfileRequest
- type UpsertCustomerRequest
- type UpsertPlanAddonRequest
- type UpsertPlanRequest
- type UpsertTaxCodeRequest
- type ValidationIssue
- type ValidationIssueSeverity
- type VersionFilter
- type VoidCreditGrantRequest
- type VoidGrantParams
- type Workflow
- type WorkflowCollectionAlignment
- func WorkflowCollectionAlignmentFromWorkflowCollectionAlignmentAnchored(value WorkflowCollectionAlignmentAnchored) (WorkflowCollectionAlignment, error)
- func WorkflowCollectionAlignmentFromWorkflowCollectionAlignmentSubscription(value WorkflowCollectionAlignmentSubscription) (WorkflowCollectionAlignment, error)
- func (u WorkflowCollectionAlignment) AsWorkflowCollectionAlignmentAnchored() (*WorkflowCollectionAlignmentAnchored, error)
- func (u WorkflowCollectionAlignment) AsWorkflowCollectionAlignmentSubscription() (*WorkflowCollectionAlignmentSubscription, error)
- func (u WorkflowCollectionAlignment) MarshalJSON() ([]byte, error)
- func (u *WorkflowCollectionAlignment) UnmarshalJSON(data []byte) error
- type WorkflowCollectionAlignmentAnchored
- type WorkflowCollectionAlignmentSubscription
- type WorkflowCollectionSettings
- type WorkflowInvoicingEmptyInvoiceMode
- type WorkflowInvoicingSettings
- type WorkflowInvoicingSubscriptionEndProrationMode
- type WorkflowPaymentChargeAutomaticallySettings
- type WorkflowPaymentSendInvoiceSettings
- type WorkflowPaymentSettings
- func (u WorkflowPaymentSettings) AsWorkflowPaymentChargeAutomaticallySettings() (*WorkflowPaymentChargeAutomaticallySettings, error)
- func (u WorkflowPaymentSettings) AsWorkflowPaymentSendInvoiceSettings() (*WorkflowPaymentSendInvoiceSettings, error)
- func (u WorkflowPaymentSettings) MarshalJSON() ([]byte, error)
- func (u *WorkflowPaymentSettings) UnmarshalJSON(data []byte) error
- type WorkflowTaxSettings
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyID = errors.New("openmeter: resource ID must not be empty")
ErrEmptyID is returned by operations that target a single resource when the resource ID is empty. It is caught before any request is made so an omitted ID surfaces as a clear client-side error rather than an ambiguous server response. Match it with errors.Is.
var Version = resolveVersion()
Version is the SDK version reported in the default User-Agent. When the SDK is consumed as a module dependency it is resolved from the consumer's build info (the module version selected by their go.mod), so tagged releases need no stamping commit. Builds where that is unavailable — the module itself, replace directives, vendored trees without version data — fall back to the sdk-version emitter option ("0.0.0-dev").
Functions ¶
func DecodeAPIError ¶
DecodeAPIError decodes an API error body into T. The returned boolean is false when err is not an APIError.
func Ptr ¶
func Ptr[T any](v T) *T
Ptr returns a pointer to v. It is the generic form covering any type; the typed String/Int/Bool/Time below remain because they let the compiler infer the element type at call sites where a bare literal would not (e.g. String("x") vs Ptr("x"), which are equivalent, but Int(1) avoids Ptr[int](1)).
Types ¶
type APIError ¶
type APIError struct {
// StatusCode is the HTTP status code of the response.
StatusCode int `json:"-"`
// Status is the status code echoed in the problem body (usually equal to
// StatusCode).
Status int `json:"status"`
// Title is a short, stable, human-readable summary of the problem.
Title string `json:"title"`
// Type is an optional machine-readable error type.
Type string `json:"type,omitempty"`
// Detail is a human-readable explanation specific to this occurrence.
Detail string `json:"detail"`
// Instance carries the correlation ID, formatted as kong:trace:<id>.
Instance string `json:"instance"`
// RawBody is the undecoded response body, always populated.
RawBody []byte `json:"-"`
}
APIError is returned for any non-2xx API response. It mirrors the API's RFC 7807-style problem body. When the body cannot be parsed as such, Title is left empty and RawBody carries the undecoded payload.
func AsAPIError ¶
AsAPIError returns the APIError inside err, when err came from an API response.
type Addon ¶
type Addon struct {
ID string `json:"id"`
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// A key is a semi-unique string that is used to identify the add-on. It is used to
// reference the latest `active` version of the add-on and is unique with the
// version number.
Key string `json:"key"`
// Version of the add-on. Incremented when the add-on is updated.
Version int64 `json:"version"`
// The InstanceType of the add-ons. Can be "single" or "multiple".
InstanceType AddonInstanceType `json:"instance_type"`
// The currency code of the add-on.
Currency BillingCurrencyCode `json:"currency"`
// The date and time when the add-on becomes effective. When not specified, the
// add-on is a draft.
EffectiveFrom *time.Time `json:"effective_from,omitempty"`
// The date and time when the add-on is no longer effective. When not specified,
// the add-on is effective indefinitely.
EffectiveTo *time.Time `json:"effective_to,omitempty"`
// The status of the add-on. Computed based on the effective start and end dates:
//
// - `draft`: `effective_from` is not set.
// - `active`: `effective_from <= now` and (`effective_to` is not set or
// `now < effective_to`).
// - `archived`: `effective_to <= now`.
Status AddonStatus `json:"status"`
// The rate cards of the add-on.
RateCards []RateCard `json:"rate_cards"`
// List of validation errors.
ValidationErrors []ProductCatalogValidationError `json:"validation_errors,omitempty"`
}
Add-on allows extending subscriptions with compatible plans with additional ratecards.
type AddonFilter ¶
type AddonFilter struct {
ID *StringExactFilter
Key *StringFilter
Name *StringFilter
Status *StringExactFilter
Currency *StringExactFilter
}
type AddonInstanceType ¶
type AddonInstanceType string
The instanceType of the add-on.
- `single`: Can be added to a subscription only once. - `multiple`: Can be added to a subscription more than once.
const ( AddonInstanceTypeSingle AddonInstanceType = "single" AddonInstanceTypeMultiple AddonInstanceType = "multiple" )
func (AddonInstanceType) Valid ¶
func (value AddonInstanceType) Valid() bool
type AddonListParams ¶
type AddonListParams struct {
Page *PageParams
Sort *Sort
Filter *AddonFilter
}
type AddonPagePaginatedResponse ¶
type AddonPagePaginatedResponse struct {
Data []Addon `json:"data"`
Meta PaginatedMeta `json:"meta"`
}
Page paginated response.
type AddonStatus ¶
type AddonStatus string
The status of the add-on defined by the `effective_from` and `effective_to` properties.
- `draft`: The add-on has not yet been published and can be edited. - `active`: The add-on is published and available for use. - `archived`: The add-on is no longer available for use.
const ( AddonStatusDraft AddonStatus = "draft" AddonStatusActive AddonStatus = "active" AddonStatusArchived AddonStatus = "archived" )
func (AddonStatus) Valid ¶
func (value AddonStatus) Valid() bool
type AddonsService ¶
type AddonsService struct {
// contains filtered or unexported fields
}
func (*AddonsService) Create ¶
func (s *AddonsService) Create(ctx context.Context, request CreateAddonRequest) (*Addon, error)
Create a new add-on.
func (*AddonsService) Delete ¶
func (s *AddonsService) Delete(ctx context.Context, addonID string) error
Soft delete add-on by id.
func (*AddonsService) List ¶
func (s *AddonsService) List(ctx context.Context, params AddonListParams) (*AddonPagePaginatedResponse, error)
List all add-ons.
func (*AddonsService) ListAll ¶
func (s *AddonsService) ListAll(ctx context.Context, params AddonListParams) iter.Seq2[Addon, error]
ListAll returns an iterator over all Addon results, fetching pages of List transparently. Iteration stops at the first error, which is yielded as the second value.
func (*AddonsService) Update ¶
func (s *AddonsService) Update(ctx context.Context, addonID string, request UpsertAddonRequest) (*Addon, error)
Update an add-on by id.
type Address ¶
type Address struct {
// Country code in [ISO 3166-1](https://www.iso.org/iso-3166-country-codes.html)
// alpha-2 format.
Country *string `json:"country,omitempty"`
// Postal code.
PostalCode *string `json:"postal_code,omitempty"`
// State or province.
State *string `json:"state,omitempty"`
// City.
City *string `json:"city,omitempty"`
// First line of the address.
Line1 *string `json:"line1,omitempty"`
// Second line of the address.
Line2 *string `json:"line2,omitempty"`
// Phone number.
PhoneNumber *string `json:"phone_number,omitempty"`
}
Address
type App ¶
type App struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
Installed application.
App is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the AppFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func AppFromAppExternalInvoicing ¶
func AppFromAppExternalInvoicing(value AppExternalInvoicing) (App, error)
func AppFromAppSandbox ¶
func AppFromAppSandbox(value AppSandbox) (App, error)
func AppFromAppStripe ¶
func (App) AsAppExternalInvoicing ¶
func (u App) AsAppExternalInvoicing() (*AppExternalInvoicing, error)
func (App) AsAppSandbox ¶
func (u App) AsAppSandbox() (*AppSandbox, error)
func (App) AsAppStripe ¶
func (App) MarshalJSON ¶
func (*App) UnmarshalJSON ¶
type AppAction ¶
type AppAction struct {
// The action type.
Type AppActionType `json:"type"`
// Human readable explanation of why the action is needed.
Description string `json:"description"`
}
An action the operator should take on an installed app.
type AppActionRequest ¶
type AppActionRequest struct {
ActionType string `json:"action_type"`
// contains filtered or unexported fields
}
Request to execute an operator action on an installed app.
AppActionRequest is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the AppActionRequestFrom* constructors. The exported ActionType field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func AppActionRequestFromAppReconcileWebhookEventsActionRequest ¶
func AppActionRequestFromAppReconcileWebhookEventsActionRequest(value AppReconcileWebhookEventsActionRequest) (AppActionRequest, error)
func (AppActionRequest) AsAppReconcileWebhookEventsActionRequest ¶
func (u AppActionRequest) AsAppReconcileWebhookEventsActionRequest() (*AppReconcileWebhookEventsActionRequest, error)
func (AppActionRequest) MarshalJSON ¶
func (u AppActionRequest) MarshalJSON() ([]byte, error)
func (*AppActionRequest) UnmarshalJSON ¶
func (u *AppActionRequest) UnmarshalJSON(data []byte) error
type AppActionType ¶
type AppActionType string
App action type.
const (
AppActionTypeReconcileWebhookEvents AppActionType = "reconcile_webhook_events"
)
func (AppActionType) Valid ¶
func (value AppActionType) Valid() bool
type AppCapability ¶
type AppCapability struct {
// Type of the capability.
Type AppCapabilityType `json:"type"`
// Key of the capability.
Key string `json:"key"`
// Name of the capability.
Name string `json:"name"`
// Description of the capability.
Description string `json:"description"`
}
App capability describes a function that an App can perform.
type AppCapabilityType ¶
type AppCapabilityType string
Supported capability types for an App.
Each capability defines an integration function that an App can perform.
const ( AppCapabilityTypeReportUsage AppCapabilityType = "report_usage" AppCapabilityTypeReportEvents AppCapabilityType = "report_events" AppCapabilityTypeCalculateTax AppCapabilityType = "calculate_tax" AppCapabilityTypeInvoiceCustomers AppCapabilityType = "invoice_customers" AppCapabilityTypeCollectPayments AppCapabilityType = "collect_payments" )
func (AppCapabilityType) Valid ¶
func (value AppCapabilityType) Valid() bool
type AppCatalogItem ¶
type AppCatalogItem struct {
// Type of the app.
Type AppType `json:"type"`
// Name of the app.
Name string `json:"name"`
// Description of the app.
Description string `json:"description"`
// Capabilities of the app.
Capabilities []AppCapability `json:"capabilities"`
// Available install methods of the app.
InstallMethods []AppInstallMethods `json:"install_methods"`
}
Available apps for billing integrations to connect with third-party services. Apps can have various capabilities like syncing data from or to external systems, integrating with third-party services for tax calculation, delivery of invoices, collection of payments, etc.
type AppCatalogItemListParams ¶
type AppCatalogItemListParams struct {
Page *PageParams
}
type AppCatalogItemPagePaginatedResponse ¶
type AppCatalogItemPagePaginatedResponse struct {
Data []AppCatalogItem `json:"data"`
Meta PaginatedMeta `json:"meta"`
}
Page paginated response.
type AppCustomerData ¶
type AppCustomerData struct {
// Used if the customer has a linked Stripe app.
//
// Set to `null` to remove the Stripe data of the customer; omit to leave it
// unchanged.
Stripe Nullable[AppCustomerDataStripe] `json:"stripe,omitempty"`
// Used if the customer has a linked external invoicing app.
//
// Set to `null` to remove the external invoicing data of the customer; omit to
// leave it unchanged.
ExternalInvoicing Nullable[AppCustomerDataExternalInvoicing] `json:"external_invoicing,omitempty"`
}
App customer data.
type AppCustomerDataExternalInvoicing ¶
type AppCustomerDataExternalInvoicing struct {
// Labels for this external invoicing integration on the customer.
Labels map[string]string `json:"labels,omitempty"`
}
External invoicing customer data.
type AppCustomerDataExternalInvoicingInput ¶
type AppCustomerDataExternalInvoicingInput struct {
// Labels for this external invoicing integration on the customer.
Labels *map[string]string `json:"labels,omitempty"`
}
External invoicing customer data.
type AppCustomerDataInput ¶
type AppCustomerDataInput struct {
// Used if the customer has a linked Stripe app.
//
// Set to `null` to remove the Stripe data of the customer; omit to leave it
// unchanged.
Stripe Nullable[AppCustomerDataStripeInput] `json:"stripe,omitempty"`
// Used if the customer has a linked external invoicing app.
//
// Set to `null` to remove the external invoicing data of the customer; omit to
// leave it unchanged.
ExternalInvoicing Nullable[AppCustomerDataExternalInvoicingInput] `json:"external_invoicing,omitempty"`
}
App customer data.
type AppCustomerDataStripe ¶
type AppCustomerDataStripe struct {
// The Stripe customer ID used.
CustomerID *string `json:"customer_id,omitempty"`
// The Stripe default payment method ID.
DefaultPaymentMethodID *string `json:"default_payment_method_id,omitempty"`
// Labels for this Stripe integration on the customer.
Labels map[string]string `json:"labels,omitempty"`
}
Stripe customer data.
type AppCustomerDataStripeInput ¶
type AppCustomerDataStripeInput struct {
// The Stripe customer ID used.
CustomerID *string `json:"customer_id,omitempty"`
// The Stripe default payment method ID.
DefaultPaymentMethodID *string `json:"default_payment_method_id,omitempty"`
// Labels for this Stripe integration on the customer.
Labels *map[string]string `json:"labels,omitempty"`
}
Stripe customer data.
type AppExternalInvoicing ¶
type AppExternalInvoicing struct {
ID string `json:"id"`
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// The app type.
Type AppType `json:"type"`
// The app catalog definition that this installed app is based on.
Definition AppCatalogItem `json:"definition"`
// Status of the app connection.
Status AppStatus `json:"status"`
// Actions the operator should take to bring the app up to date. Omitted when no
// action is required.
Actions []AppAction `json:"actions,omitempty"`
// Enable draft synchronization hook.
//
// When enabled, invoices will pause at the draft state and wait for the
// integration to call the draft synchronized endpoint before progressing to the
// issuing state. This allows the external system to validate and prepare the
// invoice data.
//
// When disabled, invoices automatically progress through the draft state based on
// the configured workflow timing.
EnableDraftSyncHook bool `json:"enable_draft_sync_hook"`
// Enable issuing synchronization hook.
//
// When enabled, invoices will pause at the issuing state and wait for the
// integration to call the issuing synchronized endpoint before progressing to the
// issued state. This ensures the external invoicing system has successfully
// created and finalized the invoice before it is marked as issued.
//
// When disabled, invoices automatically progress through the issuing state and are
// immediately marked as issued.
EnableIssuingSyncHook bool `json:"enable_issuing_sync_hook"`
}
External Invoicing app enables integration with third-party invoicing or payment system.
The app supports a bi-directional synchronization pattern where OpenMeter Billing manages the invoice lifecycle while the external system handles invoice presentation and payment collection.
Integration workflow:
1. The billing system creates invoices and transitions them through lifecycle states (draft → issuing → issued) 2. The integration receives webhook notifications about invoice state changes 3. The integration calls back to provide external system IDs and metadata 4. The integration reports payment events back via the payment status API
State synchronization is controlled by hooks that pause invoice progression until the external system confirms synchronization via API callbacks.
type AppFilter ¶
type AppFilter struct {
ID *StringExactFilter
Name *StringFilter
Type *StringExactFilter
Status *StringExactFilter
}
type AppInstallMethods ¶
type AppInstallMethods string
Supported installation methods for an app.
const ( AppInstallMethodsWithOAuth2 AppInstallMethods = "with_oauth2" AppInstallMethodsWithAPIKey AppInstallMethods = "with_api_key" AppInstallMethodsNoCredentialsRequired AppInstallMethods = "no_credentials_required" )
func (AppInstallMethods) Valid ¶
func (value AppInstallMethods) Valid() bool
type AppListParams ¶
type AppListParams struct {
Page *PageParams
Sort *Sort
Filter *AppFilter
}
type AppPagePaginatedResponse ¶
type AppPagePaginatedResponse struct {
Data []App `json:"data"`
Meta PaginatedMeta `json:"meta"`
}
Page paginated response.
type AppReconcileWebhookEventsActionRequest ¶
type AppReconcileWebhookEventsActionRequest struct {
// The action to execute.
ActionType AppActionType `json:"action_type"`
}
Request to reconcile the app's webhook events with the latest supported event set.
type AppReference ¶
type AppReference struct {
// The ID of the app.
ID string `json:"id"`
}
App reference.
type AppSandbox ¶
type AppSandbox struct {
ID string `json:"id"`
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// The app type.
Type AppType `json:"type"`
// The app catalog definition that this installed app is based on.
Definition AppCatalogItem `json:"definition"`
// Status of the app connection.
Status AppStatus `json:"status"`
// Actions the operator should take to bring the app up to date. Omitted when no
// action is required.
Actions []AppAction `json:"actions,omitempty"`
}
Sandbox app can be used for testing billing features.
type AppStatus ¶
type AppStatus string
Connection status of an installed app.
const ( AppStatusReady AppStatus = "ready" )
type AppStripe ¶
type AppStripe struct {
ID string `json:"id"`
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// The app type.
Type AppType `json:"type"`
// The app catalog definition that this installed app is based on.
Definition AppCatalogItem `json:"definition"`
// Status of the app connection.
Status AppStatus `json:"status"`
// Actions the operator should take to bring the app up to date. Omitted when no
// action is required.
Actions []AppAction `json:"actions,omitempty"`
// The Stripe account ID associated with the connected Stripe account.
AccountID string `json:"account_id"`
// Indicates whether the app is connected to a live Stripe account.
Livemode bool `json:"livemode"`
// The masked Stripe API key that only exposes the first and last few characters.
MaskedAPIKey string `json:"masked_api_key"`
}
Stripe app.
type AppStripeCheckoutSessionCustomTextParams ¶
type AppStripeCheckoutSessionCustomTextParams struct {
// Text displayed after the payment confirmation button.
AfterSubmit *AppStripeCheckoutSessionCustomTextParamsAfterSubmit `json:"after_submit,omitempty"`
// Text displayed alongside shipping address collection.
ShippingAddress *AppStripeCheckoutSessionCustomTextParamsShippingAddress `json:"shipping_address,omitempty"`
// Text displayed alongside the payment confirmation button.
Submit *AppStripeCheckoutSessionCustomTextParamsSubmit `json:"submit,omitempty"`
// Text replacing the default terms of service agreement text.
TermsOfServiceAcceptance *AppStripeCheckoutSessionCustomTextParamsTermsOfServiceAcceptance `json:"terms_of_service_acceptance,omitempty"`
}
Custom text displayed at various stages of the checkout flow.
type AppStripeCheckoutSessionCustomTextParamsAfterSubmit ¶
type AppStripeCheckoutSessionCustomTextParamsAfterSubmit struct {
// The custom message text (max 1200 characters).
Message *string `json:"message,omitempty"`
}
type AppStripeCheckoutSessionCustomTextParamsShippingAddress ¶
type AppStripeCheckoutSessionCustomTextParamsShippingAddress struct {
// The custom message text (max 1200 characters).
Message *string `json:"message,omitempty"`
}
type AppStripeCheckoutSessionCustomTextParamsSubmit ¶
type AppStripeCheckoutSessionCustomTextParamsSubmit struct {
// The custom message text (max 1200 characters).
Message *string `json:"message,omitempty"`
}
type AppStripeCheckoutSessionCustomTextParamsTermsOfServiceAcceptance ¶
type AppStripeCheckoutSessionCustomTextParamsTermsOfServiceAcceptance struct {
// The custom message text (max 1200 characters).
Message *string `json:"message,omitempty"`
}
type AppStripeCheckoutSessionMode ¶
type AppStripeCheckoutSessionMode string
Stripe Checkout Session mode.
Determines the primary purpose of the checkout session.
const (
AppStripeCheckoutSessionModeSetup AppStripeCheckoutSessionMode = "setup"
)
func (AppStripeCheckoutSessionMode) Valid ¶
func (value AppStripeCheckoutSessionMode) Valid() bool
type AppStripeCheckoutSessionUiMode ¶
type AppStripeCheckoutSessionUiMode string
Checkout Session UI mode.
const ( AppStripeCheckoutSessionUiModeEmbedded AppStripeCheckoutSessionUiMode = "embedded" AppStripeCheckoutSessionUiModeHosted AppStripeCheckoutSessionUiMode = "hosted" )
func (AppStripeCheckoutSessionUiMode) Valid ¶
func (value AppStripeCheckoutSessionUiMode) Valid() bool
type AppStripeCreateCheckoutSessionBillingAddressCollection ¶
type AppStripeCreateCheckoutSessionBillingAddressCollection string
Controls whether Checkout collects the customer's billing address.
const ( AppStripeCreateCheckoutSessionBillingAddressCollectionAuto AppStripeCreateCheckoutSessionBillingAddressCollection = "auto" AppStripeCreateCheckoutSessionBillingAddressCollectionRequired AppStripeCreateCheckoutSessionBillingAddressCollection = "required" )
func (AppStripeCreateCheckoutSessionBillingAddressCollection) Valid ¶
func (value AppStripeCreateCheckoutSessionBillingAddressCollection) Valid() bool
type AppStripeCreateCheckoutSessionConsentCollection ¶
type AppStripeCreateCheckoutSessionConsentCollection struct {
// Controls the visibility of payment method reuse agreement.
PaymentMethodReuseAgreement *AppStripeCreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreement `json:"payment_method_reuse_agreement,omitempty"`
// Enables collection of promotional communication consent.
//
// Only available to US merchants. When set to "auto", Checkout determines whether
// to show the option based on the customer's locale.
Promotions *AppStripeCreateCheckoutSessionConsentCollectionPromotions `json:"promotions,omitempty"`
// Requires customers to accept terms of service before payment.
//
// Requires a valid terms of service URL in your Stripe Dashboard settings.
TermsOfService *AppStripeCreateCheckoutSessionConsentCollectionTermsOfService `json:"terms_of_service,omitempty"`
}
Checkout Session consent collection configuration.
type AppStripeCreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreement ¶
type AppStripeCreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreement struct {
// Position and visibility of the payment method reuse agreement.
Position *AppStripeCreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPosition `json:"position,omitempty"`
}
Payment method reuse agreement configuration.
type AppStripeCreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPosition ¶
type AppStripeCreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPosition string
Position of payment method reuse agreement in the UI.
const ( AppStripeCreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPositionAuto AppStripeCreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPosition = "auto" AppStripeCreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPositionHidden AppStripeCreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPosition = "hidden" )
func (AppStripeCreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPosition) Valid ¶
func (value AppStripeCreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPosition) Valid() bool
type AppStripeCreateCheckoutSessionConsentCollectionPromotions ¶
type AppStripeCreateCheckoutSessionConsentCollectionPromotions string
Promotional communication consent collection setting.
const ( AppStripeCreateCheckoutSessionConsentCollectionPromotionsAuto AppStripeCreateCheckoutSessionConsentCollectionPromotions = "auto" AppStripeCreateCheckoutSessionConsentCollectionPromotionsNone AppStripeCreateCheckoutSessionConsentCollectionPromotions = "none" )
func (AppStripeCreateCheckoutSessionConsentCollectionPromotions) Valid ¶
func (value AppStripeCreateCheckoutSessionConsentCollectionPromotions) Valid() bool
type AppStripeCreateCheckoutSessionConsentCollectionTermsOfService ¶
type AppStripeCreateCheckoutSessionConsentCollectionTermsOfService string
Terms of service acceptance requirement.
const ( AppStripeCreateCheckoutSessionConsentCollectionTermsOfServiceNone AppStripeCreateCheckoutSessionConsentCollectionTermsOfService = "none" AppStripeCreateCheckoutSessionConsentCollectionTermsOfServiceRequired AppStripeCreateCheckoutSessionConsentCollectionTermsOfService = "required" )
func (AppStripeCreateCheckoutSessionConsentCollectionTermsOfService) Valid ¶
func (value AppStripeCreateCheckoutSessionConsentCollectionTermsOfService) Valid() bool
type AppStripeCreateCheckoutSessionCustomerUpdate ¶
type AppStripeCreateCheckoutSessionCustomerUpdate struct {
// Whether to save the billing address to customer.address.
//
// Defaults to "never".
Address *AppStripeCreateCheckoutSessionCustomerUpdateBehavior `json:"address,omitempty"`
// Whether to save the customer name to customer.name.
//
// Defaults to "never".
Name *AppStripeCreateCheckoutSessionCustomerUpdateBehavior `json:"name,omitempty"`
// Whether to save shipping information to customer.shipping.
//
// Defaults to "never".
Shipping *AppStripeCreateCheckoutSessionCustomerUpdateBehavior `json:"shipping,omitempty"`
}
Controls which customer fields can be updated by the checkout session.
type AppStripeCreateCheckoutSessionCustomerUpdateBehavior ¶
type AppStripeCreateCheckoutSessionCustomerUpdateBehavior string
Behavior for updating customer fields from checkout session.
const ( AppStripeCreateCheckoutSessionCustomerUpdateBehaviorAuto AppStripeCreateCheckoutSessionCustomerUpdateBehavior = "auto" AppStripeCreateCheckoutSessionCustomerUpdateBehaviorNever AppStripeCreateCheckoutSessionCustomerUpdateBehavior = "never" )
func (AppStripeCreateCheckoutSessionCustomerUpdateBehavior) Valid ¶
func (value AppStripeCreateCheckoutSessionCustomerUpdateBehavior) Valid() bool
type AppStripeCreateCheckoutSessionRedirectOnCompletion ¶
type AppStripeCreateCheckoutSessionRedirectOnCompletion string
Redirect behavior for embedded checkout sessions.
const ( AppStripeCreateCheckoutSessionRedirectOnCompletionAlways AppStripeCreateCheckoutSessionRedirectOnCompletion = "always" AppStripeCreateCheckoutSessionRedirectOnCompletionIfRequired AppStripeCreateCheckoutSessionRedirectOnCompletion = "if_required" AppStripeCreateCheckoutSessionRedirectOnCompletionNever AppStripeCreateCheckoutSessionRedirectOnCompletion = "never" )
func (AppStripeCreateCheckoutSessionRedirectOnCompletion) Valid ¶
func (value AppStripeCreateCheckoutSessionRedirectOnCompletion) Valid() bool
type AppStripeCreateCheckoutSessionRequestOptions ¶
type AppStripeCreateCheckoutSessionRequestOptions struct {
// Whether to collect the customer's billing address.
//
// Defaults to auto, which only collects the address when necessary for tax
// calculation.
BillingAddressCollection *AppStripeCreateCheckoutSessionBillingAddressCollection `json:"billing_address_collection,omitempty"`
// URL to redirect customers who cancel the checkout session.
//
// Not allowed when ui_mode is "embedded".
CancelURL *string `json:"cancel_url,omitempty"`
// Unique reference string for reconciling sessions with internal systems.
//
// Can be a customer ID, cart ID, or any other identifier.
ClientReferenceID *string `json:"client_reference_id,omitempty"`
// Controls which customer fields can be updated by the checkout session.
CustomerUpdate *AppStripeCreateCheckoutSessionCustomerUpdate `json:"customer_update,omitempty"`
// Configuration for collecting customer consent during checkout.
ConsentCollection *AppStripeCreateCheckoutSessionConsentCollection `json:"consent_collection,omitempty"`
// Three-letter ISO 4217 currency code in uppercase.
//
// Required for payment mode sessions. Optional for setup mode sessions.
Currency *string `json:"currency,omitempty"`
// Custom text to display during checkout at various stages.
CustomText *AppStripeCheckoutSessionCustomTextParams `json:"custom_text,omitempty"`
// Unix timestamp when the checkout session expires.
//
// Can be 30 minutes to 24 hours from creation. Defaults to 24 hours.
ExpiresAt *int64 `json:"expires_at,omitempty"`
// IETF language tag for the checkout UI locale.
//
// If blank or "auto", uses the browser's locale. Example: "en", "fr", "de".
Locale *string `json:"locale,omitempty"`
// Set of key-value pairs to attach to the checkout session.
//
// Useful for storing additional structured information.
Metadata *map[string]string `json:"metadata,omitempty"`
// Return URL for embedded checkout sessions after payment authentication.
//
// Required if ui_mode is "embedded" and redirect-based payment methods are
// enabled.
ReturnURL *string `json:"return_url,omitempty"`
// Success URL to redirect customers after completing payment or setup.
//
// Not allowed when ui_mode is "embedded". See:
// https://docs.stripe.com/payments/checkout/custom-success-page
SuccessURL *string `json:"success_url,omitempty"`
// The UI mode for the checkout session.
//
// "hosted" displays a Stripe-hosted page. "embedded" integrates directly into your
// app. Defaults to "hosted".
UiMode *AppStripeCheckoutSessionUiMode `json:"ui_mode,omitempty"`
// List of payment method types to enable (e.g., "card", "us_bank_account").
//
// If not specified, Stripe enables all relevant payment methods.
PaymentMethodTypes *[]string `json:"payment_method_types,omitempty"`
// Redirect behavior for embedded checkout sessions.
//
// Controls when to redirect users after completion. See:
// https://docs.stripe.com/payments/checkout/custom-success-page?payment-ui=embedded-form
RedirectOnCompletion *AppStripeCreateCheckoutSessionRedirectOnCompletion `json:"redirect_on_completion,omitempty"`
// Configuration for collecting tax IDs during checkout.
TaxIDCollection *AppStripeCreateCheckoutSessionTaxIDCollection `json:"tax_id_collection,omitempty"`
}
Configuration options for creating a Stripe Checkout Session.
Based on Stripe's [Checkout Session API parameters](https://docs.stripe.com/api/checkout/sessions/create).
type AppStripeCreateCheckoutSessionResult ¶
type AppStripeCreateCheckoutSessionResult struct {
// The customer ID in the billing system.
CustomerID string `json:"customer_id"`
// The Stripe customer ID.
StripeCustomerID string `json:"stripe_customer_id"`
// The Stripe checkout session ID.
SessionID string `json:"session_id"`
// The setup intent ID created for collecting the payment method.
SetupIntentID string `json:"setup_intent_id"`
// Client secret for initializing Stripe.js on the client side.
//
// Required for embedded checkout sessions. See:
// https://docs.stripe.com/payments/checkout/custom-success-page
ClientSecret *string `json:"client_secret,omitempty"`
// The client reference ID provided in the request.
//
// Useful for reconciling the session with your internal systems.
ClientReferenceID *string `json:"client_reference_id,omitempty"`
// Customer's email address if provided to Stripe.
CustomerEmail *string `json:"customer_email,omitempty"`
// Currency code for the checkout session.
Currency *string `json:"currency,omitempty"`
// Timestamp when the checkout session was created.
CreatedAt time.Time `json:"created_at"`
// Timestamp when the checkout session will expire.
ExpiresAt *time.Time `json:"expires_at,omitempty"`
// Metadata attached to the checkout session.
Metadata map[string]string `json:"metadata,omitempty"`
// The status of the checkout session.
//
// See:
// https://docs.stripe.com/api/checkout/sessions/object#checkout_session_object-status
Status *string `json:"status,omitempty"`
// URL to redirect customers to the checkout page (for hosted mode).
URL *string `json:"url,omitempty"`
// Mode of the checkout session.
//
// Currently only "setup" mode is supported for collecting payment methods.
Mode AppStripeCheckoutSessionMode `json:"mode"`
// The cancel URL where customers are redirected if they cancel.
CancelURL *string `json:"cancel_url,omitempty"`
// The success URL where customers are redirected after completion.
SuccessURL *string `json:"success_url,omitempty"`
// The return URL for embedded sessions after authentication.
ReturnURL *string `json:"return_url,omitempty"`
}
Result of creating a Stripe Checkout Session.
Contains all the information needed to redirect customers to the checkout or initialize an embedded checkout flow.
type AppStripeCreateCheckoutSessionTaxIDCollection ¶
type AppStripeCreateCheckoutSessionTaxIDCollection struct {
// Enable tax ID collection during checkout.
//
// Defaults to false.
Enabled *bool `json:"enabled,omitempty"`
// Whether tax ID collection is required.
//
// Defaults to "never".
Required *AppStripeCreateCheckoutSessionTaxIDCollectionRequired `json:"required,omitempty"`
}
Tax ID collection configuration for checkout sessions.
type AppStripeCreateCheckoutSessionTaxIDCollectionRequired ¶
type AppStripeCreateCheckoutSessionTaxIDCollectionRequired string
Tax ID collection requirement level.
const ( AppStripeCreateCheckoutSessionTaxIDCollectionRequiredIfSupported AppStripeCreateCheckoutSessionTaxIDCollectionRequired = "if_supported" AppStripeCreateCheckoutSessionTaxIDCollectionRequiredNever AppStripeCreateCheckoutSessionTaxIDCollectionRequired = "never" )
func (AppStripeCreateCheckoutSessionTaxIDCollectionRequired) Valid ¶
func (value AppStripeCreateCheckoutSessionTaxIDCollectionRequired) Valid() bool
type AppStripeCreateCustomerPortalSessionOptions ¶
type AppStripeCreateCustomerPortalSessionOptions struct {
// The ID of an existing
// [Stripe configuration](https://docs.stripe.com/api/customer_portal/configurations)
// to use for this session, describing its functionality and features. If not
// specified, the session uses the default configuration.
ConfigurationID *string `json:"configuration_id,omitempty"`
// The IETF
// [language tag](https://docs.stripe.com/api/customer_portal/sessions/create#create_portal_session-locale)
// of the locale customer portal is displayed in. If blank or `auto`, the
// customer's preferred_locales or browser's locale is used.
Locale *string `json:"locale,omitempty"`
// The
// [URL to redirect](https://docs.stripe.com/api/customer_portal/sessions/create#create_portal_session-return_url)
// the customer to after they have completed their requested actions.
ReturnURL *string `json:"return_url,omitempty"`
}
Request to create a Stripe Customer Portal Session.
type AppStripeCreateCustomerPortalSessionResult ¶
type AppStripeCreateCustomerPortalSessionResult struct {
// The ID of the customer portal session.
//
// See:
// https://docs.stripe.com/api/customer_portal/sessions/object#portal_session_object-id
ID string `json:"id"`
// The ID of the stripe customer.
StripeCustomerID string `json:"stripe_customer_id"`
// Configuration used to customize the customer portal.
//
// See:
// https://docs.stripe.com/api/customer_portal/sessions/object#portal_session_object-configuration
ConfigurationID string `json:"configuration_id"`
// Livemode.
//
// See:
// https://docs.stripe.com/api/customer_portal/sessions/object#portal_session_object-livemode
Livemode bool `json:"livemode"`
// Created at.
//
// See:
// https://docs.stripe.com/api/customer_portal/sessions/object#portal_session_object-created
CreatedAt time.Time `json:"created_at"`
// Return URL.
//
// See:
// https://docs.stripe.com/api/customer_portal/sessions/object#portal_session_object-return_url
ReturnURL string `json:"return_url"`
// The IETF language tag of the locale customer portal is displayed in.
//
// See:
// https://docs.stripe.com/api/customer_portal/sessions/object#portal_session_object-locale
Locale string `json:"locale"`
// The URL to redirect the customer to after they have completed their requested
// actions.
URL string `json:"url"`
}
Result of creating a [Stripe Customer Portal Session](https://docs.stripe.com/api/customer_portal/sessions/object).
Contains all the information needed to redirect the customer to the Stripe Customer Portal.
type AppsService ¶
type AppsService struct {
// contains filtered or unexported fields
}
func (*AppsService) ExecuteAction ¶
func (s *AppsService) ExecuteAction(ctx context.Context, appID string, request AppActionRequest) (*App, error)
Execute an operator action on an installed app. The action must be listed in the app's `actions`; otherwise the request is rejected.
func (*AppsService) GetCatalogItem ¶
func (s *AppsService) GetCatalogItem(ctx context.Context, appType string) (*AppCatalogItem, error)
Get an app catalog item by type.
func (*AppsService) Install ¶
func (s *AppsService) Install(ctx context.Context, request InstallAppRequest) (*InstallAppResponse, error)
Install an app from the catalog.
func (*AppsService) List ¶
func (s *AppsService) List(ctx context.Context, params AppListParams) (*AppPagePaginatedResponse, error)
List installed apps.
func (*AppsService) ListAll ¶
func (s *AppsService) ListAll(ctx context.Context, params AppListParams) iter.Seq2[App, error]
ListAll returns an iterator over all App results, fetching pages of List transparently. Iteration stops at the first error, which is yielded as the second value.
func (*AppsService) ListCatalog ¶
func (s *AppsService) ListCatalog(ctx context.Context, params AppCatalogItemListParams) (*AppCatalogItemPagePaginatedResponse, error)
List available apps.
func (*AppsService) ListCatalogAll ¶
func (s *AppsService) ListCatalogAll(ctx context.Context, params AppCatalogItemListParams) iter.Seq2[AppCatalogItem, error]
ListCatalogAll returns an iterator over all AppCatalogItem results, fetching pages of ListCatalog transparently. Iteration stops at the first error, which is yielded as the second value.
func (*AppsService) Uninstall ¶
func (s *AppsService) Uninstall(ctx context.Context, appID string) error
Uninstall an app by ID.
func (*AppsService) Update ¶
func (s *AppsService) Update(ctx context.Context, appID string, request UpdateAppRequest) (*App, error)
Update an installed app.
type BillingService ¶
type BillingService struct {
// contains filtered or unexported fields
}
func (*BillingService) CreateProfile ¶
func (s *BillingService) CreateProfile(ctx context.Context, request CreateBillingProfileRequest) (*Profile, error)
Create a new billing profile.
Billing profiles contain the settings for billing and controls invoice generation. An organization can have multiple billing profiles defined. A billing profile is linked to a specific app. This association is established during the billing profile's creation and remains immutable.
func (*BillingService) DeleteProfile ¶
func (s *BillingService) DeleteProfile(ctx context.Context, id string) error
Delete a billing profile.
Only such billing profiles can be deleted that are:
- not the default profile - not pinned to any customer using customer overrides - only have finalized invoices
func (*BillingService) GetProfile ¶
Get a billing profile.
func (*BillingService) ListProfiles ¶
func (s *BillingService) ListProfiles(ctx context.Context, params ProfileListParams) (*ProfilePagePaginatedResponse, error)
List billing profiles.
func (*BillingService) ListProfilesAll ¶
func (s *BillingService) ListProfilesAll(ctx context.Context, params ProfileListParams) iter.Seq2[Profile, error]
ListProfilesAll returns an iterator over all Profile results, fetching pages of ListProfiles transparently. Iteration stops at the first error, which is yielded as the second value.
func (*BillingService) UpdateProfile ¶
func (s *BillingService) UpdateProfile(ctx context.Context, id string, request UpsertBillingProfileRequest) (*Profile, error)
Update a billing profile.
type BillingSubscription ¶
type BillingSubscription struct {
ID string `json:"id"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// Display name of the subscription. Defaults to the plan name when the
// subscription is created from a plan.
Name string `json:"name"`
// Optional description of the subscription.
Description *string `json:"description,omitempty"`
// An ISO-8601 timestamp representation of when the subscription became (or will
// become) active.
ActiveFrom time.Time `json:"active_from"`
// An ISO-8601 timestamp representation of when the subscription stops being
// active. Open-ended when not set.
ActiveTo *time.Time `json:"active_to,omitempty"`
// The customer ID of the subscription.
CustomerID string `json:"customer_id"`
// The plan ID of the subscription. Set if subscription is created from a plan.
PlanID *string `json:"plan_id,omitempty"`
// The plan the subscription was created from, if any. Includes the plan key and
// version so clients can resolve the exact plan revision.
Plan *SubscriptionPlanReference `json:"plan,omitempty"`
// The fiat currency in which the subscription is invoiced.
InvoiceCurrency string `json:"invoice_currency"`
// Controls whether custom-currency cost bases are resolved dynamically or pinned
// when their currency pair is introduced to the subscription.
CostBasisMode SubscriptionCostBasisMode `json:"cost_basis_mode"`
// Cost bases pinned to custom-currency pairs for this subscription.
CostBasisPins []SubscriptionCostBasisPin `json:"cost_basis_pins"`
// The billing cadence of the subscription in ISO-8601 duration format. Defines how
// often the customer is billed. Examples: `P1M` (monthly), `P3M` (quarterly),
// `P1Y` (annually).
BillingCadence string `json:"billing_cadence"`
// The pro-rating configuration of the subscription.
ProRatingConfig *SubscriptionProRatingConfig `json:"pro_rating_config,omitempty"`
// A billing anchor is the fixed point in time that determines the subscription's
// recurring billing cycle. It affects when charges occur and how prorations are
// calculated. Common anchors:
//
// - Calendar month (1st of each month): `2025-01-01T00:00:00Z`
// - Subscription anniversary (day customer signed up)
// - Custom date (customer-specified day)
BillingAnchor time.Time `json:"billing_anchor"`
// When billing starts for the subscription. Nothing is billed for service before
// this time, while access, entitlements and metering start with the subscription.
// Use it when the time before was already billed elsewhere, for example when
// importing a subscription from another billing system.
//
// It cannot be before the start of the subscription and cannot be changed later.
// On subscriptions billed through invoice lines it must be the start of a billing
// period. If not provided, billing starts with the subscription.
//
// When billing starts inside a billing period, we recommend enabling price
// pro-rating (`prorate_prices`) on the plan. Without it that billing period's flat
// fees are billed in full.
BillingStartsAt *time.Time `json:"billing_starts_at,omitempty"`
// The status of the subscription.
Status SubscriptionStatus `json:"status"`
// Settlement mode for billing.
//
// Values:
//
// - `credit_then_invoice`: Credits are applied first, then any remainder is
// invoiced.
// - `credit_only`: Usage is settled exclusively against credits.
SettlementMode *SettlementMode `json:"settlement_mode,omitempty"`
// The current aligned billing period. Present only when the subscription is active
// and aligned.
CurrentPeriod *ClosedPeriod `json:"current_period,omitempty"`
// The phases of the subscription in chronological order. A phase groups the rate
// cards that are in effect for a segment of the subscription's lifetime.
Phases []SubscriptionPhase `json:"phases"`
}
Subscription.
type BillingSubscriptionFilter ¶
type BillingSubscriptionFilter struct {
ID *StringExactFilter
CustomerID *StringExactFilter
Status *StringExactFilter
PlanID *StringExactFilter
PlanKey *StringExactFilter
}
type BillingSubscriptionListParams ¶
type BillingSubscriptionListParams struct {
Page *PageParams
Sort *Sort
Filter *BillingSubscriptionFilter
}
type BooleanFilter ¶
type BooleanFilter struct {
Eq *bool
}
BooleanFilter expresses equality for a boolean field.
type Charge ¶
type Charge struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
Customer charge.
Charge is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the ChargeFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func ChargeFromChargeFlatFee ¶
func ChargeFromChargeFlatFee(value ChargeFlatFee) (Charge, error)
func ChargeFromChargeUsageBased ¶
func ChargeFromChargeUsageBased(value ChargeUsageBased) (Charge, error)
func (Charge) AsChargeFlatFee ¶
func (u Charge) AsChargeFlatFee() (*ChargeFlatFee, error)
func (Charge) AsChargeUsageBased ¶
func (u Charge) AsChargeUsageBased() (*ChargeUsageBased, error)
func (Charge) MarshalJSON ¶
func (*Charge) UnmarshalJSON ¶
type ChargeCostBasis ¶
type ChargeCostBasis struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
Cost basis selection for a custom-currency charge. The variant chosen fixes when and how the conversion rate is determined.
ChargeCostBasis is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the ChargeCostBasisFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func ChargeCostBasisFromChargeCostBasisDynamic ¶
func ChargeCostBasisFromChargeCostBasisDynamic(value ChargeCostBasisDynamic) (ChargeCostBasis, error)
func ChargeCostBasisFromChargeCostBasisManual ¶
func ChargeCostBasisFromChargeCostBasisManual(value ChargeCostBasisManual) (ChargeCostBasis, error)
func ChargeCostBasisFromChargeCostBasisPinned ¶
func ChargeCostBasisFromChargeCostBasisPinned(value ChargeCostBasisPinned) (ChargeCostBasis, error)
func (ChargeCostBasis) AsChargeCostBasisDynamic ¶
func (u ChargeCostBasis) AsChargeCostBasisDynamic() (*ChargeCostBasisDynamic, error)
func (ChargeCostBasis) AsChargeCostBasisManual ¶
func (u ChargeCostBasis) AsChargeCostBasisManual() (*ChargeCostBasisManual, error)
func (ChargeCostBasis) AsChargeCostBasisPinned ¶
func (u ChargeCostBasis) AsChargeCostBasisPinned() (*ChargeCostBasisPinned, error)
func (ChargeCostBasis) MarshalJSON ¶
func (u ChargeCostBasis) MarshalJSON() ([]byte, error)
func (*ChargeCostBasis) UnmarshalJSON ¶
func (u *ChargeCostBasis) UnmarshalJSON(data []byte) error
type ChargeCostBasisDynamic ¶
type ChargeCostBasisDynamic struct {
// Discriminator selecting the cost basis mode.
Type ChargeCostBasisType `json:"type"`
// The fiat currency the charge amount is converted into for invoicing.
FiatCurrency string `json:"fiat_currency"`
}
Cost basis resolved at the charge's full service period start.
type ChargeCostBasisManual ¶
type ChargeCostBasisManual struct {
// Discriminator selecting the cost basis mode.
Type ChargeCostBasisType `json:"type"`
// The fiat currency the charge amount is converted into for invoicing.
FiatCurrency *string `json:"fiat_currency,omitempty"`
// Fiat amount per one unit of the custom currency.
Rate Numeric `json:"rate"`
}
Cost basis with an explicit conversion rate supplied with the charge.
type ChargeCostBasisPinned ¶
type ChargeCostBasisPinned struct {
// Discriminator selecting the cost basis mode.
Type ChargeCostBasisType `json:"type"`
// The fiat currency the charge amount is converted into for invoicing.
FiatCurrency string `json:"fiat_currency"`
// ID of the custom currency's cost basis resource to pin.
CostBasisID string `json:"cost_basis_id"`
}
Cost basis pinned to a specific cost basis resource of the custom currency.
type ChargeCostBasisType ¶
type ChargeCostBasisType string
Cost basis resolution mode of a charge.
const ( ChargeCostBasisTypeDynamic ChargeCostBasisType = "dynamic" ChargeCostBasisTypePinned ChargeCostBasisType = "pinned" ChargeCostBasisTypeManual ChargeCostBasisType = "manual" )
func (ChargeCostBasisType) Valid ¶
func (value ChargeCostBasisType) Valid() bool
type ChargeFlatFee ¶
type ChargeFlatFee struct {
ID string `json:"id"`
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// The type of the charge.
Type ChargeType `json:"type"`
// The customer owning the charge.
//
// By default, only the `id` of the customer is returned. For more details use the
// `customer` expand.
Customer CustomerOrReference `json:"customer"`
// Indicates whether the charge lifecycle is controlled by the system or manually
// overridden by the API user.
LifecycleController LifecycleController `json:"lifecycle_controller"`
// The subscription that originated the charge, when the charge was created from a
// subscription item.
//
// By default, only the `id`, `phase.id`, `phase.item.id` of the subscription is
// returned. For more details use the `subscription` expand.
Subscription *SubscriptionOrReference `json:"subscription,omitempty"`
// The currency of the charge.
Currency BillingCurrencyCode `json:"currency"`
// The resolved fiat conversion rate of a custom-currency charge. Resolution
// depends on costbasis type: dynamic is resolved when charge becomes active, all
// other types resolved on creation.
ResolvedCostBasis *ChargeResolvedCostBasis `json:"resolved_cost_basis,omitempty"`
// The lifecycle status of the charge.
Status ChargeStatus `json:"status"`
// Validation issues found while processing the charge.
//
// Present only when there are one or more validation findings. An empty list is
// omitted.
ValidationIssues []ValidationIssue `json:"validation_issues,omitempty"`
// The timestamp when the charge is intended to be invoiced.
InvoiceAt time.Time `json:"invoice_at"`
// The effective service period covered by the charge.
ServicePeriod ClosedPeriod `json:"service_period"`
// The full, unprorated service period of the charge.
FullServicePeriod ClosedPeriod `json:"full_service_period"`
// The billing period the charge belongs to.
BillingPeriod ClosedPeriod `json:"billing_period"`
// The earliest time when the charge should be advanced again by background
// processing.
AdvanceAfter *time.Time `json:"advance_after,omitempty"`
// Unique reference ID of the charge.
UniqueReferenceID *string `json:"unique_reference_id,omitempty"`
// Settlement mode of the charge.
SettlementMode SettlementMode `json:"settlement_mode"`
// Tax configuration of the charge.
TaxConfig *TaxConfig `json:"tax_config,omitempty"`
// The realization runs of the charge, sorted by `created_at`.
Realizations []ChargeRealization `json:"realizations"`
// Payment term of the flat fee charge.
PaymentTerm PricePaymentTerm `json:"payment_term"`
// The discounts applied to the charge.
Discounts *ChargeFlatFeeDiscounts `json:"discounts,omitempty"`
// The feature associated with the charge, when applicable.
Feature *FeatureOrReference `json:"feature,omitempty"`
// The proration configuration of the charge.
ProrationConfiguration RateCardProrationConfiguration `json:"proration_configuration"`
// The amount after proration of the charge.
AmountAfterProration CurrencyAmount `json:"amount_after_proration"`
// The price of the charge.
Price PriceFlat `json:"price"`
// Current intent from the system lifecycle controller for a charge that has an
// active manual override. The top-level charge fields remain the effective
// customer-facing intent.
SystemIntent *ChargeFlatFeeSystemIntent `json:"system_intent,omitempty"`
}
A flat fee charge for a customer.
type ChargeFlatFeeDiscounts ¶
type ChargeFlatFeeDiscounts struct {
// Percentage discount applied to the price (0–100).
Percentage *float64 `json:"percentage,omitempty"`
}
Discounts applicable to flat fee charges.
This is the same as `ProductCatalog.Discounts` but without the `usage` field, which is not applicable to flat fee charges.
type ChargeFlatFeeSystemIntent ¶
type ChargeFlatFeeSystemIntent struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// The timestamp when the charge is intended to be invoiced.
InvoiceAt time.Time `json:"invoice_at"`
// The effective service period covered by the charge.
ServicePeriod ClosedPeriod `json:"service_period"`
// The full, unprorated service period of the charge.
FullServicePeriod ClosedPeriod `json:"full_service_period"`
// The billing period the charge belongs to.
BillingPeriod ClosedPeriod `json:"billing_period"`
// Payment term of the flat fee charge.
PaymentTerm PricePaymentTerm `json:"payment_term"`
// The discounts applied to the charge.
Discounts *ChargeFlatFeeDiscounts `json:"discounts,omitempty"`
// The proration configuration of the charge.
ProrationConfiguration RateCardProrationConfiguration `json:"proration_configuration"`
// The amount before proration of the system lifecycle controller flat fee intent.
AmountBeforeProration CurrencyAmount `json:"amount_before_proration"`
// The timestamp when the system lifecycle controller intent was deleted. The
// effective charge can remain visible while a manual override is active.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
}
Flat fee intent fields from the system lifecycle controller shadowed by a manual override.
type ChargePagePaginatedResponse ¶
type ChargePagePaginatedResponse struct {
Data []Charge `json:"data"`
Meta PaginatedMeta `json:"meta"`
}
Page paginated response.
type ChargeRealization ¶
type ChargeRealization struct {
// The ID of the realization run. Not present on `outstanding` entries, which are
// projections rather than persisted runs.
ID *string `json:"id,omitempty"`
// The ID of the invoice line this realization was booked to, when the realization
// has been invoiced.
LineID *string `json:"line_id,omitempty"`
// The reference of the invoice related to the realization.
Invoice *ChargeRealizationInvoiceOrReference `json:"invoice,omitempty"`
// The type of the realization run.
Type ChargeRealizationType `json:"type"`
// The service period covered by this realization run.
ServicePeriod ClosedPeriod `json:"service_period"`
// The metered usage quantity this realization run accounts for. Only present on
// usage-based charges; flat fees are not metered, so their realizations carry no
// usage.
//
// Booked entries report a signed delta: a negative value states a downward usage
// correction (or a voided run that snapshotted behind its live neighbors) instead
// of masking it as zero.
//
// On an `outstanding` entry, usage is omitted unless `real_time_usage` supplies a
// live reading. When present, it is the unbooked remainder of that reading,
// floored at zero.
Usage *Numeric `json:"usage,omitempty"`
// The payment state of the realization, when the charge requires a fiat
// transaction to settle.
Payment *ChargeRealizationPayment `json:"payment,omitempty"`
// Financial totals for the realization run, including credit allocations.
//
// Requires the `realization.totals` expand.
Totals *Totals `json:"totals,omitempty"`
// The detailed (rated) lines produced by the realization run.
//
// Requires the `realization.detailed_lines` expand.
DetailedLines []ChargeRealizationDetailedLine `json:"detailed_lines,omitempty"`
}
A realization run of a charge.
`totals` and `detailed_lines` are only populated with the `realization.totals` and `realization.detailed_lines` expands, respectively, since computing them requires re-deriving the run's rated breakdown. `invoice` is an ID reference unless the `realization.invoice` expand is used, which resolves it to the invoice header of the run's booked line: the invoice entity without its `lines` and without the `customer` snapshot (the charge itself already identifies the customer).
type ChargeRealizationAmountDiscount ¶
type ChargeRealizationAmountDiscount struct {
// The amount of the discount applied to the charge.
Amount Numeric `json:"amount"`
// The reason for the discount applied to the charge.
Reason string `json:"reason"`
// Optional human-readable description of the discount.
Description *string `json:"description,omitempty"`
// The discount amount applied to the charge, rounded to the nearest cent (or
// currency equivalent) and adjusted to compensate for rounding errors across
// multiple discounted detail lines.
RoundingAmount *Numeric `json:"rounding_amount,omitempty"`
// Unique reference ID of the discount applied to the charge.
ChildUniqueReferenceID string `json:"child_unique_reference_id"`
}
A discount applied to a charge realization detailed line.
type ChargeRealizationDetailedLine ¶
type ChargeRealizationDetailedLine struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
A detailed (child) line type of a charge realization run.
This is distinct from an invoice's own detailed lines: it represents the rated/priced breakdown produced by the realization run itself, before that breakdown is (or is not yet) reflected on an invoice line. Credit-then-invoice runs include credit allocations in these lines, while credits-only runs keep the gross rated detail.
ChargeRealizationDetailedLine is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the ChargeRealizationDetailedLineFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func ChargeRealizationDetailedLineFromChargeRealizationDetailedLineFlatFee ¶
func ChargeRealizationDetailedLineFromChargeRealizationDetailedLineFlatFee(value ChargeRealizationDetailedLineFlatFee) (ChargeRealizationDetailedLine, error)
func ChargeRealizationDetailedLineFromChargeRealizationDetailedLineUsageBased ¶
func ChargeRealizationDetailedLineFromChargeRealizationDetailedLineUsageBased(value ChargeRealizationDetailedLineUsageBased) (ChargeRealizationDetailedLine, error)
func (ChargeRealizationDetailedLine) AsChargeRealizationDetailedLineFlatFee ¶
func (u ChargeRealizationDetailedLine) AsChargeRealizationDetailedLineFlatFee() (*ChargeRealizationDetailedLineFlatFee, error)
func (ChargeRealizationDetailedLine) AsChargeRealizationDetailedLineUsageBased ¶
func (u ChargeRealizationDetailedLine) AsChargeRealizationDetailedLineUsageBased() (*ChargeRealizationDetailedLineUsageBased, error)
func (ChargeRealizationDetailedLine) MarshalJSON ¶
func (u ChargeRealizationDetailedLine) MarshalJSON() ([]byte, error)
func (*ChargeRealizationDetailedLine) UnmarshalJSON ¶
func (u *ChargeRealizationDetailedLine) UnmarshalJSON(data []byte) error
type ChargeRealizationDetailedLineCategory ¶
type ChargeRealizationDetailedLineCategory string
Cost category of a charge realization detailed line.
Values:
- `regular`: A regular charge line, based on usage or subscription pricing. - `commitment`: A commitment-derived line, such as minimum spend.
const ( ChargeRealizationDetailedLineCategoryRegular ChargeRealizationDetailedLineCategory = "regular" ChargeRealizationDetailedLineCategoryCommitment ChargeRealizationDetailedLineCategory = "commitment" )
func (ChargeRealizationDetailedLineCategory) Valid ¶
func (value ChargeRealizationDetailedLineCategory) Valid() bool
type ChargeRealizationDetailedLineCreditApplied ¶
type ChargeRealizationDetailedLineCreditApplied struct {
// The monetary amount credited.
Amount Numeric `json:"amount"`
// Human-readable description of the credit allocation.
Description *string `json:"description,omitempty"`
// The ID of the credit realization (allocation) this credit was applied from.
CreditRealizationID string `json:"credit_realization_id"`
}
A credit allocation applied to a charge realization detailed line.
type ChargeRealizationDetailedLineFlatFee ¶
type ChargeRealizationDetailedLineFlatFee struct {
ID string `json:"id"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// The type of the charge the realization belongs to.
Type ChargeType `json:"type"`
// The service period covered by this detailed line.
ServicePeriod ClosedPeriod `json:"service_period"`
// Aggregated financial totals for the detailed line.
Totals Totals `json:"totals"`
// The cost category of this detailed line.
Category ChargeRealizationDetailedLineCategory `json:"category"`
// Credits applied to this detailed line.
CreditsApplied []ChargeRealizationDetailedLineCreditApplied `json:"credits_applied,omitempty"`
// The unit price of the detailed line.
UnitPrice Numeric `json:"unit_price"`
// The amount discounts applied to the detailed line.
AmountDiscounts []ChargeRealizationAmountDiscount `json:"amount_discounts"`
}
A detailed line produced by a flat fee charge's realization run.
type ChargeRealizationDetailedLineUsageBased ¶
type ChargeRealizationDetailedLineUsageBased struct {
ID string `json:"id"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// The type of the charge the realization belongs to.
Type ChargeType `json:"type"`
// The service period covered by this detailed line.
ServicePeriod ClosedPeriod `json:"service_period"`
// Aggregated financial totals for the detailed line.
Totals Totals `json:"totals"`
// The cost category of this detailed line.
Category ChargeRealizationDetailedLineCategory `json:"category"`
// Credits applied to this detailed line.
CreditsApplied []ChargeRealizationDetailedLineCreditApplied `json:"credits_applied,omitempty"`
// The unit price of the detailed line.
UnitPrice Numeric `json:"unit_price"`
// The amount discounts applied to the detailed line.
AmountDiscounts []ChargeRealizationAmountDiscount `json:"amount_discounts"`
// The quantity of the detailed line.
Quantity Numeric `json:"quantity"`
// The ID of a prior realization run this detailed line corrects. Only set if the
// detailed line's totals are negative.
CorrectsRunID *string `json:"corrects_run_id,omitempty"`
}
A detailed line produced by a usage-based charge's realization run.
type ChargeRealizationInvoice ¶
type ChargeRealizationInvoice struct {
ID string `json:"id"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// Human-readable invoice number generated by the invoicing app.
Number string `json:"number"`
// Three-letter ISO 4217 currency code for the invoice.
Currency string `json:"currency"`
// Snapshot of the supplier's contact information at the time the invoice was
// issued.
Supplier Supplier `json:"supplier"`
// Aggregated financial totals for the invoice.
Totals Totals `json:"totals"`
// The service period covered by this invoice.
//
// For flat fee the service period can be empty which means `from` will be equals
// to `to`. In other cases those fields will be filled with the actual service
// period.
ServicePeriod ClosedPeriod `json:"service_period"`
// Validation issues found during invoice processing.
//
// Present only when there are one or more validation findings. An empty list is
// omitted.
ValidationIssues []ValidationIssue `json:"validation_issues,omitempty"`
// External identifiers assigned to this invoice by third-party systems.
ExternalReferences *InvoiceExternalReferences `json:"external_references,omitempty"`
// Discriminator field identifying this as a standard invoice.
Type InvoiceType `json:"type"`
// Current lifecycle status of the invoice.
Status InvoiceStandardStatus `json:"status"`
// Detailed status information including available actions and workflow state.
StatusDetails InvoiceStatusDetails `json:"status_details"`
// Timestamp when the invoice was issued to the customer.
IssuedAt *time.Time `json:"issued_at,omitempty"`
// Timestamp until which the invoice remains in draft state.
//
// The invoice advances automatically once this time is reached.
DraftUntil *time.Time `json:"draft_until,omitempty"`
// Timestamp when usage quantities were last snapshotted for this invoice.
QuantitySnapshottedAt *time.Time `json:"quantity_snapshotted_at,omitempty"`
// Timestamp when collection was initiated for this invoice.
CollectionAt *time.Time `json:"collection_at,omitempty"`
// Timestamp when payment is due.
DueAt *time.Time `json:"due_at,omitempty"`
// Timestamp when the invoice was sent to the customer.
SentToCustomerAt *time.Time `json:"sent_to_customer_at,omitempty"`
// Workflow configuration snapshot captured at invoice creation time.
Workflow InvoiceWorkflowSettings `json:"workflow"`
}
The invoice a charge realization was booked to, embedded as a header.
Matches the standard invoice entity, except that it carries no `customer` snapshot (the charge context already identifies the customer) and `lines` are never populated (the realization itself is the line-level breakdown). The shared invoice contract stays untouched: this model exists so the charges API can slim the embedding without loosening the invoices API.
type ChargeRealizationInvoiceOrReference ¶
type ChargeRealizationInvoiceOrReference struct {
// contains filtered or unexported fields
}
ChargeRealizationInvoice or reference.
ChargeRealizationInvoiceOrReference is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the ChargeRealizationInvoiceOrReferenceFrom* constructors.
func ChargeRealizationInvoiceOrReferenceFromChargeRealizationInvoice ¶
func ChargeRealizationInvoiceOrReferenceFromChargeRealizationInvoice(value ChargeRealizationInvoice) (ChargeRealizationInvoiceOrReference, error)
func ChargeRealizationInvoiceOrReferenceFromChargeRealizationInvoiceReference ¶
func ChargeRealizationInvoiceOrReferenceFromChargeRealizationInvoiceReference(value ChargeRealizationInvoiceReference) (ChargeRealizationInvoiceOrReference, error)
func (ChargeRealizationInvoiceOrReference) AsChargeRealizationInvoice ¶
func (u ChargeRealizationInvoiceOrReference) AsChargeRealizationInvoice() (*ChargeRealizationInvoice, error)
func (ChargeRealizationInvoiceOrReference) AsChargeRealizationInvoiceReference ¶
func (u ChargeRealizationInvoiceOrReference) AsChargeRealizationInvoiceReference() (*ChargeRealizationInvoiceReference, error)
func (ChargeRealizationInvoiceOrReference) MarshalJSON ¶
func (u ChargeRealizationInvoiceOrReference) MarshalJSON() ([]byte, error)
func (*ChargeRealizationInvoiceOrReference) UnmarshalJSON ¶
func (u *ChargeRealizationInvoiceOrReference) UnmarshalJSON(data []byte) error
type ChargeRealizationInvoiceReference ¶
type ChargeRealizationInvoiceReference struct {
ID string `json:"id"`
}
ChargeRealizationInvoice reference.
type ChargeRealizationPayment ¶
type ChargeRealizationPayment struct {
// The settlement status of the payment.
Status ChargeRealizationPaymentStatus `json:"status"`
}
Payment state of a charge realization.
type ChargeRealizationPaymentStatus ¶
type ChargeRealizationPaymentStatus string
Settlement status of a charge realization's payment.
Values:
- `authorized`: The payment has been authorized against the customer's ledger but has not settled yet. - `settled`: The payment has settled.
const ( ChargeRealizationPaymentStatusAuthorized ChargeRealizationPaymentStatus = "authorized" ChargeRealizationPaymentStatusSettled ChargeRealizationPaymentStatus = "settled" )
func (ChargeRealizationPaymentStatus) Valid ¶
func (value ChargeRealizationPaymentStatus) Valid() bool
type ChargeRealizationType ¶
type ChargeRealizationType string
Type of a charge realization run.
Values:
- `final_realization`: The run is the final realization of the charge for its service period; no further runs are expected to correct it. - `partial_invoice`: The run only realizes part of the charge, because the remainder is not yet due to be invoiced. - `outstanding`: The type an outstanding (not-yet-realized) projection would carry if it were realized now. Never returned on a booked realization run. - `voided`: The run's billing effect was undone (for example the charge's service period was extended while its invoice was still mutable); it is retained as audit history and excluded from aggregate and live calculations.
const ( ChargeRealizationTypeFinalRealization ChargeRealizationType = "final_realization" ChargeRealizationTypePartialInvoice ChargeRealizationType = "partial_invoice" ChargeRealizationTypeOutstanding ChargeRealizationType = "outstanding" ChargeRealizationTypeVoided ChargeRealizationType = "voided" )
func (ChargeRealizationType) Valid ¶
func (value ChargeRealizationType) Valid() bool
type ChargeReference ¶
type ChargeReference struct {
// Unique identifier for the charge.
ID string `json:"id"`
}
Reference to a charge associated with an invoice line.
type ChargeResolvedCostBasis ¶
type ChargeResolvedCostBasis struct {
// The fiat currency the charge amount is converted into for invoicing.
FiatCurrency string `json:"fiat_currency"`
// Fiat amount per one unit of the custom currency.
Rate Numeric `json:"rate"`
// ID of the custom currency's cost basis resource the rate was taken from. Absent
// for manual cost bases.
CostBasisID *string `json:"cost_basis_id,omitempty"`
// When the rate was resolved.
ResolvedAt time.Time `json:"resolved_at"`
}
Fiat conversion rate a custom-currency charge is invoiced at. Present once the cost basis is resolved; dynamic cost bases are exposed only after the service period has started.
type ChargeStatus ¶
type ChargeStatus string
Lifecycle status of a charge.
Values:
- `created`: The charge has been created but is not active yet. - `active`: The charge is active. - `final`: The charge is fully finalized and no further changes are expected. - `deleted`: The charge has been deleted.
const ( ChargeStatusCreated ChargeStatus = "created" ChargeStatusActive ChargeStatus = "active" ChargeStatusFinal ChargeStatus = "final" ChargeStatusDeleted ChargeStatus = "deleted" )
func (ChargeStatus) Valid ¶
func (value ChargeStatus) Valid() bool
type ChargeTotals ¶
type ChargeTotals struct {
// The amount of the charge already booked to the internal accounting system.
Booked Totals `json:"booked"`
// The realtime amount of the charge, i.e. the whole usage rated at the charge's
// price for its full service period, ignoring what has already been booked to a
// realization. This differs from the `usage` of a realization with type
// `outstanding`, which only covers the quantity not yet booked.
//
// Requires the `real_time_usage` expand.
Realtime *Totals `json:"realtime,omitempty"`
}
The totals of a charge.
`realtime` is only populated when the `real_time_usage` expand is used.
type ChargeType ¶
type ChargeType string
Type of a charge.
Values:
- `flat_fee`: A fixed-amount charge. - `usage_based`: A usage-priced charge.
const ( ChargeTypeFlatFee ChargeType = "flat_fee" ChargeTypeUsageBased ChargeType = "usage_based" )
func (ChargeType) Valid ¶
func (value ChargeType) Valid() bool
type ChargeUsageBased ¶
type ChargeUsageBased struct {
ID string `json:"id"`
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// The type of the charge.
Type ChargeType `json:"type"`
// The customer owning the charge.
//
// By default, only the `id` of the customer is returned. For more details use the
// `customer` expand.
Customer CustomerOrReference `json:"customer"`
// Indicates whether the charge lifecycle is controlled by the system or manually
// overridden by the API user.
LifecycleController LifecycleController `json:"lifecycle_controller"`
// The subscription that originated the charge, when the charge was created from a
// subscription item.
//
// By default, only the `id`, `phase.id`, `phase.item.id` of the subscription is
// returned. For more details use the `subscription` expand.
Subscription *SubscriptionOrReference `json:"subscription,omitempty"`
// The currency of the charge.
Currency BillingCurrencyCode `json:"currency"`
// The resolved fiat conversion rate of a custom-currency charge. Resolution
// depends on costbasis type: dynamic is resolved when charge becomes active, all
// other types resolved on creation.
ResolvedCostBasis *ChargeResolvedCostBasis `json:"resolved_cost_basis,omitempty"`
// The lifecycle status of the charge.
Status ChargeStatus `json:"status"`
// Validation issues found while processing the charge.
//
// Present only when there are one or more validation findings. An empty list is
// omitted.
ValidationIssues []ValidationIssue `json:"validation_issues,omitempty"`
// The timestamp when the charge is intended to be invoiced.
InvoiceAt time.Time `json:"invoice_at"`
// The effective service period covered by the charge.
ServicePeriod ClosedPeriod `json:"service_period"`
// The full, unprorated service period of the charge.
FullServicePeriod ClosedPeriod `json:"full_service_period"`
// The billing period the charge belongs to.
BillingPeriod ClosedPeriod `json:"billing_period"`
// The earliest time when the charge should be advanced again by background
// processing.
AdvanceAfter *time.Time `json:"advance_after,omitempty"`
// Unique reference ID of the charge.
UniqueReferenceID *string `json:"unique_reference_id,omitempty"`
// Settlement mode of the charge.
SettlementMode SettlementMode `json:"settlement_mode"`
// Tax configuration of the charge.
TaxConfig *TaxConfig `json:"tax_config,omitempty"`
// The realization runs of the charge, sorted by `created_at`.
Realizations []ChargeRealization `json:"realizations"`
// Discounts applied to the usage-based charge.
Discounts *RateCardDiscounts `json:"discounts,omitempty"`
// The feature associated with the charge.
Feature FeatureOrReference `json:"feature"`
// Aggregated booked and realtime totals for the charge.
Totals ChargeTotals `json:"totals"`
// The metered usage quantity of the charge for its full service period.
//
// Requires the `real_time_usage` expand, since it is computed live from the
// metering store rather than stored on the charge.
Usage *Numeric `json:"usage,omitempty"`
// The price of the charge.
//
// `free` prices are rejected on create: a usage-based charge always carries a
// concrete price.
Price PriceUsageBased `json:"price"`
// Spend commitments for the charge.
Commitments *SpendCommitments `json:"commitments,omitempty"`
// Unit conversion configuration for the charge.
//
// Synthesized on read for charges created from v1 dynamic or package prices:
// dynamic prices map to a unit price with a multiply unit config, and package
// prices map to a unit price with a divide unit config.
//
// Accepted on create only when the UnitConfig feature is enabled on the
// deployment; otherwise rejected.
UnitConfig *UnitConfig `json:"unit_config,omitempty"`
// Current intent from the system lifecycle controller for a charge that has an
// active manual override. The top-level charge fields remain the effective
// customer-facing intent.
SystemIntent *ChargeUsageBasedSystemIntent `json:"system_intent,omitempty"`
}
A usage-based charge for a customer.
type ChargeUsageBasedSystemIntent ¶
type ChargeUsageBasedSystemIntent struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// The timestamp when the charge is intended to be invoiced.
InvoiceAt time.Time `json:"invoice_at"`
// The effective service period covered by the charge.
ServicePeriod ClosedPeriod `json:"service_period"`
// The full, unprorated service period of the charge.
FullServicePeriod ClosedPeriod `json:"full_service_period"`
// The billing period the charge belongs to.
BillingPeriod ClosedPeriod `json:"billing_period"`
// Discounts applied to the usage-based charge.
Discounts *RateCardDiscounts `json:"discounts,omitempty"`
// The price of the charge.
//
// `free` prices are rejected on create: a usage-based charge always carries a
// concrete price.
Price PriceUsageBased `json:"price"`
// Spend commitments for the charge.
Commitments *SpendCommitments `json:"commitments,omitempty"`
// Unit conversion configuration for the charge.
//
// Synthesized on read for charges created from v1 dynamic or package prices:
// dynamic prices map to a unit price with a multiply unit config, and package
// prices map to a unit price with a divide unit config.
//
// Accepted on create only when the UnitConfig feature is enabled on the
// deployment; otherwise rejected.
UnitConfig *UnitConfig `json:"unit_config,omitempty"`
// The timestamp when the system lifecycle controller intent was deleted. The
// effective charge can remain visible while a manual override is active.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
}
Usage-based intent fields from the system lifecycle controller shadowed by a manual override.
type ChargesExpand ¶
type ChargesExpand string
Expands for customer charges.
Values:
- `real_time_usage`: Sets `usage` and `totals.realtime` for active usage-based charges and created usage-based charges whose effective service period contains the current time (inclusive start, exclusive end). Deleted charges are skipped. When present, the `outstanding` realization's `usage` shows the unbooked remainder of the live read. - `customer`: The complete customer entity of the charge. - `feature`: The complete feature entity of the charge. - `subscription`: The complete subscription of the charge, when present. - `realization.invoice`: The invoice header of each realization (the invoice entity without its `lines` and `customer` snapshot), in place of the ID reference. - `realization.totals`: The `totals` of each realization run, including credit allocations. - `realization.detailed_lines`: The `detailed_lines` of each realization run.
const ( ChargesExpandRealTimeUsage ChargesExpand = "real_time_usage" ChargesExpandCustomer ChargesExpand = "customer" ChargesExpandFeature ChargesExpand = "feature" ChargesExpandSubscription ChargesExpand = "subscription" ChargesExpandRealizationInvoice ChargesExpand = "realization.invoice" ChargesExpandRealizationTotals ChargesExpand = "realization.totals" ChargesExpandRealizationDetailedLines ChargesExpand = "realization.detailed_lines" )
func (ChargesExpand) Valid ¶
func (value ChargesExpand) Valid() bool
type ChargesService ¶
type ChargesService struct {
// contains filtered or unexported fields
}
func (*ChargesService) Get ¶
func (s *ChargesService) Get(ctx context.Context, chargeID string, params GetChargeParams) (*Charge, error)
Get a flat fee or usage-based charge by ID.
Deleted charges are returned with their status and realization history.
func (*ChargesService) List ¶
func (s *ChargesService) List(ctx context.Context, params ListChargesParams) (*ChargePagePaginatedResponse, error)
List charges.
Returns the charges of every customer that are represented as either flat fee or usage-based charges.
func (*ChargesService) ListAll ¶
func (s *ChargesService) ListAll(ctx context.Context, params ListChargesParams) iter.Seq2[Charge, error]
ListAll returns an iterator over all Charge results, fetching pages of List transparently. Iteration stops at the first error, which is yielded as the second value.
type Client ¶
type Client struct {
Events *EventsService
Meters *MetersService
Customers *CustomersService
Entitlements *EntitlementsService
Grants *GrantsService
Subscriptions *SubscriptionsService
Apps *AppsService
Billing *BillingService
Invoices *InvoicesService
Charges *ChargesService
Tax *TaxService
Currencies *CurrenciesService
Features *FeaturesService
LLMCost *LLMCostService
Plans *PlansService
Addons *AddonsService
PlanAddons *PlanAddonsService
Defaults *DefaultsService
EntitlementAccess *EntitlementAccessService
Notifications *NotificationsService
// contains filtered or unexported fields
}
type ClosedPeriod ¶
type ClosedPeriod struct {
// The start of the period.
//
// The period is inclusive at the start.
From time.Time `json:"from"`
// The end of the period.
//
// The period is exclusive at the end.
To time.Time `json:"to"`
}
A period with defined start and end dates.
The period is always inclusive at the start and exclusive at the end.
type CollectionAlignment ¶
type CollectionAlignment string
BillingCollectionAlignment specifies when the pending line items should be collected into an invoice.
const ( CollectionAlignmentSubscription CollectionAlignment = "subscription" CollectionAlignmentAnchored CollectionAlignment = "anchored" )
func (CollectionAlignment) Valid ¶
func (value CollectionAlignment) Valid() bool
type CollectionMethod ¶
type CollectionMethod string
Collection method specifies how the invoice should be collected (automatic or manual).
const ( CollectionMethodChargeAutomatically CollectionMethod = "charge_automatically" CollectionMethodSendInvoice CollectionMethod = "send_invoice" )
func (CollectionMethod) Valid ¶
func (value CollectionMethod) Valid() bool
type CostBasis ¶
type CostBasis struct {
ID string `json:"id"`
// The fiat currency code for the cost basis.
FiatCode string `json:"fiat_code"`
// The cost rate for the currency.
Rate Numeric `json:"rate"`
// An ISO-8601 timestamp representation of the date from which the cost basis is
// effective. If not provided, it will be effective immediately and will be set to
// `now` by the system.
EffectiveFrom *time.Time `json:"effective_from,omitempty"`
// An ISO-8601 timestamp representation of the date until which the cost basis is
// effective. If provided, it must be later than `effective_from`. If not provided,
// it remains effective until superseded.
EffectiveTo *time.Time `json:"effective_to,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
}
Describes currency basis supported by billing system.
type CostBasisFilter ¶
type CostBasisFilter struct {
// Filter cost bases by fiat currency code.
FiatCode *string
}
type CostBasisListParams ¶
type CostBasisListParams struct {
Filter *CostBasisFilter
Page *PageParams
}
type CostBasisPagePaginatedResponse ¶
type CostBasisPagePaginatedResponse struct {
Data []CostBasis `json:"data"`
Meta PaginatedMeta `json:"meta"`
}
Page paginated response.
type CreateAddonRequest ¶
type CreateAddonRequest struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
// A key is a semi-unique string that is used to identify the add-on. It is used to
// reference the latest `active` version of the add-on and is unique with the
// version number.
Key string `json:"key"`
// The InstanceType of the add-ons. Can be "single" or "multiple".
InstanceType AddonInstanceType `json:"instance_type"`
// The currency code of the add-on.
Currency BillingCurrencyCode `json:"currency"`
// The rate cards of the add-on.
RateCards []RateCardInput `json:"rate_cards"`
}
Addon create request.
type CreateBillingProfileRequest ¶
type CreateBillingProfileRequest struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
// The name and contact information for the supplier this billing profile
// represents
Supplier Party `json:"supplier"`
// The billing workflow settings for this profile
Workflow Workflow `json:"workflow"`
// The applications used by this billing profile.
Apps ProfileAppReferences `json:"apps"`
// Whether this is the default profile.
Default bool `json:"default"`
}
BillingProfile create request.
type CreateChargeFlatFeeRequest ¶
type CreateChargeFlatFeeRequest struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
// The type of the charge.
Type ChargeType `json:"type"`
// The currency of the charge.
Currency BillingCurrencyCode `json:"currency"`
// Defines how a custom-currency charge is converted into its fiat invoice
// currency; the resolved rate is exposed through `resolved_cost_basis`. Required
// when `currency` is custom and the charge settles as `credit_then_invoice`; must
// be omitted otherwise.
CostBasis *ChargeCostBasis `json:"cost_basis,omitempty"`
// The timestamp when the charge is intended to be invoiced.
InvoiceAt time.Time `json:"invoice_at"`
// The effective service period covered by the charge.
ServicePeriod ClosedPeriod `json:"service_period"`
// Unique reference ID of the charge.
UniqueReferenceID *string `json:"unique_reference_id,omitempty"`
// Settlement mode of the charge.
SettlementMode SettlementMode `json:"settlement_mode"`
// Tax configuration of the charge.
TaxConfig *TaxConfig `json:"tax_config,omitempty"`
// Payment term of the flat fee charge.
PaymentTerm PricePaymentTerm `json:"payment_term"`
// The discounts applied to the charge.
Discounts *ChargeFlatFeeDiscounts `json:"discounts,omitempty"`
// The proration configuration of the charge.
ProrationConfiguration RateCardProrationConfiguration `json:"proration_configuration"`
// The amount before proration of the charge.
AmountBeforeProration CurrencyAmount `json:"amount_before_proration"`
// A reference to the feature associated with the charge, when applicable.
Feature *FeatureReference `json:"feature,omitempty"`
// The full, unprorated service period of the charge.
FullServicePeriod *ClosedPeriod `json:"full_service_period,omitempty"`
// The billing period the charge belongs to.
BillingPeriod *ClosedPeriod `json:"billing_period,omitempty"`
}
Flat fee charge create request.
type CreateChargeRequest ¶
type CreateChargeRequest struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
Customer charge.
CreateChargeRequest is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the CreateChargeRequestFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func CreateChargeRequestFromCreateChargeFlatFeeRequest ¶
func CreateChargeRequestFromCreateChargeFlatFeeRequest(value CreateChargeFlatFeeRequest) (CreateChargeRequest, error)
func CreateChargeRequestFromCreateChargeUsageBasedRequest ¶
func CreateChargeRequestFromCreateChargeUsageBasedRequest(value CreateChargeUsageBasedRequest) (CreateChargeRequest, error)
func (CreateChargeRequest) AsCreateChargeFlatFeeRequest ¶
func (u CreateChargeRequest) AsCreateChargeFlatFeeRequest() (*CreateChargeFlatFeeRequest, error)
func (CreateChargeRequest) AsCreateChargeUsageBasedRequest ¶
func (u CreateChargeRequest) AsCreateChargeUsageBasedRequest() (*CreateChargeUsageBasedRequest, error)
func (CreateChargeRequest) MarshalJSON ¶
func (u CreateChargeRequest) MarshalJSON() ([]byte, error)
func (*CreateChargeRequest) UnmarshalJSON ¶
func (u *CreateChargeRequest) UnmarshalJSON(data []byte) error
type CreateChargeUsageBasedRequest ¶
type CreateChargeUsageBasedRequest struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
// The type of the charge.
Type ChargeType `json:"type"`
// The currency of the charge.
Currency BillingCurrencyCode `json:"currency"`
// Defines how a custom-currency charge is converted into its fiat invoice
// currency; the resolved rate is exposed through `resolved_cost_basis`. Required
// when `currency` is custom and the charge settles as `credit_then_invoice`; must
// be omitted otherwise.
CostBasis *ChargeCostBasis `json:"cost_basis,omitempty"`
// The timestamp when the charge is intended to be invoiced.
InvoiceAt time.Time `json:"invoice_at"`
// The effective service period covered by the charge.
ServicePeriod ClosedPeriod `json:"service_period"`
// Unique reference ID of the charge.
UniqueReferenceID *string `json:"unique_reference_id,omitempty"`
// Settlement mode of the charge.
SettlementMode SettlementMode `json:"settlement_mode"`
// Tax configuration of the charge.
TaxConfig *TaxConfig `json:"tax_config,omitempty"`
// Discounts applied to the usage-based charge.
Discounts *RateCardDiscounts `json:"discounts,omitempty"`
// The price of the charge.
//
// `free` prices are rejected on create: a usage-based charge always carries a
// concrete price.
Price PriceUsageBased `json:"price"`
// Spend commitments for the charge.
Commitments *SpendCommitments `json:"commitments,omitempty"`
// Unit conversion configuration for the charge.
//
// Synthesized on read for charges created from v1 dynamic or package prices:
// dynamic prices map to a unit price with a multiply unit config, and package
// prices map to a unit price with a divide unit config.
//
// Accepted on create only when the UnitConfig feature is enabled on the
// deployment; otherwise rejected.
UnitConfig *UnitConfig `json:"unit_config,omitempty"`
// A reference to the feature associated with the charge.
Feature FeatureReference `json:"feature"`
// The full, unprorated service period of the charge.
FullServicePeriod *ClosedPeriod `json:"full_service_period,omitempty"`
// The billing period the charge belongs to.
BillingPeriod *ClosedPeriod `json:"billing_period,omitempty"`
}
Usage-based charge create request.
type CreateCostBasisRequest ¶
type CreateCostBasisRequest struct {
// The fiat currency code for the cost basis.
FiatCode string `json:"fiat_code"`
// The cost rate for the currency.
Rate Numeric `json:"rate"`
// An ISO-8601 timestamp representation of the date from which the cost basis is
// effective. If not provided, it will be effective immediately and will be set to
// `now` by the system.
EffectiveFrom *time.Time `json:"effective_from,omitempty"`
// An ISO-8601 timestamp representation of the date until which the cost basis is
// effective. If provided, it must be later than `effective_from`. If not provided,
// it remains effective until superseded.
EffectiveTo *time.Time `json:"effective_to,omitempty"`
}
CostBasis create request.
type CreateCreditAdjustmentRequest ¶
type CreateCreditAdjustmentRequest struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
// The currency of the granted credits.
Currency BillingCurrencyCode `json:"currency"`
// Granted credit amount.
Amount Numeric `json:"amount"`
}
CreditAdjustment create request.
type CreateCreditGrantFilters ¶
type CreateCreditGrantFilters struct {
// Limit the credit grant to specific features. If no features are specified, the
// credit grant can be used for any feature.
Features *[]string `json:"features,omitempty"`
// Limit credits to charges from these plans. Entries are alternatives; when
// features are also specified, both dimensions must match. Omission or an empty
// list leaves plans unrestricted.
Plans *[]CreateCreditGrantPlanFilter `json:"plans,omitempty"`
}
Filters for the credit grant.
type CreateCreditGrantPlanFilter ¶
type CreateCreditGrantPlanFilter struct {
// The plan key in the customer's namespace.
Key string `json:"key"`
// Omission matches all versions, including future versions.
Version *CreateVersionFilter `json:"version,omitempty"`
}
A plan key and an optional version constraint for matching credit grants.
type CreateCreditGrantPurchase ¶
type CreateCreditGrantPurchase struct {
// Fiat currency the purchase is settled in.
//
// Must equal the grant `currency` for fiat grants and `cost_basis.fiat_currency`
// for custom-currency grants.
Currency string `json:"currency"`
// Fiat cost basis per credit unit of a fiat-currency grant.
//
// If `per_unit_cost_basis` is 0.50 and credit amount is
// $100.00, the total
// charge is $50.00. The value must be greater than 0. If the
// cost basis is 0, use `funding_method=none` instead.
//
// Only applies to fiat grants and cannot be combined with `cost_basis`. Defaults
// to 1.0 when neither is provided.
PerUnitCostBasis *Numeric `json:"per_unit_cost_basis,omitempty"`
// Defines how custom-currency credits are priced in the purchase `currency`; the
// resolved rate is exposed through `resolved_cost_basis`.
//
// Fiat grants accept only a `manual` cost basis without `fiat_currency`, where
// `rate` is the fiat cost per credit unit. Custom-currency grants require a cost
// basis of any type with `fiat_currency` set and equal to the purchase `currency`.
// A `dynamic` cost basis is resolved at the grant's effective time, so the
// currency cost basis must be effective by then. Cannot be combined with
// `per_unit_cost_basis`.
CostBasis *ChargeCostBasis `json:"cost_basis,omitempty"`
// Controls when credits become available for consumption.
//
// Defaults to `on_creation`.
AvailabilityPolicy *CreditAvailabilityPolicy `json:"availability_policy,omitempty"`
}
Purchase and payment terms of the grant.
type CreateCreditGrantRequest ¶
type CreateCreditGrantRequest struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
// Funding method of the grant.
FundingMethod CreditFundingMethod `json:"funding_method"`
// The fiat or custom currency of the granted credits.
//
// Funded custom-currency grants must define `purchase.cost_basis` to settle in a
// fiat currency.
Currency BillingCurrencyCode `json:"currency"`
// Granted credit amount.
Amount Numeric `json:"amount"`
// Present when a funding workflow applies (funding_method is not `none`).
Purchase *CreateCreditGrantPurchase `json:"purchase,omitempty"`
// Tax configuration for the grant.
//
// For `invoice` and `external` funding methods, tax configuration should be
// provided to ensure correct revenue recognition. When not provided, the default
// credit grant tax code is applied, if that's not set the global default taxcode
// is used.
TaxConfig *TaxCodeConfig `json:"tax_config,omitempty"`
Filters *CreateCreditGrantFilters `json:"filters,omitempty"`
// Draw-down priority of the grant. Lower values have higher priority.
Priority *int16 `json:"priority,omitempty"`
// The timestamp when the credit grant becomes effective.
//
// Defaults to the current date and time.
EffectiveAt *time.Time `json:"effective_at,omitempty"`
// The duration after which the credit grant expires.
//
// Defaults to never expiring.
ExpiresAfter *string `json:"expires_after,omitempty"`
// Idempotency key for the credit grant creation request.
//
// Unique per customer: reusing the same key for the same customer returns an HTTP
// 409 Conflict instead of creating a duplicate grant, which makes create requests
// safe to retry. The same key may be reused across different customers.
Key *string `json:"key,omitempty"`
}
CreditGrant create request.
type CreateCurrencyCustomRequest ¶
type CreateCurrencyCustomRequest struct {
// The name of the currency. It should be a human-readable string that represents
// the name of the currency, such as "US Dollar" or "Euro".
Name string `json:"name"`
// The symbol of the currency. It should be a string that represents the symbol of
// the currency, such as "$" for US Dollar or "€" for Euro.
Symbol *string `json:"symbol,omitempty"`
// The precision of the currency. It should be a number that represents the number
// of decimal places used for the currency, such as 2 for US Dollar or Euro.
Precision uint32 `json:"precision"`
// The decimal mark for the currency. It should be a string that represents the
// decimal mark of the currency, such as "." for US Dollar or "," for Euro.
DecimalMark string `json:"decimal_mark"`
// The thousand separator for the currency. It should be a string that represents
// the thousand separator of the currency, such as "," for US Dollar or "." for
// Euro.
ThousandSeparator string `json:"thousand_separator"`
Code string `json:"code"`
}
CurrencyCustom create request.
type CreateCustomerRequest ¶
type CreateCustomerRequest struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
Key string `json:"key"`
// Mapping to attribute metered usage to the customer by the event subject.
UsageAttribution *CustomerUsageAttribution `json:"usage_attribution,omitempty"`
// The primary email address of the customer.
PrimaryEmail *string `json:"primary_email,omitempty"`
// Currency of the customer. Used for billing, tax and invoicing.
Currency *string `json:"currency,omitempty"`
// The billing address of the customer. Used for tax and invoicing.
BillingAddress *Address `json:"billing_address,omitempty"`
}
Customer create request.
type CreateEntitlementBooleanRequest ¶
type CreateEntitlementBooleanRequest struct {
// The type of the entitlement.
Type EntitlementType `json:"type"`
// The feature the customer is entitled to use.
Feature FeatureReference `json:"feature"`
Labels *map[string]string `json:"labels,omitempty"`
// The usage period of the entitlement. The anchor defaults to the entitlement
// creation time.
UsagePeriod *RecurringPeriodInput `json:"usage_period,omitempty"`
}
Boolean entitlement create request.
type CreateEntitlementMeteredRequest ¶
type CreateEntitlementMeteredRequest struct {
// The type of the entitlement.
Type EntitlementType `json:"type"`
// The feature the customer is entitled to use.
Feature FeatureReference `json:"feature"`
Labels *map[string]string `json:"labels,omitempty"`
// If true, the customer keeps access to the feature after the balance is
// exhausted.
IsSoftLimit *bool `json:"is_soft_limit,omitempty"`
// Usage granted automatically after each reset. Cannot be combined with `grants`.
Issue *EntitlementIssueAfterReset `json:"issue,omitempty"`
// The amount granted automatically after each reset.
IssueAfterReset *Numeric `json:"issue_after_reset,omitempty"`
// The priority of the grant created after each reset.
IssueAfterResetPriority *uint8 `json:"issue_after_reset_priority,omitempty"`
// If true, the overage is preserved at reset. If false, the usage is reset to 0.
PreserveOverageAtReset *bool `json:"preserve_overage_at_reset,omitempty"`
// The usage period of the entitlement. The balance resets at the start of every
// period. The anchor defaults to the entitlement creation time.
UsagePeriod RecurringPeriodInput `json:"usage_period"`
// The time from which usage is measured. Defaults to the entitlement creation
// time.
MeasureUsageFrom *EntitlementMeasureUsageFrom `json:"measure_usage_from,omitempty"`
// Grants created together with the entitlement. Cannot be combined with `issue`.
Grants *[]EntitlementGrantCreateRequest `json:"grants,omitempty"`
}
Metered entitlement create request.
type CreateEntitlementRequest ¶
type CreateEntitlementRequest struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
Entitlement create request.
CreateEntitlementRequest is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the CreateEntitlementRequestFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func CreateEntitlementRequestFromCreateEntitlementBooleanRequest ¶
func CreateEntitlementRequestFromCreateEntitlementBooleanRequest(value CreateEntitlementBooleanRequest) (CreateEntitlementRequest, error)
func CreateEntitlementRequestFromCreateEntitlementMeteredRequest ¶
func CreateEntitlementRequestFromCreateEntitlementMeteredRequest(value CreateEntitlementMeteredRequest) (CreateEntitlementRequest, error)
func CreateEntitlementRequestFromCreateEntitlementStaticRequest ¶
func CreateEntitlementRequestFromCreateEntitlementStaticRequest(value CreateEntitlementStaticRequest) (CreateEntitlementRequest, error)
func (CreateEntitlementRequest) AsCreateEntitlementBooleanRequest ¶
func (u CreateEntitlementRequest) AsCreateEntitlementBooleanRequest() (*CreateEntitlementBooleanRequest, error)
func (CreateEntitlementRequest) AsCreateEntitlementMeteredRequest ¶
func (u CreateEntitlementRequest) AsCreateEntitlementMeteredRequest() (*CreateEntitlementMeteredRequest, error)
func (CreateEntitlementRequest) AsCreateEntitlementStaticRequest ¶
func (u CreateEntitlementRequest) AsCreateEntitlementStaticRequest() (*CreateEntitlementStaticRequest, error)
func (CreateEntitlementRequest) MarshalJSON ¶
func (u CreateEntitlementRequest) MarshalJSON() ([]byte, error)
func (*CreateEntitlementRequest) UnmarshalJSON ¶
func (u *CreateEntitlementRequest) UnmarshalJSON(data []byte) error
type CreateEntitlementStaticRequest ¶
type CreateEntitlementStaticRequest struct {
// The type of the entitlement.
Type EntitlementType `json:"type"`
// The feature the customer is entitled to use.
Feature FeatureReference `json:"feature"`
Labels *map[string]string `json:"labels,omitempty"`
// The entitlement configuration as a JSON value. Returned when checking
// entitlement access.
Config any `json:"config"`
// The usage period of the entitlement. The anchor defaults to the entitlement
// creation time.
UsagePeriod *RecurringPeriodInput `json:"usage_period,omitempty"`
}
Static entitlement create request.
type CreateFeatureRequest ¶
type CreateFeatureRequest struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
Key string `json:"key"`
// The meter that the feature is associated with and based on which usage is
// calculated. If not specified, the feature is static.
Meter *FeatureMeterReferenceInput `json:"meter,omitempty"`
// Optional per-unit cost configuration. Use "manual" for a fixed per-unit cost, or
// "llm" to look up cost from the LLM cost database based on meter group-by
// properties.
UnitCost *FeatureUnitCost `json:"unit_cost,omitempty"`
}
Feature create request.
type CreateMeterRequest ¶
type CreateMeterRequest struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
Key string `json:"key"`
// The aggregation type to use for the meter.
Aggregation MeterAggregation `json:"aggregation"`
// The event type to include in the aggregation.
EventType string `json:"event_type"`
// The date since the meter should include events. Useful to skip old events. If
// not specified, all historical events are included.
EventsFrom *time.Time `json:"events_from,omitempty"`
// JSONPath expression to extract the value from the ingested event's data
// property.
//
// The ingested value for sum, avg, min, and max aggregations is a number or a
// string that can be parsed to a number.
//
// For unique_count aggregation, the ingested value must be a string. For count
// aggregation the value_property is ignored.
ValueProperty *string `json:"value_property,omitempty"`
// Named JSONPath expressions to extract the group by values from the event data.
//
// Keys must be unique and consist only alphanumeric and underscore characters.
Dimensions *map[string]string `json:"dimensions,omitempty"`
}
Meter create request.
type CreateNotificationChannelRequest ¶
type CreateNotificationChannelRequest struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
Labels *map[string]string `json:"labels,omitempty"`
// The type of the channel. Immutable after creation.
Type NotificationChannelType `json:"type"`
// Whether the channel is disabled. Disabled channels do not receive notification
// events.
Disabled *bool `json:"disabled,omitempty"`
// The URL that webhook notification events are delivered to.
URL string `json:"url"`
// Custom HTTP headers to include on every webhook delivery request, keyed by
// header name.
CustomHeaders *map[string]string `json:"custom_headers,omitempty"`
// Secret used to sign outgoing webhook payloads so recipients can verify their
// authenticity. If omitted on create, a secret is generated automatically by the
// delivery provider. This is a sensitive credential returned in responses (unlike
// most secrets) specifically so clients can retrieve a server-generated value and
// verify webhook signatures; handle it with the same care as any other credential.
SigningSecret *string `json:"signing_secret,omitempty"`
}
NotificationChannel create request.
type CreatePlanAddonRequest ¶
type CreatePlanAddonRequest struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
// The add-on associated with the plan.
Addon AddonReference `json:"addon"`
// The key of the plan phase from which the add-on becomes available for purchase.
FromPlanPhase string `json:"from_plan_phase"`
// The maximum number of times the add-on can be purchased for the plan. For
// single-instance add-ons this field must be omitted. For multi-instance add-ons
// when omitted, unlimited quantity can be purchased.
MaxQuantity *int64 `json:"max_quantity,omitempty"`
}
PlanAddon create request.
type CreatePlanRequest ¶
type CreatePlanRequest struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
// A key is a semi-unique string that is used to identify the plan. It is used to
// reference the latest `active` version of the plan and is unique with the version
// number.
Key string `json:"key"`
// The currency code of the plan.
Currency BillingCurrencyCode `json:"currency"`
// The billing cadence for subscriptions using this plan.
BillingCadence string `json:"billing_cadence"`
// Whether pro-rating is enabled for this plan.
ProRatingEnabled *bool `json:"pro_rating_enabled,omitempty"`
// The plan phases define the pricing ramp for a subscription. A phase switch
// occurs only at the end of a billing period. At least one phase is required.
Phases []PlanPhaseInput `json:"phases"`
// Settlement mode for the plan. Defaults to `credit_then_invoice` when omitted.
SettlementMode *SettlementMode `json:"settlement_mode,omitempty"`
}
Plan create request. `settlement_mode` is re-declared as optional with a `credit_then_invoice` default, applied only on create.
type CreateSubscriptionAddonRequest ¶
type CreateSubscriptionAddonRequest struct {
Labels *map[string]string `json:"labels,omitempty"`
// The add-on associated with the subscription.
Addon AddonReference `json:"addon"`
// The quantity of the add-on. Always 1 for single instance add-ons.
Quantity int64 `json:"quantity"`
// The timing of the operation. After the create or update, a new entry will be
// created in the timeline.
Timing SubscriptionEditTiming `json:"timing"`
}
SubscriptionAddon create request.
type CreateTaxCodeRequest ¶
type CreateTaxCodeRequest struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
Key string `json:"key"`
// Mapping of app types to tax codes.
AppMappings []TaxCodeAppMapping `json:"app_mappings"`
}
TaxCode create request.
type CreateVersionFilter ¶
type CreateVersionFilter struct {
// Match this exact version.
Eq *int32 `json:"eq,omitempty"`
// Match one of these versions.
Oeq *[]int32 `json:"oeq,omitempty"`
// Match this version and later versions.
Gte *int32 `json:"gte,omitempty"`
// Match this version and earlier versions.
Lte *int32 `json:"lte,omitempty"`
}
An integer version comparison. Exactly one operator must be provided.
type CreditAdjustment ¶
type CreditAdjustment struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
}
A credit adjustment can be used to make manual adjustments to a customer's credit balance.
Supported use-cases:
- Usage correction
type CreditAvailabilityPolicy ¶
type CreditAvailabilityPolicy string
When credits become available for consumption.
- `on_creation`: Credits are available as soon as the grant is created. - `on_authorization`: Credits are available once the payment is authorized. - `on_settlement`: Credits are available once the payment is settled.
const (
CreditAvailabilityPolicyOnCreation CreditAvailabilityPolicy = "on_creation"
)
func (CreditAvailabilityPolicy) Valid ¶
func (value CreditAvailabilityPolicy) Valid() bool
type CreditBalance ¶
type CreditBalance struct {
Currency BillingCurrencyCode `json:"currency"`
// Managed currency reference. Present only for custom currencies.
CustomCurrency *CurrencyCustomReference `json:"custom_currency,omitempty"`
// Spendable balance after applying currently live, unbooked charge impacts. Can be
// negative when usage exceeds available credit.
//
// Always zero for historical balance queries using the `timestamp` parameter
// because live charge impacts cannot be reconstructed historically.
Live Numeric `json:"live"`
// Credits that have been booked on the ledger as of the balance timestamp,
// including credit-only advance debt. Can be negative.
Booked Numeric `json:"booked"`
// Deprecated alias for `booked`. Always returns the same value.
Settled Numeric `json:"settled"`
// Spendable credit at the balance timestamp, including any credit-only advance
// debt. Preserves credit already committed to later usage. Future grants cannot be
// spent early; scheduled expiry reduces availability when it takes effect. Can be
// negative when advance debt exceeds spendable credit.
Spendable Numeric `json:"spendable"`
// Credits that have been granted but are not yet written to the ledger, or are
// written to the ledger with a future booked time.
Pending Numeric `json:"pending"`
}
The credit balance by currency.
type CreditBalances ¶
type CreditBalances struct {
// The timestamp of the balance retrieval.
RetrievedAt time.Time `json:"retrieved_at"`
// The balances by currencies.
Balances []CreditBalance `json:"balances"`
}
The balances of the credits of a customer.
type CreditFundingMethod ¶
type CreditFundingMethod string
The funding method describes how the grant is funded.
- `none`: No funding workflow applies, for example promotional grants - `invoice`: The grant is funded by an in-system invoice flow - `external`: The grant is funded outside the system (e.g., wire transfer, external invoice, or manual reconciliation)
const ( CreditFundingMethodNone CreditFundingMethod = "none" CreditFundingMethodInvoice CreditFundingMethod = "invoice" CreditFundingMethodExternal CreditFundingMethod = "external" )
func (CreditFundingMethod) Valid ¶
func (value CreditFundingMethod) Valid() bool
type CreditGrant ¶
type CreditGrant struct {
ID string `json:"id"`
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// Funding method of the grant.
FundingMethod CreditFundingMethod `json:"funding_method"`
// The fiat or custom currency of the granted credits.
//
// Funded custom-currency grants must define `purchase.cost_basis` to settle in a
// fiat currency.
Currency BillingCurrencyCode `json:"currency"`
// Managed currency reference. Present only for custom currencies.
CustomCurrency *CurrencyCustomReference `json:"custom_currency,omitempty"`
// Granted credit amount.
Amount Numeric `json:"amount"`
// Present when a funding workflow applies (funding_method is not `none`).
Purchase *CreditGrantPurchase `json:"purchase,omitempty"`
// Tax configuration for the grant.
//
// For `invoice` and `external` funding methods, tax configuration should be
// provided to ensure correct revenue recognition. When not provided, the default
// credit grant tax code is applied, if that's not set the global default taxcode
// is used.
TaxConfig *TaxCodeConfig `json:"tax_config,omitempty"`
// Available when `funding_method` is `invoice`.
Invoice *CreditGrantInvoiceReference `json:"invoice,omitempty"`
Filters *CreditGrantFilters `json:"filters,omitempty"`
// Draw-down priority of the grant. Lower values have higher priority.
Priority *int16 `json:"priority,omitempty"`
// The timestamp when the credit grant becomes effective.
//
// Defaults to the current date and time.
EffectiveAt *time.Time `json:"effective_at,omitempty"`
// Idempotency key for the credit grant creation request.
//
// Unique per customer: reusing the same key for the same customer returns an HTTP
// 409 Conflict instead of creating a duplicate grant, which makes create requests
// safe to retry. The same key may be reused across different customers.
Key *string `json:"key,omitempty"`
// The timestamp when the credit grant expires.
//
// Calculated from the grant effective time and `expires_after` if provided.
ExpiresAt *time.Time `json:"expires_at,omitempty"`
// Timestamp when the grant was voided.
VoidedAt *time.Time `json:"voided_at,omitempty"`
// Current lifecycle status of the grant.
Status CreditGrantStatus `json:"status"`
// Validation issues found while processing the credit grant.
//
// Present only when there are one or more validation findings. An empty list is
// omitted.
ValidationIssues []ValidationIssue `json:"validation_issues,omitempty"`
}
A credit grant allocates credits to a customer.
Credits are drawn down against charges according to the settlement mode configured on the rate card.
type CreditGrantFilter ¶
type CreditGrantFilter struct {
// Filter credit grants by status.
Status *CreditGrantStatus
// Filter credit grants by fiat or custom currency code.
Currency *BillingCurrencyCode
// Filter credit grants by key.
Key *StringFilter
// Select grants spendable on any requested feature, including grants without
// feature restrictions. Keys are case-sensitive. Supports `eq` (or shorthand) and
// `oeq` with comma-separated keys. Omit to include all features; use
// `exists=false` for grants without feature restrictions.
FeatureKey *StringFilter
}
type CreditGrantFilters ¶
type CreditGrantFilters struct {
// Limit the credit grant to specific features. If no features are specified, the
// credit grant can be used for any feature.
Features []string `json:"features,omitempty"`
// Limit credits to charges from these plans. Entries are alternatives; when
// features are also specified, both dimensions must match. Omission or an empty
// list leaves plans unrestricted.
Plans []CreditGrantPlanFilter `json:"plans,omitempty"`
}
Filters for the credit grant.
type CreditGrantInvoiceReference ¶
type CreditGrantInvoiceReference struct {
// Identifier of the invoice associated with the grant.
ID *string `json:"id,omitempty"`
// Identifier of the invoice line associated with the grant.
Line *CreditGrantInvoiceReferenceLine `json:"line,omitempty"`
}
Invoice references for the grant.
type CreditGrantInvoiceReferenceLine ¶
type CreditGrantInvoiceReferenceLine struct {
ID string `json:"id"`
}
type CreditGrantListParams ¶
type CreditGrantListParams struct {
Page *PageParams
Sort *Sort
Filter *CreditGrantFilter
}
type CreditGrantPagePaginatedResponse ¶
type CreditGrantPagePaginatedResponse struct {
Data []CreditGrant `json:"data"`
Meta PaginatedMeta `json:"meta"`
}
Page paginated response.
type CreditGrantPlanFilter ¶
type CreditGrantPlanFilter struct {
// The plan key in the customer's namespace.
Key string `json:"key"`
// Omission matches all versions, including future versions.
Version *VersionFilter `json:"version,omitempty"`
}
A plan key and an optional version constraint for matching credit grants.
type CreditGrantPurchase ¶
type CreditGrantPurchase struct {
// Fiat currency the purchase is settled in.
//
// Must equal the grant `currency` for fiat grants and `cost_basis.fiat_currency`
// for custom-currency grants.
Currency string `json:"currency"`
// Fiat cost basis per credit unit of a fiat-currency grant.
//
// If `per_unit_cost_basis` is 0.50 and credit amount is
// $100.00, the total
// charge is $50.00. The value must be greater than 0. If the
// cost basis is 0, use `funding_method=none` instead.
//
// Only applies to fiat grants and cannot be combined with `cost_basis`. Defaults
// to 1.0 when neither is provided.
PerUnitCostBasis *Numeric `json:"per_unit_cost_basis,omitempty"`
// The rate the purchase is settled at in the purchase `currency`. Present once the
// cost basis is resolved.
ResolvedCostBasis *ChargeResolvedCostBasis `json:"resolved_cost_basis,omitempty"`
// The purchase amount, calculated from the resolved cost basis and credit
// `amount`. Present once the cost basis is resolved.
Amount *Numeric `json:"amount,omitempty"`
// Controls when credits become available for consumption.
//
// Defaults to `on_creation`.
AvailabilityPolicy *CreditAvailabilityPolicy `json:"availability_policy,omitempty"`
// Current payment settlement status.
SettlementStatus *CreditPurchasePaymentSettlementStatus `json:"settlement_status,omitempty"`
}
Purchase and payment terms of the grant.
type CreditGrantStatus ¶
type CreditGrantStatus string
Credit grant lifecycle status.
- `pending`: The credit block has been created but is not yet valid. (`effective_at` is in the future or availability_policy is not met) - `active`: The credit block is currently valid and eligible for consumption. (`effective_at` is in the past, `expires_at` is in the future and availability_policy is met) - `expired`: The credit block expired with remaining unused balance, `expires_at` time has passed. - `voided`: The credit block was voided. Remaining balance is forfeited.
const ( CreditGrantStatusPending CreditGrantStatus = "pending" CreditGrantStatusActive CreditGrantStatus = "active" CreditGrantStatusExpired CreditGrantStatus = "expired" CreditGrantStatusVoided CreditGrantStatus = "voided" )
func (CreditGrantStatus) Valid ¶
func (value CreditGrantStatus) Valid() bool
type CreditGrantVoidPaymentAdjustment ¶
type CreditGrantVoidPaymentAdjustment string
Describes how voiding a credit grant adjusts related payment state.
- `none`: Voiding does not adjust invoices, payment authorization, settlement, payment intents, or external collection state.
const (
CreditGrantVoidPaymentAdjustmentNone CreditGrantVoidPaymentAdjustment = "none"
)
func (CreditGrantVoidPaymentAdjustment) Valid ¶
func (value CreditGrantVoidPaymentAdjustment) Valid() bool
type CreditPurchasePaymentSettlementStatus ¶
type CreditPurchasePaymentSettlementStatus string
Credit purchase payment settlement status.
- `pending`: Payment has been initiated and is not yet authorized. - `authorized`: Payment has been authorized. - `settled`: Payment has been settled.
const ( CreditPurchasePaymentSettlementStatusPending CreditPurchasePaymentSettlementStatus = "pending" CreditPurchasePaymentSettlementStatusAuthorized CreditPurchasePaymentSettlementStatus = "authorized" CreditPurchasePaymentSettlementStatusSettled CreditPurchasePaymentSettlementStatus = "settled" )
func (CreditPurchasePaymentSettlementStatus) Valid ¶
func (value CreditPurchasePaymentSettlementStatus) Valid() bool
type CreditTransaction ¶
type CreditTransaction struct {
ID string `json:"id"`
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// The date and time the transaction was booked.
BookedAt time.Time `json:"booked_at"`
// The type of credit transaction.
Type CreditTransactionType `json:"type"`
// Currency of the balance affected by the transaction.
Currency BillingCurrencyCode `json:"currency"`
// Managed currency reference. Present only for custom currencies.
CustomCurrency *CurrencyCustomReference `json:"custom_currency,omitempty"`
// Signed amount of the credit movement. Positive values add balance, negative
// values reduce balance.
Amount Numeric `json:"amount"`
// The booked credit balance before and after the transaction, including
// credit-only advance debt.
AvailableBalance CreditTransactionAvailableBalance `json:"available_balance"`
}
A credit transaction represents a single credit movement on the customer's balance.
Credit transactions are immutable.
type CreditTransactionFilter ¶
type CreditTransactionFilter struct {
// Filter credit transactions by type.
Type *CreditTransactionType
// Filter credit transactions by currency code. Custom-currency rows retain their
// managed currency identifier.
Currency *BillingCurrencyCode
// Filter credit transactions by feature key. Omit to return all credit
// transactions. Use `exists=false` to return only unrestricted credit
// transactions.
FeatureKey *StringFilter
}
type CreditTransactionListParams ¶
type CreditTransactionListParams struct {
Page *CursorPageParams
Filter *CreditTransactionFilter
}
type CreditTransactionPaginatedResponse ¶
type CreditTransactionPaginatedResponse struct {
Data []CreditTransaction `json:"data"`
Meta CursorMeta `json:"meta"`
}
Cursor paginated response.
type CreditTransactionType ¶
type CreditTransactionType string
The type of the credit transaction.
- `funded`: Credit granted and available for consumption. - `consumed`: Credit consumed by usage or fees. - `correction`: A balance adjustment reversing previously recorded usage. - `expired`: Credit removed because it expired before being used. - `voided`: Credit removed because the grant was voided before being used.
const ( CreditTransactionTypeFunded CreditTransactionType = "funded" CreditTransactionTypeConsumed CreditTransactionType = "consumed" CreditTransactionTypeCorrection CreditTransactionType = "correction" CreditTransactionTypeExpired CreditTransactionType = "expired" CreditTransactionTypeVoided CreditTransactionType = "voided" )
func (CreditTransactionType) Valid ¶
func (value CreditTransactionType) Valid() bool
type CurrenciesService ¶
type CurrenciesService struct {
// contains filtered or unexported fields
}
func (*CurrenciesService) CreateCostBasis ¶
func (s *CurrenciesService) CreateCostBasis(ctx context.Context, currencyID string, request CreateCostBasisRequest) (*CostBasis, error)
Create a cost basis for a currency.
func (*CurrenciesService) CreateCustomCurrency ¶
func (s *CurrenciesService) CreateCustomCurrency(ctx context.Context, request CreateCurrencyCustomRequest) (*CurrencyCustom, error)
Create a custom currency. This operation allows defining your own custom currency for billing purposes.
func (*CurrenciesService) GetCustomCurrency ¶
func (s *CurrenciesService) GetCustomCurrency(ctx context.Context, currencyID string) (*CurrencyCustom, error)
Get a custom currency.
func (*CurrenciesService) List ¶
func (s *CurrenciesService) List(ctx context.Context, params CurrencyListParams) (*CurrencyPagePaginatedResponse, error)
List currencies supported by the billing system.
func (*CurrenciesService) ListAll ¶
func (s *CurrenciesService) ListAll(ctx context.Context, params CurrencyListParams) iter.Seq2[Currency, error]
ListAll returns an iterator over all Currency results, fetching pages of List transparently. Iteration stops at the first error, which is yielded as the second value.
func (*CurrenciesService) ListCostBases ¶
func (s *CurrenciesService) ListCostBases(ctx context.Context, currencyID string, params CostBasisListParams) (*CostBasisPagePaginatedResponse, error)
List cost bases for a currency. For custom currencies, there can be multiple cost bases with different `effective_from` dates.
func (*CurrenciesService) ListCostBasesAll ¶
func (s *CurrenciesService) ListCostBasesAll(ctx context.Context, currencyID string, params CostBasisListParams) iter.Seq2[CostBasis, error]
ListCostBasesAll returns an iterator over all CostBasis results, fetching pages of ListCostBases transparently. Iteration stops at the first error, which is yielded as the second value.
type Currency ¶
type Currency struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
Fiat or custom currency.
Currency is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the CurrencyFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func CurrencyFromCurrencyCustom ¶
func CurrencyFromCurrencyCustom(value CurrencyCustom) (Currency, error)
func CurrencyFromCurrencyFiat ¶
func CurrencyFromCurrencyFiat(value CurrencyFiat) (Currency, error)
func (Currency) AsCurrencyCustom ¶
func (u Currency) AsCurrencyCustom() (*CurrencyCustom, error)
func (Currency) AsCurrencyFiat ¶
func (u Currency) AsCurrencyFiat() (*CurrencyFiat, error)
func (Currency) MarshalJSON ¶
func (*Currency) UnmarshalJSON ¶
type CurrencyAmount ¶
type CurrencyAmount struct {
// The amount as an arbitrary-precision decimal string.
Amount Numeric `json:"amount"`
// The fiat or custom currency code of the amount.
Currency BillingCurrencyCode `json:"currency"`
}
Monetary amount in a fiat or custom currency.
type CurrencyCustom ¶
type CurrencyCustom struct {
// The type of the currency.
Type CurrencyType `json:"type"`
// The name of the currency. It should be a human-readable string that represents
// the name of the currency, such as "US Dollar" or "Euro".
Name string `json:"name"`
// The symbol of the currency. It should be a string that represents the symbol of
// the currency, such as "$" for US Dollar or "€" for Euro.
Symbol *string `json:"symbol,omitempty"`
// The precision of the currency. It should be a number that represents the number
// of decimal places used for the currency, such as 2 for US Dollar or Euro.
Precision uint32 `json:"precision"`
// The decimal mark for the currency. It should be a string that represents the
// decimal mark of the currency, such as "." for US Dollar or "," for Euro.
DecimalMark string `json:"decimal_mark"`
// The thousand separator for the currency. It should be a string that represents
// the thousand separator of the currency, such as "," for US Dollar or "." for
// Euro.
ThousandSeparator string `json:"thousand_separator"`
ID string `json:"id"`
Code string `json:"code"`
// An ISO-8601 timestamp representation of the custom currency creation date.
CreatedAt time.Time `json:"created_at"`
// The list of active and scheduled cost bases for the custom currency. Expired and
// deleted cost bases are excluded.
CostBasis []CostBasis `json:"cost_basis,omitempty"`
}
Describes custom currency.
type CurrencyCustomReference ¶
type CurrencyCustomReference struct {
ID string `json:"id"`
}
CurrencyCustom reference.
type CurrencyExpand ¶
type CurrencyExpand string
Expands for currencies.
Values:
- `cost_basis`: The currency's active and scheduled cost basis.
const (
CurrencyExpandCostBasis CurrencyExpand = "cost_basis"
)
func (CurrencyExpand) Valid ¶
func (value CurrencyExpand) Valid() bool
type CurrencyFiat ¶
type CurrencyFiat struct {
// The type of the currency.
Type CurrencyType `json:"type"`
// The name of the currency. It should be a human-readable string that represents
// the name of the currency, such as "US Dollar" or "Euro".
Name string `json:"name"`
// The symbol of the currency. It should be a string that represents the symbol of
// the currency, such as "$" for US Dollar or "€" for Euro.
Symbol *string `json:"symbol,omitempty"`
// The precision of the currency. It should be a number that represents the number
// of decimal places used for the currency, such as 2 for US Dollar or Euro.
Precision uint32 `json:"precision"`
// The decimal mark for the currency. It should be a string that represents the
// decimal mark of the currency, such as "." for US Dollar or "," for Euro.
DecimalMark string `json:"decimal_mark"`
// The thousand separator for the currency. It should be a string that represents
// the thousand separator of the currency, such as "," for US Dollar or "." for
// Euro.
ThousandSeparator string `json:"thousand_separator"`
Code string `json:"code"`
}
Currency describes a currency supported by the billing system.
type CurrencyFilter ¶
type CurrencyFilter struct {
Type *CurrencyType
Code *StringFilter
}
type CurrencyListParams ¶
type CurrencyListParams struct {
Page *PageParams
Sort *Sort
Filter *CurrencyFilter
Expand []CurrencyExpand
}
type CurrencyPagePaginatedResponse ¶
type CurrencyPagePaginatedResponse struct {
Data []Currency `json:"data"`
Meta PaginatedMeta `json:"meta"`
}
Page paginated response.
type CurrencyType ¶
type CurrencyType string
Currency type for custom currencies. It should be a unique code but not conflicting with any existing standard currency codes.
const ( CurrencyTypeFiat CurrencyType = "fiat" CurrencyTypeCustom CurrencyType = "custom" )
func (CurrencyType) Valid ¶
func (value CurrencyType) Valid() bool
type CursorMeta ¶
type CursorMeta struct {
// Page metadata.
Page CursorMetaPage `json:"page"`
}
Cursor pagination metadata.
type CursorMetaPage ¶
type CursorMetaPage struct {
// URI to the first page.
First *string `json:"first,omitempty"`
// URI to the last page.
Last *string `json:"last,omitempty"`
// URI to the next page.
Next Nullable[string] `json:"next"`
// URI to the previous page.
Previous Nullable[string] `json:"previous"`
// Requested page size.
Size int64 `json:"size"`
}
Cursor pagination metadata.
type CursorPageParams ¶
CursorPageParams selects a cursor page.
type CursorPaginationQueryPage ¶
type CursorPaginationQueryPage struct {
// The number of items to include per page.
Size *int64 `json:"size,omitempty"`
// Request the next page of data, starting with the item after this parameter.
After *string `json:"after,omitempty"`
// Request the previous page of data, starting with the item before this parameter.
Before *string `json:"before,omitempty"`
}
Determines which page of the collection to retrieve.
type Customer ¶
type Customer struct {
ID string `json:"id"`
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
Key string `json:"key"`
// Mapping to attribute metered usage to the customer by the event subject.
UsageAttribution *CustomerUsageAttribution `json:"usage_attribution,omitempty"`
// The primary email address of the customer.
PrimaryEmail *string `json:"primary_email,omitempty"`
// Currency of the customer. Used for billing, tax and invoicing.
Currency *string `json:"currency,omitempty"`
// The billing address of the customer. Used for tax and invoicing.
BillingAddress *Address `json:"billing_address,omitempty"`
}
Customers can be individuals or organizations that can subscribe to plans and have access to features.
type CustomerData ¶
type CustomerData struct {
// The billing profile explicitly selected for the customer.
//
// Unpinned customers use the current namespace default. Selecting the current
// default explicitly pins the customer to that profile.
BillingProfile Nullable[ProfileReference] `json:"billing_profile,omitempty"`
// The effective billing profile for the customer. Uses the explicitly selected
// billing profile when pinned, otherwise the current default billing profile.
EffectiveBillingProfile ProfileReference `json:"effective_billing_profile"`
// App customer data.
AppData *AppCustomerData `json:"app_data,omitempty"`
}
Billing customer data.
type CustomerFilter ¶
type CustomerFilter struct {
Key *StringFilter
Name *StringFilter
PrimaryEmail *StringFilter
UsageAttributionSubjectKey *StringFilter
PlanKey *StringFilter
BillingProfileID *StringExactFilter
}
type CustomerListParams ¶
type CustomerListParams struct {
Page *PageParams
Sort *Sort
Filter *CustomerFilter
}
type CustomerOrReference ¶
type CustomerOrReference struct {
// contains filtered or unexported fields
}
Customer or reference.
CustomerOrReference is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the CustomerOrReferenceFrom* constructors.
func CustomerOrReferenceFromCustomer ¶
func CustomerOrReferenceFromCustomer(value Customer) (CustomerOrReference, error)
func CustomerOrReferenceFromCustomerReference ¶
func CustomerOrReferenceFromCustomerReference(value CustomerReference) (CustomerOrReference, error)
func (CustomerOrReference) AsCustomer ¶
func (u CustomerOrReference) AsCustomer() (*Customer, error)
func (CustomerOrReference) AsCustomerReference ¶
func (u CustomerOrReference) AsCustomerReference() (*CustomerReference, error)
func (CustomerOrReference) MarshalJSON ¶
func (u CustomerOrReference) MarshalJSON() ([]byte, error)
func (*CustomerOrReference) UnmarshalJSON ¶
func (u *CustomerOrReference) UnmarshalJSON(data []byte) error
type CustomerPagePaginatedResponse ¶
type CustomerPagePaginatedResponse struct {
Data []Customer `json:"data"`
Meta PaginatedMeta `json:"meta"`
}
Page paginated response.
type CustomerProfile ¶
type CustomerProfile struct {
// The billing profile explicitly selected for the customer.
//
// Unpinned customers use the current namespace default. Selecting the current
// default explicitly pins the customer to that profile.
BillingProfile Nullable[ProfileReference] `json:"billing_profile,omitempty"`
// The effective billing profile for the customer. Uses the explicitly selected
// billing profile when pinned, otherwise the current default billing profile.
EffectiveBillingProfile ProfileReference `json:"effective_billing_profile"`
}
Customer billing profile selection.
type CustomerReference ¶
type CustomerReference struct {
ID string `json:"id"`
}
Customer reference.
type CustomerStripeCreateCheckoutSessionRequest ¶
type CustomerStripeCreateCheckoutSessionRequest struct {
// Options for configuring the Stripe Checkout Session.
//
// These options are passed directly to Stripe's
// [checkout session creation API](https://docs.stripe.com/api/checkout/sessions/create).
StripeOptions AppStripeCreateCheckoutSessionRequestOptions `json:"stripe_options"`
}
Request to create a Stripe Checkout Session for the customer.
Checkout Sessions are used to collect payment method information from customers in a secure, Stripe-hosted interface. This integration uses setup mode to collect payment methods that can be charged later for subscription billing.
type CustomerStripeCreateCustomerPortalSessionRequest ¶
type CustomerStripeCreateCustomerPortalSessionRequest struct {
// Options for configuring the Stripe Customer Portal Session.
StripeOptions AppStripeCreateCustomerPortalSessionOptions `json:"stripe_options"`
}
Request to create a Stripe Customer Portal Session for the customer.
Useful to redirect the customer to the Stripe Customer Portal to manage their payment methods, change their billing address and access their invoice history. Only returns URL if the customer billing profile is linked to a stripe app and customer.
type CustomerUsageAttribution ¶
type CustomerUsageAttribution struct {
// The subjects that are attributed to the customer. Can be empty when no usage
// event subjects are associated with the customer.
SubjectKeys []string `json:"subject_keys"`
}
Mapping to attribute metered usage to the customer. One customer can have zero or more subjects, but one subject can only belong to one customer.
type CustomersBillingService ¶
type CustomersBillingService struct {
// contains filtered or unexported fields
}
func (*CustomersBillingService) CreateStripeCheckoutSession ¶
func (s *CustomersBillingService) CreateStripeCheckoutSession(ctx context.Context, customerID string, request CustomerStripeCreateCheckoutSessionRequest) (*AppStripeCreateCheckoutSessionResult, error)
Create a [Stripe Checkout Session](https://docs.stripe.com/payments/checkout) for the customer.
Creates a Checkout Session for collecting payment method information from customers. The session operates in "setup" mode, which collects payment details without charging the customer immediately. The collected payment method can be used for future subscription billing.
For hosted checkout sessions, redirect customers to the returned URL. For embedded sessions, use the client_secret to initialize Stripe.js in your application.
func (*CustomersBillingService) CreateStripePortalSession ¶
func (s *CustomersBillingService) CreateStripePortalSession(ctx context.Context, customerID string, request CustomerStripeCreateCustomerPortalSessionRequest) (*AppStripeCreateCustomerPortalSessionResult, error)
Create Stripe Customer Portal Session.
Useful to redirect the customer to the Stripe Customer Portal to manage their payment methods, change their billing address and access their invoice history. Only returns URL if the customer billing profile is linked to a stripe app and customer.
func (*CustomersBillingService) Get ¶
func (s *CustomersBillingService) Get(ctx context.Context, customerID string) (*CustomerData, error)
func (*CustomersBillingService) Update ¶
func (s *CustomersBillingService) Update(ctx context.Context, customerID string, request UpsertCustomerBillingDataRequest) (*CustomerData, error)
Update billing data while preserving the current profile selection when billing_profile is omitted or null. Use the dedicated billing profile endpoint to remove the selection.
func (*CustomersBillingService) UpdateAppData ¶
func (s *CustomersBillingService) UpdateAppData(ctx context.Context, customerID string, request UpsertAppCustomerDataRequest) (*AppCustomerData, error)
func (*CustomersBillingService) UpdateProfile ¶
func (s *CustomersBillingService) UpdateProfile(ctx context.Context, customerID string, request UpsertCustomerBillingProfileRequest) (*CustomerProfile, error)
Set the customer's explicit billing profile selection. Omitting billing_profile or setting it to null removes the selection and uses the current namespace default.
type CustomersChargesService ¶
type CustomersChargesService struct {
// contains filtered or unexported fields
}
func (*CustomersChargesService) Create ¶
func (s *CustomersChargesService) Create(ctx context.Context, customerID string, request CreateChargeRequest) (*Charge, error)
Create customer charge.
func (*CustomersChargesService) Invoice ¶
func (s *CustomersChargesService) Invoice(ctx context.Context, customerID string, request *InvoiceCustomerChargesInput) (*InvoiceCustomerChargesResult, error)
Invoice a customer's charges outside the normal billing cycle. Collection alignment is bypassed. The customer's progressive billing setting applies unless explicitly overridden. All eligible pending lines are considered.
Returns the created standard invoices, one per collected currency. Lines blocked by their owning engine remain pending. If all eligible lines are blocked or no lines are eligible, returns a validation error.
func (*CustomersChargesService) List ¶
func (s *CustomersChargesService) List(ctx context.Context, customerID string, params ListCustomerChargesParams) (*ChargePagePaginatedResponse, error)
List customer charges.
Returns the customer's charges that are represented as either flat fee or usage-based charges.
func (*CustomersChargesService) ListAll ¶
func (s *CustomersChargesService) ListAll(ctx context.Context, customerID string, params ListCustomerChargesParams) iter.Seq2[Charge, error]
ListAll returns an iterator over all Charge results, fetching pages of List transparently. Iteration stops at the first error, which is yielded as the second value.
type CustomersCreditsAdjustmentsService ¶
type CustomersCreditsAdjustmentsService struct {
// contains filtered or unexported fields
}
func (*CustomersCreditsAdjustmentsService) Create ¶
func (s *CustomersCreditsAdjustmentsService) Create(ctx context.Context, customerID string, request CreateCreditAdjustmentRequest) (*CreditAdjustment, error)
A credit adjustment can be used to make manual adjustments to a customer's credit balance.
Supported use-cases:
- Usage correction
type CustomersCreditsBalanceService ¶
type CustomersCreditsBalanceService struct {
// contains filtered or unexported fields
}
func (*CustomersCreditsBalanceService) Get ¶
func (s *CustomersCreditsBalanceService) Get(ctx context.Context, customerID string, params GetCustomerCreditBalanceParams) (*CreditBalances, error)
Get a credit balance.
type CustomersCreditsGrantsService ¶
type CustomersCreditsGrantsService struct {
// contains filtered or unexported fields
}
func (*CustomersCreditsGrantsService) Create ¶
func (s *CustomersCreditsGrantsService) Create(ctx context.Context, customerID string, request CreateCreditGrantRequest) (*CreditGrant, error)
Create a new credit grant. A credit grant represents an allocation of prepaid credits to a customer.
func (*CustomersCreditsGrantsService) Get ¶
func (s *CustomersCreditsGrantsService) Get(ctx context.Context, customerID string, creditGrantID string) (*CreditGrant, error)
Get a credit grant.
func (*CustomersCreditsGrantsService) List ¶
func (s *CustomersCreditsGrantsService) List(ctx context.Context, customerID string, params CreditGrantListParams) (*CreditGrantPagePaginatedResponse, error)
List credit grants.
func (*CustomersCreditsGrantsService) ListAll ¶
func (s *CustomersCreditsGrantsService) ListAll(ctx context.Context, customerID string, params CreditGrantListParams) iter.Seq2[CreditGrant, error]
ListAll returns an iterator over all CreditGrant results, fetching pages of List transparently. Iteration stops at the first error, which is yielded as the second value.
func (*CustomersCreditsGrantsService) UpdateExternalSettlement ¶
func (s *CustomersCreditsGrantsService) UpdateExternalSettlement(ctx context.Context, customerID string, creditGrantID string, request UpdateCreditGrantExternalSettlementRequest) (*CreditGrant, error)
Update the payment settlement status of an externally funded credit grant.
Use this endpoint to synchronize the payment state of an external payment with the system so that revenue recognition and credit availability work as expected.
func (*CustomersCreditsGrantsService) Void ¶
func (s *CustomersCreditsGrantsService) Void(ctx context.Context, customerID string, creditGrantID string, request *VoidCreditGrantRequest) (*CreditGrant, error)
Void a credit grant, forfeiting the remaining unused balance.
Voiding is a forward-looking, irreversible operation. Credits already consumed by usage remain unaffected — only the remaining balance is forfeited. The grant reads as `voided` status afterwards. Payment state is not adjusted when `payment_adjustment` is `none`, so invoice-backed or externally collected payments may still collect the original amount. Only `active` grants can be voided; voiding a pending, expired, or fully consumed grant returns a conflict. Retrying a successful void is an idempotent success.
type CustomersCreditsService ¶
type CustomersCreditsService struct {
Grants *CustomersCreditsGrantsService
Balance *CustomersCreditsBalanceService
Adjustments *CustomersCreditsAdjustmentsService
Transactions *CustomersCreditsTransactionsService
// contains filtered or unexported fields
}
type CustomersCreditsTransactionsService ¶
type CustomersCreditsTransactionsService struct {
// contains filtered or unexported fields
}
func (*CustomersCreditsTransactionsService) List ¶
func (s *CustomersCreditsTransactionsService) List(ctx context.Context, customerID string, params CreditTransactionListParams) (*CreditTransactionPaginatedResponse, error)
List credit transactions for a customer.
Returns an immutable, chronological record of credit movements: funded credits and consumed credits. Transactions are returned in reverse chronological order by default.
func (*CustomersCreditsTransactionsService) ListAll ¶
func (s *CustomersCreditsTransactionsService) ListAll(ctx context.Context, customerID string, params CreditTransactionListParams) iter.Seq2[CreditTransaction, error]
ListAll returns an iterator over all CreditTransaction results, fetching pages of List transparently. Iteration stops at the first error, which is yielded as the second value.
type CustomersEntitlementsGrantsService ¶
type CustomersEntitlementsGrantsService struct {
// contains filtered or unexported fields
}
func (*CustomersEntitlementsGrantsService) Create ¶
func (s *CustomersEntitlementsGrantsService) Create(ctx context.Context, customerID string, entitlementID string, request EntitlementGrantCreateRequest) (*EntitlementGrant, error)
Issue a grant for a metered entitlement of the customer. Boolean and static entitlements cannot have grants, so the request is rejected for them.
Grants are immutable. The amount is added to the balance from `effective_at`, which cannot be earlier than the start of the current usage period.
func (*CustomersEntitlementsGrantsService) List ¶
func (s *CustomersEntitlementsGrantsService) List(ctx context.Context, customerID string, entitlementID string, params ListCustomerEntitlementGrantsParams) (*EntitlementGrantPagePaginatedResponse, error)
List the grants issued for an entitlement of the customer. Grants only exist for metered entitlements, so the list is empty for boolean and static entitlements.
Deleted grants are excluded unless `include_deleted` is set. Voided and expired grants are always included, as they are part of the balance history.
func (*CustomersEntitlementsGrantsService) ListAll ¶
func (s *CustomersEntitlementsGrantsService) ListAll(ctx context.Context, customerID string, entitlementID string, params ListCustomerEntitlementGrantsParams) iter.Seq2[EntitlementGrant, error]
ListAll returns an iterator over all EntitlementGrant results, fetching pages of List transparently. Iteration stops at the first error, which is yielded as the second value.
type CustomersEntitlementsService ¶
type CustomersEntitlementsService struct {
Grants *CustomersEntitlementsGrantsService
// contains filtered or unexported fields
}
func (*CustomersEntitlementsService) Create ¶
func (s *CustomersEntitlementsService) Create(ctx context.Context, customerID string, request CreateEntitlementRequest) (*Entitlement, error)
Create an entitlement for the customer.
A customer can have only one active entitlement per feature. The feature must be compatible with the entitlement type. Entitlements cannot be modified after creation, only deleted.
func (*CustomersEntitlementsService) Delete ¶
func (s *CustomersEntitlementsService) Delete(ctx context.Context, customerID string, entitlementID string) error
Deletes the entitlement and revokes access to its feature. A customer can hold only one active entitlement per feature, so migrating a feature requires deleting the previous entitlement first.
Deletion sets the `deleted_at` timestamp instead of removing history. Access and status queries for earlier points in time still treat the entitlement as active, so access changes are never retroactive.
func (*CustomersEntitlementsService) Get ¶
func (s *CustomersEntitlementsService) Get(ctx context.Context, customerID string, entitlementID string) (*Entitlement, error)
Get an entitlement of the customer by ID. For checking entitlement access, use the entitlement access endpoints instead.
func (*CustomersEntitlementsService) GetHistory ¶
func (s *CustomersEntitlementsService) GetHistory(ctx context.Context, customerID string, entitlementID string, params GetCustomerEntitlementHistoryParams) (*EntitlementHistory, error)
Get the balance and usage history of a metered entitlement. The queried range may span multiple usage periods.
`windowed_history` groups usage into windows of the requested size and reports the balance at the start of each window. `burndown_history` lists the periods in which grants were consumed in a fixed order, together with the usage taken from each grant.
func (*CustomersEntitlementsService) List ¶
func (s *CustomersEntitlementsService) List(ctx context.Context, customerID string, params ListCustomerEntitlementsParams) (*EntitlementPagePaginatedResponse, error)
List the entitlements of the customer that are active at the time of the request. For checking entitlement access, use the entitlement access endpoints instead.
func (*CustomersEntitlementsService) ListAll ¶
func (s *CustomersEntitlementsService) ListAll(ctx context.Context, customerID string, params ListCustomerEntitlementsParams) iter.Seq2[Entitlement, error]
ListAll returns an iterator over all Entitlement results, fetching pages of List transparently. Iteration stops at the first error, which is yielded as the second value.
func (*CustomersEntitlementsService) Override ¶
func (s *CustomersEntitlementsService) Override(ctx context.Context, customerID string, entitlementID string, request CreateEntitlementRequest) (*Entitlement, error)
Override an entitlement of the customer with a new one.
The referenced entitlement ends and the new one starts at the same instant, so access continues without a gap. Both must belong to the same feature. Use this for upgrades and downgrades.
Fails if the referenced entitlement does not exist, is deleted, or is no longer active.
func (*CustomersEntitlementsService) ResetUsage ¶
func (s *CustomersEntitlementsService) ResetUsage(ctx context.Context, customerID string, entitlementID string, request *ResetCustomerEntitlementUsageRequest) error
Reset the usage of a metered entitlement. The reset starts a new usage period: usage is zeroed and grants roll over according to their rollover settings.
Usage is reset automatically at the end of each usage period. Use this operation to reset it earlier, for example to align the entitlement with the customer's billing period. The usage period anchor can be moved at the same time.
type CustomersService ¶
type CustomersService struct {
Billing *CustomersBillingService
Entitlements *CustomersEntitlementsService
Credits *CustomersCreditsService
Charges *CustomersChargesService
// contains filtered or unexported fields
}
func (*CustomersService) Create ¶
func (s *CustomersService) Create(ctx context.Context, request CreateCustomerRequest) (*Customer, error)
func (*CustomersService) Delete ¶
func (s *CustomersService) Delete(ctx context.Context, customerID string) error
func (*CustomersService) List ¶
func (s *CustomersService) List(ctx context.Context, params CustomerListParams) (*CustomerPagePaginatedResponse, error)
func (*CustomersService) ListAll ¶
func (s *CustomersService) ListAll(ctx context.Context, params CustomerListParams) iter.Seq2[Customer, error]
ListAll returns an iterator over all Customer results, fetching pages of List transparently. Iteration stops at the first error, which is yielded as the second value.
func (*CustomersService) Upsert ¶
func (s *CustomersService) Upsert(ctx context.Context, customerID string, request UpsertCustomerRequest) (*Customer, error)
type DateTimeFilter ¶
type DateTimeFilter struct {
Eq *time.Time
Gt *time.Time
Gte *time.Time
Lt *time.Time
Lte *time.Time
}
DateTimeFilter expresses comparisons against RFC 3339 timestamps.
type DefaultsService ¶
type DefaultsService struct {
// contains filtered or unexported fields
}
func (*DefaultsService) GetOrganizationTaxCodes ¶
func (s *DefaultsService) GetOrganizationTaxCodes(ctx context.Context) (*OrganizationDefaultTaxCodes, error)
func (*DefaultsService) UpdateOrganizationTaxCodes ¶
func (s *DefaultsService) UpdateOrganizationTaxCodes(ctx context.Context, request UpdateOrganizationDefaultTaxCodesRequest) (*OrganizationDefaultTaxCodes, error)
type Entitlement ¶
type Entitlement struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
An entitlement grants a customer access to a feature.
Entitlement is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the EntitlementFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func EntitlementFromEntitlementBoolean ¶
func EntitlementFromEntitlementBoolean(value EntitlementBoolean) (Entitlement, error)
func EntitlementFromEntitlementMetered ¶
func EntitlementFromEntitlementMetered(value EntitlementMetered) (Entitlement, error)
func EntitlementFromEntitlementStatic ¶
func EntitlementFromEntitlementStatic(value EntitlementStatic) (Entitlement, error)
func (Entitlement) AsEntitlementBoolean ¶
func (u Entitlement) AsEntitlementBoolean() (*EntitlementBoolean, error)
func (Entitlement) AsEntitlementMetered ¶
func (u Entitlement) AsEntitlementMetered() (*EntitlementMetered, error)
func (Entitlement) AsEntitlementStatic ¶
func (u Entitlement) AsEntitlementStatic() (*EntitlementStatic, error)
func (Entitlement) MarshalJSON ¶
func (u Entitlement) MarshalJSON() ([]byte, error)
func (*Entitlement) UnmarshalJSON ¶
func (u *Entitlement) UnmarshalJSON(data []byte) error
type EntitlementAccessCheckResult ¶
type EntitlementAccessCheckResult struct {
// Whether the customer has access to the feature. Always true for `boolean` and
// `static` entitlements. Depends on balance for `metered` entitlements.
HasAccess bool `json:"has_access"`
// Only available for static entitlements. Config is the JSON parsable
// configuration of the entitlement. Useful to describe per customer configuration.
Config *string `json:"config,omitempty"`
// The type of the entitlement.
//
// If not provided, the feature has no entitlement defined (has access is always
// false in this case)
Type *EntitlementType `json:"type,omitempty"`
}
Entitlement access check result.
type EntitlementAccessExpand ¶
type EntitlementAccessExpand string
Expands for customer entitlement access.
Values:
- `value`: The balance details of a metered entitlement; it sets the `value` field.
const (
EntitlementAccessExpandValue EntitlementAccessExpand = "value"
)
func (EntitlementAccessExpand) Valid ¶
func (value EntitlementAccessExpand) Valid() bool
type EntitlementAccessQueryError ¶
type EntitlementAccessQueryError struct {
// Machine-readable error code.
Code EntitlementAccessQueryErrorCode `json:"code"`
// Human-readable description of the error.
Message string `json:"message"`
// Additional structured context.
Attributes map[string]any `json:"attributes,omitempty"`
// The customer identifier from the request that produced this error.
Customer *string `json:"customer,omitempty"`
}
Query error within a partially successful entitlement access query response.
type EntitlementAccessQueryErrorCode ¶
type EntitlementAccessQueryErrorCode string
Error code for an entitlement access query failure.
const ( EntitlementAccessQueryErrorCodeUnknown EntitlementAccessQueryErrorCode = "unknown" EntitlementAccessQueryErrorCodeCustomerNotFound EntitlementAccessQueryErrorCode = "customer_not_found" )
func (EntitlementAccessQueryErrorCode) Valid ¶
func (value EntitlementAccessQueryErrorCode) Valid() bool
type EntitlementAccessQueryPage ¶
type EntitlementAccessQueryPage struct {
// The number of items to include per page.
Size *int64 `json:"size,omitempty"`
// Request the next page of data, starting with the item after this parameter.
After *string `json:"after,omitempty"`
// Request the previous page of data, starting with the item before this parameter.
Before *string `json:"before,omitempty"`
}
Determines which page of the entitlement access query to retrieve. A page holds at most 100 customers.
type EntitlementAccessQueryRequest ¶
type EntitlementAccessQueryRequest struct {
// Whether to include credit balance availability for each resolved customer. When
// true, each feature evaluation includes credit balance checks.
//
// Defaults to `false`.
IncludeCredits *bool `json:"include_credits,omitempty"`
Customer EntitlementAccessQueryRequestCustomers `json:"customer"`
Feature *EntitlementAccessQueryRequestFeatures `json:"feature,omitempty"`
}
Query to evaluate feature access for a list of customers.
type EntitlementAccessQueryRequestCustomers ¶
type EntitlementAccessQueryRequestCustomers struct {
// Each entry can be a customer `key` or a usage-attribution subject `key`.
// Identifiers that cannot be resolved to a customer are reported in the response
// `errors` array.
Keys []string `json:"keys"`
}
List of customer identifiers to evaluate access for.
type EntitlementAccessQueryRequestFeatures ¶
type EntitlementAccessQueryRequestFeatures struct {
// List of feature keys to evaluate access for.
Keys []string `json:"keys"`
}
Optional list of feature keys to evaluate access for. If omitted, all features available in the organization are returned. Providing this list is recommended to reduce the response size and the load on the backend services.
type EntitlementAccessQueryResponse ¶
type EntitlementAccessQueryResponse struct {
// Access evaluation results, one entry per resolved customer.
Data []EntitlementAccessQueryResult `json:"data"`
// Partial errors encountered while processing the request.
Errors []EntitlementAccessQueryError `json:"errors"`
// Pagination metadata. The endpoint may return a partial response if the full
// response would exceed server-side limits.
Meta CursorMeta `json:"meta"`
}
Response of the entitlement access query.
type EntitlementAccessQueryResult ¶
type EntitlementAccessQueryResult struct {
// The list of identifiers from the request that resolved to this customer. Each
// entry is either the customer `key` or one of its usage-attribution subject
// `key`s.
//
// Duplicate or aliased identifiers that resolve to the same customer collapse to a
// single result entry, with every requested identifier listed here.
Matched []string `json:"matched"`
// The customer the matched identifiers resolved to.
Customer Customer `json:"customer"`
// Map of features with their access status.
//
// Map keys are the feature keys requested in `feature.keys`, or every feature
// `key` available in the organization when the feature filter was omitted.
Features map[string]EntitlementFeatureAccess `json:"features"`
// Timestamp of the most recent change to the customer's access state reflected in
// this result.
UpdatedAt time.Time `json:"updated_at"`
}
Access evaluation result for a single resolved customer.
type EntitlementAccessQueryResultListParams ¶
type EntitlementAccessQueryResultListParams struct {
Page *CursorPageParams
}
type EntitlementAccessService ¶
type EntitlementAccessService struct {
// contains filtered or unexported fields
}
func (*EntitlementAccessService) Query ¶
func (s *EntitlementAccessService) Query(ctx context.Context, request EntitlementAccessQueryRequest, params EntitlementAccessQueryResultListParams) (*EntitlementAccessQueryResponse, error)
Query feature access for a list of customers.
The endpoint resolves each provided identifier to a customer and returns the access status for the requested features, plus optional credit balance availability.
_Designed to be called on a fixed refresh interval and the query response is intended to be cached._
type EntitlementAccessValue ¶
type EntitlementAccessValue struct {
// The remaining balance of the entitlement in the usage period at the evaluation
// time.
Balance Numeric `json:"balance"`
// The usage recorded in the usage period at the evaluation time.
Usage Numeric `json:"usage"`
// The usage exceeding the available balance in the usage period at the evaluation
// time.
Overage Numeric `json:"overage"`
// The total amount granted and available to the entitlement at the evaluation
// time.
TotalAvailableGrantAmount Numeric `json:"total_available_grant_amount"`
// The remaining balance of each grant, keyed by grant ID.
GrantBalances map[string]Numeric `json:"grant_balances"`
}
Balance details of a metered entitlement at the evaluation time, which is the `at` query parameter when given and the current time otherwise.
type EntitlementBalanceThresholdTriggeredV1Payload ¶
type EntitlementBalanceThresholdTriggeredV1Payload struct {
// Entitlement.
Entitlement NotificationEventV1EntitlementMetered `json:"entitlement"`
// Feature.
Feature NotificationEventV1Feature `json:"feature"`
// Subject.
Subject NotificationEventV1Subject `json:"subject"`
// Entitlement Value.
Value NotificationEventV1EntitlementValue `json:"value"`
// Customer.
Customer *NotificationEventV1Customer `json:"customer,omitempty"`
// Threshold.
Threshold NotificationEventV1RuleBalanceThresholdValue `json:"threshold"`
}
A metered entitlement's balance crossed one of the thresholds configured on the Rule. The payload carries the entitlement, its feature, subject, customer and value, and the threshold that was crossed.
Legacy name: `entitlements.balance.threshold`.
type EntitlementBoolean ¶
type EntitlementBoolean struct {
ID string `json:"id"`
// The type of the entitlement.
Type EntitlementType `json:"type"`
// The feature the customer is entitled to use.
Feature FeatureReference `json:"feature"`
// The customer the entitlement belongs to.
Customer CustomerReference `json:"customer"`
Labels map[string]string `json:"labels,omitempty"`
// The usage period of the entitlement.
UsagePeriod *RecurringPeriod `json:"usage_period,omitempty"`
// The current usage period of the entitlement.
CurrentUsagePeriod *ClosedPeriod `json:"current_usage_period,omitempty"`
// The time from which the entitlement is active.
ActiveFrom time.Time `json:"active_from"`
// The time until which the entitlement is active. If not set, the entitlement is
// active until deleted.
ActiveTo *time.Time `json:"active_to,omitempty"`
// The time the entitlement was created.
CreatedAt time.Time `json:"created_at"`
// The time the entitlement was last updated.
UpdatedAt time.Time `json:"updated_at"`
// The time the entitlement was deleted.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
}
A boolean entitlement grants access to a feature.
type EntitlementBurndownBalance ¶
type EntitlementBurndownBalance struct {
// The balance at the start of the segment.
Start Numeric `json:"start"`
// The balance at the end of the segment.
End Numeric `json:"end"`
}
Entitlement balance at the boundaries of a burndown segment.
type EntitlementBurndownGrantBalances ¶
type EntitlementBurndownGrantBalances struct {
// The balance of each active grant at the start of the segment.
Start map[string]Numeric `json:"start"`
// The balance of each active grant at the end of the segment.
End map[string]Numeric `json:"end"`
}
Grant balances at the boundaries of a burndown segment, keyed by grant ID.
type EntitlementBurndownSegment ¶
type EntitlementBurndownSegment struct {
// The period the segment covers.
Period ClosedPeriod `json:"period"`
// The usage recorded in the segment.
Usage Numeric `json:"usage"`
// The usage in the segment not covered by any grant.
Overage Numeric `json:"overage"`
// The entitlement balance at the start and at the end of the segment.
Balance EntitlementBurndownBalance `json:"balance"`
// The balance of each active grant at the start and at the end of the segment,
// keyed by grant ID.
GrantBalances EntitlementBurndownGrantBalances `json:"grant_balances"`
// The grants consumed in the segment and the usage taken from each.
GrantUsages []EntitlementGrantUsage `json:"grant_usages"`
}
A period in which grants were consumed in a fixed order.
type EntitlementFeatureAccess ¶
type EntitlementFeatureAccess struct {
// Whether the customer currently has access to the feature.
//
// `true` for boolean and static entitlements that are available, and for metered
// entitlements with remaining balance. `false` when the feature is unavailable,
// the usage limit has been reached, or (when applicable) credits have been
// exhausted.
HasAccess bool `json:"has_access"`
// Optional reason when the customer does not have access to the feature. Populated
// when `has_access` is `false`.
Reason *EntitlementFeatureAccessReason `json:"reason,omitempty"`
}
Access status for a single feature.
type EntitlementFeatureAccessReason ¶
type EntitlementFeatureAccessReason struct {
// Machine-readable error code.
Code EntitlementFeatureAccessReasonCode `json:"code"`
// Human-readable description of the error.
Message string `json:"message"`
// Additional structured context.
Attributes map[string]any `json:"attributes,omitempty"`
}
Reason a feature is not accessible to a customer.
type EntitlementFeatureAccessReasonCode ¶
type EntitlementFeatureAccessReasonCode string
Machine-readable reason code for denied feature access.
const ( EntitlementFeatureAccessReasonCodeUnknown EntitlementFeatureAccessReasonCode = "unknown" EntitlementFeatureAccessReasonCodeUsageLimitReached EntitlementFeatureAccessReasonCode = "usage_limit_reached" EntitlementFeatureAccessReasonCodeFeatureNotFound EntitlementFeatureAccessReasonCode = "feature_not_found" EntitlementFeatureAccessReasonCodeNoCreditAvailable EntitlementFeatureAccessReasonCode = "no_credit_available" )
func (EntitlementFeatureAccessReasonCode) Valid ¶
func (value EntitlementFeatureAccessReasonCode) Valid() bool
type EntitlementFeatureValueResult ¶
type EntitlementFeatureValueResult struct {
// The feature key being evaluated.
FeatureKey string `json:"feature_key"`
// Whether the customer has access to the feature. Always true for `boolean` and
// `static` entitlements. Depends on balance for `metered` entitlements.
HasAccess bool `json:"has_access"`
// Only available for static entitlements. Config is the JSON parsable
// configuration of the entitlement. Useful to describe per customer configuration.
Config *string `json:"config,omitempty"`
// Only available for metered entitlements. The balance details of the entitlement
// at the evaluation time. Requires the `value` expand.
Value *EntitlementAccessValue `json:"value,omitempty"`
// The type of the entitlement.
//
// If not provided, the feature has no entitlement defined (has access is always
// false in this case)
Type *EntitlementType `json:"type,omitempty"`
}
Entitlement value looked up by feature key. A missing entitlement has no type and does not grant access.
type EntitlementGrant ¶
type EntitlementGrant struct {
ID string `json:"id"`
// The ID of the entitlement the grant belongs to.
EntitlementID string `json:"entitlement_id"`
// The ID of the customer the grant belongs to.
CustomerID *string `json:"customer_id,omitempty"`
// The granted amount, in the feature's unit.
Amount Numeric `json:"amount"`
// The priority of the grant. Lower values are consumed first: a grant with
// priority 1 is consumed before one with priority 2. Among equal priorities, the
// grant closest to expiration is consumed first, then the earliest created.
Priority uint8 `json:"priority"`
// The time the grant takes effect.
EffectiveAt time.Time `json:"effective_at"`
// The duration after which the grant expires, counted from `effective_at`. Always
// a single-unit duration (for example `PT12H`, `P7D`, `P2W`, `P3M`, `P1Y`). Absent
// when the grant never expires.
ExpiresAfter *string `json:"expires_after,omitempty"`
// The time the grant expires, calculated from `effective_at` and `expires_after`.
// The grant is no longer in effect from this time. Absent when the grant never
// expires.
ExpiresAt *time.Time `json:"expires_at,omitempty"`
// The maximum balance the grant carries over at reset. The balance after a reset
// is `MIN(max_rollover_amount, MAX(balance_before_reset, min_rollover_amount))`.
MaxRolloverAmount Numeric `json:"max_rollover_amount"`
// The minimum balance the grant carries over at reset. The balance after a reset
// is `MIN(max_rollover_amount, MAX(balance_before_reset, min_rollover_amount))`.
MinRolloverAmount Numeric `json:"min_rollover_amount"`
// The recurrence of the grant. When set, the grant amount is re-issued every
// interval from the anchor, which defaults to `effective_at`. Absent for
// non-recurring grants.
Recurrence *RecurringPeriod `json:"recurrence,omitempty"`
// The next time the grant recurs. Absent for non-recurring grants.
NextRecurrence *time.Time `json:"next_recurrence,omitempty"`
// The time the grant was voided. A voided grant is no longer in effect from this
// time.
VoidedAt *time.Time `json:"voided_at,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
}
A grant issued for a metered entitlement. Each grant adds its amount to the entitlement's balance from its effective time until it expires, and usage is deducted from the grants in priority order.
Grants are immutable, so the balance is deterministic regardless of when it is queried. Deleting a grant ends it at the time of the deletion.
type EntitlementGrantCreateRequest ¶
type EntitlementGrantCreateRequest struct {
// The amount to grant, in the feature's unit. Must be positive.
Amount Numeric `json:"amount"`
// The priority of the grant. Lower values have higher priority. Grants are
// consumed in priority order, then by closest expiration, then by earliest
// creation.
Priority *uint8 `json:"priority,omitempty"`
// The time the grant becomes effective and the anchor for recurring grants. The
// value is truncated to the start of the minute.
EffectiveAt time.Time `json:"effective_at"`
// The duration after which the grant expires, counted from `effective_at`. Only
// single-unit durations are accepted, such as `PT12H`, `P7D`, `P2W`, `P3M`, or
// `P1Y`. If omitted, the grant never expires.
ExpiresAfter *string `json:"expires_after,omitempty"`
// The maximum balance carried over at reset. The balance after a reset is
// `MIN(max_rollover_amount, MAX(balance_before_reset, min_rollover_amount))`.
// Defaults to `amount`.
MaxRolloverAmount *Numeric `json:"max_rollover_amount,omitempty"`
// The minimum balance carried over at reset. The balance after a reset is
// `MIN(max_rollover_amount, MAX(balance_before_reset, min_rollover_amount))`.
// Defaults to `0`.
MinRolloverAmount *Numeric `json:"min_rollover_amount,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
// The recurrence of the grant. When set, the amount is issued again every
// interval. The anchor defaults to `effective_at`.
Recurrence *RecurringPeriodInput `json:"recurrence,omitempty"`
}
A grant to issue for a metered entitlement.
type EntitlementGrantPagePaginatedResponse ¶
type EntitlementGrantPagePaginatedResponse struct {
Data []EntitlementGrant `json:"data"`
Meta PaginatedMeta `json:"meta"`
}
Page paginated response.
type EntitlementGrantUsage ¶
type EntitlementGrantUsage struct {
// The ID of the grant.
GrantID string `json:"grant_id"`
// The usage taken from the grant.
Usage Numeric `json:"usage"`
}
Usage taken from a single grant.
type EntitlementHistory ¶
type EntitlementHistory struct {
// Usage in half-open windows of the requested size, aligned to the requested time
// zone. Empty windows are included; windows before usage measurement began are
// omitted.
WindowedHistory []EntitlementHistoryWindow `json:"windowed_history"`
// Periods in which grants were consumed in a fixed order. A new segment starts
// whenever grant priorities change or a usage period starts.
BurndownHistory []EntitlementBurndownSegment `json:"burndown_history"`
}
Balance and usage history of a metered entitlement.
type EntitlementHistoryWindow ¶
type EntitlementHistoryWindow struct {
// The period the window covers.
Period ClosedPeriod `json:"period"`
// The usage recorded in the window.
Usage Numeric `json:"usage"`
// The entitlement balance at the start of the window.
BalanceAtStart Numeric `json:"balance_at_start"`
}
Usage and balance of a single history window.
type EntitlementHistoryWindowSize ¶
type EntitlementHistoryWindowSize string
The meter query granularities the usage history can be grouped into. Sub-hour windows are too expensive to compute and monthly windows are not supported.
const ( EntitlementHistoryWindowSizeHour EntitlementHistoryWindowSize = "PT1H" EntitlementHistoryWindowSizeDay EntitlementHistoryWindowSize = "P1D" )
func (EntitlementHistoryWindowSize) Valid ¶
func (value EntitlementHistoryWindowSize) Valid() bool
type EntitlementIssueAfterReset ¶
type EntitlementIssueAfterReset struct {
// The amount granted after each reset, in the feature's unit.
Amount Numeric `json:"amount"`
// The priority of the grant created after each reset. Lower values have higher
// priority.
Priority *uint8 `json:"priority,omitempty"`
}
Usage granted automatically after each reset of a metered entitlement. The balance returns to `amount` after every reset.
type EntitlementMeasureUsageFrom ¶
type EntitlementMeasureUsageFrom struct {
// contains filtered or unexported fields
}
The time from which usage is measured, as a preset or an explicit timestamp.
EntitlementMeasureUsageFrom is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the EntitlementMeasureUsageFromFrom* constructors.
func EntitlementMeasureUsageFromFromPreset ¶
func EntitlementMeasureUsageFromFromPreset(value EntitlementMeasureUsageFromPreset) (EntitlementMeasureUsageFrom, error)
func EntitlementMeasureUsageFromFromTime ¶
func EntitlementMeasureUsageFromFromTime(value time.Time) (EntitlementMeasureUsageFrom, error)
func (EntitlementMeasureUsageFrom) AsPreset ¶
func (u EntitlementMeasureUsageFrom) AsPreset() (*EntitlementMeasureUsageFromPreset, error)
func (EntitlementMeasureUsageFrom) AsTime ¶
func (u EntitlementMeasureUsageFrom) AsTime() (*time.Time, error)
func (EntitlementMeasureUsageFrom) MarshalJSON ¶
func (u EntitlementMeasureUsageFrom) MarshalJSON() ([]byte, error)
func (*EntitlementMeasureUsageFrom) UnmarshalJSON ¶
func (u *EntitlementMeasureUsageFrom) UnmarshalJSON(data []byte) error
type EntitlementMeasureUsageFromPreset ¶
type EntitlementMeasureUsageFromPreset string
Preset for the time from which usage is measured.
- `current_period_start`: the start of the current usage period. - `now`: the entitlement creation time.
const ( EntitlementMeasureUsageFromPresetCurrentPeriodStart EntitlementMeasureUsageFromPreset = "current_period_start" EntitlementMeasureUsageFromPresetNow EntitlementMeasureUsageFromPreset = "now" )
func (EntitlementMeasureUsageFromPreset) Valid ¶
func (value EntitlementMeasureUsageFromPreset) Valid() bool
type EntitlementMetered ¶
type EntitlementMetered struct {
ID string `json:"id"`
// The type of the entitlement.
Type EntitlementType `json:"type"`
// The feature the customer is entitled to use.
Feature FeatureReference `json:"feature"`
// The customer the entitlement belongs to.
Customer CustomerReference `json:"customer"`
Labels map[string]string `json:"labels,omitempty"`
// The time from which the entitlement is active.
ActiveFrom time.Time `json:"active_from"`
// The time until which the entitlement is active. If not set, the entitlement is
// active until deleted.
ActiveTo *time.Time `json:"active_to,omitempty"`
// The time the entitlement was created.
CreatedAt time.Time `json:"created_at"`
// The time the entitlement was last updated.
UpdatedAt time.Time `json:"updated_at"`
// The time the entitlement was deleted.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// The usage period of the entitlement. The balance resets at the start of every
// period.
UsagePeriod RecurringPeriod `json:"usage_period"`
// The current usage period of the entitlement.
CurrentUsagePeriod ClosedPeriod `json:"current_usage_period"`
// If true, the customer keeps access to the feature after the balance is
// exhausted.
IsSoftLimit *bool `json:"is_soft_limit,omitempty"`
// Usage granted automatically after each reset. Cannot be combined with `grants`.
Issue *EntitlementIssueAfterReset `json:"issue,omitempty"`
// The amount granted automatically after each reset.
IssueAfterReset *Numeric `json:"issue_after_reset,omitempty"`
// The priority of the grant created after each reset.
IssueAfterResetPriority *uint8 `json:"issue_after_reset_priority,omitempty"`
// If true, the overage is preserved at reset. If false, the usage is reset to 0.
PreserveOverageAtReset *bool `json:"preserve_overage_at_reset,omitempty"`
// The time from which usage is measured.
MeasureUsageFrom time.Time `json:"measure_usage_from"`
// The time of the last reset.
LastReset time.Time `json:"last_reset"`
}
A metered entitlement grants a usage allowance for a feature. Access is determined by the balance: the allowance provided by grants is burnt down by usage.
type EntitlementPagePaginatedResponse ¶
type EntitlementPagePaginatedResponse struct {
Data []Entitlement `json:"data"`
Meta PaginatedMeta `json:"meta"`
}
Page paginated response.
type EntitlementStatic ¶
type EntitlementStatic struct {
ID string `json:"id"`
// The type of the entitlement.
Type EntitlementType `json:"type"`
// The feature the customer is entitled to use.
Feature FeatureReference `json:"feature"`
// The customer the entitlement belongs to.
Customer CustomerReference `json:"customer"`
Labels map[string]string `json:"labels,omitempty"`
// The usage period of the entitlement.
UsagePeriod *RecurringPeriod `json:"usage_period,omitempty"`
// The current usage period of the entitlement.
CurrentUsagePeriod *ClosedPeriod `json:"current_usage_period,omitempty"`
// The time from which the entitlement is active.
ActiveFrom time.Time `json:"active_from"`
// The time until which the entitlement is active. If not set, the entitlement is
// active until deleted.
ActiveTo *time.Time `json:"active_to,omitempty"`
// The time the entitlement was created.
CreatedAt time.Time `json:"created_at"`
// The time the entitlement was last updated.
UpdatedAt time.Time `json:"updated_at"`
// The time the entitlement was deleted.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// The entitlement configuration as a JSON value. Returned when checking
// entitlement access.
Config any `json:"config"`
}
A static entitlement grants access to a feature together with a configuration.
type EntitlementType ¶
type EntitlementType string
The type of the entitlement.
const ( EntitlementTypeMetered EntitlementType = "metered" EntitlementTypeStatic EntitlementType = "static" EntitlementTypeBoolean EntitlementType = "boolean" )
func (EntitlementType) Valid ¶
func (value EntitlementType) Valid() bool
type EntitlementUsagePeriodResetV1Payload ¶
type EntitlementUsagePeriodResetV1Payload struct {
// Entitlement.
Entitlement NotificationEventV1EntitlementMetered `json:"entitlement"`
// Feature.
Feature NotificationEventV1Feature `json:"feature"`
// Subject.
Subject NotificationEventV1Subject `json:"subject"`
// Entitlement Value.
Value NotificationEventV1EntitlementValue `json:"value"`
// Customer.
Customer *NotificationEventV1Customer `json:"customer,omitempty"`
}
A metered entitlement's usage period was reset. The payload carries the entitlement, its feature, subject, customer and value.
Legacy name: `entitlements.reset`.
type EntitlementValueResult ¶
type EntitlementValueResult struct {
// The type of the entitlement.
Type EntitlementType `json:"type"`
// The feature key being evaluated.
FeatureKey string `json:"feature_key"`
// Whether the customer has access to the feature. Always true for `boolean` and
// `static` entitlements. Depends on balance for `metered` entitlements.
HasAccess bool `json:"has_access"`
// Only available for static entitlements. Config is the JSON parsable
// configuration of the entitlement. Useful to describe per customer configuration.
Config *string `json:"config,omitempty"`
// Only available for metered entitlements. The balance details of the entitlement
// at the evaluation time. Requires the `value` expand.
Value *EntitlementAccessValue `json:"value,omitempty"`
}
Entitlement value result.
type EntitlementsService ¶
type EntitlementsService struct {
// contains filtered or unexported fields
}
func (*EntitlementsService) Get ¶
func (s *EntitlementsService) Get(ctx context.Context, entitlementID string) (*Entitlement, error)
Get an entitlement by ID. To check entitlement access, use the entitlement access endpoints instead.
func (*EntitlementsService) GetCustomerAccess ¶
func (s *EntitlementsService) GetCustomerAccess(ctx context.Context, customerID string, featureKey string) (*EntitlementAccessCheckResult, error)
Get the customer's access to a single feature.
func (*EntitlementsService) GetCustomerValue ¶
func (s *EntitlementsService) GetCustomerValue(ctx context.Context, customerID string, entitlementID string, params GetCustomerEntitlementValueParams) (*EntitlementValueResult, error)
Get the customer's access through a single entitlement, optionally evaluated at a point in time.
func (*EntitlementsService) GetCustomerValueByFeatureKey ¶
func (s *EntitlementsService) GetCustomerValueByFeatureKey(ctx context.Context, customerID string, featureKey string, params GetCustomerEntitlementValueByFeatureKeyParams) (*EntitlementFeatureValueResult, error)
Get the customer's entitlement value for a feature at a point in time. Without an active entitlement, the result denies access and omits the type.
func (*EntitlementsService) List ¶
func (s *EntitlementsService) List(ctx context.Context, params ListEntitlementsParams) (*EntitlementPagePaginatedResponse, error)
List the active entitlements of all customers. Intended for administrative use. To list the entitlements of a single customer, use the customer entitlements endpoints; to check entitlement access, use the entitlement access endpoints.
func (*EntitlementsService) ListAll ¶
func (s *EntitlementsService) ListAll(ctx context.Context, params ListEntitlementsParams) iter.Seq2[Entitlement, error]
ListAll returns an iterator over all Entitlement results, fetching pages of List transparently. Iteration stops at the first error, which is yielded as the second value.
func (*EntitlementsService) ListCustomerAccess ¶
func (s *EntitlementsService) ListCustomerAccess(ctx context.Context, customerID string) (*ListCustomerEntitlementAccessResponseData, error)
type Event ¶
type Event struct {
// Identifies the event.
ID string `json:"id"`
// Identifies the context in which an event happened.
Source string `json:"source"`
// The version of the CloudEvents specification which the event uses.
Specversion string `json:"specversion"`
// Contains a value describing the type of event related to the originating
// occurrence.
Type string `json:"type"`
// Content type of the CloudEvents data value. Only the value "application/json" is
// allowed over HTTP.
Datacontenttype Nullable[string] `json:"datacontenttype,omitempty"`
// Identifies the schema that data adheres to.
Dataschema Nullable[string] `json:"dataschema,omitempty"`
// Describes the subject of the event in the context of the event producer
// (identified by source).
Subject string `json:"subject"`
// Timestamp of when the occurrence happened. Must adhere to RFC 3339.
Time Nullable[time.Time] `json:"time,omitempty"`
// The event payload. Optional, if present it must be a JSON object.
Data Nullable[map[string]any] `json:"data,omitempty"`
}
Metering event following the CloudEvents specification.
type EventInput ¶
type EventInput struct {
// Identifies the event.
ID string `json:"id"`
// Identifies the context in which an event happened.
Source string `json:"source"`
// The version of the CloudEvents specification which the event uses.
Specversion *string `json:"specversion,omitempty"`
// Contains a value describing the type of event related to the originating
// occurrence.
Type string `json:"type"`
// Content type of the CloudEvents data value. Only the value "application/json" is
// allowed over HTTP.
Datacontenttype Nullable[string] `json:"datacontenttype,omitempty"`
// Identifies the schema that data adheres to.
Dataschema Nullable[string] `json:"dataschema,omitempty"`
// Describes the subject of the event in the context of the event producer
// (identified by source).
Subject string `json:"subject"`
// Timestamp of when the occurrence happened. Must adhere to RFC 3339.
Time Nullable[time.Time] `json:"time,omitempty"`
// The event payload. Optional, if present it must be a JSON object.
Data Nullable[map[string]any] `json:"data,omitempty"`
}
Metering event following the CloudEvents specification.
type EventsService ¶
type EventsService struct {
// contains filtered or unexported fields
}
func (*EventsService) IngestEvent ¶
func (s *EventsService) IngestEvent(ctx context.Context, request EventInput) error
Ingests an event or batch of events following the CloudEvents specification.
func (*EventsService) IngestEvents ¶
func (s *EventsService) IngestEvents(ctx context.Context, request []EventInput) error
func (*EventsService) IngestEventsJSON ¶
func (s *EventsService) IngestEventsJSON(ctx context.Context, request OneOrMany[EventInput]) error
func (*EventsService) List ¶
func (s *EventsService) List(ctx context.Context, params IngestedEventListParams) (*IngestedEventPaginatedResponse, error)
List ingested events.
func (*EventsService) ListAll ¶
func (s *EventsService) ListAll(ctx context.Context, params IngestedEventListParams) iter.Seq2[IngestedEvent, error]
ListAll returns an iterator over all IngestedEvent results, fetching pages of List transparently. Iteration stops at the first error, which is yielded as the second value.
type Feature ¶
type Feature struct {
ID string `json:"id"`
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
Key string `json:"key"`
// The meter that the feature is associated with and based on which usage is
// calculated. If not specified, the feature is static.
Meter *FeatureMeterReference `json:"meter,omitempty"`
// Optional per-unit cost configuration. Use "manual" for a fixed per-unit cost, or
// "llm" to look up cost from the LLM cost database based on meter group-by
// properties.
UnitCost *FeatureUnitCost `json:"unit_cost,omitempty"`
}
A capability or billable dimension offered by a provider.
type FeatureCostQueryResult ¶
type FeatureCostQueryResult struct {
// Start of the queried period.
From *time.Time `json:"from,omitempty"`
// End of the queried period.
To *time.Time `json:"to,omitempty"`
// The cost data rows.
Data []FeatureCostQueryRow `json:"data"`
}
Result of a feature cost query.
type FeatureCostQueryRow ¶
type FeatureCostQueryRow struct {
// The metered usage value for the period.
Usage Numeric `json:"usage"`
// The computed cost amount (usage × unit cost). Null when pricing is not available
// for the given combination of dimensions.
Cost Nullable[Numeric] `json:"cost"`
// The currency code of the cost amount.
Currency string `json:"currency"`
// Detail message when cost amount is null, explaining why the cost could not be
// resolved.
Detail *string `json:"detail,omitempty"`
// The start of the time bucket the value is aggregated over.
From time.Time `json:"from"`
// The end of the time bucket the value is aggregated over.
To time.Time `json:"to"`
// The dimensions the value is aggregated over. `subject` and `customer_id` are
// reserved dimensions.
Dimensions map[string]string `json:"dimensions"`
}
A row in the result of a feature cost query.
type FeatureFilter ¶
type FeatureFilter struct {
MeterID *StringExactFilter
Key *StringFilter
Name *StringFilter
}
type FeatureLLMTokenType ¶
type FeatureLLMTokenType string
Token type for LLM cost lookup.
const ( FeatureLLMTokenTypeInput FeatureLLMTokenType = "input" FeatureLLMTokenTypeOutput FeatureLLMTokenType = "output" FeatureLLMTokenTypeCacheRead FeatureLLMTokenType = "cache_read" FeatureLLMTokenTypeCacheWrite FeatureLLMTokenType = "cache_write" FeatureLLMTokenTypeReasoning FeatureLLMTokenType = "reasoning" FeatureLLMTokenTypeRequest FeatureLLMTokenType = "request" FeatureLLMTokenTypeResponse FeatureLLMTokenType = "response" )
func (FeatureLLMTokenType) Valid ¶
func (value FeatureLLMTokenType) Valid() bool
type FeatureLLMUnitCost ¶
type FeatureLLMUnitCost struct {
// The type discriminator for LLM unit cost.
Type FeatureUnitCostType `json:"type"`
// Meter group-by property that holds the LLM provider. Use this when the meter has
// a group-by dimension for provider. Mutually exclusive with `provider`.
ProviderProperty *string `json:"provider_property,omitempty"`
// Static LLM provider value (e.g., "openai", "anthropic"). Use this when the
// feature tracks a single provider. Mutually exclusive with `provider_property`.
Provider *string `json:"provider,omitempty"`
// Meter group-by property that holds the model ID. Use this when the meter has a
// group-by dimension for model. Mutually exclusive with `model`.
ModelProperty *string `json:"model_property,omitempty"`
// Static model ID value (e.g., "gpt-4", "claude-3-5-sonnet"). Use this when the
// feature tracks a single model. Mutually exclusive with `model_property`.
Model *string `json:"model,omitempty"`
// Meter group-by property that holds the token type. Use this when the meter has a
// group-by dimension for token type. Mutually exclusive with `token_type`.
TokenTypeProperty *string `json:"token_type_property,omitempty"`
// Static token type value. Use this when the feature tracks a single token type
// (e.g., only input tokens). `request` is an alias for `input`, `response` is an
// alias for `output`. Mutually exclusive with `token_type_property`.
TokenType *FeatureLLMTokenType `json:"token_type,omitempty"`
// Resolved per-token pricing from the LLM cost database. Populated in responses
// when the provider and model can be determined, either from static values or from
// meter group-by filters with exact matches.
Pricing *FeatureLLMUnitCostPricing `json:"pricing,omitempty"`
}
LLM cost lookup configuration. Each dimension (provider, model, token type) can be specified as either a static value or a meter group-by property name (mutually exclusive).
type FeatureLLMUnitCostPricing ¶
type FeatureLLMUnitCostPricing struct {
// Cost per input token in USD.
InputPerToken Numeric `json:"input_per_token"`
// Cost per output token in USD.
OutputPerToken Numeric `json:"output_per_token"`
// Cost per cache read token in USD.
CacheReadPerToken *Numeric `json:"cache_read_per_token,omitempty"`
// Cost per reasoning token in USD.
ReasoningPerToken *Numeric `json:"reasoning_per_token,omitempty"`
// Cost per cache write token in USD.
CacheWritePerToken *Numeric `json:"cache_write_per_token,omitempty"`
}
Resolved per-token pricing from the LLM cost database.
type FeatureListParams ¶
type FeatureListParams struct {
Page *PageParams
Sort *Sort
Filter *FeatureFilter
}
type FeatureManualUnitCost ¶
type FeatureManualUnitCost struct {
// The type discriminator for manual unit cost.
Type FeatureUnitCostType `json:"type"`
// Fixed per-unit cost amount in USD.
Amount Numeric `json:"amount"`
}
A fixed per-unit cost amount.
type FeatureMeterReference ¶
type FeatureMeterReference struct {
// The ID of the meter to associate with this feature.
ID string `json:"id"`
// Filters to apply to the dimensions of the meter.
Filters map[string]QueryFilterStringMapItem `json:"filters,omitempty"`
}
Reference to a meter associated with a feature.
type FeatureMeterReferenceInput ¶
type FeatureMeterReferenceInput struct {
// The ID of the meter to associate with this feature.
ID string `json:"id"`
// Filters to apply to the dimensions of the meter.
Filters *map[string]QueryFilterStringMapItemInput `json:"filters,omitempty"`
}
Reference to a meter associated with a feature.
type FeatureOrReference ¶
type FeatureOrReference struct {
// contains filtered or unexported fields
}
Feature or reference.
FeatureOrReference is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the FeatureOrReferenceFrom* constructors.
func FeatureOrReferenceFromFeature ¶
func FeatureOrReferenceFromFeature(value Feature) (FeatureOrReference, error)
func FeatureOrReferenceFromFeatureReference ¶
func FeatureOrReferenceFromFeatureReference(value FeatureReference) (FeatureOrReference, error)
func (FeatureOrReference) AsFeature ¶
func (u FeatureOrReference) AsFeature() (*Feature, error)
func (FeatureOrReference) AsFeatureReference ¶
func (u FeatureOrReference) AsFeatureReference() (*FeatureReference, error)
func (FeatureOrReference) MarshalJSON ¶
func (u FeatureOrReference) MarshalJSON() ([]byte, error)
func (*FeatureOrReference) UnmarshalJSON ¶
func (u *FeatureOrReference) UnmarshalJSON(data []byte) error
type FeaturePagePaginatedResponse ¶
type FeaturePagePaginatedResponse struct {
Data []Feature `json:"data"`
Meta PaginatedMeta `json:"meta"`
}
Page paginated response.
type FeatureUnitCost ¶
type FeatureUnitCost struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
Per-unit cost configuration for a feature. Either a fixed manual amount or a dynamic LLM cost lookup.
FeatureUnitCost is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the FeatureUnitCostFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func FeatureUnitCostFromFeatureLLMUnitCost ¶
func FeatureUnitCostFromFeatureLLMUnitCost(value FeatureLLMUnitCost) (FeatureUnitCost, error)
func FeatureUnitCostFromFeatureManualUnitCost ¶
func FeatureUnitCostFromFeatureManualUnitCost(value FeatureManualUnitCost) (FeatureUnitCost, error)
func (FeatureUnitCost) AsFeatureLLMUnitCost ¶
func (u FeatureUnitCost) AsFeatureLLMUnitCost() (*FeatureLLMUnitCost, error)
func (FeatureUnitCost) AsFeatureManualUnitCost ¶
func (u FeatureUnitCost) AsFeatureManualUnitCost() (*FeatureManualUnitCost, error)
func (FeatureUnitCost) MarshalJSON ¶
func (u FeatureUnitCost) MarshalJSON() ([]byte, error)
func (*FeatureUnitCost) UnmarshalJSON ¶
func (u *FeatureUnitCost) UnmarshalJSON(data []byte) error
type FeatureUnitCostType ¶
type FeatureUnitCostType string
The type of unit cost.
const ( FeatureUnitCostTypeLLM FeatureUnitCostType = "llm" FeatureUnitCostTypeManual FeatureUnitCostType = "manual" )
func (FeatureUnitCostType) Valid ¶
func (value FeatureUnitCostType) Valid() bool
type FeaturesService ¶
type FeaturesService struct {
// contains filtered or unexported fields
}
func (*FeaturesService) Create ¶
func (s *FeaturesService) Create(ctx context.Context, request CreateFeatureRequest) (*Feature, error)
Create a feature.
func (*FeaturesService) Delete ¶
func (s *FeaturesService) Delete(ctx context.Context, featureID string) error
Delete a feature by id.
func (*FeaturesService) List ¶
func (s *FeaturesService) List(ctx context.Context, params FeatureListParams) (*FeaturePagePaginatedResponse, error)
List all features.
func (*FeaturesService) ListAll ¶
func (s *FeaturesService) ListAll(ctx context.Context, params FeatureListParams) iter.Seq2[Feature, error]
ListAll returns an iterator over all Feature results, fetching pages of List transparently. Iteration stops at the first error, which is yielded as the second value.
func (*FeaturesService) QueryCost ¶
func (s *FeaturesService) QueryCost(ctx context.Context, featureID string, request *MeterQueryRequest) (*FeatureCostQueryResult, error)
Query the cost of a feature.
func (*FeaturesService) Update ¶
func (s *FeaturesService) Update(ctx context.Context, featureID string, request UpdateFeatureRequest) (*Feature, error)
Update a feature by id. Currently only the unit_cost field can be updated.
type GetChargeParams ¶
type GetChargeParams struct {
Expand []ChargesExpand
}
type GetCustomerCreditBalanceFilter ¶
type GetCustomerCreditBalanceFilter struct {
// Filter credit balance by currency code. When historical custom currencies reuse
// a code, each managed currency is returned as a separate balance row.
Currency *StringExactFilter
// Filter credit balance by feature key. Omit to return the total portfolio value.
// Use `exists=false` to return only unrestricted balance.
FeatureKey *StringFilter
}
type GetCustomerCreditBalanceParams ¶
type GetCustomerCreditBalanceParams struct {
Timestamp *time.Time
Filter *GetCustomerCreditBalanceFilter
}
type GetCustomerEntitlementValueByFeatureKeyParams ¶
type GetCustomerEntitlementValueByFeatureKeyParams struct {
Expand []EntitlementAccessExpand
At *time.Time
}
type GetCustomerEntitlementValueParams ¶
type GetCustomerEntitlementValueParams struct {
Expand []EntitlementAccessExpand
At *time.Time
}
type GrantsService ¶
type GrantsService struct {
// contains filtered or unexported fields
}
func (*GrantsService) List ¶
func (s *GrantsService) List(ctx context.Context, params ListGrantsParams) (*EntitlementGrantPagePaginatedResponse, error)
List the grants of all customers and entitlements. To list the grants of a single entitlement, use the customer entitlement grants endpoint.
Deleted grants are excluded unless `include_deleted` is set. Voided and expired grants are always included, as they are part of the balance history.
func (*GrantsService) ListAll ¶
func (s *GrantsService) ListAll(ctx context.Context, params ListGrantsParams) iter.Seq2[EntitlementGrant, error]
ListAll returns an iterator over all EntitlementGrant results, fetching pages of List transparently. Iteration stops at the first error, which is yielded as the second value.
func (*GrantsService) Void ¶
func (s *GrantsService) Void(ctx context.Context, grantID string, params VoidGrantParams) error
Void a grant so it no longer adds to the balance. Usage already deducted from the grant is kept.
type IngestedEvent ¶
type IngestedEvent struct {
// The original event ingested.
Event Event `json:"event"`
// The customer if the event is associated with a customer.
Customer *CustomerReference `json:"customer,omitempty"`
// The date and time the event was ingested and its processing started.
IngestedAt time.Time `json:"ingested_at"`
// The date and time the event was stored in the database.
StoredAt time.Time `json:"stored_at"`
// The validation errors of the ingested event.
ValidationErrors []IngestedEventValidationError `json:"validation_errors,omitempty"`
}
An ingested metering event with ingestion metadata.
type IngestedEventFilter ¶
type IngestedEventFilter struct {
// Filter events by ID.
ID *StringFilter
// Filter events by source.
Source *StringFilter
// Filter events by subject.
Subject *StringFilter
// Filter events by type.
Type *StringFilter
// Filter events by the associated customer ID.
CustomerID *StringExactFilter
// Filter events by event time.
Time *DateTimeFilter
// Filter events by the time the event was ingested.
IngestedAt *DateTimeFilter
// Filter events by the time the event was stored.
StoredAt *DateTimeFilter
}
type IngestedEventListParams ¶
type IngestedEventListParams struct {
Page *CursorPageParams
Filter *IngestedEventFilter
Sort *Sort
}
type IngestedEventPaginatedResponse ¶
type IngestedEventPaginatedResponse struct {
Data []IngestedEvent `json:"data"`
Meta CursorMeta `json:"meta"`
}
Cursor paginated response.
type IngestedEventValidationError ¶
type IngestedEventValidationError struct {
// The machine readable code of the error.
Code string `json:"code"`
// The human readable description of the error.
Message string `json:"message"`
// Additional attributes.
Attributes map[string]any `json:"attributes,omitempty"`
}
Event validation errors.
type InstallAppExternalInvoicing ¶
type InstallAppExternalInvoicing struct {
// Type of the app.
Type AppType `json:"type"`
// Name of the app.
Name string `json:"name"`
// If true, creates the Auto Collection preset with an OpenMeter supplier in the US
// (postal code 94114), without replacing the default profile.
CreateBillingProfile bool `json:"create_billing_profile"`
}
Model for installing an External Invoicing app from the catalog.
type InstallAppRequest ¶
type InstallAppRequest struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
Request to install an app from the catalog.
InstallAppRequest is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the InstallAppRequestFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func InstallAppRequestFromInstallAppExternalInvoicing ¶
func InstallAppRequestFromInstallAppExternalInvoicing(value InstallAppExternalInvoicing) (InstallAppRequest, error)
func InstallAppRequestFromInstallAppSandbox ¶
func InstallAppRequestFromInstallAppSandbox(value InstallAppSandbox) (InstallAppRequest, error)
func InstallAppRequestFromInstallAppStripeWithAPIKey ¶
func InstallAppRequestFromInstallAppStripeWithAPIKey(value InstallAppStripeWithAPIKey) (InstallAppRequest, error)
func (InstallAppRequest) AsInstallAppExternalInvoicing ¶
func (u InstallAppRequest) AsInstallAppExternalInvoicing() (*InstallAppExternalInvoicing, error)
func (InstallAppRequest) AsInstallAppSandbox ¶
func (u InstallAppRequest) AsInstallAppSandbox() (*InstallAppSandbox, error)
func (InstallAppRequest) AsInstallAppStripeWithAPIKey ¶
func (u InstallAppRequest) AsInstallAppStripeWithAPIKey() (*InstallAppStripeWithAPIKey, error)
func (InstallAppRequest) MarshalJSON ¶
func (u InstallAppRequest) MarshalJSON() ([]byte, error)
func (*InstallAppRequest) UnmarshalJSON ¶
func (u *InstallAppRequest) UnmarshalJSON(data []byte) error
type InstallAppResponse ¶
type InstallAppResponse struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
Response of the app install.
InstallAppResponse is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the InstallAppResponseFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func InstallAppResponseFromInstalledAppExternalInvoicing ¶
func InstallAppResponseFromInstalledAppExternalInvoicing(value InstalledAppExternalInvoicing) (InstallAppResponse, error)
func InstallAppResponseFromInstalledAppSandbox ¶
func InstallAppResponseFromInstalledAppSandbox(value InstalledAppSandbox) (InstallAppResponse, error)
func InstallAppResponseFromInstalledAppStripe ¶
func InstallAppResponseFromInstalledAppStripe(value InstalledAppStripe) (InstallAppResponse, error)
func (InstallAppResponse) AsInstalledAppExternalInvoicing ¶
func (u InstallAppResponse) AsInstalledAppExternalInvoicing() (*InstalledAppExternalInvoicing, error)
func (InstallAppResponse) AsInstalledAppSandbox ¶
func (u InstallAppResponse) AsInstalledAppSandbox() (*InstalledAppSandbox, error)
func (InstallAppResponse) AsInstalledAppStripe ¶
func (u InstallAppResponse) AsInstalledAppStripe() (*InstalledAppStripe, error)
func (InstallAppResponse) MarshalJSON ¶
func (u InstallAppResponse) MarshalJSON() ([]byte, error)
func (*InstallAppResponse) UnmarshalJSON ¶
func (u *InstallAppResponse) UnmarshalJSON(data []byte) error
type InstallAppSandbox ¶
type InstallAppSandbox struct {
// Type of the app.
Type AppType `json:"type"`
// Name of the app.
Name string `json:"name"`
// If true, a billing profile will be created for the app. The Stripe app will be
// also set as the default billing profile if the current default is a Sandbox app.
CreateBillingProfile bool `json:"create_billing_profile"`
}
Base model for installing an app from the catalog.
type InstallAppStripeWithAPIKey ¶
type InstallAppStripeWithAPIKey struct {
// Type of the app.
Type AppType `json:"type"`
// Name of the app.
Name string `json:"name"`
// If true, a billing profile will be created for the app. The Stripe app will be
// also set as the default billing profile if the current default is a Sandbox app.
CreateBillingProfile bool `json:"create_billing_profile"`
// API key for the app.
APIKey string `json:"api_key"`
}
Model for installing an app from the catalog with an API key.
type InstalledAppExternalInvoicing ¶
type InstalledAppExternalInvoicing struct {
ID string `json:"id"`
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// The app type.
Type AppType `json:"type"`
// The app catalog definition that this installed app is based on.
Definition AppCatalogItem `json:"definition"`
// Status of the app connection.
Status AppStatus `json:"status"`
// Actions the operator should take to bring the app up to date. Omitted when no
// action is required.
Actions []AppAction `json:"actions,omitempty"`
// Enable draft synchronization hook.
//
// When enabled, invoices will pause at the draft state and wait for the
// integration to call the draft synchronized endpoint before progressing to the
// issuing state. This allows the external system to validate and prepare the
// invoice data.
//
// When disabled, invoices automatically progress through the draft state based on
// the configured workflow timing.
EnableDraftSyncHook bool `json:"enable_draft_sync_hook"`
// Enable issuing synchronization hook.
//
// When enabled, invoices will pause at the issuing state and wait for the
// integration to call the issuing synchronized endpoint before progressing to the
// issued state. This ensures the external invoicing system has successfully
// created and finalized the invoice before it is marked as issued.
//
// When disabled, invoices automatically progress through the issuing state and are
// immediately marked as issued.
EnableIssuingSyncHook bool `json:"enable_issuing_sync_hook"`
// Default capabilities of the installed app.
DefaultForCapabilityTypes []AppCapabilityType `json:"default_for_capability_types"`
}
Response of an installed app.
type InstalledAppSandbox ¶
type InstalledAppSandbox struct {
ID string `json:"id"`
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// The app type.
Type AppType `json:"type"`
// The app catalog definition that this installed app is based on.
Definition AppCatalogItem `json:"definition"`
// Status of the app connection.
Status AppStatus `json:"status"`
// Actions the operator should take to bring the app up to date. Omitted when no
// action is required.
Actions []AppAction `json:"actions,omitempty"`
// Default capabilities of the installed app.
DefaultForCapabilityTypes []AppCapabilityType `json:"default_for_capability_types"`
}
Response of an installed app.
type InstalledAppStripe ¶
type InstalledAppStripe struct {
ID string `json:"id"`
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// The app type.
Type AppType `json:"type"`
// The app catalog definition that this installed app is based on.
Definition AppCatalogItem `json:"definition"`
// Status of the app connection.
Status AppStatus `json:"status"`
// Actions the operator should take to bring the app up to date. Omitted when no
// action is required.
Actions []AppAction `json:"actions,omitempty"`
// The Stripe account ID associated with the connected Stripe account.
AccountID string `json:"account_id"`
// Indicates whether the app is connected to a live Stripe account.
Livemode bool `json:"livemode"`
// The masked Stripe API key that only exposes the first and last few characters.
MaskedAPIKey string `json:"masked_api_key"`
// Default capabilities of the installed app.
DefaultForCapabilityTypes []AppCapabilityType `json:"default_for_capability_types"`
}
Response of an installed app.
type Invoice ¶
type Invoice struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
An invoice issued to a customer.
The `type` field determines the concrete variant:
- `standard`: a standard invoice for charges owed.
Invoice is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the InvoiceFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func InvoiceFromInvoiceStandard ¶
func InvoiceFromInvoiceStandard(value InvoiceStandard) (Invoice, error)
func (Invoice) AsInvoiceStandard ¶
func (u Invoice) AsInvoiceStandard() (*InvoiceStandard, error)
func (Invoice) MarshalJSON ¶
func (*Invoice) UnmarshalJSON ¶
type InvoiceAvailableActionDetails ¶
type InvoiceAvailableActionDetails struct {
// The extended status the invoice will transition to after performing this action.
ResultingState string `json:"resulting_state"`
}
Details about an available invoice action including the resulting state.
type InvoiceAvailableActions ¶
type InvoiceAvailableActions struct {
// Advance the invoice to the next workflow step.
Advance *InvoiceAvailableActionDetails `json:"advance,omitempty"`
// Approve the invoice for issuance.
Approve *InvoiceAvailableActionDetails `json:"approve,omitempty"`
// Delete the invoice.
Delete *InvoiceAvailableActionDetails `json:"delete,omitempty"`
// Retry a failed workflow step.
Retry *InvoiceAvailableActionDetails `json:"retry,omitempty"`
// Snapshot the current usage quantities.
SnapshotQuantities *InvoiceAvailableActionDetails `json:"snapshot_quantities,omitempty"`
}
The set of state-transition actions available for an invoice in its current status.
A field is present only when that action is permitted from the current state.
type InvoiceCreatedV1Payload ¶
type InvoiceCreatedV1Payload struct {
// A unique identifier for the resource.
ID string `json:"id"`
// Optional description of the resource. Maximum 1024 characters.
Description *string `json:"description,omitempty"`
// Additional metadata for the resource.
Metadata Nullable[map[string]string] `json:"metadata,omitempty"`
// Timestamp of when the resource was created.
CreatedAt time.Time `json:"created_at"`
// Timestamp of when the resource was last updated.
UpdatedAt time.Time `json:"updated_at"`
// Timestamp of when the resource was permanently deleted.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// Type of the invoice.
//
// The type of invoice determines the purpose of the invoice and how it should be
// handled.
//
// Supported types:
//
// - standard: A regular commercial invoice document between a supplier and
// customer.
// - credit_note: Reflects a refund either partial or complete of the preceding
// document. A credit note effectively _extends_ the previous document.
Type NotificationEventV1InvoiceType `json:"type"`
// The taxable entity supplying the goods or services.
Supplier NotificationEventV1BillingParty `json:"supplier"`
// Legal entity receiving the goods or services.
Customer NotificationEventV1BillingInvoiceCustomerExtendedDetails `json:"customer"`
// Number specifies the human readable key used to reference this Invoice.
//
// The invoice number can change in the draft phases, as we are allocating
// temporary draft invoice numbers, but it's final as soon as the invoice gets
// finalized (issued state).
//
// Please note that the number is (depending on the upstream settings) either
// unique for the whole organization or unique for the customer, or in multi
// (stripe) account setups unique for the account.
Number string `json:"number"`
// Currency for all invoice line items.
//
// Multi currency invoices are not supported yet.
Currency string `json:"currency"`
// Key information regarding previous invoices and potentially details as to why
// they were corrected.
Preceding []NotificationEventV1InvoiceDocumentRef `json:"preceding,omitempty"`
// Summary of all the invoice totals, including taxes (calculated).
Totals NotificationEventV1InvoiceTotals `json:"totals"`
// The status of the invoice.
//
// This field only conatins a simplified status, for more detailed information use
// the statusDetails field.
Status NotificationEventV1InvoiceStatus `json:"status"`
// The details of the current invoice status.
StatusDetails NotificationEventV1InvoiceStatusDetails `json:"status_details"`
// The time the invoice was issued.
//
// Depending on the status of the invoice this can mean multiple things:
//
// - draft, gathering: The time the invoice will be issued based on the workflow
// settings.
// - issued: The time the invoice was issued.
IssuedAt *time.Time `json:"issued_at,omitempty"`
// The time until the invoice is in draft status.
//
// On draft invoice creation it is calculated from the workflow settings.
//
// If manual approval is required, the draftUntil time is set.
DraftUntil *time.Time `json:"draft_until,omitempty"`
// The time when the quantity snapshots on the invoice lines were taken.
QuantitySnapshotedAt *time.Time `json:"quantity_snapshoted_at,omitempty"`
// The time when the invoice will be/has been collected.
CollectionAt *time.Time `json:"collection_at,omitempty"`
// Due time of the fulfillment of the invoice (if available).
DueAt *time.Time `json:"due_at,omitempty"`
// The period the invoice covers. If the invoice has no line items, it's not set.
Period *NotificationEventV1Period `json:"period,omitempty"`
// The time the invoice was voided.
//
// If the invoice was voided, this field will be set to the time the invoice was
// voided.
VoidedAt *time.Time `json:"voided_at,omitempty"`
// The time the invoice was sent to customer.
SentToCustomerAt *time.Time `json:"sent_to_customer_at,omitempty"`
// The workflow associated with the invoice.
//
// It is always a snapshot of the workflow settings at the time of invoice
// creation. The field is optional as it should be explicitly requested with expand
// options.
Workflow NotificationEventV1InvoiceWorkflowSettings `json:"workflow"`
// List of invoice lines representing each of the items sold to the customer.
Lines []NotificationEventV1InvoiceLine `json:"lines,omitempty"`
// Information on when, how, and to whom the invoice should be paid.
Payment *NotificationEventV1InvoicePaymentTerms `json:"payment,omitempty"`
// Validation issues reported by the invoice workflow.
ValidationIssues []NotificationEventV1ValidationIssue `json:"validation_issues,omitempty"`
// External IDs of the invoice in other apps such as Stripe.
ExternalIds *NotificationEventV1InvoiceAppExternalIds `json:"external_ids,omitempty"`
}
An invoice was created. The payload is the invoice as it was created.
Legacy name: `invoice.created`.
type InvoiceCustomer ¶
type InvoiceCustomer struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Mapping to attribute metered usage to the customer by the event subject.
UsageAttribution *CustomerUsageAttribution `json:"usage_attribution,omitempty"`
// The billing address of the customer. Used for tax and invoicing.
BillingAddress *Address `json:"billing_address,omitempty"`
ID string `json:"id"`
// Optional external resource key for the customer.
//
// Omitted when the customer was created without a key. Unlike on the customer
// resource itself, the key is optional here because the invoice snapshot may
// predate or omit it.
Key *string `json:"key,omitempty"`
}
Snapshot of the customer's information at the time the invoice was issued.
type InvoiceCustomerChargesInput ¶
type InvoiceCustomerChargesInput struct {
// Collection cutoff. Defaults to the current time and cannot be in the future.
AsOf *time.Time `json:"as_of,omitempty"`
// Override the customer's progressive billing setting for this collection. When
// enabled, eligible usage-based lines can be collected for a partial period.
ProgressiveBillingOverride *bool `json:"progressive_billing_override,omitempty"`
}
Options for manually collecting a customer's pending lines into invoices.
type InvoiceCustomerChargesResult ¶
type InvoiceCustomerChargesResult struct {
// Created standard invoices, one per collected currency.
Invoices []Invoice `json:"invoices"`
}
Result of manually collecting a customer's pending lines into invoices.
type InvoiceDetailedLine ¶
type InvoiceDetailedLine struct {
ID string `json:"id"`
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// The service period covered by this detailed line.
ServicePeriod ClosedPeriod `json:"service_period"`
// Aggregated financial totals for the detailed line.
Totals Totals `json:"totals"`
// The cost category of this detailed line.
Category InvoiceDetailedLineCostCategory `json:"category"`
// Discounts applied to this detailed line.
Discounts *InvoiceLineDiscounts `json:"discounts,omitempty"`
// Credit applied to this detailed line.
CreditsApplied []InvoiceLineCreditsApplied `json:"credits_applied,omitempty"`
// External identifiers for this detailed line.
ExternalReferences *InvoiceLineExternalReferences `json:"external_references,omitempty"`
// The quantity of the detailed line.
Quantity Numeric `json:"quantity"`
// The unit price of the detailed line.
UnitPrice Numeric `json:"unit_price"`
}
A detailed (child) sub-line belonging to a parent invoice line.
Detailed lines represent the individual flat-fee components that make up a usage-based parent line after quantity snapshotting.
type InvoiceDetailedLineCostCategory ¶
type InvoiceDetailedLineCostCategory string
Cost category of a detailed invoice line item.
const ( InvoiceDetailedLineCostCategoryRegular InvoiceDetailedLineCostCategory = "regular" InvoiceDetailedLineCostCategoryCommitment InvoiceDetailedLineCostCategory = "commitment" )
func (InvoiceDetailedLineCostCategory) Valid ¶
func (value InvoiceDetailedLineCostCategory) Valid() bool
type InvoiceDiscountReason ¶
type InvoiceDiscountReason string
The reason a discount was applied to an invoice line.
const ( InvoiceDiscountReasonMaximumSpend InvoiceDiscountReason = "maximum_spend" InvoiceDiscountReasonRatecardPercentage InvoiceDiscountReason = "ratecard_percentage" InvoiceDiscountReasonRatecardUsage InvoiceDiscountReason = "ratecard_usage" )
func (InvoiceDiscountReason) Valid ¶
func (value InvoiceDiscountReason) Valid() bool
type InvoiceExternalReferences ¶
type InvoiceExternalReferences struct {
// The ID assigned by the external invoicing app (e.g. Stripe invoice ID).
InvoicingID *string `json:"invoicing_id,omitempty"`
// The ID assigned by the external payment app (e.g. Stripe payment intent ID).
PaymentID *string `json:"payment_id,omitempty"`
}
External identifiers assigned to an invoice by third-party systems.
type InvoiceFilter ¶
type InvoiceFilter struct {
// Filter by invoice status.
Status *StringExactFilter
// Filter by customer ID.
CustomerID *StringExactFilter
// Filter by the time the invoice was issued.
IssuedAt *DateTimeFilter
// Filter by service period start.
ServicePeriodStart *DateTimeFilter
// Filter by invoice creation time.
CreatedAt *DateTimeFilter
}
type InvoiceLine ¶
type InvoiceLine struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
A top-level line item on an invoice.
Each line represents a single charge, typically associated with a rate card from a subscription. Detailed (child) lines are nested under `detailed_lines` when present.
InvoiceLine is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the InvoiceLineFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func InvoiceLineFromInvoiceStandardLine ¶
func InvoiceLineFromInvoiceStandardLine(value InvoiceStandardLine) (InvoiceLine, error)
func (InvoiceLine) AsInvoiceStandardLine ¶
func (u InvoiceLine) AsInvoiceStandardLine() (*InvoiceStandardLine, error)
func (InvoiceLine) MarshalJSON ¶
func (u InvoiceLine) MarshalJSON() ([]byte, error)
func (*InvoiceLine) UnmarshalJSON ¶
func (u *InvoiceLine) UnmarshalJSON(data []byte) error
type InvoiceLineAmountDiscount ¶
type InvoiceLineAmountDiscount struct {
// Unique identifier for the discount.
ID string `json:"id"`
// The reason this discount was applied.
Reason InvoiceDiscountReason `json:"reason"`
// Optional human-readable description of the discount.
Description *string `json:"description,omitempty"`
// External identifiers for this discount.
ExternalReferences *InvoiceLineExternalReferences `json:"external_references,omitempty"`
// The monetary amount deducted.
Amount Numeric `json:"amount"`
}
A monetary amount discount applied to an invoice line item.
type InvoiceLineCreditsApplied ¶
type InvoiceLineCreditsApplied struct {
// The monetary amount credited.
Amount Numeric `json:"amount"`
// Optional human-readable description of the credit allocation.
Description *string `json:"description,omitempty"`
}
A credit allocation applied to an invoice line item.
type InvoiceLineDiscounts ¶
type InvoiceLineDiscounts struct {
// Monetary amount discounts (e.g. from maximum spend commitments).
Amount []InvoiceLineAmountDiscount `json:"amount,omitempty"`
// Usage quantity discounts (e.g. free tier usage allowances).
Usage []InvoiceLineUsageDiscount `json:"usage,omitempty"`
}
Discounts applied to an invoice line item.
type InvoiceLineExternalReferences ¶
type InvoiceLineExternalReferences struct {
// The ID assigned by the external invoicing app.
InvoicingID *string `json:"invoicing_id,omitempty"`
}
External identifiers for an invoice line item assigned by third-party systems.
type InvoiceLineRateCard ¶
type InvoiceLineRateCard struct {
// The price definition used to calculate charges for this line.
Price Price `json:"price"`
// Tax configuration snapshot for this line.
TaxConfig *TaxCodeConfig `json:"tax_config,omitempty"`
// The feature key associated with this line's rate card.
FeatureKey *string `json:"feature_key,omitempty"`
// Discount configuration from the rate card.
Discounts *RateCardDiscounts `json:"discounts,omitempty"`
// Unit config snapshot applied when this line was billed, converting the raw
// metered quantity into the billed quantity. Frozen at billing time; read-only.
UnitConfig *UnitConfig `json:"unit_config,omitempty"`
}
Rate card configuration snapshot for a usage-based invoice line.
type InvoiceLineType ¶
type InvoiceLineType string
Line item type discriminator.
const (
InvoiceLineTypeStandardLine InvoiceLineType = "standard_line"
)
func (InvoiceLineType) Valid ¶
func (value InvoiceLineType) Valid() bool
type InvoiceLineUsageDiscount ¶
type InvoiceLineUsageDiscount struct {
// Unique identifier for the discount.
ID string `json:"id"`
// The reason this discount was applied.
Reason InvoiceDiscountReason `json:"reason"`
// Optional human-readable description of the discount.
Description *string `json:"description,omitempty"`
// External identifiers for this discount.
ExternalReferences *InvoiceLineExternalReferences `json:"external_references,omitempty"`
// The usage quantity deducted (in billing units).
Quantity Numeric `json:"quantity"`
}
A usage quantity discount applied to an invoice line item.
type InvoiceListParams ¶
type InvoiceListParams struct {
Page *PageParams
Sort *Sort
Filter *InvoiceFilter
}
type InvoicePagePaginatedResponse ¶
type InvoicePagePaginatedResponse struct {
Data []Invoice `json:"data"`
Meta PaginatedMeta `json:"meta"`
}
Page paginated response.
type InvoiceStandard ¶
type InvoiceStandard struct {
ID string `json:"id"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// Human-readable invoice number generated by the invoicing app.
Number string `json:"number"`
// Three-letter ISO 4217 currency code for the invoice.
Currency string `json:"currency"`
// Snapshot of the supplier's contact information at the time the invoice was
// issued.
Supplier Supplier `json:"supplier"`
// Snapshot of the customer's information at the time the invoice was issued.
Customer InvoiceCustomer `json:"customer"`
// Aggregated financial totals for the invoice.
Totals Totals `json:"totals"`
// The service period covered by this invoice.
//
// For flat fee the service period can be empty which means `from` will be equals
// to `to`. In other cases those fields will be filled with the actual service
// period.
ServicePeriod ClosedPeriod `json:"service_period"`
// Validation issues found during invoice processing.
//
// Present only when there are one or more validation findings. An empty list is
// omitted.
ValidationIssues []ValidationIssue `json:"validation_issues,omitempty"`
// External identifiers assigned to this invoice by third-party systems.
ExternalReferences *InvoiceExternalReferences `json:"external_references,omitempty"`
// Discriminator field identifying this as a standard invoice.
Type InvoiceType `json:"type"`
// Current lifecycle status of the invoice.
Status InvoiceStandardStatus `json:"status"`
// Detailed status information including available actions and workflow state.
StatusDetails InvoiceStatusDetails `json:"status_details"`
// Timestamp when the invoice was issued to the customer.
IssuedAt *time.Time `json:"issued_at,omitempty"`
// Timestamp until which the invoice remains in draft state.
//
// The invoice advances automatically once this time is reached.
DraftUntil *time.Time `json:"draft_until,omitempty"`
// Timestamp when usage quantities were last snapshotted for this invoice.
QuantitySnapshottedAt *time.Time `json:"quantity_snapshotted_at,omitempty"`
// Timestamp when collection was initiated for this invoice.
CollectionAt *time.Time `json:"collection_at,omitempty"`
// Timestamp when payment is due.
DueAt *time.Time `json:"due_at,omitempty"`
// Timestamp when the invoice was sent to the customer.
SentToCustomerAt *time.Time `json:"sent_to_customer_at,omitempty"`
// Workflow configuration snapshot captured at invoice creation time.
Workflow InvoiceWorkflowSettings `json:"workflow"`
// Line items on this invoice.
//
// Always returned on single-resource GET; omitted on list endpoints unless
// explicitly expanded. Editable via update: existing lines are matched by `id`,
// lines without an `id` are created, and lines present on the invoice but omitted
// from the update request are deleted. Detailed (child) lines are always computed
// and cannot be edited directly.
Lines []InvoiceLine `json:"lines,omitempty"`
}
A standard invoice for charges owed by the customer.
type InvoiceStandardLine ¶
type InvoiceStandardLine struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// ID of the line.
//
// Optional on update: omit to create a new line, or supply the ID of an existing
// line to edit it. Existing lines omitted from an update's `lines` array are
// deleted.
ID *string `json:"id,omitempty"`
// The type of charge this line item represents.
Type InvoiceLineType `json:"type"`
// Indicates whether this line item's lifecycle is controlled by OpenMeter or
// manually overridden by the API user.
LifecycleController LifecycleController `json:"lifecycle_controller"`
// The service period covered by this invoice, spanning the earliest line start to
// the latest line end across all of its lines.
//
// For an invoice with no lines the period is empty, which means `from` will be
// equal to `to`.
ServicePeriod ClosedPeriod `json:"service_period"`
// Aggregated financial totals for the line item.
Totals Totals `json:"totals"`
// Discounts applied to this line item.
Discounts *InvoiceLineDiscounts `json:"discounts,omitempty"`
// Credit applied to this line item.
CreditsApplied []InvoiceLineCreditsApplied `json:"credits_applied,omitempty"`
// External identifiers for this line item assigned by third-party systems.
ExternalReferences *InvoiceLineExternalReferences `json:"external_references,omitempty"`
// Reference to the subscription item that generated this line.
Subscription *SubscriptionReference `json:"subscription,omitempty"`
// The rate card configuration snapshot used to price this line item.
RateCard InvoiceLineRateCard `json:"rate_card"`
// Detailed sub-lines that this line has been broken down into.
//
// Present when line has individual details.
DetailedLines []InvoiceDetailedLine `json:"detailed_lines"`
// Usage quantity details for this line when UnitConfig is in effect.
//
// Read-only; omitted for lines without unit conversion.
UsageQuantityDetail *InvoiceUsageQuantityDetail `json:"usage_quantity_detail,omitempty"`
// Reference to the charge associated with this line item.
Charge *ChargeReference `json:"charge,omitempty"`
}
A top-level line item on an invoice.
Each line represents a single charge, typically associated with a rate card from a subscription. Detailed (child) lines are nested under `detailed_lines` when present.
type InvoiceStandardStatus ¶
type InvoiceStandardStatus string
Lifecycle status of a standard invoice.
const ( InvoiceStandardStatusDraft InvoiceStandardStatus = "draft" InvoiceStandardStatusIssuing InvoiceStandardStatus = "issuing" InvoiceStandardStatusIssued InvoiceStandardStatus = "issued" InvoiceStandardStatusPaymentProcessing InvoiceStandardStatus = "payment_processing" InvoiceStandardStatusOverdue InvoiceStandardStatus = "overdue" InvoiceStandardStatusPaid InvoiceStandardStatus = "paid" InvoiceStandardStatusUncollectible InvoiceStandardStatus = "uncollectible" InvoiceStandardStatusVoided InvoiceStandardStatus = "voided" )
func (InvoiceStandardStatus) Valid ¶
func (value InvoiceStandardStatus) Valid() bool
type InvoiceStatusDetails ¶
type InvoiceStatusDetails struct {
// Whether the invoice is immutable (i.e. cannot be modified or deleted).
Immutable bool `json:"immutable"`
// Whether the invoice is in a failed state.
Failed bool `json:"failed"`
// Fine-grained internal status string providing additional workflow detail beyond
// the top-level status enum.
ExtendedStatus string `json:"extended_status"`
// The set of state-transition actions currently available for this invoice.
AvailableActions InvoiceAvailableActions `json:"available_actions"`
}
Detailed status information for a standard invoice.
type InvoiceType ¶
type InvoiceType string
The type of a billing invoice.
const (
InvoiceTypeStandard InvoiceType = "standard"
)
func (InvoiceType) Valid ¶
func (value InvoiceType) Valid() bool
type InvoiceUpdatedV1Payload ¶
type InvoiceUpdatedV1Payload struct {
// A unique identifier for the resource.
ID string `json:"id"`
// Optional description of the resource. Maximum 1024 characters.
Description *string `json:"description,omitempty"`
// Additional metadata for the resource.
Metadata Nullable[map[string]string] `json:"metadata,omitempty"`
// Timestamp of when the resource was created.
CreatedAt time.Time `json:"created_at"`
// Timestamp of when the resource was last updated.
UpdatedAt time.Time `json:"updated_at"`
// Timestamp of when the resource was permanently deleted.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// Type of the invoice.
//
// The type of invoice determines the purpose of the invoice and how it should be
// handled.
//
// Supported types:
//
// - standard: A regular commercial invoice document between a supplier and
// customer.
// - credit_note: Reflects a refund either partial or complete of the preceding
// document. A credit note effectively _extends_ the previous document.
Type NotificationEventV1InvoiceType `json:"type"`
// The taxable entity supplying the goods or services.
Supplier NotificationEventV1BillingParty `json:"supplier"`
// Legal entity receiving the goods or services.
Customer NotificationEventV1BillingInvoiceCustomerExtendedDetails `json:"customer"`
// Number specifies the human readable key used to reference this Invoice.
//
// The invoice number can change in the draft phases, as we are allocating
// temporary draft invoice numbers, but it's final as soon as the invoice gets
// finalized (issued state).
//
// Please note that the number is (depending on the upstream settings) either
// unique for the whole organization or unique for the customer, or in multi
// (stripe) account setups unique for the account.
Number string `json:"number"`
// Currency for all invoice line items.
//
// Multi currency invoices are not supported yet.
Currency string `json:"currency"`
// Key information regarding previous invoices and potentially details as to why
// they were corrected.
Preceding []NotificationEventV1InvoiceDocumentRef `json:"preceding,omitempty"`
// Summary of all the invoice totals, including taxes (calculated).
Totals NotificationEventV1InvoiceTotals `json:"totals"`
// The status of the invoice.
//
// This field only conatins a simplified status, for more detailed information use
// the statusDetails field.
Status NotificationEventV1InvoiceStatus `json:"status"`
// The details of the current invoice status.
StatusDetails NotificationEventV1InvoiceStatusDetails `json:"status_details"`
// The time the invoice was issued.
//
// Depending on the status of the invoice this can mean multiple things:
//
// - draft, gathering: The time the invoice will be issued based on the workflow
// settings.
// - issued: The time the invoice was issued.
IssuedAt *time.Time `json:"issued_at,omitempty"`
// The time until the invoice is in draft status.
//
// On draft invoice creation it is calculated from the workflow settings.
//
// If manual approval is required, the draftUntil time is set.
DraftUntil *time.Time `json:"draft_until,omitempty"`
// The time when the quantity snapshots on the invoice lines were taken.
QuantitySnapshotedAt *time.Time `json:"quantity_snapshoted_at,omitempty"`
// The time when the invoice will be/has been collected.
CollectionAt *time.Time `json:"collection_at,omitempty"`
// Due time of the fulfillment of the invoice (if available).
DueAt *time.Time `json:"due_at,omitempty"`
// The period the invoice covers. If the invoice has no line items, it's not set.
Period *NotificationEventV1Period `json:"period,omitempty"`
// The time the invoice was voided.
//
// If the invoice was voided, this field will be set to the time the invoice was
// voided.
VoidedAt *time.Time `json:"voided_at,omitempty"`
// The time the invoice was sent to customer.
SentToCustomerAt *time.Time `json:"sent_to_customer_at,omitempty"`
// The workflow associated with the invoice.
//
// It is always a snapshot of the workflow settings at the time of invoice
// creation. The field is optional as it should be explicitly requested with expand
// options.
Workflow NotificationEventV1InvoiceWorkflowSettings `json:"workflow"`
// List of invoice lines representing each of the items sold to the customer.
Lines []NotificationEventV1InvoiceLine `json:"lines,omitempty"`
// Information on when, how, and to whom the invoice should be paid.
Payment *NotificationEventV1InvoicePaymentTerms `json:"payment,omitempty"`
// Validation issues reported by the invoice workflow.
ValidationIssues []NotificationEventV1ValidationIssue `json:"validation_issues,omitempty"`
// External IDs of the invoice in other apps such as Stripe.
ExternalIds *NotificationEventV1InvoiceAppExternalIds `json:"external_ids,omitempty"`
}
An invoice was updated. The payload is the invoice after the update.
Legacy name: `invoice.updated`.
type InvoiceUsageQuantityDetail ¶
type InvoiceUsageQuantityDetail struct {
// The raw quantity as reported by the meter (native units).
RawQuantity Numeric `json:"raw_quantity"`
// The net billed quantity for this line in converted units, after rounding and any
// usage discounts.
InvoicedQuantity Numeric `json:"invoiced_quantity"`
// The display unit label (e.g., "GB", "hours", "M tokens").
DisplayUnit *string `json:"display_unit,omitempty"`
}
Usage quantity details on an invoice line item when UnitConfig is in effect.
Provides the full audit trail from raw meter output to the invoiced amount.
type InvoiceWorkflow ¶
type InvoiceWorkflow struct {
// Invoicing settings for this invoice.
Invoicing *InvoiceWorkflowInvoicingSettings `json:"invoicing,omitempty"`
// Payment settings for this invoice.
Payment *WorkflowPaymentSettings `json:"payment,omitempty"`
}
Invoice-level snapshot of the workflow configuration.
Contains only the settings that are meaningful for an already-created invoice: invoicing behaviour and payment settings. Collection alignment and tax policy are gather-time / profile-wide concerns and are not included.
type InvoiceWorkflowAppsReferences ¶
type InvoiceWorkflowAppsReferences struct {
// The tax app used for this workflow
Tax AppReference `json:"tax"`
// The invoicing app used for this workflow
Invoicing AppReference `json:"invoicing"`
// The payment app used for this workflow
Payment AppReference `json:"payment"`
}
BillingInvoiceWorkflowAppsReferences represents the references (id) to the apps used by a billing profile
type InvoiceWorkflowInvoicingSettings ¶
type InvoiceWorkflowInvoicingSettings struct {
// Whether to automatically issue the invoice after the draft_period has passed.
AutoAdvance *bool `json:"auto_advance,omitempty"`
// The period for the invoice to be kept in draft status for manual reviews.
DraftPeriod *string `json:"draft_period,omitempty"`
// The period after which the invoice is considered overdue if not paid.
DueAfter *string `json:"due_after,omitempty"`
}
Invoice-level invoicing settings.
A subset of BillingWorkflowInvoicingSettings limited to fields that are meaningful per-invoice. progressive_billing is omitted as it is a gather-time / profile-level decision.
type InvoiceWorkflowSettings ¶
type InvoiceWorkflowSettings struct {
// The apps that will be used to orchestrate the invoice's workflow.
Apps *InvoiceWorkflowAppsReferences `json:"apps,omitempty"`
// The billing profile that was the source of this workflow snapshot.
SourceBillingProfile ProfileReference `json:"source_billing_profile"`
// The workflow configuration that was active when the invoice was created.
//
// Only the fields that are meaningful at the per-invoice level are included:
// invoicing behaviour (auto-advance, draft period) and payment settings
// (collection method, due date). Profile-wide settings such as collection
// alignment, progressive billing, and tax policy are omitted.
Workflow InvoiceWorkflow `json:"workflow"`
}
Snapshot of the billing workflow configuration captured at invoice creation.
type InvoicesService ¶
type InvoicesService struct {
// contains filtered or unexported fields
}
func (*InvoicesService) Advance ¶
Advance a billing invoice.
Advances the invoice to the next workflow state. The next state is determined by the invoice's current status and workflow configuration. Only invoices in draft or issued status can be advanced.
func (*InvoicesService) Approve ¶
Approve a billing invoice.
This call instantly sends the invoice to the customer using the configured billing profile app.
This call is valid in two invoice statuses:
- draft: the invoice will be sent to the customer, the invoice state becomes issued - manual_approval_needed: the invoice will be sent to the customer, the invoice state becomes issued
func (*InvoicesService) Delete ¶
func (s *InvoicesService) Delete(ctx context.Context, invoiceID string) error
Delete a billing invoice.
Only standard invoices in draft status can be deleted. Deleting an invoice will also delete all associated line items and workflow configuration.
func (*InvoicesService) Get ¶
Get a billing invoice by ID.
Returns the full invoice resource including line items, status details, totals, and workflow configuration snapshot.
func (*InvoicesService) List ¶
func (s *InvoicesService) List(ctx context.Context, params InvoiceListParams) (*InvoicePagePaginatedResponse, error)
List billing invoices.
Returns a page of invoices. Gathering invoices are never included. Use `filter` to narrow by status, customer, dates, or service period start. Use `sort` to control ordering.
func (*InvoicesService) ListAll ¶
func (s *InvoicesService) ListAll(ctx context.Context, params InvoiceListParams) iter.Seq2[Invoice, error]
ListAll returns an iterator over all Invoice results, fetching pages of List transparently. Iteration stops at the first error, which is yielded as the second value.
func (*InvoicesService) Retry ¶
Retry sending a billing invoice.
Retry advancing the invoice after a failed attempt.
The action can be called when the invoice's statusDetails' actions field contain the "retry" action.
func (*InvoicesService) SnapshotQuantities ¶
func (s *InvoicesService) SnapshotQuantities(ctx context.Context, invoiceID string) (*Invoice, error)
Snapshot quantities for usage-based line items.
This call will snapshot the quantities for all usage based line items in the invoice.
This call is only valid in draft.waiting_for_collection status, where the collection period can be skipped using this action.
func (*InvoicesService) Update ¶
func (s *InvoicesService) Update(ctx context.Context, invoiceID string, request UpdateInvoiceRequest) (*Invoice, error)
Update a billing invoice.
Only the mutable fields of the invoice can be edited: description, labels, supplier, customer, workflow settings, and top-level lines. Top-level lines are matched by `id`; lines without an `id` are created, and existing lines omitted from `lines` are deleted. Detailed (child) lines are always computed and cannot be edited directly. Only invoices in draft status can be updated.
type LLMCostModel ¶
type LLMCostModel struct {
// Identifier of the model, e.g., "gpt-4", "claude-3-5-sonnet".
ID string `json:"id"`
// Name of the model, e.g., "GPT-4", "Claude 3.5 Sonnet".
Name string `json:"name"`
}
LLM Model
type LLMCostModelPricing ¶
type LLMCostModelPricing struct {
// Input price per token (USD).
InputPerToken Numeric `json:"input_per_token"`
// Output price per token (USD).
OutputPerToken Numeric `json:"output_per_token"`
// Cache read price per token (USD).
CacheReadPerToken *Numeric `json:"cache_read_per_token,omitempty"`
// Cache write price per token (USD).
CacheWritePerToken *Numeric `json:"cache_write_per_token,omitempty"`
// Reasoning output price per token (USD).
ReasoningPerToken *Numeric `json:"reasoning_per_token,omitempty"`
}
Token pricing for an LLM model, denominated per token.
type LLMCostOverrideCreate ¶
type LLMCostOverrideCreate struct {
// Provider/vendor of the model.
Provider string `json:"provider"`
// Canonical model identifier.
ModelID string `json:"model_id"`
// Human-readable model name.
ModelName *string `json:"model_name,omitempty"`
// Token pricing data.
Pricing LLMCostModelPricing `json:"pricing"`
// Currency code.
Currency string `json:"currency"`
// When this override becomes effective.
EffectiveFrom time.Time `json:"effective_from"`
// When this override expires.
EffectiveTo *time.Time `json:"effective_to,omitempty"`
}
Input for creating a per-namespace price override. Unique per provider, model and currency. If an override already exists for the given provider, model and currency, it will be updated. If an override does not exist, it will be created.
type LLMCostPrice ¶
type LLMCostPrice struct {
// Unique identifier.
ID string `json:"id"`
// Provider of the model.
Provider LLMCostProvider `json:"provider"`
// The model.
Model LLMCostModel `json:"model"`
// Token pricing data.
Pricing LLMCostModelPricing `json:"pricing"`
// Currency code (currently always "USD").
Currency string `json:"currency"`
// Where this price came from.
Source LLMCostPriceSource `json:"source"`
// When this price becomes effective.
EffectiveFrom time.Time `json:"effective_from"`
// When this price expires. Omitted when the price is currently effective.
EffectiveTo *time.Time `json:"effective_to,omitempty"`
// Creation timestamp.
CreatedAt time.Time `json:"created_at"`
// Last update timestamp.
UpdatedAt time.Time `json:"updated_at"`
}
An LLM cost price record, representing the cost per token for a specific model from a specific provider.
type LLMCostPriceSource ¶
type LLMCostPriceSource string
Identifies where an LLM cost price came from.
const ( LLMCostPriceSourceManual LLMCostPriceSource = "manual" LLMCostPriceSourceSystem LLMCostPriceSource = "system" )
func (LLMCostPriceSource) Valid ¶
func (value LLMCostPriceSource) Valid() bool
type LLMCostProvider ¶
type LLMCostProvider struct {
// Identifier of the provider, e.g., "openai", "anthropic".
ID string `json:"id"`
// Name of the provider, e.g., "OpenAI", "Anthropic".
Name string `json:"name"`
}
LLM Provider
type LLMCostService ¶
type LLMCostService struct {
// contains filtered or unexported fields
}
func (*LLMCostService) CreateOverride ¶
func (s *LLMCostService) CreateOverride(ctx context.Context, request LLMCostOverrideCreate) (*LLMCostPrice, error)
Create a per-namespace price override.
func (*LLMCostService) DeleteOverride ¶
func (s *LLMCostService) DeleteOverride(ctx context.Context, priceID string) error
Delete a per-namespace price override.
func (*LLMCostService) GetPrice ¶
func (s *LLMCostService) GetPrice(ctx context.Context, priceID string) (*LLMCostPrice, error)
Get a specific LLM cost price by ID. Returns the price with overrides applied if any.
func (*LLMCostService) ListOverrides ¶
func (s *LLMCostService) ListOverrides(ctx context.Context, params ListLLMCostOverridesParams) (*PricePagePaginatedResponse, error)
List per-namespace price overrides.
func (*LLMCostService) ListOverridesAll ¶
func (s *LLMCostService) ListOverridesAll(ctx context.Context, params ListLLMCostOverridesParams) iter.Seq2[LLMCostPrice, error]
ListOverridesAll returns an iterator over all LLMCostPrice results, fetching pages of ListOverrides transparently. Iteration stops at the first error, which is yielded as the second value.
func (*LLMCostService) ListPrices ¶
func (s *LLMCostService) ListPrices(ctx context.Context, params ListLLMCostPricesParams) (*PricePagePaginatedResponse, error)
List global LLM cost prices. Returns prices with overrides applied if any.
func (*LLMCostService) ListPricesAll ¶
func (s *LLMCostService) ListPricesAll(ctx context.Context, params ListLLMCostPricesParams) iter.Seq2[LLMCostPrice, error]
ListPricesAll returns an iterator over all LLMCostPrice results, fetching pages of ListPrices transparently. Iteration stops at the first error, which is yielded as the second value.
type LifecycleController ¶
type LifecycleController string
Identifies whether a resource lifecycle is controlled by OpenMeter or manually overridden by the API user.
Values:
- `system`: The resource lifecycle is controlled by OpenMeter. - `manual`: The resource lifecycle was manually overridden by the API user.
const ( LifecycleControllerSystem LifecycleController = "system" LifecycleControllerManual LifecycleController = "manual" )
func (LifecycleController) Valid ¶
func (value LifecycleController) Valid() bool
type ListChargesFilter ¶
type ListChargesFilter struct {
// Filter charges by status.
//
// Supported statuses are:
//
// - `created`
// - `active`
// - `final`
// - `deleted`
//
// If omitted, all statuses are returned except for `deleted`.
Status *StringExactFilter
// Filter charges by the ID of their associated feature.
FeatureID *StringExactFilter
// Filter charges by the key of their associated feature.
FeatureKey *StringExactFilter
// Filter charges by the start of their service period.
ServicePeriodFrom *DateTimeFilter
// Filter charges by the end of their service period.
ServicePeriodTo *DateTimeFilter
// Filter charges by the ID of their customer.
CustomerID *StringExactFilter
// Filter charges by the ID of their subscription. Only charges linked to a
// subscription can match, including when using `neq`.
SubscriptionID *StringExactFilter
}
type ListChargesParams ¶
type ListChargesParams struct {
Page *PageParams
Sort *Sort
Filter *ListChargesFilter
Expand []ChargesExpand
}
type ListCustomerChargesFilter ¶
type ListCustomerChargesFilter struct {
// Filter charges by status.
//
// Supported statuses are:
//
// - `created`
// - `active`
// - `final`
// - `deleted`
//
// If omitted, all statuses are returned except for `deleted`.
Status *StringExactFilter
// Filter charges by the ID of their associated feature.
FeatureID *StringExactFilter
// Filter charges by the key of their associated feature.
FeatureKey *StringExactFilter
// Filter charges by the start of their service period.
ServicePeriodFrom *DateTimeFilter
// Filter charges by the end of their service period.
ServicePeriodTo *DateTimeFilter
}
type ListCustomerChargesParams ¶
type ListCustomerChargesParams struct {
Page *PageParams
Sort *Sort
Filter *ListCustomerChargesFilter
Expand []ChargesExpand
}
type ListCustomerEntitlementAccessResponseData ¶
type ListCustomerEntitlementAccessResponseData struct {
// The list of entitlement access results.
Data []EntitlementValueResult `json:"data"`
}
List customer entitlement access response data.
type ListCustomerEntitlementGrantsParams ¶
type ListCustomerEntitlementGrantsParams struct {
Page *PageParams
Sort *Sort
IncludeDeleted *bool
}
type ListCustomerEntitlementsFilter ¶
type ListCustomerEntitlementsFilter struct {
// Filter entitlements by feature ID.
FeatureID *StringExactFilter
// Filter entitlements by feature key.
FeatureKey *StringExactFilter
// Filter entitlements by type (`metered`, `static` or `boolean`).
Type *StringExactFilter
}
type ListCustomerEntitlementsParams ¶
type ListCustomerEntitlementsParams struct {
Page *PageParams
Sort *Sort
Filter *ListCustomerEntitlementsFilter
}
type ListEntitlementsFilter ¶
type ListEntitlementsFilter struct {
// Filter entitlements by feature ID.
FeatureID *StringExactFilter
// Filter entitlements by feature key.
FeatureKey *StringExactFilter
// Filter entitlements by type (`metered`, `static` or `boolean`).
Type *StringExactFilter
// Filter entitlements by customer ID.
CustomerID *StringExactFilter
}
type ListEntitlementsParams ¶
type ListEntitlementsParams struct {
Page *PageParams
Sort *Sort
Filter *ListEntitlementsFilter
}
type ListEventsPage ¶
type ListEventsPage struct {
// The number of items to include per page.
Size *int64 `json:"size,omitempty"`
// Request the next page of data, starting with the item after this parameter.
After *string `json:"after,omitempty"`
// Request the previous page of data, starting with the item before this parameter.
Before *string `json:"before,omitempty"`
}
Determines which page of the metering event list to retrieve. A page holds at most 100 events.
type ListGrantsFilter ¶
type ListGrantsFilter struct {
// Filter grants by the ID of the customer that owns the entitlement.
CustomerID *StringExactFilter
// Filter grants by the ID of the entitlement's feature.
FeatureID *StringExactFilter
}
type ListGrantsParams ¶
type ListGrantsParams struct {
Page *PageParams
Sort *Sort
Filter *ListGrantsFilter
IncludeDeleted *bool
}
type ListLLMCostOverridesFilter ¶
type ListLLMCostOverridesFilter struct {
// Filter by provider. e.g. ?filter[provider][eq]=openai
Provider *StringFilter
// Filter by model ID. e.g. ?filter[model_id][eq]=gpt-4
ModelID *StringFilter
// Filter by model name. e.g. ?filter[model_name][contains]=gpt
ModelName *StringFilter
// Filter by currency code. e.g. ?filter[currency][eq]=USD
Currency *StringFilter
// Filter by source. e.g. ?filter[source][eq]=system
Source *StringFilter
}
type ListLLMCostOverridesParams ¶
type ListLLMCostOverridesParams struct {
Filter *ListLLMCostOverridesFilter
Page *PageParams
}
type ListLLMCostPricesFilter ¶
type ListLLMCostPricesFilter struct {
// Filter by provider. e.g. ?filter[provider][eq]=openai
Provider *StringFilter
// Filter by model ID. e.g. ?filter[model_id][eq]=gpt-4
ModelID *StringFilter
// Filter by model name. e.g. ?filter[model_name][contains]=gpt
ModelName *StringFilter
// Filter by currency code. e.g. ?filter[currency][eq]=USD
Currency *StringFilter
// Filter by source. e.g. ?filter[source][eq]=system
Source *StringFilter
}
type ListLLMCostPricesParams ¶
type ListLLMCostPricesParams struct {
Filter *ListLLMCostPricesFilter
Sort *Sort
Page *PageParams
}
type Meter ¶
type Meter struct {
ID string `json:"id"`
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
Key string `json:"key"`
// The aggregation type to use for the meter.
Aggregation MeterAggregation `json:"aggregation"`
// The event type to include in the aggregation.
EventType string `json:"event_type"`
// The date since the meter should include events. Useful to skip old events. If
// not specified, all historical events are included.
EventsFrom *time.Time `json:"events_from,omitempty"`
// JSONPath expression to extract the value from the ingested event's data
// property.
//
// The ingested value for sum, avg, min, and max aggregations is a number or a
// string that can be parsed to a number.
//
// For unique_count aggregation, the ingested value must be a string. For count
// aggregation the value_property is ignored.
ValueProperty *string `json:"value_property,omitempty"`
// Named JSONPath expressions to extract the group by values from the event data.
//
// Keys must be unique and consist only alphanumeric and underscore characters.
Dimensions map[string]string `json:"dimensions,omitempty"`
}
A meter is a configuration that defines how to match and aggregate events.
type MeterAggregation ¶
type MeterAggregation string
The aggregation type to use for the meter.
const ( MeterAggregationSum MeterAggregation = "sum" MeterAggregationCount MeterAggregation = "count" MeterAggregationUniqueCount MeterAggregation = "unique_count" MeterAggregationAvg MeterAggregation = "avg" MeterAggregationMin MeterAggregation = "min" MeterAggregationMax MeterAggregation = "max" MeterAggregationLatest MeterAggregation = "latest" )
func (MeterAggregation) Valid ¶
func (value MeterAggregation) Valid() bool
type MeterFilter ¶
type MeterFilter struct {
// Filter meters by key.
Key *StringFilter
// Filter meters by name.
Name *StringFilter
}
type MeterListParams ¶
type MeterListParams struct {
Page *PageParams
Sort *Sort
Filter *MeterFilter
}
type MeterPagePaginatedResponse ¶
type MeterPagePaginatedResponse struct {
Data []Meter `json:"data"`
Meta PaginatedMeta `json:"meta"`
}
Page paginated response.
type MeterQueryFilters ¶
type MeterQueryFilters struct {
// Filters to apply to the dimensions of the query. For `subject` and `customer_id`
// only equals ("eq", "in") comparisons are supported.
Dimensions *map[string]QueryFilterStringMapItemInput `json:"dimensions,omitempty"`
}
Filters to apply to a meter query.
type MeterQueryGranularity ¶
type MeterQueryGranularity string
The granularity of the time grouping. Time durations are specified in ISO 8601 format.
const ( MeterQueryGranularityMinute MeterQueryGranularity = "PT1M" MeterQueryGranularityHour MeterQueryGranularity = "PT1H" MeterQueryGranularityDay MeterQueryGranularity = "P1D" MeterQueryGranularityMonth MeterQueryGranularity = "P1M" )
func (MeterQueryGranularity) Valid ¶
func (value MeterQueryGranularity) Valid() bool
type MeterQueryRequest ¶
type MeterQueryRequest struct {
// The start of the period the usage is queried from.
From *time.Time `json:"from,omitempty"`
// The end of the period the usage is queried to.
To *time.Time `json:"to,omitempty"`
// The size of the time buckets to group the usage into. If not specified, the
// usage is aggregated over the entire period.
Granularity *MeterQueryGranularity `json:"granularity,omitempty"`
// The value is the name of the time zone as defined in the IANA Time Zone Database
// (http://www.iana.org/time-zones). The time zone is used to determine the start
// and end of the time buckets. If not specified, the UTC timezone will be used.
TimeZone *string `json:"time_zone,omitempty"`
// The dimensions to group the results by.
GroupByDimensions *[]string `json:"group_by_dimensions,omitempty"`
// Filters to apply to the query.
Filters *MeterQueryFilters `json:"filters,omitempty"`
}
A meter query request.
type MeterQueryResult ¶
type MeterQueryResult struct {
// The start of the period the usage is queried from.
From *time.Time `json:"from,omitempty"`
// The end of the period the usage is queried to.
To *time.Time `json:"to,omitempty"`
// The usage data. If no data is available, an empty array is returned.
Data []MeterQueryRow `json:"data"`
}
Meter query result.
type MeterQueryRow ¶
type MeterQueryRow struct {
// The aggregated value.
Value Numeric `json:"value"`
// The start of the time bucket the value is aggregated over.
From time.Time `json:"from"`
// The end of the time bucket the value is aggregated over.
To time.Time `json:"to"`
// The dimensions the value is aggregated over. `subject` and `customer_id` are
// reserved dimensions.
Dimensions map[string]string `json:"dimensions"`
}
A row in the result of a meter query.
type MetersService ¶
type MetersService struct {
// contains filtered or unexported fields
}
func (*MetersService) Create ¶
func (s *MetersService) Create(ctx context.Context, request CreateMeterRequest) (*Meter, error)
Create a meter.
func (*MetersService) Delete ¶
func (s *MetersService) Delete(ctx context.Context, meterID string) error
Delete a meter.
func (*MetersService) List ¶
func (s *MetersService) List(ctx context.Context, params MeterListParams) (*MeterPagePaginatedResponse, error)
List meters.
func (*MetersService) ListAll ¶
func (s *MetersService) ListAll(ctx context.Context, params MeterListParams) iter.Seq2[Meter, error]
ListAll returns an iterator over all Meter results, fetching pages of List transparently. Iteration stops at the first error, which is yielded as the second value.
func (*MetersService) Query ¶
func (s *MetersService) Query(ctx context.Context, meterID string, request MeterQueryRequest) (*MeterQueryResult, error)
Query a meter for usage.
Set `Accept: application/json` (the default) to get a structured JSON response. Set `Accept: text/csv` to download the same data as a CSV file suitable for spreadsheets. The CSV columns, in order, are:
`from, to, [subject,] [customer_id, customer_key, customer_name,] <dimensions...>, value`
The `subject` column is emitted only when `subject` is in the query's `group_by_dimensions`. The three `customer_*` columns are emitted together only when `customer_id` is in the query's `group_by_dimensions`.
func (*MetersService) QueryCSV ¶
func (s *MetersService) QueryCSV(ctx context.Context, meterID string, request MeterQueryRequest) ([]byte, error)
func (*MetersService) QueryCSVStream ¶
func (s *MetersService) QueryCSVStream(ctx context.Context, meterID string, request MeterQueryRequest) (io.ReadCloser, error)
func (*MetersService) Update ¶
func (s *MetersService) Update(ctx context.Context, meterID string, request UpdateMeterRequest) (*Meter, error)
Update a meter.
type NotificationBalanceThreshold ¶
type NotificationBalanceThreshold struct {
// What the threshold value is measured against.
Type NotificationBalanceThresholdType `json:"type"`
// The threshold value.
Value float64 `json:"value"`
}
A balance threshold of a notification rule. Crossing it generates an `entitlements.balance.threshold` event.
type NotificationBalanceThresholdType ¶
type NotificationBalanceThresholdType string
What a balance threshold is measured against.
const ( NotificationBalanceThresholdTypeBalanceValue NotificationBalanceThresholdType = "balance_value" NotificationBalanceThresholdTypeUsagePercentage NotificationBalanceThresholdType = "usage_percentage" NotificationBalanceThresholdTypeUsageValue NotificationBalanceThresholdType = "usage_value" )
func (NotificationBalanceThresholdType) Valid ¶
func (value NotificationBalanceThresholdType) Valid() bool
type NotificationChannel ¶
type NotificationChannel struct {
ID string `json:"id"`
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// The type of the channel. Immutable after creation.
Type NotificationChannelType `json:"type"`
// Whether the channel is disabled. Disabled channels do not receive notification
// events.
Disabled *bool `json:"disabled,omitempty"`
// The URL that webhook notification events are delivered to.
URL string `json:"url"`
// Custom HTTP headers to include on every webhook delivery request, keyed by
// header name.
CustomHeaders map[string]string `json:"custom_headers,omitempty"`
// Secret used to sign outgoing webhook payloads so recipients can verify their
// authenticity. If omitted on create, a secret is generated automatically by the
// delivery provider. This is a sensitive credential returned in responses (unlike
// most secrets) specifically so clients can retrieve a server-generated value and
// verify webhook signatures; handle it with the same care as any other credential.
SigningSecret *string `json:"signing_secret,omitempty"`
}
A notification channel delivers notification events, such as entitlement balance threshold crossings, to an external system. Today the only supported channel type is a webhook delivered via Svix.
type NotificationChannelFilter ¶
type NotificationChannelFilter struct {
ID *StringExactFilter
Name *StringFilter
Type *StringExactFilter
Disabled *BooleanFilter
CreatedAt *DateTimeFilter
UpdatedAt *DateTimeFilter
}
type NotificationChannelListParams ¶
type NotificationChannelListParams struct {
Page *PageParams
Sort *Sort
Filter *NotificationChannelFilter
}
type NotificationChannelPagePaginatedResponse ¶
type NotificationChannelPagePaginatedResponse struct {
Data []NotificationChannel `json:"data"`
Meta PaginatedMeta `json:"meta"`
}
Page paginated response.
type NotificationChannelReference ¶
type NotificationChannelReference struct {
ID string `json:"id"`
}
NotificationChannel reference.
type NotificationChannelType ¶
type NotificationChannelType string
The type of a notification channel.
Currently the only supported channel type is `webhook`; the domain model anticipates additional channel types (e.g. email, Slack) in the future, so this is modeled as an enum rather than a boolean/constant even though it has a single member today.
const (
NotificationChannelTypeWebhook NotificationChannelType = "webhook"
)
func (NotificationChannelType) Valid ¶
func (value NotificationChannelType) Valid() bool
type NotificationEvent ¶
type NotificationEvent struct {
// The unique identifier of the event.
ID string `json:"id"`
// The type of the event.
Type NotificationEventType `json:"type"`
// When the event was generated.
CreatedAt time.Time `json:"created_at"`
// The rule that generated the event.
Rule NotificationRuleReference `json:"rule"`
// The delivery status of the event, one entry per channel of the rule.
DeliveryStatus []NotificationEventDeliveryStatus `json:"delivery_status"`
// The payload delivered to the channels.
Payload NotificationEventPayload `json:"payload"`
}
A notification event records that a notification rule fired and tracks the delivery of its payload to each channel of the rule. Events are created by the system and cannot be modified.
type NotificationEventBalanceThresholdPayload ¶
type NotificationEventBalanceThresholdPayload struct {
// The identifier of the event the payload belongs to.
ID string `json:"id"`
// The type of the event.
Type NotificationEventType `json:"type"`
// When the event was generated.
Timestamp time.Time `json:"timestamp"`
// The entities and threshold the event refers to.
Data EntitlementBalanceThresholdTriggeredV1Payload `json:"data"`
}
A balance threshold notification event payload.
type NotificationEventDeliveryAttempt ¶
type NotificationEventDeliveryAttempt struct {
// The delivery state reached by this attempt.
State NotificationEventDeliveryState `json:"state"`
// The response returned by the recipient.
Response NotificationEventDeliveryAttemptResponse `json:"response"`
// When the attempt was made.
Timestamp time.Time `json:"timestamp"`
}
A single delivery attempt to a channel.
type NotificationEventDeliveryAttemptResponse ¶
type NotificationEventDeliveryAttemptResponse struct {
// The HTTP status code returned by the recipient. Absent when no response was
// received.
StatusCode *int32 `json:"status_code,omitempty"`
// The response body returned by the recipient. Empty when no body was received.
Body string `json:"body"`
// How long the delivery attempt took, in milliseconds.
DurationMs int64 `json:"duration_ms"`
// The URL the event was delivered to. Only set for webhook channels.
URL *string `json:"url,omitempty"`
}
The response the recipient returned for a delivery attempt. For webhook channels this is the HTTP response.
type NotificationEventDeliveryState ¶
type NotificationEventDeliveryState string
The delivery state of a notification event for a single channel.
const ( NotificationEventDeliveryStateSuccess NotificationEventDeliveryState = "success" NotificationEventDeliveryStateFailed NotificationEventDeliveryState = "failed" NotificationEventDeliveryStateSending NotificationEventDeliveryState = "sending" NotificationEventDeliveryStatePending NotificationEventDeliveryState = "pending" NotificationEventDeliveryStateResending NotificationEventDeliveryState = "resending" )
func (NotificationEventDeliveryState) Valid ¶
func (value NotificationEventDeliveryState) Valid() bool
type NotificationEventDeliveryStatus ¶
type NotificationEventDeliveryStatus struct {
// The identifier of the channel this delivery status belongs to.
ChannelID string `json:"channel_id"`
// The current delivery state.
State NotificationEventDeliveryState `json:"state"`
// The reason for the last state change. Empty for successful deliveries.
Reason string `json:"reason"`
// When the delivery state was last updated.
UpdatedAt time.Time `json:"updated_at"`
// When the next delivery attempt is scheduled. Absent when no further attempts
// will be made.
NextAttempt *time.Time `json:"next_attempt,omitempty"`
// The delivery attempts made so far, most recent first.
Attempts []NotificationEventDeliveryAttempt `json:"attempts"`
}
The delivery status of a notification event for one channel of the generating rule.
type NotificationEventFilter ¶
type NotificationEventFilter struct {
ID *StringExactFilter
Type *StringExactFilter
CreatedAt *DateTimeFilter
RuleID *StringExactFilter
// Filter by a channel of the generating rule. Matches events whose rule targets at
// least one of the given channels. Only `eq` and `oeq` are supported.
ChannelID *StringExactFilter
// Filter by delivery state. Matches events where delivery to at least one channel
// is in one of the given states. Only `eq` and `oeq` are supported.
DeliveryStatus *StringExactFilter
// Filter by the key of the subject the event refers to. Events without a subject
// never match, not even with `neq`.
SubjectKey *StringExactFilter
// Filter by the id of the subject the event refers to. Events without a subject
// never match, not even with `neq`.
SubjectID *StringExactFilter
// Filter by the key of the feature the event refers to. Events without a feature
// never match, not even with `neq`.
FeatureKey *StringExactFilter
// Filter by the id of the feature the event refers to. Events without a feature
// never match, not even with `neq`.
FeatureID *StringExactFilter
}
type NotificationEventInvoiceCreatedPayload ¶
type NotificationEventInvoiceCreatedPayload struct {
// The identifier of the event the payload belongs to.
ID string `json:"id"`
// The type of the event.
Type NotificationEventType `json:"type"`
// When the event was generated.
Timestamp time.Time `json:"timestamp"`
// The invoice the event refers to.
Data InvoiceCreatedV1Payload `json:"data"`
}
An invoice created notification event payload.
type NotificationEventInvoiceUpdatedPayload ¶
type NotificationEventInvoiceUpdatedPayload struct {
// The identifier of the event the payload belongs to.
ID string `json:"id"`
// The type of the event.
Type NotificationEventType `json:"type"`
// When the event was generated.
Timestamp time.Time `json:"timestamp"`
// The invoice the event refers to.
Data InvoiceUpdatedV1Payload `json:"data"`
}
An invoice updated notification event payload.
type NotificationEventListParams ¶
type NotificationEventListParams struct {
Page *PageParams
Sort *Sort
Filter *NotificationEventFilter
}
type NotificationEventPagePaginatedResponse ¶
type NotificationEventPagePaginatedResponse struct {
Data []NotificationEvent `json:"data"`
Meta PaginatedMeta `json:"meta"`
}
Page paginated response.
type NotificationEventPayload ¶
type NotificationEventPayload struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
The payload delivered to the channels, discriminated by the event type.
NotificationEventPayload is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the NotificationEventPayloadFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func NotificationEventPayloadFromNotificationEventBalanceThresholdPayload ¶
func NotificationEventPayloadFromNotificationEventBalanceThresholdPayload(value NotificationEventBalanceThresholdPayload) (NotificationEventPayload, error)
func NotificationEventPayloadFromNotificationEventInvoiceCreatedPayload ¶
func NotificationEventPayloadFromNotificationEventInvoiceCreatedPayload(value NotificationEventInvoiceCreatedPayload) (NotificationEventPayload, error)
func NotificationEventPayloadFromNotificationEventInvoiceUpdatedPayload ¶
func NotificationEventPayloadFromNotificationEventInvoiceUpdatedPayload(value NotificationEventInvoiceUpdatedPayload) (NotificationEventPayload, error)
func NotificationEventPayloadFromNotificationEventResetPayload ¶
func NotificationEventPayloadFromNotificationEventResetPayload(value NotificationEventResetPayload) (NotificationEventPayload, error)
func (NotificationEventPayload) AsNotificationEventBalanceThresholdPayload ¶
func (u NotificationEventPayload) AsNotificationEventBalanceThresholdPayload() (*NotificationEventBalanceThresholdPayload, error)
func (NotificationEventPayload) AsNotificationEventInvoiceCreatedPayload ¶
func (u NotificationEventPayload) AsNotificationEventInvoiceCreatedPayload() (*NotificationEventInvoiceCreatedPayload, error)
func (NotificationEventPayload) AsNotificationEventInvoiceUpdatedPayload ¶
func (u NotificationEventPayload) AsNotificationEventInvoiceUpdatedPayload() (*NotificationEventInvoiceUpdatedPayload, error)
func (NotificationEventPayload) AsNotificationEventResetPayload ¶
func (u NotificationEventPayload) AsNotificationEventResetPayload() (*NotificationEventResetPayload, error)
func (NotificationEventPayload) MarshalJSON ¶
func (u NotificationEventPayload) MarshalJSON() ([]byte, error)
func (*NotificationEventPayload) UnmarshalJSON ¶
func (u *NotificationEventPayload) UnmarshalJSON(data []byte) error
type NotificationEventResetPayload ¶
type NotificationEventResetPayload struct {
// The identifier of the event the payload belongs to.
ID string `json:"id"`
// The type of the event.
Type NotificationEventType `json:"type"`
// When the event was generated.
Timestamp time.Time `json:"timestamp"`
// The entities the event refers to.
Data EntitlementUsagePeriodResetV1Payload `json:"data"`
}
An entitlement reset notification event payload.
type NotificationEventType ¶
type NotificationEventType string
The type of a notification event. It determines which payload variant the event carries.
const ( NotificationEventTypeEntitlementsBalanceThreshold NotificationEventType = "entitlements.balance.threshold" NotificationEventTypeEntitlementsReset NotificationEventType = "entitlements.reset" NotificationEventTypeInvoiceCreated NotificationEventType = "invoice.created" NotificationEventTypeInvoiceUpdated NotificationEventType = "invoice.updated" )
func (NotificationEventType) Valid ¶
func (value NotificationEventType) Valid() bool
type NotificationEventTypeDefinition ¶
type NotificationEventTypeDefinition struct {
// The canonical event type, `v<version>.<name>`, for example
// `v1.billing.invoice.created`.
Type string `json:"type"`
// What the event type means, including the legacy name it replaces, if any.
Description string `json:"description"`
// The event type that replaces this one. Deprecated event types stay usable.
// Absent when the event type is not deprecated.
DeprecatedBy *string `json:"deprecated_by,omitempty"`
// The JSON Schema (draft 2020-12) of the event payload.
PayloadJSONSchema map[string]any `json:"payload_json_schema"`
// The JSON Schema (draft 2020-12) of the rule configuration. Absent when no rule
// can produce the event type.
RuleConfigJSONSchema map[string]any `json:"rule_config_json_schema,omitempty"`
}
A notification event type with the JSON Schemas of its contract.
type NotificationEventTypeSummary ¶
type NotificationEventTypeSummary struct {
// The canonical event type, `v<version>.<name>`, for example
// `v1.billing.invoice.created`.
Type string `json:"type"`
// What the event type means, including the legacy name it replaces, if any.
Description string `json:"description"`
// The event type that replaces this one. Deprecated event types stay usable.
// Absent when the event type is not deprecated.
DeprecatedBy *string `json:"deprecated_by,omitempty"`
}
A versioned kind of notification event. Its contract covers the payload and, when rules can produce it, the rule configuration.
type NotificationEventTypeSummaryFilter ¶
type NotificationEventTypeSummaryFilter struct {
Type *StringFilter
}
type NotificationEventTypeSummaryListParams ¶
type NotificationEventTypeSummaryListParams struct {
Page *CursorPageParams
Filter *NotificationEventTypeSummaryFilter
}
type NotificationEventTypeSummaryPaginatedResponse ¶
type NotificationEventTypeSummaryPaginatedResponse struct {
Data []NotificationEventTypeSummary `json:"data"`
Meta CursorMeta `json:"meta"`
}
Cursor paginated response.
type NotificationEventV1Address ¶
type NotificationEventV1Address struct {
// Country code in [ISO 3166-1](https://www.iso.org/iso-3166-country-codes.html)
// alpha-2 format.
Country *string `json:"country,omitempty"`
// Postal code.
PostalCode *string `json:"postal_code,omitempty"`
// State or province.
State *string `json:"state,omitempty"`
// City.
City *string `json:"city,omitempty"`
// First line of the address.
Line1 *string `json:"line1,omitempty"`
// Second line of the address.
Line2 *string `json:"line2,omitempty"`
// Phone number.
PhoneNumber *string `json:"phone_number,omitempty"`
}
Address
type NotificationEventV1Alignment ¶
type NotificationEventV1Alignment struct {
// Whether all Billable items and RateCards must align. Alignment means the Price's
// BillingCadence must align for both duration and anchor time.
BillablesMustAlign *bool `json:"billables_must_align,omitempty"`
}
Alignment configuration for a plan or subscription.
type NotificationEventV1App ¶
type NotificationEventV1App struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
App. One of: stripe
NotificationEventV1App is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the NotificationEventV1AppFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func NotificationEventV1AppFromNotificationEventV1CustomInvoicingApp ¶
func NotificationEventV1AppFromNotificationEventV1CustomInvoicingApp(value NotificationEventV1CustomInvoicingApp) (NotificationEventV1App, error)
func NotificationEventV1AppFromNotificationEventV1SandboxApp ¶
func NotificationEventV1AppFromNotificationEventV1SandboxApp(value NotificationEventV1SandboxApp) (NotificationEventV1App, error)
func NotificationEventV1AppFromNotificationEventV1StripeApp ¶
func NotificationEventV1AppFromNotificationEventV1StripeApp(value NotificationEventV1StripeApp) (NotificationEventV1App, error)
func (NotificationEventV1App) AsNotificationEventV1CustomInvoicingApp ¶
func (u NotificationEventV1App) AsNotificationEventV1CustomInvoicingApp() (*NotificationEventV1CustomInvoicingApp, error)
func (NotificationEventV1App) AsNotificationEventV1SandboxApp ¶
func (u NotificationEventV1App) AsNotificationEventV1SandboxApp() (*NotificationEventV1SandboxApp, error)
func (NotificationEventV1App) AsNotificationEventV1StripeApp ¶
func (u NotificationEventV1App) AsNotificationEventV1StripeApp() (*NotificationEventV1StripeApp, error)
func (NotificationEventV1App) MarshalJSON ¶
func (u NotificationEventV1App) MarshalJSON() ([]byte, error)
func (*NotificationEventV1App) UnmarshalJSON ¶
func (u *NotificationEventV1App) UnmarshalJSON(data []byte) error
type NotificationEventV1AppCapability ¶
type NotificationEventV1AppCapability struct {
// The capability type.
Type NotificationEventV1AppCapabilityType `json:"type"`
// Key
Key string `json:"key"`
// The capability name.
Name string `json:"name"`
// The capability description.
Description string `json:"description"`
}
App capability.
Capabilities only exist in config so they don't extend the Resource model.
type NotificationEventV1AppCapabilityType ¶
type NotificationEventV1AppCapabilityType string
App capability type.
const ( NotificationEventV1AppCapabilityTypeReportUsage NotificationEventV1AppCapabilityType = "reportUsage" NotificationEventV1AppCapabilityTypeReportEvents NotificationEventV1AppCapabilityType = "reportEvents" NotificationEventV1AppCapabilityTypeCalculateTax NotificationEventV1AppCapabilityType = "calculateTax" NotificationEventV1AppCapabilityTypeInvoiceCustomers NotificationEventV1AppCapabilityType = "invoiceCustomers" NotificationEventV1AppCapabilityTypeCollectPayments NotificationEventV1AppCapabilityType = "collectPayments" )
func (NotificationEventV1AppCapabilityType) Valid ¶
func (value NotificationEventV1AppCapabilityType) Valid() bool
type NotificationEventV1AppStatus ¶
type NotificationEventV1AppStatus string
App installed status.
const ( NotificationEventV1AppStatusReady NotificationEventV1AppStatus = "ready" )
func (NotificationEventV1AppStatus) Valid ¶
func (value NotificationEventV1AppStatus) Valid() bool
type NotificationEventV1AppType ¶
type NotificationEventV1AppType string
Type of the app.
const ( NotificationEventV1AppTypeStripe NotificationEventV1AppType = "stripe" NotificationEventV1AppTypeSandbox NotificationEventV1AppType = "sandbox" NotificationEventV1AppTypeCustomInvoicing NotificationEventV1AppType = "custom_invoicing" )
func (NotificationEventV1AppType) Valid ¶
func (value NotificationEventV1AppType) Valid() bool
type NotificationEventV1BillingDiscountPercentage ¶
type NotificationEventV1BillingDiscountPercentage struct {
// The percentage of the discount.
Percentage float64 `json:"percentage"`
// Correlation ID for the discount.
//
// This is used to link discounts across different invoices (progressive billing
// use case).
//
// If not provided, the invoicing engine will auto-generate one. When editing an
// invoice line, please make sure to keep the same correlation ID of the discount
// or in progressive billing setups the discount amounts might be incorrect.
CorrelationID *string `json:"correlation_id,omitempty"`
}
A percentage discount.
type NotificationEventV1BillingDiscountReason ¶
type NotificationEventV1BillingDiscountReason struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
The reason for the discount.
NotificationEventV1BillingDiscountReason is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the NotificationEventV1BillingDiscountReasonFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func NotificationEventV1BillingDiscountReasonFromNotificationEventV1DiscountReasonMaximumSpend ¶
func NotificationEventV1BillingDiscountReasonFromNotificationEventV1DiscountReasonMaximumSpend(value NotificationEventV1DiscountReasonMaximumSpend) (NotificationEventV1BillingDiscountReason, error)
func NotificationEventV1BillingDiscountReasonFromNotificationEventV1DiscountReasonRatecardPercentage ¶
func NotificationEventV1BillingDiscountReasonFromNotificationEventV1DiscountReasonRatecardPercentage(value NotificationEventV1DiscountReasonRatecardPercentage) (NotificationEventV1BillingDiscountReason, error)
func NotificationEventV1BillingDiscountReasonFromNotificationEventV1DiscountReasonRatecardUsage ¶
func NotificationEventV1BillingDiscountReasonFromNotificationEventV1DiscountReasonRatecardUsage(value NotificationEventV1DiscountReasonRatecardUsage) (NotificationEventV1BillingDiscountReason, error)
func (NotificationEventV1BillingDiscountReason) AsNotificationEventV1DiscountReasonMaximumSpend ¶
func (u NotificationEventV1BillingDiscountReason) AsNotificationEventV1DiscountReasonMaximumSpend() (*NotificationEventV1DiscountReasonMaximumSpend, error)
func (NotificationEventV1BillingDiscountReason) AsNotificationEventV1DiscountReasonRatecardPercentage ¶
func (u NotificationEventV1BillingDiscountReason) AsNotificationEventV1DiscountReasonRatecardPercentage() (*NotificationEventV1DiscountReasonRatecardPercentage, error)
func (NotificationEventV1BillingDiscountReason) AsNotificationEventV1DiscountReasonRatecardUsage ¶
func (u NotificationEventV1BillingDiscountReason) AsNotificationEventV1DiscountReasonRatecardUsage() (*NotificationEventV1DiscountReasonRatecardUsage, error)
func (NotificationEventV1BillingDiscountReason) MarshalJSON ¶
func (u NotificationEventV1BillingDiscountReason) MarshalJSON() ([]byte, error)
func (*NotificationEventV1BillingDiscountReason) UnmarshalJSON ¶
func (u *NotificationEventV1BillingDiscountReason) UnmarshalJSON(data []byte) error
type NotificationEventV1BillingDiscountUsage ¶
type NotificationEventV1BillingDiscountUsage struct {
// The quantity of the usage discount.
//
// Must be positive.
Quantity string `json:"quantity"`
// Correlation ID for the discount.
//
// This is used to link discounts across different invoices (progressive billing
// use case).
//
// If not provided, the invoicing engine will auto-generate one. When editing an
// invoice line, please make sure to keep the same correlation ID of the discount
// or in progressive billing setups the discount amounts might be incorrect.
CorrelationID *string `json:"correlation_id,omitempty"`
}
A usage discount.
type NotificationEventV1BillingDiscounts ¶
type NotificationEventV1BillingDiscounts struct {
// The percentage discount.
Percentage *NotificationEventV1BillingDiscountPercentage `json:"percentage,omitempty"`
// The usage discount.
Usage *NotificationEventV1BillingDiscountUsage `json:"usage,omitempty"`
}
A discount by type.
type NotificationEventV1BillingInvoiceCustomerExtendedDetails ¶
type NotificationEventV1BillingInvoiceCustomerExtendedDetails struct {
// Unique identifier for the party (if available)
ID *string `json:"id,omitempty"`
// An optional unique key of the party (if available)
Key *string `json:"key,omitempty"`
// Legal name or representation of the organization.
Name *string `json:"name,omitempty"`
// The entity's legal ID code used for tax purposes. They may have other numbers,
// but we're only interested in those valid for tax purposes.
TaxID *NotificationEventV1BillingPartyTaxIdentity `json:"tax_id,omitempty"`
// Regular post addresses for where information should be sent if needed.
Addresses []NotificationEventV1Address `json:"addresses,omitempty"`
// Mapping to attribute metered usage to the customer
UsageAttribution NotificationEventV1CustomerUsageAttribution `json:"usage_attribution"`
}
BillingInvoiceCustomerExtendedDetails is a collection of fields that are used to extend the billing party details for invoices.
These fields contain the OpenMeter specific details for the customer, that are not strictly required for the invoice itself.
type NotificationEventV1BillingParty ¶
type NotificationEventV1BillingParty struct {
// Unique identifier for the party (if available)
ID *string `json:"id,omitempty"`
// An optional unique key of the party (if available)
Key *string `json:"key,omitempty"`
// Legal name or representation of the organization.
Name *string `json:"name,omitempty"`
// The entity's legal ID code used for tax purposes. They may have other numbers,
// but we're only interested in those valid for tax purposes.
TaxID *NotificationEventV1BillingPartyTaxIdentity `json:"tax_id,omitempty"`
// Regular post addresses for where information should be sent if needed.
Addresses []NotificationEventV1Address `json:"addresses,omitempty"`
}
Party represents a person or business entity.
type NotificationEventV1BillingPartyTaxIdentity ¶
type NotificationEventV1BillingPartyTaxIdentity struct {
// Normalized tax code shown on the original identity document.
Code *string `json:"code,omitempty"`
}
Identity stores the details required to identify an entity for tax purposes in a specific country.
type NotificationEventV1BillingProfileApps ¶
type NotificationEventV1BillingProfileApps struct {
// The tax app used for this workflow
Tax Nullable[NotificationEventV1App] `json:"tax"`
// The invoicing app used for this workflow
Invoicing Nullable[NotificationEventV1App] `json:"invoicing"`
// The payment app used for this workflow
Payment Nullable[NotificationEventV1App] `json:"payment"`
}
BillingProfileApps represents the applications used by a billing profile
type NotificationEventV1BillingSettlementMode ¶
type NotificationEventV1BillingSettlementMode string
The settlement mode of a plan. It determines how the billing system generates invoices and credits for the subscriptions using this plan.
- credit_then_invoice: credits from the previous billing period are applied first, then the remaining balance is invoiced. This is the default and most common settlement mode. - credit_only: only credits from the previous billing period are generated and applied. No invoices are generated for the subscription.
const ( NotificationEventV1BillingSettlementModeCreditThenInvoice NotificationEventV1BillingSettlementMode = "credit_then_invoice" NotificationEventV1BillingSettlementModeCreditOnly NotificationEventV1BillingSettlementMode = "credit_only" )
func (NotificationEventV1BillingSettlementMode) Valid ¶
func (value NotificationEventV1BillingSettlementMode) Valid() bool
type NotificationEventV1BillingWorkflow ¶
type NotificationEventV1BillingWorkflow struct {
// The collection settings for this workflow
Collection *NotificationEventV1BillingWorkflowCollectionSettings `json:"collection,omitempty"`
// The invoicing settings for this workflow
Invoicing *NotificationEventV1BillingWorkflowInvoicingSettings `json:"invoicing,omitempty"`
// The payment settings for this workflow
Payment *NotificationEventV1BillingWorkflowPaymentSettings `json:"payment,omitempty"`
// The tax settings for this workflow
Tax *NotificationEventV1BillingWorkflowTaxSettings `json:"tax,omitempty"`
}
BillingWorkflow represents the settings for a billing workflow.
type NotificationEventV1BillingWorkflowCollectionAlignment ¶
type NotificationEventV1BillingWorkflowCollectionAlignment struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
The alignment for collecting the pending line items into an invoice.
Defaults to subscription, which means that we are to create a new invoice every time the a subscription period starts (for in advance items) or ends (for in arrears items).
NotificationEventV1BillingWorkflowCollectionAlignment is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the NotificationEventV1BillingWorkflowCollectionAlignmentFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func NotificationEventV1BillingWorkflowCollectionAlignmentFromNotificationEventV1BillingWorkflowCollectionAlignmentAnchored ¶
func NotificationEventV1BillingWorkflowCollectionAlignmentFromNotificationEventV1BillingWorkflowCollectionAlignmentAnchored(value NotificationEventV1BillingWorkflowCollectionAlignmentAnchored) (NotificationEventV1BillingWorkflowCollectionAlignment, error)
func NotificationEventV1BillingWorkflowCollectionAlignmentFromNotificationEventV1BillingWorkflowCollectionAlignmentSubscription ¶
func NotificationEventV1BillingWorkflowCollectionAlignmentFromNotificationEventV1BillingWorkflowCollectionAlignmentSubscription(value NotificationEventV1BillingWorkflowCollectionAlignmentSubscription) (NotificationEventV1BillingWorkflowCollectionAlignment, error)
func (NotificationEventV1BillingWorkflowCollectionAlignment) AsNotificationEventV1BillingWorkflowCollectionAlignmentAnchored ¶
func (u NotificationEventV1BillingWorkflowCollectionAlignment) AsNotificationEventV1BillingWorkflowCollectionAlignmentAnchored() (*NotificationEventV1BillingWorkflowCollectionAlignmentAnchored, error)
func (NotificationEventV1BillingWorkflowCollectionAlignment) AsNotificationEventV1BillingWorkflowCollectionAlignmentSubscription ¶
func (u NotificationEventV1BillingWorkflowCollectionAlignment) AsNotificationEventV1BillingWorkflowCollectionAlignmentSubscription() (*NotificationEventV1BillingWorkflowCollectionAlignmentSubscription, error)
func (NotificationEventV1BillingWorkflowCollectionAlignment) MarshalJSON ¶
func (u NotificationEventV1BillingWorkflowCollectionAlignment) MarshalJSON() ([]byte, error)
func (*NotificationEventV1BillingWorkflowCollectionAlignment) UnmarshalJSON ¶
func (u *NotificationEventV1BillingWorkflowCollectionAlignment) UnmarshalJSON(data []byte) error
type NotificationEventV1BillingWorkflowCollectionAlignmentAnchored ¶
type NotificationEventV1BillingWorkflowCollectionAlignmentAnchored struct {
// The type of alignment.
Type string `json:"type"`
// The recurring period for the alignment.
RecurringPeriod NotificationEventV1RecurringPeriodV2 `json:"recurring_period"`
}
BillingWorkflowCollectionAlignmentAnchored specifies the alignment for collecting the pending line items into an invoice.
type NotificationEventV1BillingWorkflowCollectionAlignmentSubscription ¶
type NotificationEventV1BillingWorkflowCollectionAlignmentSubscription struct {
// The type of alignment.
Type string `json:"type"`
}
BillingWorkflowCollectionAlignmentSubscription specifies the alignment for collecting the pending line items into an invoice.
type NotificationEventV1BillingWorkflowCollectionSettings ¶
type NotificationEventV1BillingWorkflowCollectionSettings struct {
// The alignment for collecting the pending line items into an invoice.
Alignment *NotificationEventV1BillingWorkflowCollectionAlignment `json:"alignment,omitempty"`
// This grace period can be used to delay the collection of the pending line items
// specified in alignment.
//
// This is useful, in case of multiple subscriptions having slightly different
// billing periods.
Interval *string `json:"interval,omitempty"`
}
Workflow collection specifies how to collect the pending line items for an invoice
type NotificationEventV1BillingWorkflowInvoicingSettings ¶
type NotificationEventV1BillingWorkflowInvoicingSettings struct {
// Whether to automatically issue the invoice after the draftPeriod has passed.
AutoAdvance *bool `json:"auto_advance,omitempty"`
// The period for the invoice to be kept in draft status for manual reviews.
DraftPeriod *string `json:"draft_period,omitempty"`
// The period after which the invoice is due. With some payment solutions it's only
// applicable for manual collection method.
DueAfter *string `json:"due_after,omitempty"`
// Should progressive billing be allowed for this workflow?
ProgressiveBilling *bool `json:"progressive_billing,omitempty"`
// Controls how subscription-ending shortened service periods are billed.
SubscriptionEndProrationMode *NotificationEventV1BillingWorkflowInvoicingSubscriptionEndProrationMode `json:"subscription_end_proration_mode,omitempty"`
// Default tax configuration to apply to the invoices.
//
// Setting a tax code (`stripe.code` / `taxCodeId`) on a profile's default tax
// config is deprecated and can no longer be added or changed: the organization
// default tax code is used instead. Existing tax-code values may still be removed,
// and `behavior` remains fully supported.
DefaultTaxConfig *NotificationEventV1TaxConfig `json:"default_tax_config,omitempty"`
}
BillingWorkflowInvoicingSettings represents the invoice settings for a billing workflow
type NotificationEventV1BillingWorkflowInvoicingSubscriptionEndProrationMode ¶
type NotificationEventV1BillingWorkflowInvoicingSubscriptionEndProrationMode string
Billing workflow subscription end proration mode.
const ( NotificationEventV1BillingWorkflowInvoicingSubscriptionEndProrationModeBillFullPeriod NotificationEventV1BillingWorkflowInvoicingSubscriptionEndProrationMode = "bill_full_period" NotificationEventV1BillingWorkflowInvoicingSubscriptionEndProrationModeBillActualPeriod NotificationEventV1BillingWorkflowInvoicingSubscriptionEndProrationMode = "bill_actual_period" )
func (NotificationEventV1BillingWorkflowInvoicingSubscriptionEndProrationMode) Valid ¶
func (value NotificationEventV1BillingWorkflowInvoicingSubscriptionEndProrationMode) Valid() bool
type NotificationEventV1BillingWorkflowPaymentSettings ¶
type NotificationEventV1BillingWorkflowPaymentSettings struct {
// The payment method for the invoice.
CollectionMethod *NotificationEventV1CollectionMethod `json:"collection_method,omitempty"`
}
BillingWorkflowPaymentSettings represents the payment settings for a billing workflow
type NotificationEventV1BillingWorkflowTaxSettings ¶
type NotificationEventV1BillingWorkflowTaxSettings struct {
// Enable automatic tax calculation when tax is supported by the app. For example,
// with Stripe Invoicing when enabled, tax is calculated via Stripe Tax.
Enabled *bool `json:"enabled,omitempty"`
// Enforce tax calculation when tax is supported by the app. When enabled,
// OpenMeter will not allow to create an invoice without tax calculation.
// Enforcement is different per apps, for example, Stripe app requires customer to
// have a tax location when starting a paid subscription.
Enforced *bool `json:"enforced,omitempty"`
}
BillingWorkflowTaxSettings represents the tax settings for a billing workflow
type NotificationEventV1CollectionMethod ¶
type NotificationEventV1CollectionMethod string
CollectionMethod specifies how the invoice should be collected (automatic vs manual)
const ( NotificationEventV1CollectionMethodChargeAutomatically NotificationEventV1CollectionMethod = "charge_automatically" NotificationEventV1CollectionMethodSendInvoice NotificationEventV1CollectionMethod = "send_invoice" )
func (NotificationEventV1CollectionMethod) Valid ¶
func (value NotificationEventV1CollectionMethod) Valid() bool
type NotificationEventV1CustomInvoicingApp ¶
type NotificationEventV1CustomInvoicingApp struct {
// A unique identifier for the resource.
ID string `json:"id"`
// Human-readable name for the resource. Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource. Maximum 1024 characters.
Description *string `json:"description,omitempty"`
// Additional metadata for the resource.
Metadata Nullable[map[string]string] `json:"metadata,omitempty"`
// Timestamp of when the resource was created.
CreatedAt time.Time `json:"created_at"`
// Timestamp of when the resource was last updated.
UpdatedAt time.Time `json:"updated_at"`
// Timestamp of when the resource was permanently deleted.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// The marketplace listing that this installed app is based on.
Listing NotificationEventV1MarketplaceListing `json:"listing"`
// Status of the app connection.
Status NotificationEventV1AppStatus `json:"status"`
// The app's type is CustomInvoicing.
Type string `json:"type"`
// Enable draft.sync hook.
//
// If the hook is not enabled, the invoice will be progressed to the next state
// automatically.
EnableDraftSyncHook bool `json:"enable_draft_sync_hook"`
// Enable issuing.sync hook.
//
// If the hook is not enabled, the invoice will be progressed to the next state
// automatically.
EnableIssuingSyncHook bool `json:"enable_issuing_sync_hook"`
}
Custom Invoicing app can be used for interface with any invoicing or payment system.
This app provides ways to manipulate invoices and payments, however the integration must rely on Notifications API to get notified about invoice changes.
type NotificationEventV1CustomInvoicingTaxConfig ¶
type NotificationEventV1CustomInvoicingTaxConfig struct {
// Tax code.
//
// The tax code should be interpreted by the custom invoicing provider.
Code string `json:"code"`
}
Custom invoicing tax config.
type NotificationEventV1Customer ¶
type NotificationEventV1Customer struct {
// A unique identifier for the resource.
ID string `json:"id"`
// Human-readable name for the resource. Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource. Maximum 1024 characters.
Description *string `json:"description,omitempty"`
// Additional metadata for the resource.
Metadata Nullable[map[string]string] `json:"metadata,omitempty"`
// Timestamp of when the resource was created.
CreatedAt time.Time `json:"created_at"`
// Timestamp of when the resource was last updated.
UpdatedAt time.Time `json:"updated_at"`
// Timestamp of when the resource was permanently deleted.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// An optional unique key of the customer. Either key or
// usageAttribution.subjectKeys must be provided. Useful to reference the customer
// in external systems. For example, your database ID.
Key *string `json:"key,omitempty"`
// Mapping to attribute metered usage to the customer Either key or
// usageAttribution.subjectKeys must be provided.
UsageAttribution *NotificationEventV1CustomerUsageAttribution `json:"usage_attribution,omitempty"`
// The primary email address of the customer.
PrimaryEmail *string `json:"primary_email,omitempty"`
// Currency of the customer. Used for billing, tax and invoicing.
Currency *string `json:"currency,omitempty"`
// The billing address of the customer. Used for tax and invoicing.
BillingAddress *NotificationEventV1Address `json:"billing_address,omitempty"`
// The ID of the Subscription if the customer has one.
CurrentSubscriptionID *string `json:"current_subscription_id,omitempty"`
// The subscriptions of the customer. Only with the `subscriptions` expand option.
Subscriptions []NotificationEventV1Subscription `json:"subscriptions,omitempty"`
// Set of key-value pairs managed by the system. Cannot be modified by user.
Annotations map[string]any `json:"annotations,omitempty"`
}
A customer object.
type NotificationEventV1CustomerUsageAttribution ¶
type NotificationEventV1CustomerUsageAttribution struct {
// The subjects that are attributed to the customer. Can be empty when no subjects
// are associated with the customer.
SubjectKeys Nullable[[]string] `json:"subject_keys"`
}
Mapping to attribute metered usage to the customer. One customer can have zero or more subjects, but one subject can only belong to one customer.
type NotificationEventV1DiscountReasonMaximumSpend ¶
type NotificationEventV1DiscountReasonMaximumSpend struct {
// type.
Type string `json:"type"`
}
The reason for the discount is a maximum spend.
type NotificationEventV1DiscountReasonRatecardPercentage ¶
type NotificationEventV1DiscountReasonRatecardPercentage struct {
// type.
Type string `json:"type"`
// The percentage of the discount.
Percentage float64 `json:"percentage"`
// Correlation ID for the discount.
//
// This is used to link discounts across different invoices (progressive billing
// use case).
//
// If not provided, the invoicing engine will auto-generate one. When editing an
// invoice line, please make sure to keep the same correlation ID of the discount
// or in progressive billing setups the discount amounts might be incorrect.
CorrelationID *string `json:"correlation_id,omitempty"`
}
The reason for the discount is a ratecard percentage.
type NotificationEventV1DiscountReasonRatecardUsage ¶
type NotificationEventV1DiscountReasonRatecardUsage struct {
// type.
Type string `json:"type"`
// The quantity of the usage discount.
//
// Must be positive.
Quantity string `json:"quantity"`
// Correlation ID for the discount.
//
// This is used to link discounts across different invoices (progressive billing
// use case).
//
// If not provided, the invoicing engine will auto-generate one. When editing an
// invoice line, please make sure to keep the same correlation ID of the discount
// or in progressive billing setups the discount amounts might be incorrect.
CorrelationID *string `json:"correlation_id,omitempty"`
}
The reason for the discount is a ratecard usage.
type NotificationEventV1DynamicPriceWithCommitments ¶
type NotificationEventV1DynamicPriceWithCommitments struct {
// The type of the price.
Type string `json:"type"`
// The multiplier to apply to the base price to get the dynamic price.
//
// Examples:
//
// - 0.0: the price is zero
// - 0.5: the price is 50% of the base price
// - 1.0: the price is the same as the base price
// - 1.5: the price is 150% of the base price
Multiplier *string `json:"multiplier,omitempty"`
// The customer is committed to spend at least the amount.
MinimumAmount *string `json:"minimum_amount,omitempty"`
// The customer is limited to spend at most the amount.
MaximumAmount *string `json:"maximum_amount,omitempty"`
}
Dynamic price with spend commitments.
type NotificationEventV1EntitlementMetered ¶
type NotificationEventV1EntitlementMetered struct {
// type.
Type string `json:"type"`
// If softLimit=true the subject can use the feature even if the entitlement is
// exhausted, hasAccess will always be true.
IsSoftLimit *bool `json:"is_soft_limit,omitempty"`
// Deprecated, ignored by the backend. Please use isSoftLimit instead; this field
// will be removed in the future.
IsUnlimited *bool `json:"is_unlimited,omitempty"`
// You can grant usage automatically alongside the entitlement, the example
// scenario would be creating a starting balance. If an amount is specified here, a
// grant will be created alongside the entitlement with the specified amount. That
// grant will have it's rollover settings configured in a way that after each reset
// operation, the balance will return the original amount specified here. Manually
// creating such a grant would mean having the "amount", "minRolloverAmount", and
// "maxRolloverAmount" fields all be the same.
IssueAfterReset *float64 `json:"issue_after_reset,omitempty"`
// Defines the grant priority for the default grant.
IssueAfterResetPriority *uint8 `json:"issue_after_reset_priority,omitempty"`
// If true, the overage is preserved at reset. If false, the usage is reset to 0.
PreserveOverageAtReset *bool `json:"preserve_overage_at_reset,omitempty"`
// Timestamp of when the resource was created.
CreatedAt time.Time `json:"created_at"`
// Timestamp of when the resource was last updated.
UpdatedAt time.Time `json:"updated_at"`
// Timestamp of when the resource was permanently deleted.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// Additional metadata for the feature.
Metadata map[string]string `json:"metadata,omitempty"`
// The cadence start of the resource.
ActiveFrom time.Time `json:"active_from"`
// The cadence end of the resource.
ActiveTo *time.Time `json:"active_to,omitempty"`
// The annotations of the entitlement.
Annotations map[string]any `json:"annotations,omitempty"`
// Readonly unique ULID identifier.
ID string `json:"id"`
// The identifier key unique to the subject. NOTE: Subjects are being deprecated,
// please use the new customer APIs.
SubjectKey string `json:"subject_key"`
// The feature the subject is entitled to use.
FeatureKey string `json:"feature_key"`
// The feature the subject is entitled to use.
FeatureID string `json:"feature_id"`
// The time the last reset happened.
LastReset time.Time `json:"last_reset"`
// The current usage period.
CurrentUsagePeriod NotificationEventV1Period `json:"current_usage_period"`
// The time from which usage is measured. If not specified on creation, defaults to
// entitlement creation time.
MeasureUsageFrom time.Time `json:"measure_usage_from"`
// THe usage period of the entitlement.
UsagePeriod NotificationEventV1RecurringPeriod `json:"usage_period"`
}
Metered entitlements are useful for many different use cases, from setting up usage based access to implementing complex credit systems. Access is determined based on feature usage using a balance calculation (the "usage allowance" provided by the issued grants is "burnt down" by the usage).
type NotificationEventV1EntitlementValue ¶
type NotificationEventV1EntitlementValue struct {
// Whether the subject has access to the feature. Shared accross all entitlement
// types.
HasAccess bool `json:"has_access"`
// Only available for metered entitlements. Metered entitlements are built around a
// balance calculation where feature usage is deducted from the issued grants.
// Balance represents the remaining balance of the entitlement, it's value never
// turns negative.
Balance *float64 `json:"balance,omitempty"`
// Only available for metered entitlements. Returns the total feature usage in the
// current period.
Usage *float64 `json:"usage,omitempty"`
// Only available for metered entitlements. Overage represents the usage that
// wasn't covered by grants, e.g. if the subject had a total feature usage of 100
// in the period but they were only granted 80, there would be 20 overage.
Overage *float64 `json:"overage,omitempty"`
// Only available for metered entitlements. The summed amount of all grant active
// at query time PLUS the used amount of since inactive grants.
TotalAvailableGrantAmount *float64 `json:"total_available_grant_amount,omitempty"`
// Only available for static entitlements. The JSON parsable config of the
// entitlement.
Config *string `json:"config,omitempty"`
}
Entitlements are the core of OpenMeter access management. They define access to features for subjects. Entitlements can be metered, boolean, or static.
type NotificationEventV1Feature ¶
type NotificationEventV1Feature struct {
// Timestamp of when the resource was created.
CreatedAt time.Time `json:"created_at"`
// Timestamp of when the resource was last updated.
UpdatedAt time.Time `json:"updated_at"`
// Timestamp of when the resource was permanently deleted.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// Timestamp of when the resource was archived.
ArchivedAt *time.Time `json:"archived_at,omitempty"`
// A key is a unique string that is used to identify a resource.
Key string `json:"key"`
// The human-readable name of the feature.
Name string `json:"name"`
// Optional metadata.
Metadata map[string]string `json:"metadata,omitempty"`
// A key is a unique string that is used to identify a resource.
MeterSlug *string `json:"meter_slug,omitempty"`
// Optional meter group by filters. Useful if the meter scope is broader than what
// feature tracks. Example scenario would be a meter tracking all token use with
// groupBy fields for the model, then the feature could filter for model=gpt-4.
//
// ⚠️ **Deprecated**: Use advancedMeterGroupByFilters instead
MeterGroupByFilters map[string]string `json:"meter_group_by_filters,omitempty"`
// Optional advanced meter group by filters. You can use this to filter for values
// of the meter groupBy fields.
AdvancedMeterGroupByFilters map[string]NotificationEventV1FilterString `json:"advanced_meter_group_by_filters,omitempty"`
// Optional per-unit cost configuration. Use "manual" for a fixed per-unit cost, or
// "llm" to look up cost from the LLM cost database based on meter group-by
// properties.
UnitCost *NotificationEventV1FeatureUnitCost `json:"unit_cost,omitempty"`
// Readonly unique ULID identifier.
ID string `json:"id"`
}
Represents a feature that can be enabled or disabled for a plan. Used both for product catalog and entitlements.
type NotificationEventV1FeatureLLMUnitCost ¶
type NotificationEventV1FeatureLLMUnitCost struct {
// type.
Type string `json:"type"`
// Meter group-by property that holds the LLM provider. Use this when the meter has
// a group-by dimension for provider. Mutually exclusive with `provider`.
ProviderProperty *string `json:"provider_property,omitempty"`
// Static LLM provider value (e.g., "openai", "anthropic"). Use this when the
// feature tracks a single provider. Mutually exclusive with `providerProperty`.
Provider *string `json:"provider,omitempty"`
// Meter group-by property that holds the model ID. Use this when the meter has a
// group-by dimension for model. Mutually exclusive with `model`.
ModelProperty *string `json:"model_property,omitempty"`
// Static model ID value (e.g., "gpt-4", "claude-3-5-sonnet"). Use this when the
// feature tracks a single model. Mutually exclusive with `modelProperty`.
Model *string `json:"model,omitempty"`
// Meter group-by property that holds the token type. Use this when the meter has a
// group-by dimension for token type. Mutually exclusive with `tokenType`.
TokenTypeProperty *string `json:"token_type_property,omitempty"`
// Static token type value. Use this when the feature tracks a single token type
// (e.g., only input tokens). Expected values: input, output, cache_read,
// reasoning, cache_write, request, response. `request` is an alias for `input`,
// `response` is an alias for `output`. Mutually exclusive with
// `tokenTypeProperty`.
TokenType *string `json:"token_type,omitempty"`
// Resolved per-token pricing from the LLM cost database. Only populated in
// responses when the feature's meter group-by filters specify exact provider and
// model values.
Pricing *NotificationEventV1FeatureLLMUnitCostPricing `json:"pricing,omitempty"`
}
LLM cost lookup configuration. Maps meter group-by dimensions to LLM cost database fields.
type NotificationEventV1FeatureLLMUnitCostPricing ¶
type NotificationEventV1FeatureLLMUnitCostPricing struct {
// Cost per input token in USD.
InputPerToken string `json:"input_per_token"`
// Cost per output token in USD.
OutputPerToken string `json:"output_per_token"`
// Cost per cache read token in USD.
CacheReadPerToken *string `json:"cache_read_per_token,omitempty"`
// Cost per reasoning token in USD.
ReasoningPerToken *string `json:"reasoning_per_token,omitempty"`
// Cost per cache write token in USD.
CacheWritePerToken *string `json:"cache_write_per_token,omitempty"`
}
Resolved per-token pricing from the LLM cost database.
type NotificationEventV1FeatureManualUnitCost ¶
type NotificationEventV1FeatureManualUnitCost struct {
// type.
Type string `json:"type"`
// Fixed per-unit cost amount in USD.
Amount string `json:"amount"`
}
A fixed per-unit cost amount.
type NotificationEventV1FeatureUnitCost ¶
type NotificationEventV1FeatureUnitCost struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
Per-unit cost configuration for a feature. Either a fixed manual amount or a dynamic LLM cost lookup.
NotificationEventV1FeatureUnitCost is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the NotificationEventV1FeatureUnitCostFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func NotificationEventV1FeatureUnitCostFromNotificationEventV1FeatureLLMUnitCost ¶
func NotificationEventV1FeatureUnitCostFromNotificationEventV1FeatureLLMUnitCost(value NotificationEventV1FeatureLLMUnitCost) (NotificationEventV1FeatureUnitCost, error)
func NotificationEventV1FeatureUnitCostFromNotificationEventV1FeatureManualUnitCost ¶
func NotificationEventV1FeatureUnitCostFromNotificationEventV1FeatureManualUnitCost(value NotificationEventV1FeatureManualUnitCost) (NotificationEventV1FeatureUnitCost, error)
func (NotificationEventV1FeatureUnitCost) AsNotificationEventV1FeatureLLMUnitCost ¶
func (u NotificationEventV1FeatureUnitCost) AsNotificationEventV1FeatureLLMUnitCost() (*NotificationEventV1FeatureLLMUnitCost, error)
func (NotificationEventV1FeatureUnitCost) AsNotificationEventV1FeatureManualUnitCost ¶
func (u NotificationEventV1FeatureUnitCost) AsNotificationEventV1FeatureManualUnitCost() (*NotificationEventV1FeatureManualUnitCost, error)
func (NotificationEventV1FeatureUnitCost) MarshalJSON ¶
func (u NotificationEventV1FeatureUnitCost) MarshalJSON() ([]byte, error)
func (*NotificationEventV1FeatureUnitCost) UnmarshalJSON ¶
func (u *NotificationEventV1FeatureUnitCost) UnmarshalJSON(data []byte) error
type NotificationEventV1FilterString ¶
type NotificationEventV1FilterString struct {
// The field must be equal to the provided value.
Eq Nullable[string] `json:"$eq,omitempty"`
// The field must not be equal to the provided value.
Ne Nullable[string] `json:"$ne,omitempty"`
// The field must be in the provided list of values.
In Nullable[[]string] `json:"$in,omitempty"`
// The field must not be in the provided list of values.
Nin Nullable[[]string] `json:"$nin,omitempty"`
// The field must match the provided value.
Like Nullable[string] `json:"$like,omitempty"`
// The field must not match the provided value.
Nlike Nullable[string] `json:"$nlike,omitempty"`
// The field must match the provided value, ignoring case.
Ilike Nullable[string] `json:"$ilike,omitempty"`
// The field must not match the provided value, ignoring case.
Nilike Nullable[string] `json:"$nilike,omitempty"`
// The field must be greater than the provided value.
Gt Nullable[string] `json:"$gt,omitempty"`
// The field must be greater than or equal to the provided value.
Gte Nullable[string] `json:"$gte,omitempty"`
// The field must be less than the provided value.
Lt Nullable[string] `json:"$lt,omitempty"`
// The field must be less than or equal to the provided value.
Lte Nullable[string] `json:"$lte,omitempty"`
// Provide a list of filters to be combined with a logical AND.
And Nullable[[]NotificationEventV1FilterString] `json:"$and,omitempty"`
// Provide a list of filters to be combined with a logical OR.
Or Nullable[[]NotificationEventV1FilterString] `json:"$or,omitempty"`
}
A filter for a string field.
type NotificationEventV1FlatPrice ¶
type NotificationEventV1FlatPrice struct {
// The type of the price.
Type string `json:"type"`
// The amount of the flat price.
Amount string `json:"amount"`
}
Flat price.
type NotificationEventV1FlatPriceWithPaymentTerm ¶
type NotificationEventV1FlatPriceWithPaymentTerm struct {
// The type of the price.
Type string `json:"type"`
// The amount of the flat price.
Amount string `json:"amount"`
// The payment term of the flat price. Defaults to in advance.
PaymentTerm *NotificationEventV1PricePaymentTerm `json:"payment_term,omitempty"`
}
Flat price with payment term.
type NotificationEventV1IDResource ¶
type NotificationEventV1IDResource struct {
// A unique identifier for the resource.
ID string `json:"id"`
}
IDResource is a resouce with an ID.
type NotificationEventV1InstallMethod ¶
type NotificationEventV1InstallMethod string
Install method of the application.
const ( NotificationEventV1InstallMethodWithOauth2 NotificationEventV1InstallMethod = "with_oauth2" NotificationEventV1InstallMethodWithAPIKey NotificationEventV1InstallMethod = "with_api_key" NotificationEventV1InstallMethodNoCredentialsRequired NotificationEventV1InstallMethod = "no_credentials_required" )
func (NotificationEventV1InstallMethod) Valid ¶
func (value NotificationEventV1InstallMethod) Valid() bool
type NotificationEventV1InvoiceAppExternalIds ¶
type NotificationEventV1InvoiceAppExternalIds struct {
// The external ID of the invoice in the invoicing app if available.
Invoicing *string `json:"invoicing,omitempty"`
// The external ID of the invoice in the tax app if available.
Tax *string `json:"tax,omitempty"`
// The external ID of the invoice in the payment app if available.
Payment *string `json:"payment,omitempty"`
}
InvoiceAppExternalIds contains the external IDs of the invoice in other apps such as Stripe.
type NotificationEventV1InvoiceAvailableActionDetails ¶
type NotificationEventV1InvoiceAvailableActionDetails struct {
// The state the invoice will reach if the action is activated and all intermediate
// steps are successful.
//
// For example advancing a draft_created invoice will result in a
// draft_manual_approval_needed invoice.
ResultingState string `json:"resulting_state"`
}
InvoiceAvailableActionInvoiceDetails represents the details of the invoice action for non-gathering invoices.
type NotificationEventV1InvoiceAvailableActionInvoiceDetails ¶
type NotificationEventV1InvoiceAvailableActionInvoiceDetails struct{}
InvoiceAvailableActionInvoiceDetails represents the details of the invoice action for gathering invoices.
type NotificationEventV1InvoiceAvailableActions ¶
type NotificationEventV1InvoiceAvailableActions struct {
// Advance the invoice to the next status.
Advance *NotificationEventV1InvoiceAvailableActionDetails `json:"advance,omitempty"`
// Approve an invoice that requires manual approval.
Approve *NotificationEventV1InvoiceAvailableActionDetails `json:"approve,omitempty"`
// Delete the invoice (only non-issued invoices can be deleted).
Delete *NotificationEventV1InvoiceAvailableActionDetails `json:"delete,omitempty"`
// Retry an invoice issuing step that failed.
Retry *NotificationEventV1InvoiceAvailableActionDetails `json:"retry,omitempty"`
// Snapshot quantities for usage based line items.
SnapshotQuantities *NotificationEventV1InvoiceAvailableActionDetails `json:"snapshot_quantities,omitempty"`
// Void an already issued invoice.
Void *NotificationEventV1InvoiceAvailableActionDetails `json:"void,omitempty"`
// Invoice a gathering invoice
Invoice *NotificationEventV1InvoiceAvailableActionInvoiceDetails `json:"invoice,omitempty"`
}
InvoiceAvailableActions represents the actions that can be performed on the invoice.
type NotificationEventV1InvoiceDetailedLine ¶
type NotificationEventV1InvoiceDetailedLine struct {
// Human-readable name for the resource. Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource. Maximum 1024 characters.
Description *string `json:"description,omitempty"`
// Additional metadata for the resource.
Metadata Nullable[map[string]string] `json:"metadata,omitempty"`
// Timestamp of when the resource was created.
CreatedAt time.Time `json:"created_at"`
// Timestamp of when the resource was last updated.
UpdatedAt time.Time `json:"updated_at"`
// Timestamp of when the resource was permanently deleted.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// ID of the line.
ID string `json:"id"`
// managedBy specifies if the line is manually added via the api or managed by
// OpenMeter.
ManagedBy NotificationEventV1InvoiceLineManagedBy `json:"managed_by"`
// Status of the line.
//
// External calls always create valid lines, other line types are managed by the
// billing engine of OpenMeter.
Status NotificationEventV1InvoiceLineStatus `json:"status"`
// Discounts detailes applied to this line.
//
// New discounts can be added via the invoice's discounts API, to facilitate
// discounts that are affecting multiple lines.
Discounts *NotificationEventV1InvoiceLineDiscounts `json:"discounts,omitempty"`
// Credit allocations applied to this line.
//
// Credits are deducted from the line total before taxes are applied.
CreditAllocations []NotificationEventV1InvoiceLineCreditAllocation `json:"credit_allocations,omitempty"`
// The invoice this item belongs to.
Invoice *NotificationEventV1InvoiceReference `json:"invoice,omitempty"`
// The currency of this line.
Currency string `json:"currency"`
// Taxes applied to the invoice totals.
Taxes []NotificationEventV1InvoiceLineTaxItem `json:"taxes,omitempty"`
// Tax config specify the tax configuration for this line.
TaxConfig *NotificationEventV1TaxConfig `json:"tax_config,omitempty"`
// Totals for this line.
Totals NotificationEventV1InvoiceTotals `json:"totals"`
// Period of the line item applies to for revenue recognition pruposes.
//
// Billing always treats periods as start being inclusive and end being exclusive.
Period NotificationEventV1Period `json:"period"`
// External IDs of the invoice in other apps such as Stripe.
ExternalIds *NotificationEventV1InvoiceLineAppExternalIds `json:"external_ids,omitempty"`
// Subscription are the references to the subscritpions that this line is related
// to.
Subscription *NotificationEventV1InvoiceLineSubscriptionReference `json:"subscription,omitempty"`
// The time this line item should be invoiced.
InvoiceAt time.Time `json:"invoice_at"`
// Type of the line.
Type string `json:"type"`
// Price of the item being sold.
PerUnitAmount *string `json:"per_unit_amount,omitempty"`
// Payment term of the line.
PaymentTerm *NotificationEventV1PricePaymentTerm `json:"payment_term,omitempty"`
// Quantity of the item being sold.
Quantity *string `json:"quantity,omitempty"`
// The rate card that is used for this line.
RateCard *NotificationEventV1InvoiceDetailedLineRateCard `json:"rate_card,omitempty"`
// Category of the flat fee.
Category *NotificationEventV1InvoiceDetailedLineCostCategory `json:"category,omitempty"`
}
InvoiceDetailedLine represents a line item that is sold to the customer as a manually added fee.
type NotificationEventV1InvoiceDetailedLineCostCategory ¶
type NotificationEventV1InvoiceDetailedLineCostCategory string
InvoiceDetailedLineCostCategory determines if the flat fee is a regular fee due to use due to a commitment.
const ( NotificationEventV1InvoiceDetailedLineCostCategoryRegular NotificationEventV1InvoiceDetailedLineCostCategory = "regular" NotificationEventV1InvoiceDetailedLineCostCategoryCommitment NotificationEventV1InvoiceDetailedLineCostCategory = "commitment" )
func (NotificationEventV1InvoiceDetailedLineCostCategory) Valid ¶
func (value NotificationEventV1InvoiceDetailedLineCostCategory) Valid() bool
type NotificationEventV1InvoiceDetailedLineRateCard ¶
type NotificationEventV1InvoiceDetailedLineRateCard struct {
// The tax config of the rate card. When undefined, the tax config of the feature
// or the default tax config of the plan is used.
TaxConfig *NotificationEventV1TaxConfig `json:"tax_config,omitempty"`
// The price of the rate card. When null, the feature or service is free.
Price Nullable[NotificationEventV1FlatPriceWithPaymentTerm] `json:"price"`
// Quantity of the item being sold.
//
// Default: 1
Quantity *string `json:"quantity,omitempty"`
// The discounts that are applied to the line.
Discounts *NotificationEventV1BillingDiscounts `json:"discounts,omitempty"`
}
InvoiceDetailedLineRateCard represents the rate card (intent) for a flat fee line.
type NotificationEventV1InvoiceDocumentRef ¶
type NotificationEventV1InvoiceDocumentRef struct {
// Type of the document referenced.
Type NotificationEventV1InvoiceDocumentRefType `json:"type"`
// Human readable description on why this reference is here or needs to be used.
Reason *string `json:"reason,omitempty"`
// Additional details about the document.
Description *string `json:"description,omitempty"`
}
InvoiceDocumentRef is used to describe a reference to an existing document (invoice).
The v1 schema describes credit note references with issued_at, number and url, but the v1 API only ever sends the generic fields below.
type NotificationEventV1InvoiceDocumentRefType ¶
type NotificationEventV1InvoiceDocumentRefType string
InvoiceDocumentRefType defines the type of document that is being referenced.
const (
NotificationEventV1InvoiceDocumentRefTypeCreditNoteOriginalInvoice NotificationEventV1InvoiceDocumentRefType = "credit_note_original_invoice"
)
func (NotificationEventV1InvoiceDocumentRefType) Valid ¶
func (value NotificationEventV1InvoiceDocumentRefType) Valid() bool
type NotificationEventV1InvoiceLine ¶
type NotificationEventV1InvoiceLine struct {
// Human-readable name for the resource. Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource. Maximum 1024 characters.
Description *string `json:"description,omitempty"`
// Additional metadata for the resource.
Metadata Nullable[map[string]string] `json:"metadata,omitempty"`
// Timestamp of when the resource was created.
CreatedAt time.Time `json:"created_at"`
// Timestamp of when the resource was last updated.
UpdatedAt time.Time `json:"updated_at"`
// Timestamp of when the resource was permanently deleted.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// ID of the line.
ID string `json:"id"`
// managedBy specifies if the line is manually added via the api or managed by
// OpenMeter.
ManagedBy NotificationEventV1InvoiceLineManagedBy `json:"managed_by"`
// Status of the line.
//
// External calls always create valid lines, other line types are managed by the
// billing engine of OpenMeter.
Status NotificationEventV1InvoiceLineStatus `json:"status"`
// Discounts detailes applied to this line.
//
// New discounts can be added via the invoice's discounts API, to facilitate
// discounts that are affecting multiple lines.
Discounts *NotificationEventV1InvoiceLineDiscounts `json:"discounts,omitempty"`
// Credit allocations applied to this line.
//
// Credits are deducted from the line total before taxes are applied.
CreditAllocations []NotificationEventV1InvoiceLineCreditAllocation `json:"credit_allocations,omitempty"`
// The invoice this item belongs to.
Invoice *NotificationEventV1InvoiceReference `json:"invoice,omitempty"`
// The currency of this line.
Currency string `json:"currency"`
// Taxes applied to the invoice totals.
Taxes []NotificationEventV1InvoiceLineTaxItem `json:"taxes,omitempty"`
// Tax config specify the tax configuration for this line.
TaxConfig *NotificationEventV1TaxConfig `json:"tax_config,omitempty"`
// Totals for this line.
Totals NotificationEventV1InvoiceTotals `json:"totals"`
// Period of the line item applies to for revenue recognition pruposes.
//
// Billing always treats periods as start being inclusive and end being exclusive.
Period NotificationEventV1Period `json:"period"`
// The time this line item should be invoiced.
InvoiceAt time.Time `json:"invoice_at"`
// External IDs of the invoice in other apps such as Stripe.
ExternalIds *NotificationEventV1InvoiceLineAppExternalIds `json:"external_ids,omitempty"`
// Subscription are the references to the subscritpions that this line is related
// to.
Subscription *NotificationEventV1InvoiceLineSubscriptionReference `json:"subscription,omitempty"`
// Type of the line.
Type string `json:"type"`
// Price of the usage-based item being sold.
Price *NotificationEventV1RateCardUsageBasedPrice `json:"price,omitempty"`
// The feature that the usage is based on.
FeatureKey *string `json:"feature_key,omitempty"`
// The lines detailing the item or service sold.
Children []NotificationEventV1InvoiceDetailedLine `json:"children,omitempty"`
// The rate card that is used for this line.
//
// The rate card captures the intent of the price and discounts for the usage-based
// item.
RateCard *NotificationEventV1InvoiceUsageBasedRateCard `json:"rate_card,omitempty"`
// The quantity of the item being sold.
//
// Any usage discounts applied previously are deducted from this quantity.
Quantity *string `json:"quantity,omitempty"`
// The quantity of the item that has been metered for the period before any
// discounts were applied.
MeteredQuantity *string `json:"metered_quantity,omitempty"`
// The quantity of the item used before this line's period.
//
// It is non-zero in case of progressive billing, when this shows how much of the
// usage was already billed.
//
// Any usage discounts applied previously are deducted from this quantity.
PreLinePeriodQuantity *string `json:"pre_line_period_quantity,omitempty"`
// The metered quantity of the item used in before this line's period without any
// discounts applied.
//
// It is non-zero in case of progressive billing, when this shows how much of the
// usage was already billed.
MeteredPreLinePeriodQuantity *string `json:"metered_pre_line_period_quantity,omitempty"`
}
InvoiceUsageBasedLine represents a line item that is sold to the customer based on usage.
type NotificationEventV1InvoiceLineAmountDiscount ¶
type NotificationEventV1InvoiceLineAmountDiscount struct {
// Timestamp of when the resource was created.
CreatedAt time.Time `json:"created_at"`
// Timestamp of when the resource was last updated.
UpdatedAt time.Time `json:"updated_at"`
// Timestamp of when the resource was permanently deleted.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// ID of the charge or discount.
ID string `json:"id"`
// Reason code.
Reason NotificationEventV1BillingDiscountReason `json:"reason"`
// Text description as to why the discount was applied.
Description *string `json:"description,omitempty"`
// External IDs of the invoice in other apps such as Stripe.
ExternalIds *NotificationEventV1InvoiceLineAppExternalIds `json:"external_ids,omitempty"`
// Fixed discount amount to apply (calculated if percent present).
Amount string `json:"amount"`
}
InvoiceLineAmountDiscount represents an amount deducted from the line, and will be applied before taxes.
type NotificationEventV1InvoiceLineAppExternalIds ¶
type NotificationEventV1InvoiceLineAppExternalIds struct {
// The external ID of the invoice in the invoicing app if available.
Invoicing *string `json:"invoicing,omitempty"`
// The external ID of the invoice in the tax app if available.
Tax *string `json:"tax,omitempty"`
}
InvoiceLineAppExternalIds contains the external IDs of the invoice in other apps such as Stripe.
type NotificationEventV1InvoiceLineCreditAllocation ¶
type NotificationEventV1InvoiceLineCreditAllocation struct {
// Amount allocated from credits.
Amount string `json:"amount"`
// Text description as to why the credit was allocated.
Description *string `json:"description,omitempty"`
}
InvoiceLineCreditAllocation represents a credit amount allocated to the line before taxes are applied.
type NotificationEventV1InvoiceLineDiscounts ¶
type NotificationEventV1InvoiceLineDiscounts struct {
// Amount based discounts applied to the line.
//
// Amount based discounts are deduced from the total price of the line.
Amount []NotificationEventV1InvoiceLineAmountDiscount `json:"amount,omitempty"`
// Usage based discounts applied to the line.
//
// Usage based discounts are deduced from the usage of the line before price
// calculations are applied.
Usage []NotificationEventV1InvoiceLineUsageDiscount `json:"usage,omitempty"`
}
InvoiceLineDiscounts represents the discounts applied to the invoice line by type.
type NotificationEventV1InvoiceLineManagedBy ¶
type NotificationEventV1InvoiceLineManagedBy string
InvoiceLineManagedBy specifies who manages the line.
const ( NotificationEventV1InvoiceLineManagedBySubscription NotificationEventV1InvoiceLineManagedBy = "subscription" NotificationEventV1InvoiceLineManagedBySystem NotificationEventV1InvoiceLineManagedBy = "system" NotificationEventV1InvoiceLineManagedByManual NotificationEventV1InvoiceLineManagedBy = "manual" )
func (NotificationEventV1InvoiceLineManagedBy) Valid ¶
func (value NotificationEventV1InvoiceLineManagedBy) Valid() bool
type NotificationEventV1InvoiceLineStatus ¶
type NotificationEventV1InvoiceLineStatus string
Line status specifies the status of the line.
const ( NotificationEventV1InvoiceLineStatusValid NotificationEventV1InvoiceLineStatus = "valid" NotificationEventV1InvoiceLineStatusDetailed NotificationEventV1InvoiceLineStatus = "detailed" NotificationEventV1InvoiceLineStatusSplit NotificationEventV1InvoiceLineStatus = "split" )
func (NotificationEventV1InvoiceLineStatus) Valid ¶
func (value NotificationEventV1InvoiceLineStatus) Valid() bool
type NotificationEventV1InvoiceLineSubscriptionReference ¶
type NotificationEventV1InvoiceLineSubscriptionReference struct {
// The subscription.
Subscription NotificationEventV1IDResource `json:"subscription"`
// The phase of the subscription.
Phase NotificationEventV1IDResource `json:"phase"`
// The item this line is related to.
Item NotificationEventV1IDResource `json:"item"`
// The billing period of the subscription. In case the subscription item's billing
// period is different from the subscription's billing period, this field will
// contain the billing period of the subscription itself.
//
// For example, in case of:
//
// - A monthly billed subscription anchored to 2025-01-01
// - A subscription item billed daily
//
// An example line would have the period of 2025-01-02 to 2025-01-03 as the item is
// billed daily, but the subscription's billing period will be 2025-01-01 to
// 2025-01-31.
BillingPeriod NotificationEventV1Period `json:"billing_period"`
}
InvoiceLineSubscriptionReference contains the references to the subscription that this line is related to.
type NotificationEventV1InvoiceLineTaxBehavior ¶
type NotificationEventV1InvoiceLineTaxBehavior string
InvoiceLineTaxBehavior details how the tax item is applied to the base amount.
Inclusive means the tax is included in the base amount. Exclusive means the tax is added to the base amount.
const ( NotificationEventV1InvoiceLineTaxBehaviorInclusive NotificationEventV1InvoiceLineTaxBehavior = "inclusive" NotificationEventV1InvoiceLineTaxBehaviorExclusive NotificationEventV1InvoiceLineTaxBehavior = "exclusive" )
func (NotificationEventV1InvoiceLineTaxBehavior) Valid ¶
func (value NotificationEventV1InvoiceLineTaxBehavior) Valid() bool
type NotificationEventV1InvoiceLineTaxItem ¶
type NotificationEventV1InvoiceLineTaxItem struct {
// Tax provider configuration.
Config *NotificationEventV1TaxConfig `json:"config,omitempty"`
// Percent defines the percentage set manually or determined from the rate key
// (calculated if rate present). A nil percent implies that this tax combo is
// **exempt** from tax.")
Percent *float64 `json:"percent,omitempty"`
// Some countries require an additional surcharge (calculated if rate present).
Surcharge *string `json:"surcharge,omitempty"`
// Is the tax item inclusive or exclusive of the base amount.
Behavior *NotificationEventV1InvoiceLineTaxBehavior `json:"behavior,omitempty"`
}
TaxConfig stores the configuration for a tax line relative to an invoice line.
type NotificationEventV1InvoiceLineUsageDiscount ¶
type NotificationEventV1InvoiceLineUsageDiscount struct {
// Timestamp of when the resource was created.
CreatedAt time.Time `json:"created_at"`
// Timestamp of when the resource was last updated.
UpdatedAt time.Time `json:"updated_at"`
// Timestamp of when the resource was permanently deleted.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// ID of the charge or discount.
ID string `json:"id"`
// Reason code.
Reason NotificationEventV1BillingDiscountReason `json:"reason"`
// Text description as to why the discount was applied.
Description *string `json:"description,omitempty"`
// External IDs of the invoice in other apps such as Stripe.
ExternalIds *NotificationEventV1InvoiceLineAppExternalIds `json:"external_ids,omitempty"`
// The usage to apply.
Quantity string `json:"quantity"`
// The usage discount already applied to the previous split lines.
//
// Only set if progressive billing is enabled and the line is a split line.
PreLinePeriodQuantity *string `json:"pre_line_period_quantity,omitempty"`
}
InvoiceLineUsageDiscount represents an usage-based discount applied to the line.
The deduction is done before the pricing algorithm is applied.
type NotificationEventV1InvoicePaymentTerms ¶
type NotificationEventV1InvoicePaymentTerms struct {
// The terms of payment for the invoice.
Terms *NotificationEventV1PaymentTerms `json:"terms,omitempty"`
}
Payment contains details as to how the invoice should be paid.
type NotificationEventV1InvoiceReference ¶
type NotificationEventV1InvoiceReference struct {
// The ID of the invoice.
ID string `json:"id"`
// The number of the invoice.
Number *string `json:"number,omitempty"`
}
Reference to an invoice.
type NotificationEventV1InvoiceStatus ¶
type NotificationEventV1InvoiceStatus string
InvoiceStatus describes the status of an invoice.
const ( NotificationEventV1InvoiceStatusGathering NotificationEventV1InvoiceStatus = "gathering" NotificationEventV1InvoiceStatusDraft NotificationEventV1InvoiceStatus = "draft" NotificationEventV1InvoiceStatusIssuing NotificationEventV1InvoiceStatus = "issuing" NotificationEventV1InvoiceStatusIssued NotificationEventV1InvoiceStatus = "issued" NotificationEventV1InvoiceStatusPaymentProcessing NotificationEventV1InvoiceStatus = "payment_processing" NotificationEventV1InvoiceStatusOverdue NotificationEventV1InvoiceStatus = "overdue" NotificationEventV1InvoiceStatusPaid NotificationEventV1InvoiceStatus = "paid" NotificationEventV1InvoiceStatusUncollectible NotificationEventV1InvoiceStatus = "uncollectible" NotificationEventV1InvoiceStatusVoided NotificationEventV1InvoiceStatus = "voided" )
func (NotificationEventV1InvoiceStatus) Valid ¶
func (value NotificationEventV1InvoiceStatus) Valid() bool
type NotificationEventV1InvoiceStatusDetails ¶
type NotificationEventV1InvoiceStatusDetails struct {
// Is the invoice editable?
Immutable bool `json:"immutable"`
// Is the invoice in a failed state?
Failed bool `json:"failed"`
// Extended status information for the invoice.
ExtendedStatus string `json:"extended_status"`
// The actions that can be performed on the invoice.
AvailableActions NotificationEventV1InvoiceAvailableActions `json:"available_actions"`
}
InvoiceStatusDetails represents the details of the invoice status.
API users are encouraged to rely on the immutable/failed/avaliableActions fields to determine the next steps of the invoice instead of the extendedStatus field.
type NotificationEventV1InvoiceTotals ¶
type NotificationEventV1InvoiceTotals struct {
// The total value of the line before taxes, discounts and commitments.
Amount string `json:"amount"`
// The amount of value of the line that are due to additional charges.
ChargesTotal string `json:"charges_total"`
// The amount of value of the line that are due to discounts.
DiscountsTotal string `json:"discounts_total"`
// The amount of value of the line that are due to credits.
CreditsTotal string `json:"credits_total"`
// The total amount of taxes that are included in the line.
TaxesInclusiveTotal string `json:"taxes_inclusive_total"`
// The total amount of taxes that are added on top of amount from the line.
TaxesExclusiveTotal string `json:"taxes_exclusive_total"`
// The total amount of taxes for this line.
TaxesTotal string `json:"taxes_total"`
// The total amount value of the line after taxes, discounts and commitments.
Total string `json:"total"`
}
Totals contains the summaries of all calculations for the invoice.
type NotificationEventV1InvoiceType ¶
type NotificationEventV1InvoiceType string
InvoiceType represents the type of invoice.
The type of invoice determines the purpose of the invoice and how it should be handled.
const ( NotificationEventV1InvoiceTypeStandard NotificationEventV1InvoiceType = "standard" NotificationEventV1InvoiceTypeCreditNote NotificationEventV1InvoiceType = "credit_note" )
func (NotificationEventV1InvoiceType) Valid ¶
func (value NotificationEventV1InvoiceType) Valid() bool
type NotificationEventV1InvoiceUsageBasedRateCard ¶
type NotificationEventV1InvoiceUsageBasedRateCard struct {
// The feature the customer is entitled to use.
FeatureKey *string `json:"feature_key,omitempty"`
// The tax config of the rate card. When undefined, the tax config of the feature
// or the default tax config of the plan is used.
TaxConfig *NotificationEventV1TaxConfig `json:"tax_config,omitempty"`
// The price of the rate card. When null, the feature or service is free.
Price Nullable[NotificationEventV1RateCardUsageBasedPrice] `json:"price"`
// The discounts that are applied to the line.
Discounts *NotificationEventV1BillingDiscounts `json:"discounts,omitempty"`
}
InvoiceUsageBasedRateCard represents the rate card (intent) for an usage-based line.
type NotificationEventV1InvoiceWorkflowSettings ¶
type NotificationEventV1InvoiceWorkflowSettings struct {
// The apps that will be used to orchestrate the invoice's workflow.
//
// The v1 schema allows app references here too, but the v1 Event payloads always
// carry the full apps.
Apps *NotificationEventV1BillingProfileApps `json:"apps,omitempty"`
// sourceBillingProfileID is the billing profile on which the workflow was based
// on.
//
// The profile is snapshotted on invoice creation, after which it can be altered
// independently of the profile itself.
SourceBillingProfileID string `json:"source_billing_profile_id"`
// The workflow details used by this invoice.
Workflow NotificationEventV1BillingWorkflow `json:"workflow"`
}
InvoiceWorkflowSettings represents the workflow settings used by the invoice.
This is a clone of the billing profile's workflow settings at the time of invoice creation with customer overrides considered.
type NotificationEventV1MarketplaceListing ¶
type NotificationEventV1MarketplaceListing struct {
// The app's type
Type NotificationEventV1AppType `json:"type"`
// The app's name.
Name string `json:"name"`
// The app's description.
Description string `json:"description"`
// The app's capabilities.
Capabilities []NotificationEventV1AppCapability `json:"capabilities"`
// Install methods.
//
// List of methods to install the app.
InstallMethods []NotificationEventV1InstallMethod `json:"install_methods"`
}
A marketplace listing. Represent an available app in the app marketplace that can be installed to the organization.
Marketplace apps only exist in config so they don't extend the Resource model.
type NotificationEventV1PackagePriceWithCommitments ¶
type NotificationEventV1PackagePriceWithCommitments struct {
// The type of the price.
Type string `json:"type"`
// The price of one package.
Amount string `json:"amount"`
// The quantity per package.
QuantityPerPackage string `json:"quantity_per_package"`
// The customer is committed to spend at least the amount.
MinimumAmount *string `json:"minimum_amount,omitempty"`
// The customer is limited to spend at most the amount.
MaximumAmount *string `json:"maximum_amount,omitempty"`
}
Package price with spend commitments.
type NotificationEventV1PaymentDueDate ¶
type NotificationEventV1PaymentDueDate struct {
// When the payment is due.
DueAt time.Time `json:"due_at"`
// Other details to take into account for the due date.
Notes *string `json:"notes,omitempty"`
// How much needs to be paid by the date.
Amount string `json:"amount"`
// Percentage of the total that should be paid by the date.
Percent *float64 `json:"percent,omitempty"`
// If different from the parent document's base currency.
Currency *string `json:"currency,omitempty"`
}
PaymentDueDate contains an amount that should be paid by the given date.
type NotificationEventV1PaymentTermDueDate ¶
type NotificationEventV1PaymentTermDueDate struct {
// Type of terms to be applied.
Type string `json:"type"`
// Text detail of the chosen payment terms.
Detail *string `json:"detail,omitempty"`
// Description of the conditions for payment.
Notes *string `json:"notes,omitempty"`
// When the payment is due.
DueAt []NotificationEventV1PaymentDueDate `json:"due_at"`
}
PaymentTermDueDate defines the terms for payment on a specific date.
type NotificationEventV1PaymentTermInstant ¶
type NotificationEventV1PaymentTermInstant struct {
// Type of terms to be applied.
Type string `json:"type"`
// Text detail of the chosen payment terms.
Detail *string `json:"detail,omitempty"`
// Description of the conditions for payment.
Notes *string `json:"notes,omitempty"`
}
PaymentTermInstant defines the terms for payment on receipt of invoice.
type NotificationEventV1PaymentTerms ¶
type NotificationEventV1PaymentTerms struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
PaymentTerms defines the terms for payment.
NotificationEventV1PaymentTerms is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the NotificationEventV1PaymentTermsFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func NotificationEventV1PaymentTermsFromNotificationEventV1PaymentTermDueDate ¶
func NotificationEventV1PaymentTermsFromNotificationEventV1PaymentTermDueDate(value NotificationEventV1PaymentTermDueDate) (NotificationEventV1PaymentTerms, error)
func NotificationEventV1PaymentTermsFromNotificationEventV1PaymentTermInstant ¶
func NotificationEventV1PaymentTermsFromNotificationEventV1PaymentTermInstant(value NotificationEventV1PaymentTermInstant) (NotificationEventV1PaymentTerms, error)
func (NotificationEventV1PaymentTerms) AsNotificationEventV1PaymentTermDueDate ¶
func (u NotificationEventV1PaymentTerms) AsNotificationEventV1PaymentTermDueDate() (*NotificationEventV1PaymentTermDueDate, error)
func (NotificationEventV1PaymentTerms) AsNotificationEventV1PaymentTermInstant ¶
func (u NotificationEventV1PaymentTerms) AsNotificationEventV1PaymentTermInstant() (*NotificationEventV1PaymentTermInstant, error)
func (NotificationEventV1PaymentTerms) MarshalJSON ¶
func (u NotificationEventV1PaymentTerms) MarshalJSON() ([]byte, error)
func (*NotificationEventV1PaymentTerms) UnmarshalJSON ¶
func (u *NotificationEventV1PaymentTerms) UnmarshalJSON(data []byte) error
type NotificationEventV1Period ¶
type NotificationEventV1Period struct {
// Period start time.
From time.Time `json:"from"`
// Period end time.
To time.Time `json:"to"`
}
A period with a start and end time.
type NotificationEventV1PlanReference ¶
type NotificationEventV1PlanReference struct {
// The plan ID.
ID string `json:"id"`
// The plan key.
Key string `json:"key"`
// The plan version.
Version int64 `json:"version"`
}
References an exact plan.
type NotificationEventV1PricePaymentTerm ¶
type NotificationEventV1PricePaymentTerm string
The payment term of a flat price. One of: in_advance or in_arrears.
const ( NotificationEventV1PricePaymentTermInAdvance NotificationEventV1PricePaymentTerm = "in_advance" NotificationEventV1PricePaymentTermInArrears NotificationEventV1PricePaymentTerm = "in_arrears" )
func (NotificationEventV1PricePaymentTerm) Valid ¶
func (value NotificationEventV1PricePaymentTerm) Valid() bool
type NotificationEventV1PriceTier ¶
type NotificationEventV1PriceTier struct {
// Up to and including to this quantity will be contained in the tier. If null, the
// tier is open-ended.
UpToAmount *string `json:"up_to_amount,omitempty"`
// The flat price component of the tier.
FlatPrice Nullable[NotificationEventV1FlatPrice] `json:"flat_price"`
// The unit price component of the tier.
UnitPrice Nullable[NotificationEventV1UnitPrice] `json:"unit_price"`
}
A price tier. At least one price component is required in each tier.
type NotificationEventV1ProRatingConfig ¶
type NotificationEventV1ProRatingConfig struct {
// Whether pro-rating is enabled for this plan.
Enabled bool `json:"enabled"`
// How to handle pro-rating for billing period changes.
Mode NotificationEventV1ProRatingMode `json:"mode"`
}
Configuration for pro-rating behavior.
type NotificationEventV1ProRatingMode ¶
type NotificationEventV1ProRatingMode string
Pro-rating mode options for handling billing period changes.
const (
NotificationEventV1ProRatingModeProratePrices NotificationEventV1ProRatingMode = "prorate_prices"
)
func (NotificationEventV1ProRatingMode) Valid ¶
func (value NotificationEventV1ProRatingMode) Valid() bool
type NotificationEventV1RateCardUsageBasedPrice ¶
type NotificationEventV1RateCardUsageBasedPrice struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
The price of the usage based rate card.
NotificationEventV1RateCardUsageBasedPrice is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the NotificationEventV1RateCardUsageBasedPriceFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func NotificationEventV1RateCardUsageBasedPriceFromNotificationEventV1DynamicPriceWithCommitments ¶
func NotificationEventV1RateCardUsageBasedPriceFromNotificationEventV1DynamicPriceWithCommitments(value NotificationEventV1DynamicPriceWithCommitments) (NotificationEventV1RateCardUsageBasedPrice, error)
func NotificationEventV1RateCardUsageBasedPriceFromNotificationEventV1FlatPriceWithPaymentTerm ¶
func NotificationEventV1RateCardUsageBasedPriceFromNotificationEventV1FlatPriceWithPaymentTerm(value NotificationEventV1FlatPriceWithPaymentTerm) (NotificationEventV1RateCardUsageBasedPrice, error)
func NotificationEventV1RateCardUsageBasedPriceFromNotificationEventV1PackagePriceWithCommitments ¶
func NotificationEventV1RateCardUsageBasedPriceFromNotificationEventV1PackagePriceWithCommitments(value NotificationEventV1PackagePriceWithCommitments) (NotificationEventV1RateCardUsageBasedPrice, error)
func NotificationEventV1RateCardUsageBasedPriceFromNotificationEventV1TieredPriceWithCommitments ¶
func NotificationEventV1RateCardUsageBasedPriceFromNotificationEventV1TieredPriceWithCommitments(value NotificationEventV1TieredPriceWithCommitments) (NotificationEventV1RateCardUsageBasedPrice, error)
func NotificationEventV1RateCardUsageBasedPriceFromNotificationEventV1UnitPriceWithCommitments ¶
func NotificationEventV1RateCardUsageBasedPriceFromNotificationEventV1UnitPriceWithCommitments(value NotificationEventV1UnitPriceWithCommitments) (NotificationEventV1RateCardUsageBasedPrice, error)
func (NotificationEventV1RateCardUsageBasedPrice) AsNotificationEventV1DynamicPriceWithCommitments ¶
func (u NotificationEventV1RateCardUsageBasedPrice) AsNotificationEventV1DynamicPriceWithCommitments() (*NotificationEventV1DynamicPriceWithCommitments, error)
func (NotificationEventV1RateCardUsageBasedPrice) AsNotificationEventV1FlatPriceWithPaymentTerm ¶
func (u NotificationEventV1RateCardUsageBasedPrice) AsNotificationEventV1FlatPriceWithPaymentTerm() (*NotificationEventV1FlatPriceWithPaymentTerm, error)
func (NotificationEventV1RateCardUsageBasedPrice) AsNotificationEventV1PackagePriceWithCommitments ¶
func (u NotificationEventV1RateCardUsageBasedPrice) AsNotificationEventV1PackagePriceWithCommitments() (*NotificationEventV1PackagePriceWithCommitments, error)
func (NotificationEventV1RateCardUsageBasedPrice) AsNotificationEventV1TieredPriceWithCommitments ¶
func (u NotificationEventV1RateCardUsageBasedPrice) AsNotificationEventV1TieredPriceWithCommitments() (*NotificationEventV1TieredPriceWithCommitments, error)
func (NotificationEventV1RateCardUsageBasedPrice) AsNotificationEventV1UnitPriceWithCommitments ¶
func (u NotificationEventV1RateCardUsageBasedPrice) AsNotificationEventV1UnitPriceWithCommitments() (*NotificationEventV1UnitPriceWithCommitments, error)
func (NotificationEventV1RateCardUsageBasedPrice) MarshalJSON ¶
func (u NotificationEventV1RateCardUsageBasedPrice) MarshalJSON() ([]byte, error)
func (*NotificationEventV1RateCardUsageBasedPrice) UnmarshalJSON ¶
func (u *NotificationEventV1RateCardUsageBasedPrice) UnmarshalJSON(data []byte) error
type NotificationEventV1RecurringPeriod ¶
type NotificationEventV1RecurringPeriod struct {
// The unit of time for the interval. Heuristically maps ISO duraitons to enum
// values or returns the ISO duration.
Interval NotificationEventV1RecurringPeriodInterval `json:"interval"`
// A date-time anchor to base the recurring period on.
Anchor time.Time `json:"anchor"`
// The unit of time for the interval in ISO8601 format.
IntervalIso string `json:"interval_iso"`
}
Recurring period with an interval and an anchor.
type NotificationEventV1RecurringPeriodInterval ¶
type NotificationEventV1RecurringPeriodInterval string
Period duration for the recurrence
type NotificationEventV1RecurringPeriodIntervalEnum ¶
type NotificationEventV1RecurringPeriodIntervalEnum string
The unit of time for the interval. One of: `day`, `week`, `month`, or `year`.
const ( NotificationEventV1RecurringPeriodIntervalEnumDay NotificationEventV1RecurringPeriodIntervalEnum = "DAY" NotificationEventV1RecurringPeriodIntervalEnumWeek NotificationEventV1RecurringPeriodIntervalEnum = "WEEK" NotificationEventV1RecurringPeriodIntervalEnumMonth NotificationEventV1RecurringPeriodIntervalEnum = "MONTH" NotificationEventV1RecurringPeriodIntervalEnumYear NotificationEventV1RecurringPeriodIntervalEnum = "YEAR" )
func (NotificationEventV1RecurringPeriodIntervalEnum) Valid ¶
func (value NotificationEventV1RecurringPeriodIntervalEnum) Valid() bool
type NotificationEventV1RecurringPeriodV2 ¶
type NotificationEventV1RecurringPeriodV2 struct {
// The unit of time for the interval. Heuristically maps ISO duraitons to enum
// values or returns the ISO duration.
Interval NotificationEventV1RecurringPeriodInterval `json:"interval"`
// A date-time anchor to base the recurring period on.
Anchor time.Time `json:"anchor"`
}
Recurring period with an interval and an anchor.
type NotificationEventV1RuleBalanceThresholdValue ¶
type NotificationEventV1RuleBalanceThresholdValue struct {
// Value of the threshold.
Value float64 `json:"value"`
// Type of the threshold.
Type NotificationEventV1RuleBalanceThresholdValueType `json:"type"`
}
Threshold value with multiple supported types.
type NotificationEventV1RuleBalanceThresholdValueType ¶
type NotificationEventV1RuleBalanceThresholdValueType string
Type of the rule in the balance threshold specification:
- `balance_value`: threshold defined by the remaining balance value based on usage and the total of grants in the current usage period - `usage_percentage`: threshold defined by the usage percentage compared to the total of grants in the current usage period - `usage_value`: threshold defined by the usage value in the current usage period - `NUMBER` (**deprecated**): see `usage_value` - `PERCENT` (**deprecated**): see `usage_percentage`
const ( NotificationEventV1RuleBalanceThresholdValueTypePercent NotificationEventV1RuleBalanceThresholdValueType = "PERCENT" NotificationEventV1RuleBalanceThresholdValueTypeNumber NotificationEventV1RuleBalanceThresholdValueType = "NUMBER" NotificationEventV1RuleBalanceThresholdValueTypeBalanceValue NotificationEventV1RuleBalanceThresholdValueType = "balance_value" NotificationEventV1RuleBalanceThresholdValueTypeUsagePercentage NotificationEventV1RuleBalanceThresholdValueType = "usage_percentage" NotificationEventV1RuleBalanceThresholdValueTypeUsageValue NotificationEventV1RuleBalanceThresholdValueType = "usage_value" )
func (NotificationEventV1RuleBalanceThresholdValueType) Valid ¶
func (value NotificationEventV1RuleBalanceThresholdValueType) Valid() bool
type NotificationEventV1SandboxApp ¶
type NotificationEventV1SandboxApp struct {
// A unique identifier for the resource.
ID string `json:"id"`
// Human-readable name for the resource. Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource. Maximum 1024 characters.
Description *string `json:"description,omitempty"`
// Additional metadata for the resource.
Metadata Nullable[map[string]string] `json:"metadata,omitempty"`
// Timestamp of when the resource was created.
CreatedAt time.Time `json:"created_at"`
// Timestamp of when the resource was last updated.
UpdatedAt time.Time `json:"updated_at"`
// Timestamp of when the resource was permanently deleted.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// The marketplace listing that this installed app is based on.
Listing NotificationEventV1MarketplaceListing `json:"listing"`
// Status of the app connection.
Status NotificationEventV1AppStatus `json:"status"`
// The app's type is Sandbox.
Type string `json:"type"`
}
Sandbox app can be used for testing OpenMeter features.
The app is not creating anything in external systems, thus it is safe to use for verifying OpenMeter features.
type NotificationEventV1StripeApp ¶
type NotificationEventV1StripeApp struct {
// A unique identifier for the resource.
ID string `json:"id"`
// Human-readable name for the resource. Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource. Maximum 1024 characters.
Description *string `json:"description,omitempty"`
// Additional metadata for the resource.
Metadata Nullable[map[string]string] `json:"metadata,omitempty"`
// Timestamp of when the resource was created.
CreatedAt time.Time `json:"created_at"`
// Timestamp of when the resource was last updated.
UpdatedAt time.Time `json:"updated_at"`
// Timestamp of when the resource was permanently deleted.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// The marketplace listing that this installed app is based on.
Listing NotificationEventV1MarketplaceListing `json:"listing"`
// Status of the app connection.
Status NotificationEventV1AppStatus `json:"status"`
// The app's type is Stripe.
Type string `json:"type"`
// The Stripe account ID.
StripeAccountID string `json:"stripe_account_id"`
// Livemode, true if the app is in production mode.
Livemode bool `json:"livemode"`
// The masked API key. Only shows the first 8 and last 3 characters.
MaskedAPIKey string `json:"masked_api_key"`
}
A installed Stripe app object.
type NotificationEventV1StripeTaxConfig ¶
type NotificationEventV1StripeTaxConfig struct {
// Product tax code.
//
// See: https://docs.stripe.com/tax/tax-codes
Code string `json:"code"`
}
The tax config for Stripe.
type NotificationEventV1Subject ¶
type NotificationEventV1Subject struct {
// Timestamp of when the resource was created.
CreatedAt time.Time `json:"created_at"`
// Timestamp of when the resource was last updated.
UpdatedAt time.Time `json:"updated_at"`
// Timestamp of when the resource was permanently deleted.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// A unique identifier for the subject.
ID string `json:"id"`
// A unique, human-readable identifier for the subject. This is typically a
// database ID or a customer key.
Key string `json:"key"`
// A human-readable display name for the subject.
DisplayName Nullable[string] `json:"display_name,omitempty"`
// Metadata for the subject.
Metadata Nullable[map[string]any] `json:"metadata,omitempty"`
// The start of the current period for the subject.
CurrentPeriodStart *time.Time `json:"current_period_start,omitempty"`
// The end of the current period for the subject.
CurrentPeriodEnd *time.Time `json:"current_period_end,omitempty"`
// The Stripe customer ID for the subject.
StripeCustomerID Nullable[string] `json:"stripe_customer_id,omitempty"`
}
A subject is a unique identifier for a usage attribution by its key. Subjects only exist in the concept of metering. Subjects are optional to create and work as an enrichment for the subject key like displayName, metadata, etc. Subjects are useful when you are reporting usage events with your own database ID but want to enrich the subject with a human-readable name or metadata. For most use cases, a subject is equivalent to a customer.
⚠️ **Deprecated**: Subjects as managable entities are being depracated, use customers with subject key usage attribution instead.
type NotificationEventV1Subscription ¶
type NotificationEventV1Subscription struct {
// A unique identifier for the resource.
ID string `json:"id"`
// Human-readable name for the resource. Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource. Maximum 1024 characters.
Description *string `json:"description,omitempty"`
// Additional metadata for the resource.
Metadata Nullable[map[string]string] `json:"metadata,omitempty"`
// Timestamp of when the resource was created.
CreatedAt time.Time `json:"created_at"`
// Timestamp of when the resource was last updated.
UpdatedAt time.Time `json:"updated_at"`
// Timestamp of when the resource was permanently deleted.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// The cadence start of the resource.
ActiveFrom time.Time `json:"active_from"`
// The cadence end of the resource.
ActiveTo *time.Time `json:"active_to,omitempty"`
// Set of key-value pairs managed by the system. Cannot be modified by user.
Annotations map[string]any `json:"annotations,omitempty"`
// Alignment configuration for the plan.
Alignment *NotificationEventV1Alignment `json:"alignment,omitempty"`
// The status of the subscription.
Status NotificationEventV1SubscriptionStatus `json:"status"`
// The customer ID of the subscription.
CustomerID string `json:"customer_id"`
// The plan of the subscription.
Plan *NotificationEventV1PlanReference `json:"plan,omitempty"`
// The fiat currency in which the subscription is invoiced.
Currency string `json:"currency"`
// Controls whether custom-currency cost bases are resolved dynamically or pinned
// when their currency pair is introduced to the subscription.
CostBasisMode NotificationEventV1SubscriptionCostBasisMode `json:"cost_basis_mode"`
// Cost bases pinned to custom-currency pairs for this subscription.
CostBasisPins []NotificationEventV1SubscriptionCostBasisPin `json:"cost_basis_pins"`
// The billing cadence for the subscriptions. Defines how often customers are
// billed using ISO8601 duration format. Examples: "P1M" (monthly), "P3M"
// (quarterly), "P1Y" (annually).
BillingCadence string `json:"billing_cadence"`
// The pro-rating configuration for the subscriptions.
ProRatingConfig *NotificationEventV1ProRatingConfig `json:"pro_rating_config,omitempty"`
// The normalizedbilling anchor of the subscription.
BillingAnchor time.Time `json:"billing_anchor"`
// The settlement mode of the subscription.
//
// - credit_then_invoice: credits from the previous billing period are applied
// first, then the remaining balance is invoiced.
// - credit_only: only credits from the previous billing period are generated and
// applied. No invoices are generated for the subscription. This is the default
// and most common settlement mode.
SettlementMode NotificationEventV1BillingSettlementMode `json:"settlement_mode"`
}
Subscription is an exact subscription instance.
type NotificationEventV1SubscriptionCostBasisMode ¶
type NotificationEventV1SubscriptionCostBasisMode string
Controls how custom-currency cost bases are selected for the subscription.
const ( NotificationEventV1SubscriptionCostBasisModeDynamic NotificationEventV1SubscriptionCostBasisMode = "dynamic" NotificationEventV1SubscriptionCostBasisModePinned NotificationEventV1SubscriptionCostBasisMode = "pinned" )
func (NotificationEventV1SubscriptionCostBasisMode) Valid ¶
func (value NotificationEventV1SubscriptionCostBasisMode) Valid() bool
type NotificationEventV1SubscriptionCostBasisPin ¶
type NotificationEventV1SubscriptionCostBasisPin struct {
// The managed custom currency ID.
CustomCurrencyID string `json:"custom_currency_id"`
// The fiat currency in which the subscription is invoiced.
InvoiceCurrency string `json:"invoice_currency"`
// The pinned cost basis resource ID.
CostBasisID string `json:"cost_basis_id"`
}
A cost basis pinned to a custom-currency pair for the subscription.
type NotificationEventV1SubscriptionStatus ¶
type NotificationEventV1SubscriptionStatus string
Subscription status.
const ( NotificationEventV1SubscriptionStatusActive NotificationEventV1SubscriptionStatus = "active" NotificationEventV1SubscriptionStatusInactive NotificationEventV1SubscriptionStatus = "inactive" NotificationEventV1SubscriptionStatusCanceled NotificationEventV1SubscriptionStatus = "canceled" NotificationEventV1SubscriptionStatusScheduled NotificationEventV1SubscriptionStatus = "scheduled" )
func (NotificationEventV1SubscriptionStatus) Valid ¶
func (value NotificationEventV1SubscriptionStatus) Valid() bool
type NotificationEventV1TaxBehavior ¶
type NotificationEventV1TaxBehavior string
Tax behavior.
This enum is used to specify whether tax is included in the price or excluded from the price.
const ( NotificationEventV1TaxBehaviorInclusive NotificationEventV1TaxBehavior = "inclusive" NotificationEventV1TaxBehaviorExclusive NotificationEventV1TaxBehavior = "exclusive" )
func (NotificationEventV1TaxBehavior) Valid ¶
func (value NotificationEventV1TaxBehavior) Valid() bool
type NotificationEventV1TaxConfig ¶
type NotificationEventV1TaxConfig struct {
// Tax behavior.
//
// If not specified the billing profile is used to determine the tax behavior. If
// not specified in the billing profile, the provider's default behavior is used.
Behavior *NotificationEventV1TaxBehavior `json:"behavior,omitempty"`
// Stripe tax config.
Stripe *NotificationEventV1StripeTaxConfig `json:"stripe,omitempty"`
// Custom invoicing tax config.
CustomInvoicing *NotificationEventV1CustomInvoicingTaxConfig `json:"custom_invoicing,omitempty"`
// Tax code reference.
//
// When both `taxCodeId` and `stripe.code` are provided, `taxCodeId` takes
// precedence: the referenced tax code entity is used and `stripe.code` is ignored.
TaxCodeID *string `json:"tax_code_id,omitempty"`
}
Set of provider specific tax configs.
type NotificationEventV1TieredPriceMode ¶
type NotificationEventV1TieredPriceMode string
The mode of the tiered price.
const ( NotificationEventV1TieredPriceModeVolume NotificationEventV1TieredPriceMode = "volume" NotificationEventV1TieredPriceModeGraduated NotificationEventV1TieredPriceMode = "graduated" )
func (NotificationEventV1TieredPriceMode) Valid ¶
func (value NotificationEventV1TieredPriceMode) Valid() bool
type NotificationEventV1TieredPriceWithCommitments ¶
type NotificationEventV1TieredPriceWithCommitments struct {
// The type of the price.
//
// One of: flat, unit, or tiered.
Type string `json:"type"`
// Defines if the tiering mode is volume-based or graduated:
//
// - In `volume`-based tiering, the maximum quantity within a period determines the
// per unit price.
// - In `graduated` tiering, pricing can change as the quantity grows.
Mode NotificationEventV1TieredPriceMode `json:"mode"`
// The tiers of the tiered price. At least one price component is required in each
// tier.
Tiers []NotificationEventV1PriceTier `json:"tiers"`
// The customer is committed to spend at least the amount.
MinimumAmount *string `json:"minimum_amount,omitempty"`
// The customer is limited to spend at most the amount.
MaximumAmount *string `json:"maximum_amount,omitempty"`
}
Tiered price with spend commitments.
type NotificationEventV1UnitPrice ¶
type NotificationEventV1UnitPrice struct {
// The type of the price.
Type string `json:"type"`
// The amount of the unit price.
Amount string `json:"amount"`
}
Unit price.
type NotificationEventV1UnitPriceWithCommitments ¶
type NotificationEventV1UnitPriceWithCommitments struct {
// The type of the price.
Type string `json:"type"`
// The amount of the unit price.
Amount string `json:"amount"`
// The customer is committed to spend at least the amount.
MinimumAmount *string `json:"minimum_amount,omitempty"`
// The customer is limited to spend at most the amount.
MaximumAmount *string `json:"maximum_amount,omitempty"`
}
Unit price with spend commitments.
type NotificationEventV1ValidationIssue ¶
type NotificationEventV1ValidationIssue struct {
// Timestamp of when the resource was created.
CreatedAt time.Time `json:"created_at"`
// Timestamp of when the resource was last updated.
UpdatedAt time.Time `json:"updated_at"`
// Timestamp of when the resource was permanently deleted.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// ID of the charge or discount.
ID string `json:"id"`
// The severity of the issue.
Severity NotificationEventV1ValidationIssueSeverity `json:"severity"`
// The field that the issue is related to, if available in JSON path format.
Field *string `json:"field,omitempty"`
// Machine indentifiable code for the issue, if available.
Code *string `json:"code,omitempty"`
// Component reporting the issue.
Component string `json:"component"`
// A human-readable description of the issue.
Message string `json:"message"`
// Additional context for the issue.
Metadata map[string]string `json:"metadata,omitempty"`
}
ValidationIssue captures any validation issues related to the invoice.
Issues with severity "critical" will prevent the invoice from being issued.
type NotificationEventV1ValidationIssueSeverity ¶
type NotificationEventV1ValidationIssueSeverity string
ValidationIssueSeverity describes the severity of a validation issue.
Issues with severity "critical" will prevent the invoice from being issued.
const ( NotificationEventV1ValidationIssueSeverityCritical NotificationEventV1ValidationIssueSeverity = "critical" NotificationEventV1ValidationIssueSeverityWarning NotificationEventV1ValidationIssueSeverity = "warning" )
func (NotificationEventV1ValidationIssueSeverity) Valid ¶
func (value NotificationEventV1ValidationIssueSeverity) Valid() bool
type NotificationRule ¶
type NotificationRule struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
A notification rule selects the type of event to generate, the conditions specific to that type, and the channels to deliver the events to.
NotificationRule is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the NotificationRuleFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func NotificationRuleFromNotificationRuleBalanceThreshold ¶
func NotificationRuleFromNotificationRuleBalanceThreshold(value NotificationRuleBalanceThreshold) (NotificationRule, error)
func NotificationRuleFromNotificationRuleEntitlementReset ¶
func NotificationRuleFromNotificationRuleEntitlementReset(value NotificationRuleEntitlementReset) (NotificationRule, error)
func NotificationRuleFromNotificationRuleInvoiceCreated ¶
func NotificationRuleFromNotificationRuleInvoiceCreated(value NotificationRuleInvoiceCreated) (NotificationRule, error)
func NotificationRuleFromNotificationRuleInvoiceUpdated ¶
func NotificationRuleFromNotificationRuleInvoiceUpdated(value NotificationRuleInvoiceUpdated) (NotificationRule, error)
func (NotificationRule) AsNotificationRuleBalanceThreshold ¶
func (u NotificationRule) AsNotificationRuleBalanceThreshold() (*NotificationRuleBalanceThreshold, error)
func (NotificationRule) AsNotificationRuleEntitlementReset ¶
func (u NotificationRule) AsNotificationRuleEntitlementReset() (*NotificationRuleEntitlementReset, error)
func (NotificationRule) AsNotificationRuleInvoiceCreated ¶
func (u NotificationRule) AsNotificationRuleInvoiceCreated() (*NotificationRuleInvoiceCreated, error)
func (NotificationRule) AsNotificationRuleInvoiceUpdated ¶
func (u NotificationRule) AsNotificationRuleInvoiceUpdated() (*NotificationRuleInvoiceUpdated, error)
func (NotificationRule) MarshalJSON ¶
func (u NotificationRule) MarshalJSON() ([]byte, error)
func (*NotificationRule) UnmarshalJSON ¶
func (u *NotificationRule) UnmarshalJSON(data []byte) error
type NotificationRuleBalanceThreshold ¶
type NotificationRuleBalanceThreshold struct {
ID string `json:"id"`
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// The type of event the rule generates. Immutable after creation.
Type NotificationEventType `json:"type"`
// Whether the rule is disabled. Disabled rules do not generate events.
Disabled *bool `json:"disabled,omitempty"`
// The channels the rule delivers its events to. At least one and at most five
// channels are required. Responses omit channels that have since been disabled or
// deleted.
Channels []NotificationChannelReference `json:"channels"`
// The thresholds that generate an event when crossed.
Thresholds []NotificationBalanceThreshold `json:"thresholds"`
// The features the rule applies to. When omitted, the rule applies to every
// feature.
Features []FeatureReference `json:"features,omitempty"`
}
A rule that generates an event when an entitlement balance crosses one of its thresholds.
type NotificationRuleBalanceThresholdRequest ¶
type NotificationRuleBalanceThresholdRequest struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
Labels *map[string]string `json:"labels,omitempty"`
// The type of event the rule generates. Immutable after creation.
Type NotificationEventType `json:"type"`
// Whether the rule is disabled. Disabled rules do not generate events.
Disabled *bool `json:"disabled,omitempty"`
// The channels the rule delivers its events to. At least one and at most five
// channels are required. Responses omit channels that have since been disabled or
// deleted.
Channels []NotificationChannelReference `json:"channels"`
// The thresholds that generate an event when crossed.
Thresholds []NotificationBalanceThreshold `json:"thresholds"`
// The features the rule applies to. When omitted, the rule applies to every
// feature.
Features *[]FeatureReference `json:"features,omitempty"`
}
Request body for a balance threshold rule.
type NotificationRuleEntitlementReset ¶
type NotificationRuleEntitlementReset struct {
ID string `json:"id"`
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// The type of event the rule generates. Immutable after creation.
Type NotificationEventType `json:"type"`
// Whether the rule is disabled. Disabled rules do not generate events.
Disabled *bool `json:"disabled,omitempty"`
// The channels the rule delivers its events to. At least one and at most five
// channels are required. Responses omit channels that have since been disabled or
// deleted.
Channels []NotificationChannelReference `json:"channels"`
// The features the rule applies to. When omitted, the rule applies to every
// feature.
Features []FeatureReference `json:"features,omitempty"`
}
A rule that generates an event when an entitlement usage period is reset.
type NotificationRuleEntitlementResetRequest ¶
type NotificationRuleEntitlementResetRequest struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
Labels *map[string]string `json:"labels,omitempty"`
// The type of event the rule generates. Immutable after creation.
Type NotificationEventType `json:"type"`
// Whether the rule is disabled. Disabled rules do not generate events.
Disabled *bool `json:"disabled,omitempty"`
// The channels the rule delivers its events to. At least one and at most five
// channels are required. Responses omit channels that have since been disabled or
// deleted.
Channels []NotificationChannelReference `json:"channels"`
// The features the rule applies to. When omitted, the rule applies to every
// feature.
Features *[]FeatureReference `json:"features,omitempty"`
}
Request body for an entitlement reset rule.
type NotificationRuleFilter ¶
type NotificationRuleFilter struct {
ID *StringExactFilter
Name *StringFilter
Type *StringExactFilter
Disabled *BooleanFilter
CreatedAt *DateTimeFilter
UpdatedAt *DateTimeFilter
// Filter by an assigned channel. Matches rules that deliver to at least one of the
// given channels. Only `eq` and `oeq` are supported.
ChannelID *StringExactFilter
}
type NotificationRuleInvoiceCreated ¶
type NotificationRuleInvoiceCreated struct {
ID string `json:"id"`
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// The type of event the rule generates. Immutable after creation.
Type NotificationEventType `json:"type"`
// Whether the rule is disabled. Disabled rules do not generate events.
Disabled *bool `json:"disabled,omitempty"`
// The channels the rule delivers its events to. At least one and at most five
// channels are required. Responses omit channels that have since been disabled or
// deleted.
Channels []NotificationChannelReference `json:"channels"`
}
A rule that generates an event when an invoice is created.
type NotificationRuleInvoiceCreatedRequest ¶
type NotificationRuleInvoiceCreatedRequest struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
Labels *map[string]string `json:"labels,omitempty"`
// The type of event the rule generates. Immutable after creation.
Type NotificationEventType `json:"type"`
// Whether the rule is disabled. Disabled rules do not generate events.
Disabled *bool `json:"disabled,omitempty"`
// The channels the rule delivers its events to. At least one and at most five
// channels are required. Responses omit channels that have since been disabled or
// deleted.
Channels []NotificationChannelReference `json:"channels"`
}
Request body for an invoice created rule.
type NotificationRuleInvoiceUpdated ¶
type NotificationRuleInvoiceUpdated struct {
ID string `json:"id"`
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// The type of event the rule generates. Immutable after creation.
Type NotificationEventType `json:"type"`
// Whether the rule is disabled. Disabled rules do not generate events.
Disabled *bool `json:"disabled,omitempty"`
// The channels the rule delivers its events to. At least one and at most five
// channels are required. Responses omit channels that have since been disabled or
// deleted.
Channels []NotificationChannelReference `json:"channels"`
}
A rule that generates an event when an invoice is updated.
type NotificationRuleInvoiceUpdatedRequest ¶
type NotificationRuleInvoiceUpdatedRequest struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
Labels *map[string]string `json:"labels,omitempty"`
// The type of event the rule generates. Immutable after creation.
Type NotificationEventType `json:"type"`
// Whether the rule is disabled. Disabled rules do not generate events.
Disabled *bool `json:"disabled,omitempty"`
// The channels the rule delivers its events to. At least one and at most five
// channels are required. Responses omit channels that have since been disabled or
// deleted.
Channels []NotificationChannelReference `json:"channels"`
}
Request body for an invoice updated rule.
type NotificationRuleListParams ¶
type NotificationRuleListParams struct {
Page *PageParams
Sort *Sort
Filter *NotificationRuleFilter
}
type NotificationRulePagePaginatedResponse ¶
type NotificationRulePagePaginatedResponse struct {
Data []NotificationRule `json:"data"`
Meta PaginatedMeta `json:"meta"`
}
Page paginated response.
type NotificationRuleReference ¶
type NotificationRuleReference struct {
// The unique identifier of the rule.
ID string `json:"id"`
// The type of event the rule generates.
Type NotificationEventType `json:"type"`
// The user-provided name of the rule.
Name string `json:"name"`
}
A reference to the notification rule that generated an event.
type NotificationRuleRequest ¶
type NotificationRuleRequest struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
Request body for creating or updating a notification rule. Updates replace the rule's mutable state: omitting `disabled`, `labels`, or `features` resets them to their defaults. The `type` must match the existing rule on update.
NotificationRuleRequest is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the NotificationRuleRequestFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func NotificationRuleRequestFromNotificationRuleBalanceThresholdRequest ¶
func NotificationRuleRequestFromNotificationRuleBalanceThresholdRequest(value NotificationRuleBalanceThresholdRequest) (NotificationRuleRequest, error)
func NotificationRuleRequestFromNotificationRuleEntitlementResetRequest ¶
func NotificationRuleRequestFromNotificationRuleEntitlementResetRequest(value NotificationRuleEntitlementResetRequest) (NotificationRuleRequest, error)
func NotificationRuleRequestFromNotificationRuleInvoiceCreatedRequest ¶
func NotificationRuleRequestFromNotificationRuleInvoiceCreatedRequest(value NotificationRuleInvoiceCreatedRequest) (NotificationRuleRequest, error)
func NotificationRuleRequestFromNotificationRuleInvoiceUpdatedRequest ¶
func NotificationRuleRequestFromNotificationRuleInvoiceUpdatedRequest(value NotificationRuleInvoiceUpdatedRequest) (NotificationRuleRequest, error)
func (NotificationRuleRequest) AsNotificationRuleBalanceThresholdRequest ¶
func (u NotificationRuleRequest) AsNotificationRuleBalanceThresholdRequest() (*NotificationRuleBalanceThresholdRequest, error)
func (NotificationRuleRequest) AsNotificationRuleEntitlementResetRequest ¶
func (u NotificationRuleRequest) AsNotificationRuleEntitlementResetRequest() (*NotificationRuleEntitlementResetRequest, error)
func (NotificationRuleRequest) AsNotificationRuleInvoiceCreatedRequest ¶
func (u NotificationRuleRequest) AsNotificationRuleInvoiceCreatedRequest() (*NotificationRuleInvoiceCreatedRequest, error)
func (NotificationRuleRequest) AsNotificationRuleInvoiceUpdatedRequest ¶
func (u NotificationRuleRequest) AsNotificationRuleInvoiceUpdatedRequest() (*NotificationRuleInvoiceUpdatedRequest, error)
func (NotificationRuleRequest) MarshalJSON ¶
func (u NotificationRuleRequest) MarshalJSON() ([]byte, error)
func (*NotificationRuleRequest) UnmarshalJSON ¶
func (u *NotificationRuleRequest) UnmarshalJSON(data []byte) error
type NotificationsService ¶
type NotificationsService struct {
// contains filtered or unexported fields
}
func (*NotificationsService) CreateBillingChannel ¶
func (s *NotificationsService) CreateBillingChannel(ctx context.Context, request CreateNotificationChannelRequest) (*NotificationChannel, error)
Create a notification channel.
func (*NotificationsService) CreateBillingRule ¶
func (s *NotificationsService) CreateBillingRule(ctx context.Context, request NotificationRuleRequest) (*NotificationRule, error)
Create a notification rule.
func (*NotificationsService) DeleteBillingChannel ¶
func (s *NotificationsService) DeleteBillingChannel(ctx context.Context, notificationChannelID string) error
Delete a notification channel by id.
func (*NotificationsService) DeleteBillingRule ¶
func (s *NotificationsService) DeleteBillingRule(ctx context.Context, notificationRuleID string) error
Delete a notification rule by id.
func (*NotificationsService) GetBillingChannel ¶
func (s *NotificationsService) GetBillingChannel(ctx context.Context, notificationChannelID string) (*NotificationChannel, error)
Get a notification channel by id.
func (*NotificationsService) GetBillingEvent ¶
func (s *NotificationsService) GetBillingEvent(ctx context.Context, notificationEventID string) (*NotificationEvent, error)
Get a notification event by id.
func (*NotificationsService) GetBillingEventType ¶
func (s *NotificationsService) GetBillingEventType(ctx context.Context, notificationEventType string) (*NotificationEventTypeDefinition, error)
Get a notification event type with the JSON Schemas of its payload and rule configuration.
func (*NotificationsService) GetBillingRule ¶
func (s *NotificationsService) GetBillingRule(ctx context.Context, notificationRuleID string) (*NotificationRule, error)
Get a notification rule by id.
func (*NotificationsService) ListBillingChannels ¶
func (s *NotificationsService) ListBillingChannels(ctx context.Context, params NotificationChannelListParams) (*NotificationChannelPagePaginatedResponse, error)
List all notification channels.
func (*NotificationsService) ListBillingChannelsAll ¶
func (s *NotificationsService) ListBillingChannelsAll(ctx context.Context, params NotificationChannelListParams) iter.Seq2[NotificationChannel, error]
ListBillingChannelsAll returns an iterator over all NotificationChannel results, fetching pages of ListBillingChannels transparently. Iteration stops at the first error, which is yielded as the second value.
func (*NotificationsService) ListBillingEventTypes ¶
func (s *NotificationsService) ListBillingEventTypes(ctx context.Context, params NotificationEventTypeSummaryListParams) (*NotificationEventTypeSummaryPaginatedResponse, error)
List the notification event types, without their JSON Schemas. Event types are the same in every namespace. Deprecated event types stay listed.
func (*NotificationsService) ListBillingEventTypesAll ¶
func (s *NotificationsService) ListBillingEventTypesAll(ctx context.Context, params NotificationEventTypeSummaryListParams) iter.Seq2[NotificationEventTypeSummary, error]
ListBillingEventTypesAll returns an iterator over all NotificationEventTypeSummary results, fetching pages of ListBillingEventTypes transparently. Iteration stops at the first error, which is yielded as the second value.
func (*NotificationsService) ListBillingEvents ¶
func (s *NotificationsService) ListBillingEvents(ctx context.Context, params NotificationEventListParams) (*NotificationEventPagePaginatedResponse, error)
List all notification events.
func (*NotificationsService) ListBillingEventsAll ¶
func (s *NotificationsService) ListBillingEventsAll(ctx context.Context, params NotificationEventListParams) iter.Seq2[NotificationEvent, error]
ListBillingEventsAll returns an iterator over all NotificationEvent results, fetching pages of ListBillingEvents transparently. Iteration stops at the first error, which is yielded as the second value.
func (*NotificationsService) ListBillingRules ¶
func (s *NotificationsService) ListBillingRules(ctx context.Context, params NotificationRuleListParams) (*NotificationRulePagePaginatedResponse, error)
List all notification rules.
func (*NotificationsService) ListBillingRulesAll ¶
func (s *NotificationsService) ListBillingRulesAll(ctx context.Context, params NotificationRuleListParams) iter.Seq2[NotificationRule, error]
ListBillingRulesAll returns an iterator over all NotificationRule results, fetching pages of ListBillingRules transparently. Iteration stops at the first error, which is yielded as the second value.
func (*NotificationsService) ResendBillingEvent ¶
func (s *NotificationsService) ResendBillingEvent(ctx context.Context, notificationEventID string, request ResendBillingNotificationEventRequest) error
Resend a notification event to the channels of the rule that generated it.
Delivery is asynchronous: the request marks the selected channels for redelivery and returns immediately. Channels whose delivery is still pending or already being resent are left untouched.
func (*NotificationsService) TestBillingRule ¶
func (s *NotificationsService) TestBillingRule(ctx context.Context, notificationRuleID string) (*NotificationEvent, error)
Test a notification rule by generating an event with sample data and delivering it to the rule's channels. The test event is persisted and listed like any other event.
func (*NotificationsService) UpdateBillingChannel ¶
func (s *NotificationsService) UpdateBillingChannel(ctx context.Context, notificationChannelID string, request UpdateBillingNotificationChannelRequest) (*NotificationChannel, error)
Update a notification channel by id.
func (*NotificationsService) UpdateBillingRule ¶
func (s *NotificationsService) UpdateBillingRule(ctx context.Context, notificationRuleID string, request NotificationRuleRequest) (*NotificationRule, error)
Update a notification rule by id.
type Nullable ¶
Nullable represents a JSON field with three states: unspecified, explicit null, or a concrete value. Optional nullable fields use this as a value with omitempty; do not wrap it in a pointer.
func NullableValue ¶
NullableValue constructs a non-null value.
type Numeric ¶
type Numeric = string
Numeric represents an arbitrary-precision number. The API encodes it as a decimal string (e.g. "12.3456") to avoid float precision loss, so the SDK surfaces it as a string. Parse with a decimal library when arithmetic is needed.
type NumericFilter ¶
type NumericFilter struct {
Eq *float64
Neq *float64
Gt *float64
Gte *float64
Lt *float64
Lte *float64
Oeq []float64
}
NumericFilter expresses numeric comparison operators.
type OneOrMany ¶
type OneOrMany[T any] struct { // contains filtered or unexported fields }
OneOrMany represents a JSON value that accepts either one T or an array of T. The zero value holds neither variant and marshals as JSON null.
func (OneOrMany[T]) AsMany ¶
AsMany returns the array. The boolean is false when the single-value variant is set or the value is empty.
func (OneOrMany[T]) AsOne ¶
AsOne returns the single value. The boolean is false when the array variant is set or the value is empty.
func (OneOrMany[T]) MarshalJSON ¶
func (*OneOrMany[T]) UnmarshalJSON ¶
type Option ¶
type Option func(*Client)
Option configures a Client during New.
func WithHTTPClient ¶
WithHTTPClient replaces the default *http.Client. The provided client owns all transport behavior: retries, timeouts, proxies, TLS, and tracing. Pass nil to keep the default.
func WithToken ¶
WithToken sets the bearer token sent in the Authorization header of every request. The header is applied during request construction, so it is honored regardless of any client injected via WithHTTPClient.
func WithUserAgent ¶
WithUserAgent overrides the User-Agent header sent with each request.
type OrganizationDefaultTaxCodes ¶
type OrganizationDefaultTaxCodes struct {
// Default tax code for invoicing.
InvoicingTaxCode TaxCodeReference `json:"invoicing_tax_code"`
// Default tax code for credit grants.
CreditGrantTaxCode TaxCodeReference `json:"credit_grant_tax_code"`
// Timestamp of creation.
CreatedAt time.Time `json:"created_at"`
// Timestamp of last update.
UpdatedAt time.Time `json:"updated_at"`
}
Organization-level default tax code references.
Stores the default tax codes applied to specific billing contexts for this organization. Provisioned automatically when the organization is created.
type PageParams ¶
PageParams selects a numbered page.
type PaginatedMeta ¶
type PaginatedMeta struct {
Page PageMeta `json:"page"`
}
type Party ¶
type Party struct {
// Unique identifier for the party.
ID *string `json:"id,omitempty"`
// An optional unique key of the party.
Key *string `json:"key,omitempty"`
// Legal name or representation of the party.
Name *string `json:"name,omitempty"`
// The entity's legal identification used for tax purposes. They may have other
// numbers, but we're only interested in those valid for tax purposes.
TaxID *PartyTaxIdentity `json:"tax_id,omitempty"`
// Address for where information should be sent if needed.
Addresses *PartyAddresses `json:"addresses,omitempty"`
}
Party represents a person or business entity.
type PartyAddresses ¶
type PartyAddresses struct {
// Billing address.
BillingAddress Address `json:"billing_address"`
}
A collection of addresses for the party.
type PartyTaxIdentity ¶
type PartyTaxIdentity struct {
// Normalized tax identification code shown on the original identity document.
Code *string `json:"code,omitempty"`
}
Identity stores the details required to identify an entity for tax purposes in a specific country.
type Plan ¶
type Plan struct {
ID string `json:"id"`
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// A key is a semi-unique string that is used to identify the plan. It is used to
// reference the latest `active` version of the plan and is unique with the version
// number.
Key string `json:"key"`
// Plans are versioned to allow you to make changes without affecting running
// subscriptions.
Version int64 `json:"version"`
// The currency code of the plan.
Currency BillingCurrencyCode `json:"currency"`
// The billing cadence for subscriptions using this plan.
BillingCadence string `json:"billing_cadence"`
// Whether pro-rating is enabled for this plan.
ProRatingEnabled *bool `json:"pro_rating_enabled,omitempty"`
// The date and time when the plan becomes `active`. When not specified, the plan
// is in `draft` status.
EffectiveFrom *time.Time `json:"effective_from,omitempty"`
// A scheduled date and time when the plan becomes `archived`. When not specified,
// the plan is in `active` status indefinitely.
EffectiveTo *time.Time `json:"effective_to,omitempty"`
// The status of the plan. Computed based on the effective start and end dates:
//
// - `draft`: `effective_from` is not set.
// - `scheduled`: `now < effective_from`.
// - `active`: `effective_from <= now` and (`effective_to` is not set or
// `now < effective_to`).
// - `archived`: `effective_to <= now`.
Status PlanStatus `json:"status"`
// The plan phases define the pricing ramp for a subscription. A phase switch
// occurs only at the end of a billing period. At least one phase is required.
Phases []PlanPhase `json:"phases"`
// Settlement mode for plan.
//
// Values:
//
// - `credit_then_invoice`: Credits are applied first, then any remainder is
// invoiced.
// - `credit_only`: Usage is settled exclusively against credits.
SettlementMode SettlementMode `json:"settlement_mode"`
// List of validation errors in `draft` state that prevent the plan from being
// published.
ValidationErrors []ProductCatalogValidationError `json:"validation_errors,omitempty"`
}
Plans provide a template for subscriptions.
type PlanAddon ¶
type PlanAddon struct {
ID string `json:"id"`
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// The add-on associated with the plan.
Addon AddonReference `json:"addon"`
// The key of the plan phase from which the add-on becomes available for purchase.
FromPlanPhase string `json:"from_plan_phase"`
// The maximum number of times the add-on can be purchased for the plan. For
// single-instance add-ons this field must be omitted. For multi-instance add-ons
// when omitted, unlimited quantity can be purchased.
MaxQuantity *int64 `json:"max_quantity,omitempty"`
// List of validation errors.
ValidationErrors []ProductCatalogValidationError `json:"validation_errors,omitempty"`
}
PlanAddon represents an association between a plan and an add-on, controlling which add-ons are available for purchase within a plan.
type PlanAddonFilter ¶
type PlanAddonFilter struct {
ID *StringExactFilter
PlanKey *StringFilter
AddonID *StringExactFilter
AddonKey *StringFilter
AddonName *StringFilter
PlanCurrency *StringFilter
}
type PlanAddonListParams ¶
type PlanAddonListParams struct {
Page *PageParams
Sort *Sort
Filter *PlanAddonFilter
}
type PlanAddonPagePaginatedResponse ¶
type PlanAddonPagePaginatedResponse struct {
Data []PlanAddon `json:"data"`
Meta PaginatedMeta `json:"meta"`
}
Page paginated response.
type PlanAddonsService ¶
type PlanAddonsService struct {
// contains filtered or unexported fields
}
func (*PlanAddonsService) Create ¶
func (s *PlanAddonsService) Create(ctx context.Context, planID string, request CreatePlanAddonRequest) (*PlanAddon, error)
Add an add-on to a plan.
func (*PlanAddonsService) Get ¶
func (s *PlanAddonsService) Get(ctx context.Context, planID string, planAddonID string) (*PlanAddon, error)
Get an add-on association for a plan.
func (*PlanAddonsService) List ¶
func (s *PlanAddonsService) List(ctx context.Context, planID string, params PlanAddonListParams) (*PlanAddonPagePaginatedResponse, error)
List add-ons associated with a plan.
func (*PlanAddonsService) ListAll ¶
func (s *PlanAddonsService) ListAll(ctx context.Context, planID string, params PlanAddonListParams) iter.Seq2[PlanAddon, error]
ListAll returns an iterator over all PlanAddon results, fetching pages of List transparently. Iteration stops at the first error, which is yielded as the second value.
func (*PlanAddonsService) Update ¶
func (s *PlanAddonsService) Update(ctx context.Context, planID string, planAddonID string, request UpsertPlanAddonRequest) (*PlanAddon, error)
Update an add-on association for a plan.
type PlanFilter ¶
type PlanFilter struct {
Key *StringFilter
Name *StringFilter
Status *StringExactFilter
Currency *StringExactFilter
}
type PlanListParams ¶
type PlanListParams struct {
Page *PageParams
Sort *Sort
Filter *PlanFilter
}
type PlanPagePaginatedResponse ¶
type PlanPagePaginatedResponse struct {
Data []Plan `json:"data"`
Meta PaginatedMeta `json:"meta"`
}
Page paginated response.
type PlanPhase ¶
type PlanPhase struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Key string `json:"key"`
// The duration of the phase. When not specified, the phase runs indefinitely. Only
// the last phase may omit the duration.
Duration *string `json:"duration,omitempty"`
// The rate cards of the plan.
RateCards []RateCard `json:"rate_cards"`
}
The plan phase or pricing ramp allows changing a plan's rate cards over time as a subscription progresses.
type PlanPhaseInput ¶
type PlanPhaseInput struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
Key string `json:"key"`
// The duration of the phase. When not specified, the phase runs indefinitely. Only
// the last phase may omit the duration.
Duration *string `json:"duration,omitempty"`
// The rate cards of the plan.
RateCards []RateCardInput `json:"rate_cards"`
}
The plan phase or pricing ramp allows changing a plan's rate cards over time as a subscription progresses.
type PlanStatus ¶
type PlanStatus string
The status of a plan.
- `draft`: The plan has not yet been published and can be edited. - `active`: The plan is published and can be used in subscriptions. - `archived`: The plan is no longer available for use. - `scheduled`: The plan is scheduled to be published at a future date.
const ( PlanStatusDraft PlanStatus = "draft" PlanStatusActive PlanStatus = "active" PlanStatusArchived PlanStatus = "archived" PlanStatusScheduled PlanStatus = "scheduled" )
func (PlanStatus) Valid ¶
func (value PlanStatus) Valid() bool
type PlansService ¶
type PlansService struct {
// contains filtered or unexported fields
}
func (*PlansService) Create ¶
func (s *PlansService) Create(ctx context.Context, request CreatePlanRequest) (*Plan, error)
Create a new plan.
func (*PlansService) Delete ¶
func (s *PlansService) Delete(ctx context.Context, planID string) error
Delete a plan by id.
func (*PlansService) List ¶
func (s *PlansService) List(ctx context.Context, params PlanListParams) (*PlanPagePaginatedResponse, error)
List all plans.
func (*PlansService) ListAll ¶
func (s *PlansService) ListAll(ctx context.Context, params PlanListParams) iter.Seq2[Plan, error]
ListAll returns an iterator over all Plan results, fetching pages of List transparently. Iteration stops at the first error, which is yielded as the second value.
func (*PlansService) Update ¶
func (s *PlansService) Update(ctx context.Context, planID string, request UpsertPlanRequest) (*Plan, error)
Update a plan by id.
type Price ¶
type Price struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
Price.
Price is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the PriceFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func PriceFromPriceFlat ¶
func PriceFromPriceFree ¶
func PriceFromPriceGraduated ¶
func PriceFromPriceGraduated(value PriceGraduated) (Price, error)
func PriceFromPriceUnit ¶
func PriceFromPriceVolume ¶
func PriceFromPriceVolume(value PriceVolume) (Price, error)
func (Price) AsPriceFlat ¶
func (Price) AsPriceFree ¶
func (Price) AsPriceGraduated ¶
func (u Price) AsPriceGraduated() (*PriceGraduated, error)
func (Price) AsPriceUnit ¶
func (Price) AsPriceVolume ¶
func (u Price) AsPriceVolume() (*PriceVolume, error)
func (Price) MarshalJSON ¶
func (*Price) UnmarshalJSON ¶
type PriceFlat ¶
type PriceFlat struct {
// The type of the price.
Type PriceType `json:"type"`
// The amount of the flat price.
Amount Numeric `json:"amount"`
}
Flat price.
type PriceFree ¶
type PriceFree struct {
// The type of the price.
Type PriceType `json:"type"`
}
Free price.
type PriceGraduated ¶
type PriceGraduated struct {
// The type of the price.
Type PriceType `json:"type"`
// The tiers of the graduated price. At least one tier is required.
Tiers []PriceTier `json:"tiers"`
}
Graduated tiered price.
Each tier's rate applies only to the usage within that tier. Pricing can change as cumulative usage crosses tier boundaries.
When UnitConfig is present on the containing resource, tier boundaries (up_to_amount) are expressed in converted billing units.
type PricePagePaginatedResponse ¶
type PricePagePaginatedResponse struct {
Data []LLMCostPrice `json:"data"`
Meta PaginatedMeta `json:"meta"`
}
Page paginated response.
type PricePaymentTerm ¶
type PricePaymentTerm string
The payment term of a flat price.
const ( PricePaymentTermInAdvance PricePaymentTerm = "in_advance" PricePaymentTermInArrears PricePaymentTerm = "in_arrears" )
func (PricePaymentTerm) Valid ¶
func (value PricePaymentTerm) Valid() bool
type PriceTier ¶
type PriceTier struct {
// Up to and including this quantity will be contained in the tier. If undefined,
// the tier is open-ended (the last tier).
UpToAmount *Numeric `json:"up_to_amount,omitempty"`
// The flat price component of the tier. Charged once when the tier is entered.
FlatPrice *PriceFlat `json:"flat_price,omitempty"`
// The unit price component of the tier. Charged per billing unit within the tier.
UnitPrice *PriceUnit `json:"unit_price,omitempty"`
}
A price tier used in graduated and volume pricing.
At least one price component (flat_price or unit_price) must be set. When UnitConfig is present on the containing resource, up_to_amount is expressed in converted billing units.
type PriceType ¶
type PriceType string
The type of the price.
- `free`: No charge, the rate card is included at no cost. - `flat`: A fixed amount charged once per billing period, regardless of usage. - `unit`: A fixed rate charged per billing unit consumed. - `graduated`: Tiered pricing where each tier's rate applies only to usage within that tier. - `volume`: Tiered pricing where the rate for the highest tier reached applies to all units in the period.
type PriceUnit ¶
type PriceUnit struct {
// The type of the price.
Type PriceType `json:"type"`
// The amount of the unit price.
Amount Numeric `json:"amount"`
}
Unit price.
Charges a fixed rate per billing unit. When UnitConfig is present on the object, billing units are the converted quantities (e.g. GB instead of bytes).
type PriceUsageBased ¶
type PriceUsageBased struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
Usage-based price types for a rate card or charge.
When UnitConfig is present on the object, these price types operate on billing units (i.e. post-conversion quantities), not raw metered units.
PriceUsageBased is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the PriceUsageBasedFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func PriceUsageBasedFromPriceGraduated ¶
func PriceUsageBasedFromPriceGraduated(value PriceGraduated) (PriceUsageBased, error)
func PriceUsageBasedFromPriceUnit ¶
func PriceUsageBasedFromPriceUnit(value PriceUnit) (PriceUsageBased, error)
func PriceUsageBasedFromPriceVolume ¶
func PriceUsageBasedFromPriceVolume(value PriceVolume) (PriceUsageBased, error)
func (PriceUsageBased) AsPriceGraduated ¶
func (u PriceUsageBased) AsPriceGraduated() (*PriceGraduated, error)
func (PriceUsageBased) AsPriceUnit ¶
func (u PriceUsageBased) AsPriceUnit() (*PriceUnit, error)
func (PriceUsageBased) AsPriceVolume ¶
func (u PriceUsageBased) AsPriceVolume() (*PriceVolume, error)
func (PriceUsageBased) MarshalJSON ¶
func (u PriceUsageBased) MarshalJSON() ([]byte, error)
func (*PriceUsageBased) UnmarshalJSON ¶
func (u *PriceUsageBased) UnmarshalJSON(data []byte) error
type PriceVolume ¶
type PriceVolume struct {
// The type of the price.
Type PriceType `json:"type"`
// The tiers of the volume price. At least one tier is required.
Tiers []PriceTier `json:"tiers"`
}
Volume tiered price.
The maximum quantity within a period determines the per-unit price for all units in that period.
When UnitConfig is present on the containing resource, tier boundaries (up_to_amount) are expressed in converted billing units.
type ProductCatalogValidationError ¶
type ProductCatalogValidationError struct {
// Machine-readable error code.
Code string `json:"code"`
// Human-readable description of the error.
Message string `json:"message"`
// Additional structured context.
Attributes map[string]any `json:"attributes,omitempty"`
// The path to the field.
Field string `json:"field"`
}
Validation errors providing detailed description of the issue.
type Profile ¶
type Profile struct {
ID string `json:"id"`
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// The name and contact information for the supplier this billing profile
// represents
Supplier Party `json:"supplier"`
// The billing workflow settings for this profile
Workflow Workflow `json:"workflow"`
// The applications used by this billing profile.
Apps ProfileAppReferences `json:"apps"`
// Whether this is the default profile.
Default bool `json:"default"`
}
Billing profiles contain the settings for billing and controls invoice generation.
type ProfileAppReferences ¶
type ProfileAppReferences struct {
// The tax app used for this workflow.
Tax AppReference `json:"tax"`
// The invoicing app used for this workflow.
Invoicing AppReference `json:"invoicing"`
// The payment app used for this workflow.
Payment AppReference `json:"payment"`
}
References to the applications used by a billing profile.
type ProfileFilter ¶
type ProfileFilter struct {
ID *StringExactFilter
Name *StringFilter
}
type ProfileListParams ¶
type ProfileListParams struct {
Page *PageParams
Sort *Sort
Filter *ProfileFilter
}
type ProfilePagePaginatedResponse ¶
type ProfilePagePaginatedResponse struct {
Data []Profile `json:"data"`
Meta PaginatedMeta `json:"meta"`
}
Page paginated response.
type ProfileReference ¶
type ProfileReference struct {
// The ID of the billing profile.
ID string `json:"id"`
}
Billing profile reference.
type QueryFilterString ¶
type QueryFilterString struct {
// The attribute equals the provided value.
Eq *string `json:"eq,omitempty"`
// The attribute does not equal the provided value.
Neq *string `json:"neq,omitempty"`
// The attribute is one of the provided values.
In []string `json:"in,omitempty"`
// The attribute is not one of the provided values.
Nin []string `json:"nin,omitempty"`
// The attribute contains the provided value.
Contains *string `json:"contains,omitempty"`
// The attribute does not contain the provided value.
Ncontains *string `json:"ncontains,omitempty"`
// Combines the provided filters with a logical AND.
And []QueryFilterString `json:"and,omitempty"`
// Combines the provided filters with a logical OR.
Or []QueryFilterString `json:"or,omitempty"`
}
A query filter for a string attribute. Operators are mutually exclusive, only one operator is allowed at a time.
type QueryFilterStringInput ¶
type QueryFilterStringInput struct {
// The attribute equals the provided value.
Eq *string `json:"eq,omitempty"`
// The attribute does not equal the provided value.
Neq *string `json:"neq,omitempty"`
// The attribute is one of the provided values.
In *[]string `json:"in,omitempty"`
// The attribute is not one of the provided values.
Nin *[]string `json:"nin,omitempty"`
// The attribute contains the provided value.
Contains *string `json:"contains,omitempty"`
// The attribute does not contain the provided value.
Ncontains *string `json:"ncontains,omitempty"`
// Combines the provided filters with a logical AND.
And *[]QueryFilterStringInput `json:"and,omitempty"`
// Combines the provided filters with a logical OR.
Or *[]QueryFilterStringInput `json:"or,omitempty"`
}
A query filter for a string attribute. Operators are mutually exclusive, only one operator is allowed at a time.
type QueryFilterStringMapItem ¶
type QueryFilterStringMapItem struct {
// The attribute exists.
Exists *bool `json:"exists,omitempty"`
// The attribute equals the provided value.
Eq *string `json:"eq,omitempty"`
// The attribute does not equal the provided value.
Neq *string `json:"neq,omitempty"`
// The attribute is one of the provided values.
In []string `json:"in,omitempty"`
// The attribute is not one of the provided values.
Nin []string `json:"nin,omitempty"`
// The attribute contains the provided value.
Contains *string `json:"contains,omitempty"`
// The attribute does not contain the provided value.
Ncontains *string `json:"ncontains,omitempty"`
// Combines the provided filters with a logical AND.
And []QueryFilterString `json:"and,omitempty"`
// Combines the provided filters with a logical OR.
Or []QueryFilterString `json:"or,omitempty"`
}
A query filter for an item in a string map attribute. Operators are mutually exclusive, only one operator is allowed at a time.
type QueryFilterStringMapItemInput ¶
type QueryFilterStringMapItemInput struct {
// The attribute exists.
Exists *bool `json:"exists,omitempty"`
// The attribute equals the provided value.
Eq *string `json:"eq,omitempty"`
// The attribute does not equal the provided value.
Neq *string `json:"neq,omitempty"`
// The attribute is one of the provided values.
In *[]string `json:"in,omitempty"`
// The attribute is not one of the provided values.
Nin *[]string `json:"nin,omitempty"`
// The attribute contains the provided value.
Contains *string `json:"contains,omitempty"`
// The attribute does not contain the provided value.
Ncontains *string `json:"ncontains,omitempty"`
// Combines the provided filters with a logical AND.
And *[]QueryFilterStringInput `json:"and,omitempty"`
// Combines the provided filters with a logical OR.
Or *[]QueryFilterStringInput `json:"or,omitempty"`
}
A query filter for an item in a string map attribute. Operators are mutually exclusive, only one operator is allowed at a time.
type RateCard ¶
type RateCard struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Key string `json:"key"`
// The feature associated with the rate card.
Feature *FeatureReference `json:"feature,omitempty"`
// Overrides the containing plan or add-on currency for this rate card. When
// omitted, the containing resource currency applies.
Currency *BillingCurrencyCode `json:"currency,omitempty"`
// The billing cadence of the rate card. When null, the charge is one-time
// (non-recurring). Only valid for flat prices.
BillingCadence *string `json:"billing_cadence,omitempty"`
// The price of the rate card.
Price Price `json:"price"`
// Unit conversion configuration for the rate card.
//
// Synthesized on read for plans authored with v1 dynamic or package prices:
// dynamic prices map to a unit price with a multiply unit config, and package
// prices map to a unit price with a divide unit config.
//
// Accepted on create and update only when the UnitConfig feature is enabled on the
// deployment; otherwise rejected.
UnitConfig *UnitConfig `json:"unit_config,omitempty"`
// The payment term of the rate card. In advance payment term can only be used for
// flat prices.
PaymentTerm *PricePaymentTerm `json:"payment_term,omitempty"`
// Spend commitments for this rate card. Only applicable to usage-based prices
// (unit, graduated, volume).
Commitments *SpendCommitments `json:"commitments,omitempty"`
// The discounts of the rate card.
Discounts *RateCardDiscounts `json:"discounts,omitempty"`
// The tax config of the rate card.
TaxConfig *TaxCodeConfig `json:"tax_config,omitempty"`
// The entitlement template granted to subscribers of a plan or addon containing
// this rate card. Requires `feature` to be set.
Entitlement *RateCardEntitlement `json:"entitlement,omitempty"`
}
A rate card defines the pricing and entitlement of a feature or service.
type RateCardBooleanEntitlement ¶
type RateCardBooleanEntitlement struct {
// The type of the entitlement template.
Type EntitlementType `json:"type"`
}
The entitlement template of a boolean entitlement.
type RateCardDiscounts ¶
type RateCardDiscounts struct {
// Percentage discount applied to the price (0–100).
Percentage *float64 `json:"percentage,omitempty"`
// Number of usage units granted free before billing starts. Only applies to
// usage-based lines (not flat fees). Usage is treated as zero until this amount is
// exhausted.
Usage *Numeric `json:"usage,omitempty"`
}
Discount configuration for a rate card.
type RateCardEntitlement ¶
type RateCardEntitlement struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
Entitlement template configured on a rate card. The feature is taken from the rate card itself, so it is omitted here.
RateCardEntitlement is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the RateCardEntitlementFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func RateCardEntitlementFromRateCardBooleanEntitlement ¶
func RateCardEntitlementFromRateCardBooleanEntitlement(value RateCardBooleanEntitlement) (RateCardEntitlement, error)
func RateCardEntitlementFromRateCardMeteredEntitlement ¶
func RateCardEntitlementFromRateCardMeteredEntitlement(value RateCardMeteredEntitlement) (RateCardEntitlement, error)
func RateCardEntitlementFromRateCardStaticEntitlement ¶
func RateCardEntitlementFromRateCardStaticEntitlement(value RateCardStaticEntitlement) (RateCardEntitlement, error)
func (RateCardEntitlement) AsRateCardBooleanEntitlement ¶
func (u RateCardEntitlement) AsRateCardBooleanEntitlement() (*RateCardBooleanEntitlement, error)
func (RateCardEntitlement) AsRateCardMeteredEntitlement ¶
func (u RateCardEntitlement) AsRateCardMeteredEntitlement() (*RateCardMeteredEntitlement, error)
func (RateCardEntitlement) AsRateCardStaticEntitlement ¶
func (u RateCardEntitlement) AsRateCardStaticEntitlement() (*RateCardStaticEntitlement, error)
func (RateCardEntitlement) MarshalJSON ¶
func (u RateCardEntitlement) MarshalJSON() ([]byte, error)
func (*RateCardEntitlement) UnmarshalJSON ¶
func (u *RateCardEntitlement) UnmarshalJSON(data []byte) error
type RateCardInput ¶
type RateCardInput struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
Key string `json:"key"`
// The feature associated with the rate card.
Feature *FeatureReference `json:"feature,omitempty"`
// Overrides the containing plan or add-on currency for this rate card. When
// omitted, the containing resource currency applies.
Currency *BillingCurrencyCode `json:"currency,omitempty"`
// The billing cadence of the rate card. When null, the charge is one-time
// (non-recurring). Only valid for flat prices.
BillingCadence *string `json:"billing_cadence,omitempty"`
// The price of the rate card.
Price Price `json:"price"`
// Unit conversion configuration for the rate card.
//
// Synthesized on read for plans authored with v1 dynamic or package prices:
// dynamic prices map to a unit price with a multiply unit config, and package
// prices map to a unit price with a divide unit config.
//
// Accepted on create and update only when the UnitConfig feature is enabled on the
// deployment; otherwise rejected.
UnitConfig *UnitConfig `json:"unit_config,omitempty"`
// The payment term of the rate card. In advance payment term can only be used for
// flat prices.
PaymentTerm *PricePaymentTerm `json:"payment_term,omitempty"`
// Spend commitments for this rate card. Only applicable to usage-based prices
// (unit, graduated, volume).
Commitments *SpendCommitments `json:"commitments,omitempty"`
// The discounts of the rate card.
Discounts *RateCardDiscounts `json:"discounts,omitempty"`
// The tax config of the rate card.
TaxConfig *TaxCodeConfig `json:"tax_config,omitempty"`
// The entitlement template granted to subscribers of a plan or addon containing
// this rate card. Requires `feature` to be set.
Entitlement *RateCardEntitlement `json:"entitlement,omitempty"`
}
A rate card defines the pricing and entitlement of a feature or service.
type RateCardMeteredEntitlement ¶
type RateCardMeteredEntitlement struct {
// The type of the entitlement template.
Type EntitlementType `json:"type"`
// If soft limit is true, the subject can use the feature even if the entitlement
// is exhausted; access remains granted.
IsSoftLimit *bool `json:"is_soft_limit,omitempty"`
// The amount of usage granted each usage period, in the feature's unit. Usage is
// counted against this allowance and the balance resets every usage period. When
// `is_soft_limit` is true the subject keeps access after the limit is reached;
// otherwise access is denied once the allowance is exhausted.
Limit *float64 `json:"limit,omitempty"`
// The reset interval of the metered entitlement in ISO8601 format. Defaults to the
// billing cadence of the rate card.
UsagePeriod *string `json:"usage_period,omitempty"`
}
The entitlement template of a metered entitlement.
type RateCardProrationConfiguration ¶
type RateCardProrationConfiguration struct {
// The proration mode of the rate card.
Mode RateCardProrationMode `json:"mode"`
}
The proration configuration of the rate card.
type RateCardProrationMode ¶
type RateCardProrationMode string
The proration mode of the rate card.
Values:
- `no_proration`: No proration. - `prorate_prices`: Prorate the price based on the time remaining in the billing period.
const ( RateCardProrationModeNoProration RateCardProrationMode = "no_proration" RateCardProrationModeProratePrices RateCardProrationMode = "prorate_prices" )
func (RateCardProrationMode) Valid ¶
func (value RateCardProrationMode) Valid() bool
type RateCardStaticEntitlement ¶
type RateCardStaticEntitlement struct {
// The type of the entitlement template.
Type EntitlementType `json:"type"`
// The entitlement config as a JSON object. Returned when checking entitlement
// access; useful for configuring fine-grained access settings implemented in your
// own system.
Config any `json:"config"`
}
The entitlement template of a static entitlement.
type RecurringPeriod ¶
type RecurringPeriod struct {
// A date-time anchor to base the recurring period on.
Anchor time.Time `json:"anchor"`
// The interval duration in ISO 8601 format.
Interval string `json:"interval"`
}
Recurring period with an anchor and an interval.
type RecurringPeriodInput ¶
type RecurringPeriodInput struct {
// The interval duration in ISO 8601 format.
Interval string `json:"interval"`
// A date-time anchor to base the recurring period on.
Anchor *time.Time `json:"anchor,omitempty"`
}
Recurring period input. The anchor is optional; the owning resource defines the default, typically its creation time.
type ResendBillingNotificationEventRequest ¶
type ResendBillingNotificationEventRequest struct {
// The channels to resend the event to. When omitted or empty, the event is resent
// to every enabled channel of the rule. Channels not targeted by the rule or
// disabled are rejected.
Channels *[]NotificationChannelReference `json:"channels,omitempty"`
}
Request body for resending a notification event.
type ResetCustomerEntitlementUsageRequest ¶
type ResetCustomerEntitlementUsageRequest struct {
// The time the reset takes effect. Defaults to the current time and cannot be in
// the future. Truncated to the minute.
EffectiveAt *time.Time `json:"effective_at,omitempty"`
// Whether the usage period anchor is kept. When false, the anchor moves to
// `effective_at`.
RetainAnchor *bool `json:"retain_anchor,omitempty"`
// Whether overage carries over into the new usage period. Defaults to the
// entitlement's own setting.
PreserveOverage *bool `json:"preserve_overage,omitempty"`
}
Request body for resetting the usage of a metered entitlement.
type SettlementMode ¶
type SettlementMode string
Settlement mode for billing.
Values:
- `credit_then_invoice`: Credits are applied first, then any remainder is invoiced. - `credit_only`: Usage is settled exclusively against credits.
const ( SettlementModeCreditThenInvoice SettlementMode = "credit_then_invoice" SettlementModeCreditOnly SettlementMode = "credit_only" )
func (SettlementMode) Valid ¶
func (value SettlementMode) Valid() bool
type SpendCommitments ¶
type SpendCommitments struct {
// The customer is committed to spend at least the amount.
MinimumAmount *Numeric `json:"minimum_amount,omitempty"`
// The customer is limited to spend at most the amount.
MaximumAmount *Numeric `json:"maximum_amount,omitempty"`
}
Spend commitments for a usage-based price. The customer is committed to spend at least the minimum amount and at most the maximum amount.
type StringExactFilter ¶
StringExactFilter expresses exact comparisons for strings and ULIDs.
type StringFilter ¶
type StringFilter struct {
Eq *string
Neq *string
Gt *string
Gte *string
Lt *string
Lte *string
Contains *string
Oeq []string
Ocontains []string
Exists *bool
}
StringFilter expresses the comparison operators accepted for string fields.
type SubscriptionAddon ¶
type SubscriptionAddon struct {
ID string `json:"id"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
// The add-on associated with the subscription.
Addon AddonReference `json:"addon"`
// The quantity of the add-on. Always 1 for single instance add-ons.
Quantity int64 `json:"quantity"`
// An ISO-8601 timestamp representation of which point in time the quantity was
// resolved to.
QuantityAt time.Time `json:"quantity_at"`
// An ISO-8601 timestamp representation of the cadence start of the resource.
ActiveFrom time.Time `json:"active_from"`
// An ISO-8601 timestamp representation of the cadence end of the resource.
ActiveTo *time.Time `json:"active_to,omitempty"`
// The timeline of the add-on. The returned periods are sorted and continuous.
Timeline []SubscriptionAddonTimelineSegment `json:"timeline"`
// The rate cards of the add-on.
RateCards []SubscriptionAddonRateCard `json:"rate_cards"`
}
Addon purchased with a subscription.
type SubscriptionAddonListParams ¶
type SubscriptionAddonListParams struct {
Page *PageParams
Sort *Sort
}
type SubscriptionAddonPagePaginatedResponse ¶
type SubscriptionAddonPagePaginatedResponse struct {
Data []SubscriptionAddon `json:"data"`
Meta PaginatedMeta `json:"meta"`
}
Page paginated response.
type SubscriptionAddonRateCard ¶
type SubscriptionAddonRateCard struct {
// The rate card.
RateCard RateCard `json:"rate_card"`
// The IDs of the subscription items that this rate card belongs to.
AffectedSubscriptionItemIds []string `json:"affected_subscription_item_ids"`
}
A rate card for a subscription add-on.
type SubscriptionAddonTimelineSegment ¶
type SubscriptionAddonTimelineSegment struct {
// An ISO-8601 timestamp representation of the cadence start of the resource.
ActiveFrom time.Time `json:"active_from"`
// An ISO-8601 timestamp representation of the cadence end of the resource.
ActiveTo *time.Time `json:"active_to,omitempty"`
// The quantity of the add-on for the given period.
Quantity int64 `json:"quantity"`
}
A subscription add-on event.
type SubscriptionAddonUpdate ¶
type SubscriptionAddonUpdate struct {
// The new quantity of the add-on. Must be at least 0. A quantity of 0 removes the
// add-on from the point the timing resolves to.
Quantity int64 `json:"quantity"`
// The timing of the update. A new entry is appended to the add-on's timeline at
// this point.
Timing SubscriptionEditTiming `json:"timing"`
}
Request for updating a subscription add-on. Only the quantity can be changed; the timing controls when the new quantity takes effect.
type SubscriptionBase ¶
type SubscriptionBase struct {
ID string `json:"id"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
// Display name of the subscription. Defaults to the plan name when the
// subscription is created from a plan.
Name string `json:"name"`
// Optional description of the subscription.
Description *string `json:"description,omitempty"`
// An ISO-8601 timestamp representation of when the subscription became (or will
// become) active.
ActiveFrom time.Time `json:"active_from"`
// An ISO-8601 timestamp representation of when the subscription stops being
// active. Open-ended when not set.
ActiveTo *time.Time `json:"active_to,omitempty"`
// The customer ID of the subscription.
CustomerID string `json:"customer_id"`
// The plan ID of the subscription. Set if subscription is created from a plan.
PlanID *string `json:"plan_id,omitempty"`
// The plan the subscription was created from, if any. Includes the plan key and
// version so clients can resolve the exact plan revision.
Plan *SubscriptionPlanReference `json:"plan,omitempty"`
// The fiat currency in which the subscription is invoiced.
InvoiceCurrency string `json:"invoice_currency"`
// Controls whether custom-currency cost bases are resolved dynamically or pinned
// when their currency pair is introduced to the subscription.
CostBasisMode SubscriptionCostBasisMode `json:"cost_basis_mode"`
// Cost bases pinned to custom-currency pairs for this subscription.
CostBasisPins []SubscriptionCostBasisPin `json:"cost_basis_pins"`
// The billing cadence of the subscription in ISO-8601 duration format. Defines how
// often the customer is billed. Examples: `P1M` (monthly), `P3M` (quarterly),
// `P1Y` (annually).
BillingCadence string `json:"billing_cadence"`
// The pro-rating configuration of the subscription.
ProRatingConfig *SubscriptionProRatingConfig `json:"pro_rating_config,omitempty"`
// A billing anchor is the fixed point in time that determines the subscription's
// recurring billing cycle. It affects when charges occur and how prorations are
// calculated. Common anchors:
//
// - Calendar month (1st of each month): `2025-01-01T00:00:00Z`
// - Subscription anniversary (day customer signed up)
// - Custom date (customer-specified day)
BillingAnchor time.Time `json:"billing_anchor"`
// When billing starts for the subscription. Nothing is billed for service before
// this time, while access, entitlements and metering start with the subscription.
// Use it when the time before was already billed elsewhere, for example when
// importing a subscription from another billing system.
//
// It cannot be before the start of the subscription and cannot be changed later.
// On subscriptions billed through invoice lines it must be the start of a billing
// period. If not provided, billing starts with the subscription.
//
// When billing starts inside a billing period, we recommend enabling price
// pro-rating (`prorate_prices`) on the plan. Without it that billing period's flat
// fees are billed in full.
BillingStartsAt *time.Time `json:"billing_starts_at,omitempty"`
// The status of the subscription.
Status SubscriptionStatus `json:"status"`
// Settlement mode for billing.
//
// Values:
//
// - `credit_then_invoice`: Credits are applied first, then any remainder is
// invoiced.
// - `credit_only`: Usage is settled exclusively against credits.
SettlementMode *SettlementMode `json:"settlement_mode,omitempty"`
}
Subscription fields without phases or the current billing period.
type SubscriptionCancel ¶
type SubscriptionCancel struct {
// If not provided the subscription is canceled immediately.
Timing *SubscriptionEditTiming `json:"timing,omitempty"`
}
Request for canceling a subscription.
type SubscriptionChange ¶
type SubscriptionChange struct {
Labels *map[string]string `json:"labels,omitempty"`
// Settlement mode for billing.
//
// Values:
//
// - `credit_then_invoice`: Credits are applied first, then any remainder is
// invoiced.
// - `credit_only`: Usage is settled exclusively against credits.
SettlementMode *SettlementMode `json:"settlement_mode,omitempty"`
// The customer to create the subscription for.
Customer SubscriptionChangeCustomer `json:"customer"`
// A reference to a published plan the subscription is created from.
//
// Exactly one of `plan` or `custom_plan` must be provided. Use `plan` to base the
// subscription on an existing published plan; use `custom_plan` to define the plan
// inline.
Plan *SubscriptionChangePlan `json:"plan,omitempty"`
// An inline plan definition to create the subscription from, without referencing a
// published plan.
//
// Exactly one of `plan` or `custom_plan` must be provided. The subscription is not
// linked to a persisted plan, so the response omits the `plan` reference.
CustomPlan *SubscriptionCustomPlan `json:"custom_plan,omitempty"`
// The key of the phase to start the subscription in. If not provided, the
// subscription starts in the first phase of the plan.
//
// Only applies when creating from a published `plan`; custom plans define their
// own phases inline.
StartingPhase *string `json:"starting_phase,omitempty"`
// A billing anchor is the fixed point in time that determines the subscription's
// recurring billing cycle. It affects when charges occur and how prorations are
// calculated. Common anchors:
//
// - Calendar month (1st of each month): `2025-01-01T00:00:00Z`
// - Subscription anniversary (day customer signed up)
// - Custom date (customer-specified day)
//
// If not provided, the subscription will be created with the subscription's
// creation time as the billing anchor.
BillingAnchor *time.Time `json:"billing_anchor,omitempty"`
// Controls how custom-currency cost bases are selected for the subscription.
CostBasisMode *SubscriptionCostBasisMode `json:"cost_basis_mode,omitempty"`
// Timing configuration for the change, when the change should take effect. For
// changing a subscription, the accepted values depend on the subscription
// configuration.
Timing SubscriptionEditTiming `json:"timing"`
}
Request for changing a subscription.
type SubscriptionChangeCustomer ¶
type SubscriptionChangeCustomer struct {
// The ID of the customer to create the subscription for.
//
// Either customer ID or customer key must be provided. If both are provided, the
// ID will be used.
ID *string `json:"id,omitempty"`
// The key of the customer to create the subscription for.
//
// Either customer ID or customer key must be provided. If both are provided, the
// ID will be used.
Key *string `json:"key,omitempty"`
}
type SubscriptionChangePlan ¶
type SubscriptionChangePlan struct {
// The plan ID of the subscription. Set if subscription is created from a plan.
//
// ID or Key of the plan is required if creating a subscription from a plan. If
// both are provided, the ID will be used.
ID *string `json:"id,omitempty"`
// The plan Key of the subscription, if any. Set if subscription is created from a
// plan.
//
// ID or Key of the plan is required if creating a subscription from a plan. If
// both are provided, the ID will be used.
Key *string `json:"key,omitempty"`
// The plan version of the subscription, if any. If not provided, the latest
// version of the plan will be used.
Version *int64 `json:"version,omitempty"`
}
type SubscriptionChangeResponse ¶
type SubscriptionChangeResponse struct {
// The current subscription before the change.
Current BillingSubscription `json:"current"`
// The new state of the subscription after the change.
Next BillingSubscription `json:"next"`
}
Response for changing a subscription.
type SubscriptionCostBasisMode ¶
type SubscriptionCostBasisMode string
Controls how custom-currency cost bases are selected for the subscription.
const ( SubscriptionCostBasisModeDynamic SubscriptionCostBasisMode = "dynamic" SubscriptionCostBasisModePinned SubscriptionCostBasisMode = "pinned" )
func (SubscriptionCostBasisMode) Valid ¶
func (value SubscriptionCostBasisMode) Valid() bool
type SubscriptionCostBasisPin ¶
type SubscriptionCostBasisPin struct {
// The managed custom currency ID.
CustomCurrencyID string `json:"custom_currency_id"`
// The fiat currency in which the subscription is invoiced.
InvoiceCurrency string `json:"invoice_currency"`
// The pinned cost basis resource ID.
CostBasisID string `json:"cost_basis_id"`
}
A cost basis pinned to a custom-currency pair for the subscription.
type SubscriptionCreate ¶
type SubscriptionCreate struct {
Labels *map[string]string `json:"labels,omitempty"`
// When billing starts for the subscription. Nothing is billed for service before
// this time, while access, entitlements and metering start with the subscription.
// Use it when the time before was already billed elsewhere, for example when
// importing a subscription from another billing system.
//
// It cannot be before the start of the subscription and cannot be changed later.
// On subscriptions billed through invoice lines it must be the start of a billing
// period. If not provided, billing starts with the subscription.
//
// When billing starts inside a billing period, we recommend enabling price
// pro-rating (`prorate_prices`) on the plan. Without it that billing period's flat
// fees are billed in full.
BillingStartsAt *time.Time `json:"billing_starts_at,omitempty"`
// Settlement mode for billing.
//
// Values:
//
// - `credit_then_invoice`: Credits are applied first, then any remainder is
// invoiced.
// - `credit_only`: Usage is settled exclusively against credits.
SettlementMode *SettlementMode `json:"settlement_mode,omitempty"`
// The customer to create the subscription for.
Customer SubscriptionChangeCustomer `json:"customer"`
// A reference to a published plan the subscription is created from.
//
// Exactly one of `plan` or `custom_plan` must be provided. Use `plan` to base the
// subscription on an existing published plan; use `custom_plan` to define the plan
// inline.
Plan *SubscriptionChangePlan `json:"plan,omitempty"`
// An inline plan definition to create the subscription from, without referencing a
// published plan.
//
// Exactly one of `plan` or `custom_plan` must be provided. The subscription is not
// linked to a persisted plan, so the response omits the `plan` reference.
CustomPlan *SubscriptionCustomPlan `json:"custom_plan,omitempty"`
// The key of the phase to start the subscription in. If not provided, the
// subscription starts in the first phase of the plan.
//
// Only applies when creating from a published `plan`; custom plans define their
// own phases inline.
StartingPhase *string `json:"starting_phase,omitempty"`
// When the subscription should start. If not provided, the subscription starts
// immediately. Provide a future timestamp to schedule the subscription to start
// later — this creates a not-yet-active, scheduled subscription. A timestamp in
// the past is rejected.
Timing *SubscriptionCreateTiming `json:"timing,omitempty"`
// A billing anchor is the fixed point in time that determines the subscription's
// recurring billing cycle. It affects when charges occur and how prorations are
// calculated. Common anchors:
//
// - Calendar month (1st of each month): `2025-01-01T00:00:00Z`
// - Subscription anniversary (day customer signed up)
// - Custom date (customer-specified day)
//
// If not provided, the subscription will be created with the subscription's
// creation time as the billing anchor.
BillingAnchor *time.Time `json:"billing_anchor,omitempty"`
// Controls how custom-currency cost bases are selected for the subscription.
CostBasisMode *SubscriptionCostBasisMode `json:"cost_basis_mode,omitempty"`
}
type SubscriptionCreateTiming ¶
type SubscriptionCreateTiming struct {
// contains filtered or unexported fields
}
When a subscription should start: immediate (the default) or a custom timestamp to schedule a future start.
SubscriptionCreateTiming is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the SubscriptionCreateTimingFrom* constructors.
func SubscriptionCreateTimingFromCustom ¶
func SubscriptionCreateTimingFromCustom(value time.Time) (SubscriptionCreateTiming, error)
func SubscriptionCreateTimingFromEnum ¶
func SubscriptionCreateTimingFromEnum(value SubscriptionCreateTimingEnum) (SubscriptionCreateTiming, error)
func (SubscriptionCreateTiming) AsCustom ¶
func (u SubscriptionCreateTiming) AsCustom() (*time.Time, error)
func (SubscriptionCreateTiming) AsEnum ¶
func (u SubscriptionCreateTiming) AsEnum() (*SubscriptionCreateTimingEnum, error)
func (SubscriptionCreateTiming) MarshalJSON ¶
func (u SubscriptionCreateTiming) MarshalJSON() ([]byte, error)
func (*SubscriptionCreateTiming) UnmarshalJSON ¶
func (u *SubscriptionCreateTiming) UnmarshalJSON(data []byte) error
type SubscriptionCreateTimingEnum ¶
type SubscriptionCreateTimingEnum string
Subscription create timing. Only immediate is supported as an enum value — unlike edit timing, next_billing_cycle is not accepted on create, since a new subscription has no current billing cycle to schedule against.
const (
SubscriptionCreateTimingEnumImmediate SubscriptionCreateTimingEnum = "immediate"
)
func (SubscriptionCreateTimingEnum) Valid ¶
func (value SubscriptionCreateTimingEnum) Valid() bool
type SubscriptionCustomPlan ¶
type SubscriptionCustomPlan struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
// The currency code of the plan.
Currency BillingCurrencyCode `json:"currency"`
// The billing cadence for subscriptions using this plan.
BillingCadence string `json:"billing_cadence"`
// Whether pro-rating is enabled for this plan.
ProRatingEnabled *bool `json:"pro_rating_enabled,omitempty"`
// The plan phases define the pricing ramp for a subscription. A phase switch
// occurs only at the end of a billing period. At least one phase is required.
Phases []PlanPhaseInput `json:"phases"`
}
An inline (custom) plan definition used to create or change a subscription without referencing a published plan. Mirrors the plan create shape without a key or version, since a custom plan is not persisted or versioned on its own.
`settlement_mode` is also omitted: it is a subscription-level concern set via the `settlement_mode` field on the create/change request, not on the inline plan.
type SubscriptionEdit ¶
type SubscriptionEdit struct {
// The ordered batch of customizations to apply to the running subscription.
Customizations []SubscriptionEditOperation `json:"customizations"`
// When the requested changes should take effect. Defaults to immediate.
Timing *SubscriptionEditTiming `json:"timing,omitempty"`
}
Request for editing a running subscription. Applies an ordered batch of customizations to the subscription's phases and items. A later customization observes the state produced by earlier ones.
type SubscriptionEditAddItem ¶
type SubscriptionEditAddItem struct {
// Discriminator for the add-item operation.
Type SubscriptionEditOperationType `json:"type"`
// The key of the phase to add the item to.
PhaseKey string `json:"phase_key"`
// The rate card describing what the customer gets and pays for the new item.
RateCard RateCardInput `json:"rate_card"`
}
Add a new rate card to a phase. Adding an item to the current phase closes the active version of the same item key and appends a new version.
type SubscriptionEditAddPhase ¶
type SubscriptionEditAddPhase struct {
// Discriminator for the add-phase operation.
Type SubscriptionEditOperationType `json:"type"`
// The phase to add.
Phase SubscriptionPhaseCreate `json:"phase"`
}
Add a new phase to the subscription. The phase is created without items; use add-item operations to populate it.
type SubscriptionEditOperation ¶
type SubscriptionEditOperation struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
A single customization to apply to a running subscription. The `type` field discriminates which operation is performed.
SubscriptionEditOperation is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the SubscriptionEditOperationFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func SubscriptionEditOperationFromSubscriptionEditAddItem ¶
func SubscriptionEditOperationFromSubscriptionEditAddItem(value SubscriptionEditAddItem) (SubscriptionEditOperation, error)
func SubscriptionEditOperationFromSubscriptionEditAddPhase ¶
func SubscriptionEditOperationFromSubscriptionEditAddPhase(value SubscriptionEditAddPhase) (SubscriptionEditOperation, error)
func SubscriptionEditOperationFromSubscriptionEditRemoveItem ¶
func SubscriptionEditOperationFromSubscriptionEditRemoveItem(value SubscriptionEditRemoveItem) (SubscriptionEditOperation, error)
func SubscriptionEditOperationFromSubscriptionEditRemovePhase ¶
func SubscriptionEditOperationFromSubscriptionEditRemovePhase(value SubscriptionEditRemovePhase) (SubscriptionEditOperation, error)
func SubscriptionEditOperationFromSubscriptionEditStretchPhase ¶
func SubscriptionEditOperationFromSubscriptionEditStretchPhase(value SubscriptionEditStretchPhase) (SubscriptionEditOperation, error)
func SubscriptionEditOperationFromSubscriptionEditUnscheduleEdit ¶
func SubscriptionEditOperationFromSubscriptionEditUnscheduleEdit(value SubscriptionEditUnscheduleEdit) (SubscriptionEditOperation, error)
func (SubscriptionEditOperation) AsSubscriptionEditAddItem ¶
func (u SubscriptionEditOperation) AsSubscriptionEditAddItem() (*SubscriptionEditAddItem, error)
func (SubscriptionEditOperation) AsSubscriptionEditAddPhase ¶
func (u SubscriptionEditOperation) AsSubscriptionEditAddPhase() (*SubscriptionEditAddPhase, error)
func (SubscriptionEditOperation) AsSubscriptionEditRemoveItem ¶
func (u SubscriptionEditOperation) AsSubscriptionEditRemoveItem() (*SubscriptionEditRemoveItem, error)
func (SubscriptionEditOperation) AsSubscriptionEditRemovePhase ¶
func (u SubscriptionEditOperation) AsSubscriptionEditRemovePhase() (*SubscriptionEditRemovePhase, error)
func (SubscriptionEditOperation) AsSubscriptionEditStretchPhase ¶
func (u SubscriptionEditOperation) AsSubscriptionEditStretchPhase() (*SubscriptionEditStretchPhase, error)
func (SubscriptionEditOperation) AsSubscriptionEditUnscheduleEdit ¶
func (u SubscriptionEditOperation) AsSubscriptionEditUnscheduleEdit() (*SubscriptionEditUnscheduleEdit, error)
func (SubscriptionEditOperation) MarshalJSON ¶
func (u SubscriptionEditOperation) MarshalJSON() ([]byte, error)
func (*SubscriptionEditOperation) UnmarshalJSON ¶
func (u *SubscriptionEditOperation) UnmarshalJSON(data []byte) error
type SubscriptionEditOperationType ¶
type SubscriptionEditOperationType string
The type of a subscription edit operation.
- `add_item`: Add a rate card to a phase. - `remove_item`: Remove a rate card from a phase. - `add_phase`: Add a new phase to the subscription. - `remove_phase`: Remove a phase from the subscription. - `stretch_phase`: Extend the duration of a phase. - `unschedule_edit`: Discard scheduled edits on the current phase.
const ( SubscriptionEditOperationTypeAddItem SubscriptionEditOperationType = "add_item" SubscriptionEditOperationTypeRemoveItem SubscriptionEditOperationType = "remove_item" SubscriptionEditOperationTypeAddPhase SubscriptionEditOperationType = "add_phase" SubscriptionEditOperationTypeRemovePhase SubscriptionEditOperationType = "remove_phase" SubscriptionEditOperationTypeStretchPhase SubscriptionEditOperationType = "stretch_phase" SubscriptionEditOperationTypeUnscheduleEdit SubscriptionEditOperationType = "unschedule_edit" )
func (SubscriptionEditOperationType) Valid ¶
func (value SubscriptionEditOperationType) Valid() bool
type SubscriptionEditRemoveItem ¶
type SubscriptionEditRemoveItem struct {
// Discriminator for the remove-item operation.
Type SubscriptionEditOperationType `json:"type"`
// The key of the phase to remove the item from.
PhaseKey string `json:"phase_key"`
// The key of the item to remove.
ItemKey string `json:"item_key"`
}
Remove a rate card from a phase.
type SubscriptionEditRemovePhase ¶
type SubscriptionEditRemovePhase struct {
// Discriminator for the remove-phase operation.
Type SubscriptionEditOperationType `json:"type"`
// The key of the phase to remove.
PhaseKey string `json:"phase_key"`
// The direction to shift surrounding phases to fill the removed phase's span.
Shift SubscriptionRemovePhaseShifting `json:"shift"`
}
Remove a phase from the subscription.
type SubscriptionEditStretchPhase ¶
type SubscriptionEditStretchPhase struct {
// Discriminator for the stretch-phase operation.
Type SubscriptionEditOperationType `json:"type"`
// The key of the phase to stretch.
PhaseKey string `json:"phase_key"`
// The ISO-8601 duration to extend the phase by.
ExtendBy string `json:"extend_by"`
}
Extend the duration of a phase, shifting later phases by the same amount.
type SubscriptionEditTiming ¶
type SubscriptionEditTiming struct {
// contains filtered or unexported fields
}
Subscription edit timing defined when the changes should take effect. If the provided configuration is not supported by the subscription, an error will be returned.
SubscriptionEditTiming is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the SubscriptionEditTimingFrom* constructors.
func SubscriptionEditTimingFromCustom ¶
func SubscriptionEditTimingFromCustom(value time.Time) (SubscriptionEditTiming, error)
func SubscriptionEditTimingFromEnum ¶
func SubscriptionEditTimingFromEnum(value SubscriptionEditTimingEnum) (SubscriptionEditTiming, error)
func (SubscriptionEditTiming) AsCustom ¶
func (u SubscriptionEditTiming) AsCustom() (*time.Time, error)
func (SubscriptionEditTiming) AsEnum ¶
func (u SubscriptionEditTiming) AsEnum() (*SubscriptionEditTimingEnum, error)
func (SubscriptionEditTiming) MarshalJSON ¶
func (u SubscriptionEditTiming) MarshalJSON() ([]byte, error)
func (*SubscriptionEditTiming) UnmarshalJSON ¶
func (u *SubscriptionEditTiming) UnmarshalJSON(data []byte) error
type SubscriptionEditTimingEnum ¶
type SubscriptionEditTimingEnum string
Subscription edit timing. When immediate, the requested changes take effect immediately. When next_billing_cycle, the requested changes take effect at the next billing cycle.
const ( SubscriptionEditTimingEnumImmediate SubscriptionEditTimingEnum = "immediate" SubscriptionEditTimingEnumNextBillingCycle SubscriptionEditTimingEnum = "next_billing_cycle" )
func (SubscriptionEditTimingEnum) Valid ¶
func (value SubscriptionEditTimingEnum) Valid() bool
type SubscriptionEditUnscheduleEdit ¶
type SubscriptionEditUnscheduleEdit struct {
// Discriminator for the unschedule-edit operation.
Type SubscriptionEditOperationType `json:"type"`
}
Discard any scheduled edits on the current phase, reverting it to its previously persisted state.
type SubscriptionItem ¶
type SubscriptionItem struct {
// The unique identifier of the subscription item instance.
ID string `json:"id"`
// An ISO-8601 timestamp representation of when this item version becomes active.
ActiveFrom time.Time `json:"active_from"`
// An ISO-8601 timestamp representation of when this item version stops being
// active.
ActiveTo *time.Time `json:"active_to,omitempty"`
// The rate card describing what the customer gets and pays for this item.
RateCard RateCard `json:"rate_card"`
}
A subscription item pins a rate card to a cadence within a subscription phase.
type SubscriptionMigrate ¶
type SubscriptionMigrate struct {
// When the migration takes effect: immediately (default), at the next billing
// cycle, or at an explicit billing-aligned timestamp. In-place migrations may
// target a later phase when the phase timelines match. The target plan reference
// is saved now; changed items take effect at the requested time.
Timing *SubscriptionEditTiming `json:"timing,omitempty"`
// A strictly later version of the current plan. Omit to use its latest version.
TargetVersion *int64 `json:"target_version,omitempty"`
// Explicitly replace the subscription, starting in this target plan phase. Always
// selects replacement, even when the phase matches the current one. Replacement
// may produce billing adjustments and does not transfer addons.
StartingPhase *string `json:"starting_phase,omitempty"`
// Providing a different billing anchor explicitly replaces the subscription. The
// supplied anchor is preserved and may be before or after the replacement's start
// time. Omit to retain the existing anchor.
BillingAnchor *time.Time `json:"billing_anchor,omitempty"`
}
Request for migrating to a later version of the subscription's current plan.
type SubscriptionMigrateResponse ¶
type SubscriptionMigrateResponse struct {
// The original subscription's own fields returned by the migration. For an
// in-place migration this is the before snapshot; for replacement it includes the
// cancellation. Does not include phases or the current billing period.
Current SubscriptionBase `json:"current"`
// The resulting subscription, including its phases and items.
Next BillingSubscription `json:"next"`
}
Response for migrating a subscription.
type SubscriptionOrReference ¶
type SubscriptionOrReference struct {
// contains filtered or unexported fields
}
Subscription or reference.
SubscriptionOrReference is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the SubscriptionOrReferenceFrom* constructors.
func SubscriptionOrReferenceFromBillingSubscription ¶
func SubscriptionOrReferenceFromBillingSubscription(value BillingSubscription) (SubscriptionOrReference, error)
func SubscriptionOrReferenceFromSubscriptionReference ¶
func SubscriptionOrReferenceFromSubscriptionReference(value SubscriptionReference) (SubscriptionOrReference, error)
func (SubscriptionOrReference) AsBillingSubscription ¶
func (u SubscriptionOrReference) AsBillingSubscription() (*BillingSubscription, error)
func (SubscriptionOrReference) AsSubscriptionReference ¶
func (u SubscriptionOrReference) AsSubscriptionReference() (*SubscriptionReference, error)
func (SubscriptionOrReference) MarshalJSON ¶
func (u SubscriptionOrReference) MarshalJSON() ([]byte, error)
func (*SubscriptionOrReference) UnmarshalJSON ¶
func (u *SubscriptionOrReference) UnmarshalJSON(data []byte) error
type SubscriptionPagePaginatedResponse ¶
type SubscriptionPagePaginatedResponse struct {
Data []BillingSubscription `json:"data"`
Meta PaginatedMeta `json:"meta"`
}
Page paginated response.
type SubscriptionPhase ¶
type SubscriptionPhase struct {
ID string `json:"id"`
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
Key string `json:"key"`
// An ISO-8601 timestamp representation of when the phase becomes active.
ActiveFrom time.Time `json:"active_from"`
// An ISO-8601 timestamp representation of when the phase stops being active.
// Open-ended for the last phase.
ActiveTo *time.Time `json:"active_to,omitempty"`
// The rate cards in effect for this phase, resolved to the version active at the
// queried time (the currently active version for the current phase, the first
// version for future phases, and the last version for past phases).
Items []SubscriptionItem `json:"items"`
}
A subscription phase groups the rate cards in effect for a segment of the subscription's lifetime. Analogous to plan phases.
type SubscriptionPhaseCreate ¶
type SubscriptionPhaseCreate struct {
// A locally unique identifier for the phase.
Key string `json:"key"`
// The name of the phase.
Name string `json:"name"`
// An optional description of the phase.
Description *string `json:"description,omitempty"`
// The ISO-8601 interval after the subscription start at which the phase begins.
// When null, the phase starts immediately after the subscription starts.
StartAfter Nullable[string] `json:"start_after"`
// The intended ISO-8601 duration of the phase. Required unless the phase will be
// the last phase of the subscription.
Duration *string `json:"duration,omitempty"`
}
The definition of a new subscription phase to add via an edit.
type SubscriptionPlanReference ¶
type SubscriptionPlanReference struct {
// The plan ID (exact revision).
ID string `json:"id"`
// The plan key. References the plan across versions.
Key string `json:"key"`
// The plan version.
Version int64 `json:"version"`
}
A reference to the plan a subscription was created from, pinned to an exact revision.
type SubscriptionProRatingConfig ¶
type SubscriptionProRatingConfig struct {
// Whether pro-rating is enabled.
Enabled bool `json:"enabled"`
// How pro-rating is calculated when enabled.
Mode RateCardProrationMode `json:"mode"`
}
The pro-rating configuration of a subscription.
type SubscriptionReference ¶
type SubscriptionReference struct {
// The ID of the subscription.
ID string `json:"id"`
// The display name of the subscription.
//
// Only populated where the referencing endpoint documents a `subscription` expand
// that resolves it.
Name *string `json:"name,omitempty"`
// The phase of the subscription.
Phase SubscriptionReferencePhase `json:"phase"`
}
Subscription reference represents a reference to the specific subscription item this entity represents.
type SubscriptionReferencePhase ¶
type SubscriptionReferencePhase struct {
// The ID of the phase.
ID string `json:"id"`
// The item of the phase.
Item SubscriptionReferencePhaseItem `json:"item"`
}
type SubscriptionReferencePhaseItem ¶
type SubscriptionReferencePhaseItem struct {
// The ID of the item.
ID string `json:"id"`
}
type SubscriptionRemovePhaseShifting ¶
type SubscriptionRemovePhaseShifting string
The direction to shift surrounding phases when a phase is removed.
- `next`: Shift all subsequent phases to start sooner by the removed phase's length. - `prev`: Extend the previous phase to end later by the removed phase's length.
const ( SubscriptionRemovePhaseShiftingNext SubscriptionRemovePhaseShifting = "next" SubscriptionRemovePhaseShiftingPrev SubscriptionRemovePhaseShifting = "prev" )
func (SubscriptionRemovePhaseShifting) Valid ¶
func (value SubscriptionRemovePhaseShifting) Valid() bool
type SubscriptionStatus ¶
type SubscriptionStatus string
Subscription status.
const ( SubscriptionStatusActive SubscriptionStatus = "active" SubscriptionStatusInactive SubscriptionStatus = "inactive" SubscriptionStatusCanceled SubscriptionStatus = "canceled" SubscriptionStatusScheduled SubscriptionStatus = "scheduled" )
func (SubscriptionStatus) Valid ¶
func (value SubscriptionStatus) Valid() bool
type SubscriptionsService ¶
type SubscriptionsService struct {
// contains filtered or unexported fields
}
func (*SubscriptionsService) Cancel ¶
func (s *SubscriptionsService) Cancel(ctx context.Context, subscriptionID string, request SubscriptionCancel) (*BillingSubscription, error)
Cancels the subscription. Will result in a scheduling conflict if there are other subscriptions scheduled to start after the cancelation time.
func (*SubscriptionsService) Change ¶
func (s *SubscriptionsService) Change(ctx context.Context, subscriptionID string, request SubscriptionChange) (*SubscriptionChangeResponse, error)
Closes a running subscription and starts a new one according to the specification. Can be used for upgrades, downgrades, and plan changes.
func (*SubscriptionsService) Create ¶
func (s *SubscriptionsService) Create(ctx context.Context, request SubscriptionCreate) (*BillingSubscription, error)
func (*SubscriptionsService) CreateAddon ¶
func (s *SubscriptionsService) CreateAddon(ctx context.Context, subscriptionID string, request CreateSubscriptionAddonRequest) (*SubscriptionAddon, error)
Add add-on to a subscription.
func (*SubscriptionsService) Edit ¶
func (s *SubscriptionsService) Edit(ctx context.Context, subscriptionID string, request SubscriptionEdit) (*BillingSubscription, error)
Edits a running subscription by applying an ordered batch of customizations (adding or removing items, adding, removing, or stretching phases, or unscheduling a pending edit). The changes may take effect immediately or at the next billing cycle. Subscriptions that have add-ons cannot be edited.
func (*SubscriptionsService) Get ¶
func (s *SubscriptionsService) Get(ctx context.Context, subscriptionID string) (*BillingSubscription, error)
func (*SubscriptionsService) GetAddon ¶
func (s *SubscriptionsService) GetAddon(ctx context.Context, subscriptionID string, subscriptionAddonID string) (*SubscriptionAddon, error)
Get an add-on association for a subscription.
func (*SubscriptionsService) List ¶
func (s *SubscriptionsService) List(ctx context.Context, params BillingSubscriptionListParams) (*SubscriptionPagePaginatedResponse, error)
func (*SubscriptionsService) ListAddons ¶
func (s *SubscriptionsService) ListAddons(ctx context.Context, subscriptionID string, params SubscriptionAddonListParams) (*SubscriptionAddonPagePaginatedResponse, error)
List the add-ons of a subscription.
func (*SubscriptionsService) ListAddonsAll ¶
func (s *SubscriptionsService) ListAddonsAll(ctx context.Context, subscriptionID string, params SubscriptionAddonListParams) iter.Seq2[SubscriptionAddon, error]
ListAddonsAll returns an iterator over all SubscriptionAddon results, fetching pages of ListAddons transparently. Iteration stops at the first error, which is yielded as the second value.
func (*SubscriptionsService) ListAll ¶
func (s *SubscriptionsService) ListAll(ctx context.Context, params BillingSubscriptionListParams) iter.Seq2[BillingSubscription, error]
ListAll returns an iterator over all BillingSubscription results, fetching pages of List transparently. Iteration stops at the first error, which is yielded as the second value.
func (*SubscriptionsService) Migrate ¶
func (s *SubscriptionsService) Migrate(ctx context.Context, subscriptionID string, request SubscriptionMigrate) (*SubscriptionMigrateResponse, error)
Migrates to a later version of the current plan. With starting_phase omitted and billing_anchor omitted or unchanged, migration amends the subscription in place: unchanged items retain their service periods and both response entries have the same ID. Existing addons must remain compatible with the target plan. Incompatible phase timelines or billing settings return an error. Providing starting_phase or a different billing_anchor explicitly requests replacement, which resets the phase timeline, may produce billing adjustments, and does not transfer addons. Custom subscriptions cannot be migrated.
func (*SubscriptionsService) Restore ¶
func (s *SubscriptionsService) Restore(ctx context.Context, subscriptionID string) (*BillingSubscription, error)
Restores the subscription by deleting any later-scheduled successor subscriptions and continuing this one indefinitely. This is the inverse of a future-dated change, which schedules a successor. Restore is not available when multi-subscription is enabled.
func (*SubscriptionsService) Unschedule ¶
func (s *SubscriptionsService) Unschedule(ctx context.Context, subscriptionID string) error
Deletes a scheduled subscription that has not yet become active, removing it and resolving any scheduling conflict it was holding. This is distinct from canceling: cancel ends a running subscription, whereas unscheduling removes a not-yet-active one. Only scheduled subscriptions can be unscheduled; unscheduling an active or already-started subscription is rejected.
func (*SubscriptionsService) UnscheduleCancelation ¶
func (s *SubscriptionsService) UnscheduleCancelation(ctx context.Context, subscriptionID string) (*BillingSubscription, error)
Unschedules the subscription cancelation.
func (*SubscriptionsService) UpdateAddon ¶
func (s *SubscriptionsService) UpdateAddon(ctx context.Context, subscriptionID string, subscriptionAddonID string, request SubscriptionAddonUpdate) (*SubscriptionAddon, error)
Update a subscription add-on. Only the quantity is mutable; the timing controls when the new quantity takes effect. A new entry is appended to the add-on's timeline.
type Supplier ¶
type Supplier struct {
// Legal name or representation of the party.
Name *string `json:"name,omitempty"`
// The entity's legal identification used for tax purposes. They may have other
// numbers, but we're only interested in those valid for tax purposes.
TaxID *PartyTaxIdentity `json:"tax_id,omitempty"`
// Address for where information should be sent if needed.
Addresses *PartyAddresses `json:"addresses,omitempty"`
// Unique identifier for the party.
ID *string `json:"id,omitempty"`
}
Snapshot of the supplier's information at the time the invoice was issued.
Structurally a read-only subset of `BillingParty` (the type configured on the billing profile), so the snapshot stays aligned with the source. `key` is omitted because it is not part of the snapshotted supplier data.
type TaxBehavior ¶
type TaxBehavior string
Tax behavior.
This enum is used to specify whether tax is included in the price or excluded from the price.
const ( TaxBehaviorInclusive TaxBehavior = "inclusive" TaxBehaviorExclusive TaxBehavior = "exclusive" )
func (TaxBehavior) Valid ¶
func (value TaxBehavior) Valid() bool
type TaxCode ¶
type TaxCode struct {
ID string `json:"id"`
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
// An ISO-8601 timestamp representation of entity creation date.
CreatedAt time.Time `json:"created_at"`
// An ISO-8601 timestamp representation of entity last update date.
UpdatedAt time.Time `json:"updated_at"`
// An ISO-8601 timestamp representation of entity deletion date.
DeletedAt *time.Time `json:"deleted_at,omitempty"`
Key string `json:"key"`
// Mapping of app types to tax codes.
AppMappings []TaxCodeAppMapping `json:"app_mappings"`
}
Tax codes by provider.
type TaxCodeAppMapping ¶
type TaxCodeAppMapping struct {
// The app type that the tax code is associated with.
AppType AppType `json:"app_type"`
// Tax code.
TaxCode string `json:"tax_code"`
}
Mapping of app types to tax codes.
type TaxCodeConfig ¶
type TaxCodeConfig struct {
// Tax behavior.
//
// This enum is used to specify whether tax is included in the price or excluded
// from the price. If not specified, the billing profile is used to determine the
// tax behavior. If not specified in the billing profile, the provider's default
// behavior is used.
Behavior *TaxBehavior `json:"behavior,omitempty"`
// Tax code applied to the invoice line item.
Code *TaxCodeReference `json:"code,omitempty"`
}
Tax configuration for a billable resource.
Applies a tax code and tax behavior to the resulting invoice line items. When not set, the applicable default is used: the billing profile default tax configuration, then the organization default tax code.
type TaxCodeListParams ¶
type TaxCodeListParams struct {
Page *PageParams
IncludeDeleted *bool
}
type TaxCodePagePaginatedResponse ¶
type TaxCodePagePaginatedResponse struct {
Data []TaxCode `json:"data"`
Meta PaginatedMeta `json:"meta"`
}
Page paginated response.
type TaxConfig ¶
type TaxConfig struct {
// Tax behavior.
//
// If not specified the billing profile is used to determine the tax behavior. If
// not specified in the billing profile, the provider's default behavior is used.
Behavior *TaxBehavior `json:"behavior,omitempty"`
// Stripe tax config.
Stripe *TaxConfigStripe `json:"stripe,omitempty"`
// External invoicing tax config.
ExternalInvoicing *TaxConfigExternalInvoicing `json:"external_invoicing,omitempty"`
// Tax code ID.
TaxCodeID *string `json:"tax_code_id,omitempty"`
// Tax code reference.
//
// When both `tax_code` and `tax_code_id` are provided, `tax_code` takes
// precedence. When `stripe.code` is also provided, `tax_code` still wins and
// `stripe.code` is ignored.
TaxCode *TaxCodeReference `json:"tax_code,omitempty"`
}
Set of provider specific tax configs.
type TaxConfigExternalInvoicing ¶
type TaxConfigExternalInvoicing struct {
// The tax code should be interpreted by the external invoicing provider.
Code string `json:"code"`
}
External invoicing tax config.
type TaxConfigStripe ¶
type TaxConfigStripe struct {
// Product [tax code](https://docs.stripe.com/tax/tax-codes).
Code string `json:"code"`
}
The tax config for Stripe.
type TaxService ¶
type TaxService struct {
// contains filtered or unexported fields
}
func (*TaxService) CreateCode ¶
func (s *TaxService) CreateCode(ctx context.Context, request CreateTaxCodeRequest) (*TaxCode, error)
func (*TaxService) DeleteCode ¶
func (s *TaxService) DeleteCode(ctx context.Context, taxCodeID string) error
func (*TaxService) ListCodes ¶
func (s *TaxService) ListCodes(ctx context.Context, params TaxCodeListParams) (*TaxCodePagePaginatedResponse, error)
func (*TaxService) ListCodesAll ¶
func (s *TaxService) ListCodesAll(ctx context.Context, params TaxCodeListParams) iter.Seq2[TaxCode, error]
ListCodesAll returns an iterator over all TaxCode results, fetching pages of ListCodes transparently. Iteration stops at the first error, which is yielded as the second value.
func (*TaxService) UpsertCode ¶
func (s *TaxService) UpsertCode(ctx context.Context, taxCodeID string, request UpsertTaxCodeRequest) (*TaxCode, error)
type Totals ¶
type Totals struct {
// The total value of the resource before taxes, discounts and commitments.
Amount Numeric `json:"amount"`
// The total tax amount applied to the resource.
TaxesTotal Numeric `json:"taxes_total"`
// The total tax amount already included in the resource amount.
TaxesInclusiveTotal Numeric `json:"taxes_inclusive_total"`
// The total tax amount added on top of the resource amount.
TaxesExclusiveTotal Numeric `json:"taxes_exclusive_total"`
// The total amount contributed by additional charges.
ChargesTotal Numeric `json:"charges_total"`
// The total amount deducted through discounts.
DiscountsTotal Numeric `json:"discounts_total"`
// The total amount deducted through credits before taxes are applied.
CreditsTotal Numeric `json:"credits_total"`
// The final total value of the resource after taxes, discounts and commitments.
Total Numeric `json:"total"`
}
Totals contains the summaries of all calculations for a billing resource.
type UnitConfig ¶
type UnitConfig struct {
// The arithmetic operation to apply to the raw metered quantity.
Operation UnitConfigOperation `json:"operation"`
// The factor used in the conversion operation.
//
// - For `divide`: `converted = raw / conversionFactor`.
// - For `multiply`: `converted = raw × conversionFactor`.
//
// Must be a positive non-zero value.
ConversionFactor Numeric `json:"conversion_factor"`
// The rounding mode applied to the converted quantity for invoicing.
//
// Defaults to none (no rounding). Entitlement checks always use the precise
// (unrounded) value.
Rounding *UnitConfigRoundingMode `json:"rounding,omitempty"`
// The number of decimal places to retain after rounding.
//
// Only meaningful when rounding is not "none". Defaults to 0 (round to whole
// numbers).
Precision *int64 `json:"precision,omitempty"`
// A human-readable label for the converted unit shown on invoices and in the
// customer portal (e.g., "GB", "hours", "M tokens").
//
// Optional. When omitted, no unit label is rendered.
DisplayUnit *string `json:"display_unit,omitempty"`
}
Unit conversion configuration.
Transforms raw metered quantities into billing-ready units before pricing and entitlement evaluation. Stored with a resource's rating configuration so the same metered feature can be billed in different units across plans and charges.
Examples:
- Meter bytes, bill GB: operation=divide, conversionFactor=1e9, rounding=ceiling, displayUnit="GB" - Meter seconds, bill hours: operation=divide, conversionFactor=3600, rounding=ceiling, displayUnit="hours" - Cost + 20% margin: operation=multiply, conversionFactor=1.2 - Bill per million tokens: operation=divide, conversionFactor=1e6, rounding=ceiling, displayUnit="M"
v1 equivalents:
- DynamicPrice(multiplier): operation=multiply, conversionFactor=multiplier + UnitPrice(amount=1) - PackagePrice(amount, quantityPerPkg): operation=divide, conversionFactor=quantityPerPkg, rounding=ceiling + UnitPrice(amount)
type UnitConfigOperation ¶
type UnitConfigOperation string
The arithmetic operation used to convert raw metered units into billing units.
- `divide`: Divide the metered quantity by the conversion factor (e.g., bytes ÷ 1e9 = GB). - `multiply`: Multiply the metered quantity by the conversion factor (e.g., cost × 1.2 = cost + 20% margin).
const ( UnitConfigOperationDivide UnitConfigOperation = "divide" UnitConfigOperationMultiply UnitConfigOperation = "multiply" )
func (UnitConfigOperation) Valid ¶
func (value UnitConfigOperation) Valid() bool
type UnitConfigRoundingMode ¶
type UnitConfigRoundingMode string
The rounding mode applied to the converted quantity for invoicing.
Rounding is applied only to the invoiced quantity. Entitlement balance checks use the precise decimal value after conversion.
- `ceiling`: Round up to the next integer (typical for package-style billing). - `floor`: Round down to the previous integer. - `half_up`: Round to the nearest integer, with 0.5 rounding up. - `none`: No rounding; the converted value is used as-is.
const ( UnitConfigRoundingModeCeiling UnitConfigRoundingMode = "ceiling" UnitConfigRoundingModeFloor UnitConfigRoundingMode = "floor" UnitConfigRoundingModeHalfUp UnitConfigRoundingMode = "half_up" UnitConfigRoundingModeNone UnitConfigRoundingMode = "none" )
func (UnitConfigRoundingMode) Valid ¶
func (value UnitConfigRoundingMode) Valid() bool
type UpdateAppExternalInvoicingRequest ¶
type UpdateAppExternalInvoicingRequest struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
// The app type.
Type AppType `json:"type"`
// Enable draft synchronization hook.
//
// When enabled, invoices will pause at the draft state and wait for the
// integration to call the draft synchronized endpoint before progressing to the
// issuing state. This allows the external system to validate and prepare the
// invoice data.
//
// When disabled, invoices automatically progress through the draft state based on
// the configured workflow timing.
EnableDraftSyncHook bool `json:"enable_draft_sync_hook"`
// Enable issuing synchronization hook.
//
// When enabled, invoices will pause at the issuing state and wait for the
// integration to call the issuing synchronized endpoint before progressing to the
// issued state. This ensures the external invoicing system has successfully
// created and finalized the invoice before it is marked as issued.
//
// When disabled, invoices automatically progress through the issuing state and are
// immediately marked as issued.
EnableIssuingSyncHook bool `json:"enable_issuing_sync_hook"`
}
AppExternalInvoicing update request.
type UpdateAppRequest ¶
type UpdateAppRequest struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
Request to update an installed app.
UpdateAppRequest is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the UpdateAppRequestFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func UpdateAppRequestFromUpdateAppExternalInvoicingRequest ¶
func UpdateAppRequestFromUpdateAppExternalInvoicingRequest(value UpdateAppExternalInvoicingRequest) (UpdateAppRequest, error)
func UpdateAppRequestFromUpdateAppSandboxRequest ¶
func UpdateAppRequestFromUpdateAppSandboxRequest(value UpdateAppSandboxRequest) (UpdateAppRequest, error)
func UpdateAppRequestFromUpdateAppStripeRequest ¶
func UpdateAppRequestFromUpdateAppStripeRequest(value UpdateAppStripeRequest) (UpdateAppRequest, error)
func (UpdateAppRequest) AsUpdateAppExternalInvoicingRequest ¶
func (u UpdateAppRequest) AsUpdateAppExternalInvoicingRequest() (*UpdateAppExternalInvoicingRequest, error)
func (UpdateAppRequest) AsUpdateAppSandboxRequest ¶
func (u UpdateAppRequest) AsUpdateAppSandboxRequest() (*UpdateAppSandboxRequest, error)
func (UpdateAppRequest) AsUpdateAppStripeRequest ¶
func (u UpdateAppRequest) AsUpdateAppStripeRequest() (*UpdateAppStripeRequest, error)
func (UpdateAppRequest) MarshalJSON ¶
func (u UpdateAppRequest) MarshalJSON() ([]byte, error)
func (*UpdateAppRequest) UnmarshalJSON ¶
func (u *UpdateAppRequest) UnmarshalJSON(data []byte) error
type UpdateAppSandboxRequest ¶
type UpdateAppSandboxRequest struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
// The app type.
Type AppType `json:"type"`
}
AppSandbox update request.
type UpdateAppStripeRequest ¶
type UpdateAppStripeRequest struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
// The app type.
Type AppType `json:"type"`
// The Stripe secret API key used to authenticate API requests.
SecretAPIKey *string `json:"secret_api_key,omitempty"`
}
AppStripe update request.
type UpdateBillingInvoiceWorkflow ¶
type UpdateBillingInvoiceWorkflow struct {
// Invoicing settings for this invoice.
Invoicing *UpdateBillingInvoiceWorkflowInvoicingSettings `json:"invoicing,omitempty"`
// Payment settings for this invoice.
Payment *WorkflowPaymentSettings `json:"payment,omitempty"`
}
Invoice-level snapshot of the workflow configuration.
Contains only the settings that are meaningful for an already-created invoice: invoicing behaviour and payment settings. Collection alignment and tax policy are gather-time / profile-wide concerns and are not included.
type UpdateBillingInvoiceWorkflowInvoicingSettings ¶
type UpdateBillingInvoiceWorkflowInvoicingSettings struct {
// Whether to automatically issue the invoice after the draft_period has passed.
AutoAdvance *bool `json:"auto_advance,omitempty"`
// The period for the invoice to be kept in draft status for manual reviews.
DraftPeriod *string `json:"draft_period,omitempty"`
}
Invoice-level invoicing settings.
A subset of BillingWorkflowInvoicingSettings limited to fields that are meaningful per-invoice. progressive_billing is omitted as it is a gather-time / profile-level decision.
type UpdateBillingNotificationChannelRequest ¶
type UpdateBillingNotificationChannelRequest struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// The type of the channel. Immutable after creation.
Type NotificationChannelType `json:"type"`
// The URL that webhook notification events are delivered to.
URL string `json:"url"`
Labels *map[string]string `json:"labels,omitempty"`
// Whether the channel is disabled. Disabled channels do not receive notification
// events.
Disabled *bool `json:"disabled,omitempty"`
// Custom HTTP headers to include on every webhook delivery request, keyed by
// header name.
CustomHeaders *map[string]string `json:"custom_headers,omitempty"`
// Secret used to sign outgoing webhook payloads so recipients can verify their
// authenticity. If omitted on create, a secret is generated automatically by the
// delivery provider. This is a sensitive credential returned in responses (unlike
// most secrets) specifically so clients can retrieve a server-generated value and
// verify webhook signatures; handle it with the same care as any other credential.
SigningSecret *string `json:"signing_secret,omitempty"`
}
Request body for updating a notification channel. Updates replace the channel's mutable state rather than merging it: `type`, `name`, and `url` must always be provided, and omitting `disabled`, `labels`, or `custom_headers` resets them to their defaults (enabled, no labels, no custom headers). `signing_secret` is the one exception: omitting it keeps the channel's current signing secret instead of clearing the credential.
type UpdateCreditGrantExternalSettlementRequest ¶
type UpdateCreditGrantExternalSettlementRequest struct {
// The new payment settlement status.
Status CreditPurchasePaymentSettlementStatus `json:"status"`
}
Request body for updating the external payment settlement status of a credit grant.
type UpdateFeatureRequest ¶
type UpdateFeatureRequest struct {
// Optional per-unit cost configuration. Use "manual" for a fixed per-unit cost, or
// "llm" to look up cost from the LLM cost database based on meter group-by
// properties. Set to `null` to clear the existing unit cost; omit to leave it
// unchanged.
UnitCost Nullable[FeatureUnitCost] `json:"unit_cost,omitempty"`
}
Request body for updating a feature. Currently only the unit_cost field can be updated.
type UpdateInvoiceLine ¶
type UpdateInvoiceLine struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
A top-level line item on an invoice.
Each line represents a single charge, typically associated with a rate card from a subscription. Detailed (child) lines are nested under `detailed_lines` when present.
UpdateInvoiceLine is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the UpdateInvoiceLineFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func UpdateInvoiceLineFromUpdateInvoiceStandardLine ¶
func UpdateInvoiceLineFromUpdateInvoiceStandardLine(value UpdateInvoiceStandardLine) (UpdateInvoiceLine, error)
func (UpdateInvoiceLine) AsUpdateInvoiceStandardLine ¶
func (u UpdateInvoiceLine) AsUpdateInvoiceStandardLine() (*UpdateInvoiceStandardLine, error)
func (UpdateInvoiceLine) MarshalJSON ¶
func (u UpdateInvoiceLine) MarshalJSON() ([]byte, error)
func (*UpdateInvoiceLine) UnmarshalJSON ¶
func (u *UpdateInvoiceLine) UnmarshalJSON(data []byte) error
type UpdateInvoiceLineRateCard ¶
type UpdateInvoiceLineRateCard struct {
// The price definition used to calculate charges for this line.
Price Price `json:"price"`
// Tax configuration snapshot for this line.
TaxConfig *TaxCodeConfig `json:"tax_config,omitempty"`
// The feature key associated with this line's rate card.
FeatureKey *string `json:"feature_key,omitempty"`
// Discount configuration from the rate card.
Discounts *RateCardDiscounts `json:"discounts,omitempty"`
}
Rate card configuration snapshot for a usage-based invoice line.
type UpdateInvoiceRequest ¶
type UpdateInvoiceRequest struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
UpdateInvoiceRequest update request.
UpdateInvoiceRequest is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the UpdateInvoiceRequestFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func UpdateInvoiceRequestFromUpdateInvoiceStandardRequest ¶
func UpdateInvoiceRequestFromUpdateInvoiceStandardRequest(value UpdateInvoiceStandardRequest) (UpdateInvoiceRequest, error)
func (UpdateInvoiceRequest) AsUpdateInvoiceStandardRequest ¶
func (u UpdateInvoiceRequest) AsUpdateInvoiceStandardRequest() (*UpdateInvoiceStandardRequest, error)
func (UpdateInvoiceRequest) MarshalJSON ¶
func (u UpdateInvoiceRequest) MarshalJSON() ([]byte, error)
func (*UpdateInvoiceRequest) UnmarshalJSON ¶
func (u *UpdateInvoiceRequest) UnmarshalJSON(data []byte) error
type UpdateInvoiceStandardLine ¶
type UpdateInvoiceStandardLine struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
// ID of the line.
//
// Optional on update: omit to create a new line, or supply the ID of an existing
// line to edit it. Existing lines omitted from an update's `lines` array are
// deleted.
ID *string `json:"id,omitempty"`
// The type of charge this line item represents.
Type InvoiceLineType `json:"type"`
// The service period covered by this invoice, spanning the earliest line start to
// the latest line end across all of its lines.
//
// For an invoice with no lines the period is empty, which means `from` will be
// equal to `to`.
ServicePeriod ClosedPeriod `json:"service_period"`
// The rate card configuration snapshot used to price this line item.
RateCard UpdateInvoiceLineRateCard `json:"rate_card"`
}
A top-level line item on an invoice.
Each line represents a single charge, typically associated with a rate card from a subscription. Detailed (child) lines are nested under `detailed_lines` when present.
type UpdateInvoiceStandardRequest ¶
type UpdateInvoiceStandardRequest struct {
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
// Snapshot of the supplier's contact information at the time the invoice was
// issued.
Supplier Supplier `json:"supplier"`
// Snapshot of the customer's information at the time the invoice was issued.
Customer InvoiceCustomer `json:"customer"`
// Discriminator field identifying this as a standard invoice.
Type InvoiceType `json:"type"`
// Workflow configuration snapshot captured at invoice creation time.
Workflow UpdateInvoiceWorkflowSettings `json:"workflow"`
// Line items on this invoice.
//
// Always returned on single-resource GET; omitted on list endpoints unless
// explicitly expanded. Editable via update: existing lines are matched by `id`,
// lines without an `id` are created, and lines present on the invoice but omitted
// from the update request are deleted. Detailed (child) lines are always computed
// and cannot be edited directly.
Lines *[]UpdateInvoiceLine `json:"lines,omitempty"`
}
InvoiceStandard update request.
type UpdateInvoiceWorkflowSettings ¶
type UpdateInvoiceWorkflowSettings struct {
// The workflow configuration that was active when the invoice was created.
//
// Only the fields that are meaningful at the per-invoice level are included:
// invoicing behaviour (auto-advance, draft period) and payment settings
// (collection method, due date). Profile-wide settings such as collection
// alignment, progressive billing, and tax policy are omitted.
Workflow UpdateBillingInvoiceWorkflow `json:"workflow"`
}
Snapshot of the billing workflow configuration captured at invoice creation.
type UpdateMeterRequest ¶
type UpdateMeterRequest struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name *string `json:"name,omitempty"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
// Named JSONPath expressions to extract the group by values from the event data.
//
// Keys must be unique and consist only alphanumeric and underscore characters.
Dimensions *map[string]string `json:"dimensions,omitempty"`
}
Meter update request.
type UpdateOrganizationDefaultTaxCodesRequest ¶
type UpdateOrganizationDefaultTaxCodesRequest struct {
// Default tax code for invoicing.
InvoicingTaxCode *TaxCodeReference `json:"invoicing_tax_code,omitempty"`
// Default tax code for credit grants.
CreditGrantTaxCode *TaxCodeReference `json:"credit_grant_tax_code,omitempty"`
}
OrganizationDefaultTaxCodes update request.
type UpsertAddonRequest ¶
type UpsertAddonRequest struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
// The InstanceType of the add-ons. Can be "single" or "multiple".
InstanceType AddonInstanceType `json:"instance_type"`
// The rate cards of the add-on.
RateCards []RateCardInput `json:"rate_cards"`
}
Addon upsert request.
type UpsertAppCustomerDataRequest ¶
type UpsertAppCustomerDataRequest struct {
// Used if the customer has a linked Stripe app.
//
// Set to `null` to remove the Stripe data of the customer; omit to leave it
// unchanged.
Stripe Nullable[AppCustomerDataStripeInput] `json:"stripe,omitempty"`
// Used if the customer has a linked external invoicing app.
//
// Set to `null` to remove the external invoicing data of the customer; omit to
// leave it unchanged.
ExternalInvoicing Nullable[AppCustomerDataExternalInvoicingInput] `json:"external_invoicing,omitempty"`
}
AppCustomerData upsert request.
type UpsertBillingProfileRequest ¶
type UpsertBillingProfileRequest struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
// The name and contact information for the supplier this billing profile
// represents
Supplier Party `json:"supplier"`
// The billing workflow settings for this profile
Workflow Workflow `json:"workflow"`
// Whether this is the default profile.
Default bool `json:"default"`
}
BillingProfile upsert request.
type UpsertCustomerBillingDataRequest ¶
type UpsertCustomerBillingDataRequest struct {
// The billing profile explicitly selected for the customer.
//
// Unpinned customers use the current namespace default. Selecting the current
// default explicitly pins the customer to that profile.
BillingProfile Nullable[ProfileReference] `json:"billing_profile,omitempty"`
// App customer data.
AppData *AppCustomerDataInput `json:"app_data,omitempty"`
}
CustomerBillingData upsert request.
type UpsertCustomerBillingProfileRequest ¶
type UpsertCustomerBillingProfileRequest struct {
// The billing profile explicitly selected for the customer.
//
// Unpinned customers use the current namespace default. Selecting the current
// default explicitly pins the customer to that profile.
BillingProfile Nullable[ProfileReference] `json:"billing_profile,omitempty"`
}
CustomerBillingProfile upsert request.
type UpsertCustomerRequest ¶
type UpsertCustomerRequest struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
// Mapping to attribute metered usage to the customer by the event subject.
UsageAttribution *CustomerUsageAttribution `json:"usage_attribution,omitempty"`
// The primary email address of the customer.
PrimaryEmail *string `json:"primary_email,omitempty"`
// Currency of the customer. Used for billing, tax and invoicing.
Currency *string `json:"currency,omitempty"`
// The billing address of the customer. Used for tax and invoicing.
BillingAddress *Address `json:"billing_address,omitempty"`
}
Customer upsert request.
type UpsertPlanAddonRequest ¶
type UpsertPlanAddonRequest struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
// The key of the plan phase from which the add-on becomes available for purchase.
FromPlanPhase string `json:"from_plan_phase"`
// The maximum number of times the add-on can be purchased for the plan. For
// single-instance add-ons this field must be omitted. For multi-instance add-ons
// when omitted, unlimited quantity can be purchased.
MaxQuantity *int64 `json:"max_quantity,omitempty"`
}
PlanAddon upsert request.
type UpsertPlanRequest ¶
type UpsertPlanRequest struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
// Whether pro-rating is enabled for this plan.
ProRatingEnabled *bool `json:"pro_rating_enabled,omitempty"`
// The plan phases define the pricing ramp for a subscription. A phase switch
// occurs only at the end of a billing period. At least one phase is required.
Phases []PlanPhaseInput `json:"phases"`
// Settlement mode for the plan. When omitted, the existing settlement mode is
// preserved.
SettlementMode *SettlementMode `json:"settlement_mode,omitempty"`
}
Plan upsert (update) request. `settlement_mode` is re-declared as optional with no default, so an omitted value leaves the plan's existing settlement mode unchanged.
type UpsertTaxCodeRequest ¶
type UpsertTaxCodeRequest struct {
// Display name of the resource.
//
// Between 1 and 256 characters.
Name string `json:"name"`
// Optional description of the resource.
//
// Maximum 1024 characters.
Description *string `json:"description,omitempty"`
Labels *map[string]string `json:"labels,omitempty"`
// Mapping of app types to tax codes.
AppMappings []TaxCodeAppMapping `json:"app_mappings"`
}
TaxCode upsert request.
type ValidationIssue ¶
type ValidationIssue struct {
// Machine-readable error code.
Code string `json:"code"`
// Human-readable description of the error.
Message string `json:"message"`
// Additional structured context.
Attributes map[string]any `json:"attributes,omitempty"`
// Severity of the validation issue.
Severity ValidationIssueSeverity `json:"severity"`
// JSON path to the field that caused the validation issue, if applicable.
Field *string `json:"field,omitempty"`
// Component that reported the validation issue, if applicable.
Component *string `json:"component,omitempty"`
}
A validation issue found while processing a billing resource.
type ValidationIssueSeverity ¶
type ValidationIssueSeverity string
Severity level of a billing validation issue.
const ( ValidationIssueSeverityCritical ValidationIssueSeverity = "critical" ValidationIssueSeverityWarning ValidationIssueSeverity = "warning" )
func (ValidationIssueSeverity) Valid ¶
func (value ValidationIssueSeverity) Valid() bool
type VersionFilter ¶
type VersionFilter struct {
// Match this exact version.
Eq *int32 `json:"eq,omitempty"`
// Match one of these versions.
Oeq []int32 `json:"oeq,omitempty"`
// Match this version and later versions.
Gte *int32 `json:"gte,omitempty"`
// Match this version and earlier versions.
Lte *int32 `json:"lte,omitempty"`
}
An integer version comparison. Exactly one operator must be provided.
type VoidCreditGrantRequest ¶
type VoidCreditGrantRequest struct {
// How voiding adjusts payment state related to the grant.
//
// Currently only `none` is supported: voiding does not adjust invoices, payment
// authorization, settlement, payment intents, or external collection state. If
// payment later completes, the original invoiced amount may still be collected.
PaymentAdjustment *CreditGrantVoidPaymentAdjustment `json:"payment_adjustment,omitempty"`
}
Request body for voiding a credit grant.
type VoidGrantParams ¶
type Workflow ¶
type Workflow struct {
// The collection settings for this workflow
Collection *WorkflowCollectionSettings `json:"collection,omitempty"`
// The invoicing settings for this workflow
Invoicing *WorkflowInvoicingSettings `json:"invoicing,omitempty"`
// The payment settings for this workflow
Payment *WorkflowPaymentSettings `json:"payment,omitempty"`
// The tax settings for this workflow
Tax *WorkflowTaxSettings `json:"tax,omitempty"`
}
Billing workflow settings.
type WorkflowCollectionAlignment ¶
type WorkflowCollectionAlignment struct {
Type string `json:"type"`
// contains filtered or unexported fields
}
The alignment for collecting the pending line items into an invoice.
Defaults to subscription, which means that we are to create a new invoice every time the a subscription period starts (for in advance items) or ends (for in arrears items).
WorkflowCollectionAlignment is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the WorkflowCollectionAlignmentFrom* constructors. The exported Type field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func WorkflowCollectionAlignmentFromWorkflowCollectionAlignmentAnchored ¶
func WorkflowCollectionAlignmentFromWorkflowCollectionAlignmentAnchored(value WorkflowCollectionAlignmentAnchored) (WorkflowCollectionAlignment, error)
func WorkflowCollectionAlignmentFromWorkflowCollectionAlignmentSubscription ¶
func WorkflowCollectionAlignmentFromWorkflowCollectionAlignmentSubscription(value WorkflowCollectionAlignmentSubscription) (WorkflowCollectionAlignment, error)
func (WorkflowCollectionAlignment) AsWorkflowCollectionAlignmentAnchored ¶
func (u WorkflowCollectionAlignment) AsWorkflowCollectionAlignmentAnchored() (*WorkflowCollectionAlignmentAnchored, error)
func (WorkflowCollectionAlignment) AsWorkflowCollectionAlignmentSubscription ¶
func (u WorkflowCollectionAlignment) AsWorkflowCollectionAlignmentSubscription() (*WorkflowCollectionAlignmentSubscription, error)
func (WorkflowCollectionAlignment) MarshalJSON ¶
func (u WorkflowCollectionAlignment) MarshalJSON() ([]byte, error)
func (*WorkflowCollectionAlignment) UnmarshalJSON ¶
func (u *WorkflowCollectionAlignment) UnmarshalJSON(data []byte) error
type WorkflowCollectionAlignmentAnchored ¶
type WorkflowCollectionAlignmentAnchored struct {
// The type of alignment.
Type CollectionAlignment `json:"type"`
// The recurring period for the alignment.
RecurringPeriod RecurringPeriod `json:"recurring_period"`
}
BillingWorkflowCollectionAlignmentAnchored specifies the alignment for collecting the pending line items into an invoice.
type WorkflowCollectionAlignmentSubscription ¶
type WorkflowCollectionAlignmentSubscription struct {
// The type of alignment.
Type CollectionAlignment `json:"type"`
}
BillingWorkflowCollectionAlignmentSubscription specifies the alignment for collecting the pending line items into an invoice.
type WorkflowCollectionSettings ¶
type WorkflowCollectionSettings struct {
// The alignment for collecting the pending line items into an invoice.
Alignment *WorkflowCollectionAlignment `json:"alignment,omitempty"`
// This grace period can be used to delay the collection of the pending line items
// specified in alignment.
//
// This is useful, in case of multiple subscriptions having slightly different
// billing periods.
Interval *string `json:"interval,omitempty"`
}
Workflow collection specifies how to collect the pending line items for an invoice.
type WorkflowInvoicingEmptyInvoiceMode ¶
type WorkflowInvoicingEmptyInvoiceMode string
Billing workflow empty invoice mode.
const ( WorkflowInvoicingEmptyInvoiceModeCreate WorkflowInvoicingEmptyInvoiceMode = "create" WorkflowInvoicingEmptyInvoiceModeOmit WorkflowInvoicingEmptyInvoiceMode = "omit" )
func (WorkflowInvoicingEmptyInvoiceMode) Valid ¶
func (value WorkflowInvoicingEmptyInvoiceMode) Valid() bool
type WorkflowInvoicingSettings ¶
type WorkflowInvoicingSettings struct {
// Whether to automatically issue the invoice after the draftPeriod has passed.
AutoAdvance *bool `json:"auto_advance,omitempty"`
// The period for the invoice to be kept in draft status for manual reviews.
DraftPeriod *string `json:"draft_period,omitempty"`
// Should progressive billing be allowed for this workflow?
ProgressiveBilling *bool `json:"progressive_billing,omitempty"`
// Controls how subscription-ending shortened service periods are billed.
SubscriptionEndProrationMode *WorkflowInvoicingSubscriptionEndProrationMode `json:"subscription_end_proration_mode,omitempty"`
// Controls whether empty invoices are created in the invoicing app. An invoice is
// empty when it has no line items or its total is zero.
EmptyInvoiceMode *WorkflowInvoicingEmptyInvoiceMode `json:"empty_invoice_mode,omitempty"`
}
Invoice settings for a billing workflow.
type WorkflowInvoicingSubscriptionEndProrationMode ¶
type WorkflowInvoicingSubscriptionEndProrationMode string
Billing workflow subscription end proration mode.
const ( WorkflowInvoicingSubscriptionEndProrationModeBillFullPeriod WorkflowInvoicingSubscriptionEndProrationMode = "bill_full_period" WorkflowInvoicingSubscriptionEndProrationModeBillActualPeriod WorkflowInvoicingSubscriptionEndProrationMode = "bill_actual_period" )
func (WorkflowInvoicingSubscriptionEndProrationMode) Valid ¶
func (value WorkflowInvoicingSubscriptionEndProrationMode) Valid() bool
type WorkflowPaymentChargeAutomaticallySettings ¶
type WorkflowPaymentChargeAutomaticallySettings struct {
// The collection method for the invoice.
CollectionMethod CollectionMethod `json:"collection_method"`
}
Payment settings for a billing workflow when the collection method is charge automatically.
type WorkflowPaymentSendInvoiceSettings ¶
type WorkflowPaymentSendInvoiceSettings struct {
// The collection method for the invoice.
CollectionMethod CollectionMethod `json:"collection_method"`
// The period after which the invoice is due. With some payment solutions it's only
// applicable for manual collection method.
DueAfter *string `json:"due_after,omitempty"`
}
Payment settings for a billing workflow when the collection method is send invoice.
type WorkflowPaymentSettings ¶
type WorkflowPaymentSettings struct {
CollectionMethod string `json:"collection_method"`
// contains filtered or unexported fields
}
Payment settings for a billing workflow.
WorkflowPaymentSettings is a JSON-preserving tagged union: its zero value marshals as JSON null, and values must be built with the WorkflowPaymentSettingsFrom* constructors. The exported CollectionMethod field is decode-side metadata; MarshalJSON round-trips the original payload and ignores writes to it.
func WorkflowPaymentSettingsFromWorkflowPaymentChargeAutomaticallySettings ¶
func WorkflowPaymentSettingsFromWorkflowPaymentChargeAutomaticallySettings(value WorkflowPaymentChargeAutomaticallySettings) (WorkflowPaymentSettings, error)
func WorkflowPaymentSettingsFromWorkflowPaymentSendInvoiceSettings ¶
func WorkflowPaymentSettingsFromWorkflowPaymentSendInvoiceSettings(value WorkflowPaymentSendInvoiceSettings) (WorkflowPaymentSettings, error)
func (WorkflowPaymentSettings) AsWorkflowPaymentChargeAutomaticallySettings ¶
func (u WorkflowPaymentSettings) AsWorkflowPaymentChargeAutomaticallySettings() (*WorkflowPaymentChargeAutomaticallySettings, error)
func (WorkflowPaymentSettings) AsWorkflowPaymentSendInvoiceSettings ¶
func (u WorkflowPaymentSettings) AsWorkflowPaymentSendInvoiceSettings() (*WorkflowPaymentSendInvoiceSettings, error)
func (WorkflowPaymentSettings) MarshalJSON ¶
func (u WorkflowPaymentSettings) MarshalJSON() ([]byte, error)
func (*WorkflowPaymentSettings) UnmarshalJSON ¶
func (u *WorkflowPaymentSettings) UnmarshalJSON(data []byte) error
type WorkflowTaxSettings ¶
type WorkflowTaxSettings struct {
// Enable automatic tax calculation when tax is supported by the app. For example,
// with Stripe Invoicing when enabled, tax is calculated via Stripe Tax.
Enabled *bool `json:"enabled,omitempty"`
// Enforce tax calculation when tax is supported by the app. When enabled, the
// billing system will not allow to create an invoice without tax calculation.
// Enforcement is different per apps, for example, Stripe app requires customer to
// have a tax location when starting a paid subscription.
Enforced *bool `json:"enforced,omitempty"`
// Default tax configuration to apply to the invoices for line items.
//
// Setting a tax code (`stripe.code` / `taxCodeId`) on a profile's default tax
// config is deprecated and can no longer be added or changed: the organization
// default tax code is used instead. Existing tax-code values may still be removed,
// and `behavior` remains fully supported.
DefaultTaxConfig *TaxConfig `json:"default_tax_config,omitempty"`
}
Tax settings for a billing workflow.
Source Files
¶
- addons.go
- apps.go
- billing.go
- charges.go
- client.go
- currencies.go
- customers.go
- customers_billing.go
- customers_charges.go
- customers_credits.go
- customers_credits_adjustments.go
- customers_credits_balance.go
- customers_credits_grants.go
- customers_credits_transactions.go
- customers_entitlements.go
- customers_entitlements_grants.go
- defaults.go
- doc.go
- entitlement_access.go
- entitlements.go
- errors.go
- events.go
- features.go
- filters.go
- grants.go
- invoices.go
- llm_cost.go
- meters.go
- models_addons.go
- models_apps.go
- models_billing.go
- models_currencies.go
- models_customers.go
- models_defaults.go
- models_entitlement_access.go
- models_entitlements.go
- models_events.go
- models_features.go
- models_invoices.go
- models_llm_cost.go
- models_meters.go
- models_notifications.go
- models_plan_addons.go
- models_plans.go
- models_shared.go
- models_subscriptions.go
- models_tax.go
- notifications.go
- nullable.go
- one_or_many.go
- option.go
- pagination.go
- plan_addons.go
- plans.go
- ptr.go
- query.go
- request_content_type.go
- subscriptions.go
- tax.go
- transport.go
- types.go