| |
|
|
| package openmeter |
|
|
| import ( |
| "encoding/json" |
| "fmt" |
| "time" |
| ) |
|
|
| |
| type AppCustomerData struct { |
| |
| Stripe *AppCustomerDataStripe `json:"stripe,omitempty"` |
| |
| ExternalInvoicing *AppCustomerDataExternalInvoicing `json:"external_invoicing,omitempty"` |
| } |
|
|
| |
| type AppCustomerDataInput struct { |
| |
| Stripe *AppCustomerDataStripeInput `json:"stripe,omitempty"` |
| |
| ExternalInvoicing *AppCustomerDataExternalInvoicingInput `json:"external_invoicing,omitempty"` |
| } |
|
|
| |
| type AppCustomerDataExternalInvoicing struct { |
| |
| Labels map[string]string `json:"labels,omitempty"` |
| } |
|
|
| |
| type AppCustomerDataExternalInvoicingInput struct { |
| |
| Labels *map[string]string `json:"labels,omitempty"` |
| } |
|
|
| |
| type AppCustomerDataStripe struct { |
| |
| CustomerID *string `json:"customer_id,omitempty"` |
| |
| DefaultPaymentMethodID *string `json:"default_payment_method_id,omitempty"` |
| |
| Labels map[string]string `json:"labels,omitempty"` |
| } |
|
|
| |
| type AppCustomerDataStripeInput struct { |
| |
| CustomerID *string `json:"customer_id,omitempty"` |
| |
| DefaultPaymentMethodID *string `json:"default_payment_method_id,omitempty"` |
| |
| Labels *map[string]string `json:"labels,omitempty"` |
| } |
|
|
| |
| type AppStripeCheckoutSessionCustomTextParams struct { |
| |
| AfterSubmit *AppStripeCheckoutSessionCustomTextParamsAfterSubmit `json:"after_submit,omitempty"` |
| |
| ShippingAddress *AppStripeCheckoutSessionCustomTextParamsShippingAddress `json:"shipping_address,omitempty"` |
| |
| Submit *AppStripeCheckoutSessionCustomTextParamsSubmit `json:"submit,omitempty"` |
| |
| TermsOfServiceAcceptance *AppStripeCheckoutSessionCustomTextParamsTermsOfServiceAcceptance `json:"terms_of_service_acceptance,omitempty"` |
| } |
|
|
| type AppStripeCheckoutSessionCustomTextParamsAfterSubmit struct { |
| |
| Message *string `json:"message,omitempty"` |
| } |
|
|
| type AppStripeCheckoutSessionCustomTextParamsShippingAddress struct { |
| |
| Message *string `json:"message,omitempty"` |
| } |
|
|
| type AppStripeCheckoutSessionCustomTextParamsSubmit struct { |
| |
| Message *string `json:"message,omitempty"` |
| } |
|
|
| type AppStripeCheckoutSessionCustomTextParamsTermsOfServiceAcceptance struct { |
| |
| Message *string `json:"message,omitempty"` |
| } |
|
|
| |
| |
| |
| type AppStripeCheckoutSessionMode string |
|
|
| const ( |
| AppStripeCheckoutSessionModeSetup AppStripeCheckoutSessionMode = "setup" |
| ) |
|
|
| func (value AppStripeCheckoutSessionMode) Valid() bool { |
| switch value { |
| case AppStripeCheckoutSessionModeSetup: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| type AppStripeCheckoutSessionUiMode string |
|
|
| const ( |
| AppStripeCheckoutSessionUiModeEmbedded AppStripeCheckoutSessionUiMode = "embedded" |
| AppStripeCheckoutSessionUiModeHosted AppStripeCheckoutSessionUiMode = "hosted" |
| ) |
|
|
| func (value AppStripeCheckoutSessionUiMode) Valid() bool { |
| switch value { |
| case AppStripeCheckoutSessionUiModeEmbedded, AppStripeCheckoutSessionUiModeHosted: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| type AppStripeCreateCheckoutSessionBillingAddressCollection string |
|
|
| const ( |
| AppStripeCreateCheckoutSessionBillingAddressCollectionAuto AppStripeCreateCheckoutSessionBillingAddressCollection = "auto" |
| AppStripeCreateCheckoutSessionBillingAddressCollectionRequired AppStripeCreateCheckoutSessionBillingAddressCollection = "required" |
| ) |
|
|
| func (value AppStripeCreateCheckoutSessionBillingAddressCollection) Valid() bool { |
| switch value { |
| case AppStripeCreateCheckoutSessionBillingAddressCollectionAuto, AppStripeCreateCheckoutSessionBillingAddressCollectionRequired: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| type AppStripeCreateCheckoutSessionConsentCollection struct { |
| |
| PaymentMethodReuseAgreement *AppStripeCreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreement `json:"payment_method_reuse_agreement,omitempty"` |
| |
| |
| |
| |
| Promotions *AppStripeCreateCheckoutSessionConsentCollectionPromotions `json:"promotions,omitempty"` |
| |
| |
| |
| TermsOfService *AppStripeCreateCheckoutSessionConsentCollectionTermsOfService `json:"terms_of_service,omitempty"` |
| } |
|
|
| |
| type AppStripeCreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreement struct { |
| |
| Position *AppStripeCreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPosition `json:"position,omitempty"` |
| } |
|
|
| |
| type AppStripeCreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPosition string |
|
|
| const ( |
| AppStripeCreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPositionAuto AppStripeCreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPosition = "auto" |
| AppStripeCreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPositionHidden AppStripeCreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPosition = "hidden" |
| ) |
|
|
| func (value AppStripeCreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPosition) Valid() bool { |
| switch value { |
| case AppStripeCreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPositionAuto, AppStripeCreateCheckoutSessionConsentCollectionPaymentMethodReuseAgreementPositionHidden: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| type AppStripeCreateCheckoutSessionConsentCollectionPromotions string |
|
|
| const ( |
| AppStripeCreateCheckoutSessionConsentCollectionPromotionsAuto AppStripeCreateCheckoutSessionConsentCollectionPromotions = "auto" |
| AppStripeCreateCheckoutSessionConsentCollectionPromotionsNone AppStripeCreateCheckoutSessionConsentCollectionPromotions = "none" |
| ) |
|
|
| func (value AppStripeCreateCheckoutSessionConsentCollectionPromotions) Valid() bool { |
| switch value { |
| case AppStripeCreateCheckoutSessionConsentCollectionPromotionsAuto, AppStripeCreateCheckoutSessionConsentCollectionPromotionsNone: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| type AppStripeCreateCheckoutSessionConsentCollectionTermsOfService string |
|
|
| const ( |
| AppStripeCreateCheckoutSessionConsentCollectionTermsOfServiceNone AppStripeCreateCheckoutSessionConsentCollectionTermsOfService = "none" |
| AppStripeCreateCheckoutSessionConsentCollectionTermsOfServiceRequired AppStripeCreateCheckoutSessionConsentCollectionTermsOfService = "required" |
| ) |
|
|
| func (value AppStripeCreateCheckoutSessionConsentCollectionTermsOfService) Valid() bool { |
| switch value { |
| case AppStripeCreateCheckoutSessionConsentCollectionTermsOfServiceNone, AppStripeCreateCheckoutSessionConsentCollectionTermsOfServiceRequired: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| type AppStripeCreateCheckoutSessionCustomerUpdate struct { |
| |
| |
| |
| Address *AppStripeCreateCheckoutSessionCustomerUpdateBehavior `json:"address,omitempty"` |
| |
| |
| |
| Name *AppStripeCreateCheckoutSessionCustomerUpdateBehavior `json:"name,omitempty"` |
| |
| |
| |
| Shipping *AppStripeCreateCheckoutSessionCustomerUpdateBehavior `json:"shipping,omitempty"` |
| } |
|
|
| |
| type AppStripeCreateCheckoutSessionCustomerUpdateBehavior string |
|
|
| const ( |
| AppStripeCreateCheckoutSessionCustomerUpdateBehaviorAuto AppStripeCreateCheckoutSessionCustomerUpdateBehavior = "auto" |
| AppStripeCreateCheckoutSessionCustomerUpdateBehaviorNever AppStripeCreateCheckoutSessionCustomerUpdateBehavior = "never" |
| ) |
|
|
| func (value AppStripeCreateCheckoutSessionCustomerUpdateBehavior) Valid() bool { |
| switch value { |
| case AppStripeCreateCheckoutSessionCustomerUpdateBehaviorAuto, AppStripeCreateCheckoutSessionCustomerUpdateBehaviorNever: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| type AppStripeCreateCheckoutSessionRedirectOnCompletion string |
|
|
| const ( |
| AppStripeCreateCheckoutSessionRedirectOnCompletionAlways AppStripeCreateCheckoutSessionRedirectOnCompletion = "always" |
| AppStripeCreateCheckoutSessionRedirectOnCompletionIfRequired AppStripeCreateCheckoutSessionRedirectOnCompletion = "if_required" |
| AppStripeCreateCheckoutSessionRedirectOnCompletionNever AppStripeCreateCheckoutSessionRedirectOnCompletion = "never" |
| ) |
|
|
| func (value AppStripeCreateCheckoutSessionRedirectOnCompletion) Valid() bool { |
| switch value { |
| case AppStripeCreateCheckoutSessionRedirectOnCompletionAlways, AppStripeCreateCheckoutSessionRedirectOnCompletionIfRequired, AppStripeCreateCheckoutSessionRedirectOnCompletionNever: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| |
| |
| |
| type AppStripeCreateCheckoutSessionRequestOptions struct { |
| |
| |
| |
| |
| BillingAddressCollection *AppStripeCreateCheckoutSessionBillingAddressCollection `json:"billing_address_collection,omitempty"` |
| |
| |
| |
| CancelURL *string `json:"cancel_url,omitempty"` |
| |
| |
| |
| ClientReferenceID *string `json:"client_reference_id,omitempty"` |
| |
| CustomerUpdate *AppStripeCreateCheckoutSessionCustomerUpdate `json:"customer_update,omitempty"` |
| |
| ConsentCollection *AppStripeCreateCheckoutSessionConsentCollection `json:"consent_collection,omitempty"` |
| |
| |
| |
| Currency *string `json:"currency,omitempty"` |
| |
| CustomText *AppStripeCheckoutSessionCustomTextParams `json:"custom_text,omitempty"` |
| |
| |
| |
| ExpiresAt *int64 `json:"expires_at,omitempty"` |
| |
| |
| |
| Locale *string `json:"locale,omitempty"` |
| |
| |
| |
| Metadata *map[string]string `json:"metadata,omitempty"` |
| |
| |
| |
| |
| ReturnURL *string `json:"return_url,omitempty"` |
| |
| |
| |
| |
| SuccessURL *string `json:"success_url,omitempty"` |
| |
| |
| |
| |
| UiMode *AppStripeCheckoutSessionUiMode `json:"ui_mode,omitempty"` |
| |
| |
| |
| PaymentMethodTypes *[]string `json:"payment_method_types,omitempty"` |
| |
| |
| |
| |
| RedirectOnCompletion *AppStripeCreateCheckoutSessionRedirectOnCompletion `json:"redirect_on_completion,omitempty"` |
| |
| TaxIDCollection *AppStripeCreateCheckoutSessionTaxIDCollection `json:"tax_id_collection,omitempty"` |
| } |
|
|
| |
| |
| |
| |
| type AppStripeCreateCheckoutSessionResult struct { |
| |
| CustomerID string `json:"customer_id"` |
| |
| StripeCustomerID string `json:"stripe_customer_id"` |
| |
| SessionID string `json:"session_id"` |
| |
| SetupIntentID string `json:"setup_intent_id"` |
| |
| |
| |
| |
| ClientSecret *string `json:"client_secret,omitempty"` |
| |
| |
| |
| ClientReferenceID *string `json:"client_reference_id,omitempty"` |
| |
| CustomerEmail *string `json:"customer_email,omitempty"` |
| |
| Currency *string `json:"currency,omitempty"` |
| |
| CreatedAt time.Time `json:"created_at"` |
| |
| ExpiresAt *time.Time `json:"expires_at,omitempty"` |
| |
| Metadata map[string]string `json:"metadata,omitempty"` |
| |
| |
| |
| |
| Status *string `json:"status,omitempty"` |
| |
| URL *string `json:"url,omitempty"` |
| |
| |
| |
| Mode AppStripeCheckoutSessionMode `json:"mode"` |
| |
| CancelURL *string `json:"cancel_url,omitempty"` |
| |
| SuccessURL *string `json:"success_url,omitempty"` |
| |
| ReturnURL *string `json:"return_url,omitempty"` |
| } |
|
|
| |
| type AppStripeCreateCheckoutSessionTaxIDCollection struct { |
| |
| |
| |
| Enabled *bool `json:"enabled,omitempty"` |
| |
| |
| |
| Required *AppStripeCreateCheckoutSessionTaxIDCollectionRequired `json:"required,omitempty"` |
| } |
|
|
| |
| type AppStripeCreateCheckoutSessionTaxIDCollectionRequired string |
|
|
| const ( |
| AppStripeCreateCheckoutSessionTaxIDCollectionRequiredIfSupported AppStripeCreateCheckoutSessionTaxIDCollectionRequired = "if_supported" |
| AppStripeCreateCheckoutSessionTaxIDCollectionRequiredNever AppStripeCreateCheckoutSessionTaxIDCollectionRequired = "never" |
| ) |
|
|
| func (value AppStripeCreateCheckoutSessionTaxIDCollectionRequired) Valid() bool { |
| switch value { |
| case AppStripeCreateCheckoutSessionTaxIDCollectionRequiredIfSupported, AppStripeCreateCheckoutSessionTaxIDCollectionRequiredNever: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| type AppStripeCreateCustomerPortalSessionOptions struct { |
| |
| |
| |
| |
| ConfigurationID *string `json:"configuration_id,omitempty"` |
| |
| |
| |
| |
| Locale *string `json:"locale,omitempty"` |
| |
| |
| |
| ReturnURL *string `json:"return_url,omitempty"` |
| } |
|
|
| |
| |
| |
| |
| |
| type AppStripeCreateCustomerPortalSessionResult struct { |
| |
| |
| |
| |
| ID string `json:"id"` |
| |
| StripeCustomerID string `json:"stripe_customer_id"` |
| |
| |
| |
| |
| ConfigurationID string `json:"configuration_id"` |
| |
| |
| |
| |
| Livemode bool `json:"livemode"` |
| |
| |
| |
| |
| CreatedAt time.Time `json:"created_at"` |
| |
| |
| |
| |
| ReturnURL string `json:"return_url"` |
| |
| |
| |
| |
| Locale string `json:"locale"` |
| |
| |
| URL string `json:"url"` |
| } |
|
|
| |
| type BillingCustomerReference struct { |
| |
| ID string `json:"id"` |
| } |
|
|
| |
| |
| |
| |
| type Charge struct { |
| Type string `json:"type"` |
| raw json.RawMessage |
| } |
|
|
| func (u *Charge) UnmarshalJSON(data []byte) error { |
| u.raw = append([]byte(nil), data...) |
| if string(data) == "null" { |
| u.Type = "" |
| return nil |
| } |
|
|
| var envelope struct { |
| Value string `json:"type"` |
| } |
| if err := json.Unmarshal(data, &envelope); err != nil { |
| return err |
| } |
| u.Type = envelope.Value |
| return nil |
| } |
|
|
| func (u Charge) MarshalJSON() ([]byte, error) { |
| if len(u.raw) == 0 { |
| return []byte("null"), nil |
| } |
| return append([]byte(nil), u.raw...), nil |
| } |
|
|
| func (u Charge) AsChargeFlatFee() (*ChargeFlatFee, error) { |
| if u.Type != "flat_fee" { |
| return nil, fmt.Errorf("Charge: expected type %q, got %q", "flat_fee", u.Type) |
| } |
| var value ChargeFlatFee |
| if err := json.Unmarshal(u.raw, &value); err != nil { |
| return nil, err |
| } |
| return &value, nil |
| } |
|
|
| func ChargeFromChargeFlatFee(value ChargeFlatFee) (Charge, error) { |
| value.Type = "flat_fee" |
| raw, err := json.Marshal(value) |
| if err != nil { |
| return Charge{}, err |
| } |
| var result Charge |
| if err := result.UnmarshalJSON(raw); err != nil { |
| return Charge{}, err |
| } |
| return result, nil |
| } |
|
|
| func (u Charge) AsChargeUsageBased() (*ChargeUsageBased, error) { |
| if u.Type != "usage_based" { |
| return nil, fmt.Errorf("Charge: expected type %q, got %q", "usage_based", u.Type) |
| } |
| var value ChargeUsageBased |
| if err := json.Unmarshal(u.raw, &value); err != nil { |
| return nil, err |
| } |
| return &value, nil |
| } |
|
|
| func ChargeFromChargeUsageBased(value ChargeUsageBased) (Charge, error) { |
| value.Type = "usage_based" |
| raw, err := json.Marshal(value) |
| if err != nil { |
| return Charge{}, err |
| } |
| var result Charge |
| if err := result.UnmarshalJSON(raw); err != nil { |
| return Charge{}, err |
| } |
| return result, nil |
| } |
|
|
| |
| type ChargeFlatFee struct { |
| ID string `json:"id"` |
| |
| |
| |
| Name string `json:"name"` |
| |
| |
| |
| Description *string `json:"description,omitempty"` |
| Labels map[string]string `json:"labels,omitempty"` |
| |
| CreatedAt time.Time `json:"created_at"` |
| |
| UpdatedAt time.Time `json:"updated_at"` |
| |
| DeletedAt *time.Time `json:"deleted_at,omitempty"` |
| |
| Type ChargeType `json:"type"` |
| |
| Customer BillingCustomerReference `json:"customer"` |
| |
| |
| LifecycleController LifecycleController `json:"lifecycle_controller"` |
| |
| |
| Subscription *SubscriptionReference `json:"subscription,omitempty"` |
| |
| Currency string `json:"currency"` |
| |
| Status ChargeStatus `json:"status"` |
| |
| InvoiceAt time.Time `json:"invoice_at"` |
| |
| ServicePeriod ClosedPeriod `json:"service_period"` |
| |
| FullServicePeriod ClosedPeriod `json:"full_service_period"` |
| |
| BillingPeriod ClosedPeriod `json:"billing_period"` |
| |
| |
| AdvanceAfter *time.Time `json:"advance_after,omitempty"` |
| |
| UniqueReferenceID *string `json:"unique_reference_id,omitempty"` |
| |
| SettlementMode SettlementMode `json:"settlement_mode"` |
| |
| TaxConfig *TaxConfig `json:"tax_config,omitempty"` |
| |
| PaymentTerm PricePaymentTerm `json:"payment_term"` |
| |
| Discounts *ChargeFlatFeeDiscounts `json:"discounts,omitempty"` |
| |
| FeatureKey *string `json:"feature_key,omitempty"` |
| |
| ProrationConfiguration RateCardProrationConfiguration `json:"proration_configuration"` |
| |
| AmountAfterProration CurrencyAmount `json:"amount_after_proration"` |
| |
| Price Price `json:"price"` |
| |
| |
| |
| SystemIntent *ChargeFlatFeeSystemIntent `json:"system_intent,omitempty"` |
| } |
|
|
| |
| |
| |
| |
| type ChargeFlatFeeDiscounts struct { |
| |
| Percentage *float64 `json:"percentage,omitempty"` |
| } |
|
|
| |
| |
| type ChargeFlatFeeSystemIntent struct { |
| |
| |
| |
| Name string `json:"name"` |
| |
| |
| |
| Description *string `json:"description,omitempty"` |
| Labels map[string]string `json:"labels,omitempty"` |
| |
| InvoiceAt time.Time `json:"invoice_at"` |
| |
| ServicePeriod ClosedPeriod `json:"service_period"` |
| |
| FullServicePeriod ClosedPeriod `json:"full_service_period"` |
| |
| BillingPeriod ClosedPeriod `json:"billing_period"` |
| |
| PaymentTerm PricePaymentTerm `json:"payment_term"` |
| |
| Discounts *ChargeFlatFeeDiscounts `json:"discounts,omitempty"` |
| |
| ProrationConfiguration RateCardProrationConfiguration `json:"proration_configuration"` |
| |
| AmountBeforeProration CurrencyAmount `json:"amount_before_proration"` |
| |
| |
| DeletedAt *time.Time `json:"deleted_at,omitempty"` |
| } |
|
|
| |
| type ChargePagePaginatedResponse struct { |
| Data []Charge `json:"data"` |
| Meta PaginatedMeta `json:"meta"` |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| type ChargeStatus string |
|
|
| const ( |
| ChargeStatusCreated ChargeStatus = "created" |
| ChargeStatusActive ChargeStatus = "active" |
| ChargeStatusFinal ChargeStatus = "final" |
| ChargeStatusDeleted ChargeStatus = "deleted" |
| ) |
|
|
| func (value ChargeStatus) Valid() bool { |
| switch value { |
| case ChargeStatusCreated, ChargeStatusActive, ChargeStatusFinal, ChargeStatusDeleted: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| |
| |
| type ChargeTotals struct { |
| |
| Booked Totals `json:"booked"` |
| |
| |
| |
| Realtime *Totals `json:"realtime,omitempty"` |
| } |
|
|
| |
| |
| |
| |
| |
| |
| type ChargeType string |
|
|
| const ( |
| ChargeTypeFlatFee ChargeType = "flat_fee" |
| ChargeTypeUsageBased ChargeType = "usage_based" |
| ) |
|
|
| func (value ChargeType) Valid() bool { |
| switch value { |
| case ChargeTypeFlatFee, ChargeTypeUsageBased: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| type ChargeUsageBased struct { |
| ID string `json:"id"` |
| |
| |
| |
| Name string `json:"name"` |
| |
| |
| |
| Description *string `json:"description,omitempty"` |
| Labels map[string]string `json:"labels,omitempty"` |
| |
| CreatedAt time.Time `json:"created_at"` |
| |
| UpdatedAt time.Time `json:"updated_at"` |
| |
| DeletedAt *time.Time `json:"deleted_at,omitempty"` |
| |
| Type ChargeType `json:"type"` |
| |
| Customer BillingCustomerReference `json:"customer"` |
| |
| |
| LifecycleController LifecycleController `json:"lifecycle_controller"` |
| |
| |
| Subscription *SubscriptionReference `json:"subscription,omitempty"` |
| |
| Currency string `json:"currency"` |
| |
| Status ChargeStatus `json:"status"` |
| |
| InvoiceAt time.Time `json:"invoice_at"` |
| |
| ServicePeriod ClosedPeriod `json:"service_period"` |
| |
| FullServicePeriod ClosedPeriod `json:"full_service_period"` |
| |
| BillingPeriod ClosedPeriod `json:"billing_period"` |
| |
| |
| AdvanceAfter *time.Time `json:"advance_after,omitempty"` |
| |
| UniqueReferenceID *string `json:"unique_reference_id,omitempty"` |
| |
| SettlementMode SettlementMode `json:"settlement_mode"` |
| |
| TaxConfig *TaxConfig `json:"tax_config,omitempty"` |
| |
| Discounts *RateCardDiscounts `json:"discounts,omitempty"` |
| |
| FeatureKey string `json:"feature_key"` |
| |
| Totals ChargeTotals `json:"totals"` |
| |
| Price Price `json:"price"` |
| |
| |
| |
| SystemIntent *ChargeUsageBasedSystemIntent `json:"system_intent,omitempty"` |
| } |
|
|
| |
| |
| type ChargeUsageBasedSystemIntent struct { |
| |
| |
| |
| Name string `json:"name"` |
| |
| |
| |
| Description *string `json:"description,omitempty"` |
| Labels map[string]string `json:"labels,omitempty"` |
| |
| InvoiceAt time.Time `json:"invoice_at"` |
| |
| ServicePeriod ClosedPeriod `json:"service_period"` |
| |
| FullServicePeriod ClosedPeriod `json:"full_service_period"` |
| |
| BillingPeriod ClosedPeriod `json:"billing_period"` |
| |
| Discounts *RateCardDiscounts `json:"discounts,omitempty"` |
| |
| Price Price `json:"price"` |
| |
| |
| DeletedAt *time.Time `json:"deleted_at,omitempty"` |
| } |
|
|
| |
| |
| |
| |
| |
| type ChargesExpand string |
|
|
| const ( |
| ChargesExpandRealTimeUsage ChargesExpand = "real_time_usage" |
| ) |
|
|
| func (value ChargesExpand) Valid() bool { |
| switch value { |
| case ChargesExpandRealTimeUsage: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| type CreateChargeFlatFeeRequest struct { |
| |
| |
| |
| Name string `json:"name"` |
| |
| |
| |
| Description *string `json:"description,omitempty"` |
| Labels *map[string]string `json:"labels,omitempty"` |
| |
| Type ChargeType `json:"type"` |
| |
| Currency string `json:"currency"` |
| |
| InvoiceAt time.Time `json:"invoice_at"` |
| |
| ServicePeriod ClosedPeriod `json:"service_period"` |
| |
| UniqueReferenceID *string `json:"unique_reference_id,omitempty"` |
| |
| SettlementMode SettlementMode `json:"settlement_mode"` |
| |
| TaxConfig *TaxConfig `json:"tax_config,omitempty"` |
| |
| PaymentTerm PricePaymentTerm `json:"payment_term"` |
| |
| Discounts *ChargeFlatFeeDiscounts `json:"discounts,omitempty"` |
| |
| FeatureKey *string `json:"feature_key,omitempty"` |
| |
| ProrationConfiguration RateCardProrationConfiguration `json:"proration_configuration"` |
| |
| AmountBeforeProration CurrencyAmount `json:"amount_before_proration"` |
| |
| FullServicePeriod *ClosedPeriod `json:"full_service_period,omitempty"` |
| |
| BillingPeriod *ClosedPeriod `json:"billing_period,omitempty"` |
| } |
|
|
| |
| |
| |
| |
| type CreateChargeRequest struct { |
| Type string `json:"type"` |
| raw json.RawMessage |
| } |
|
|
| func (u *CreateChargeRequest) UnmarshalJSON(data []byte) error { |
| u.raw = append([]byte(nil), data...) |
| if string(data) == "null" { |
| u.Type = "" |
| return nil |
| } |
|
|
| var envelope struct { |
| Value string `json:"type"` |
| } |
| if err := json.Unmarshal(data, &envelope); err != nil { |
| return err |
| } |
| u.Type = envelope.Value |
| return nil |
| } |
|
|
| func (u CreateChargeRequest) MarshalJSON() ([]byte, error) { |
| if len(u.raw) == 0 { |
| return []byte("null"), nil |
| } |
| return append([]byte(nil), u.raw...), nil |
| } |
|
|
| func (u CreateChargeRequest) AsCreateChargeFlatFeeRequest() (*CreateChargeFlatFeeRequest, error) { |
| if u.Type != "flat_fee" { |
| return nil, fmt.Errorf("CreateChargeRequest: expected type %q, got %q", "flat_fee", u.Type) |
| } |
| var value CreateChargeFlatFeeRequest |
| if err := json.Unmarshal(u.raw, &value); err != nil { |
| return nil, err |
| } |
| return &value, nil |
| } |
|
|
| func CreateChargeRequestFromCreateChargeFlatFeeRequest(value CreateChargeFlatFeeRequest) (CreateChargeRequest, error) { |
| value.Type = "flat_fee" |
| raw, err := json.Marshal(value) |
| if err != nil { |
| return CreateChargeRequest{}, err |
| } |
| var result CreateChargeRequest |
| if err := result.UnmarshalJSON(raw); err != nil { |
| return CreateChargeRequest{}, err |
| } |
| return result, nil |
| } |
|
|
| func (u CreateChargeRequest) AsCreateChargeUsageBasedRequest() (*CreateChargeUsageBasedRequest, error) { |
| if u.Type != "usage_based" { |
| return nil, fmt.Errorf("CreateChargeRequest: expected type %q, got %q", "usage_based", u.Type) |
| } |
| var value CreateChargeUsageBasedRequest |
| if err := json.Unmarshal(u.raw, &value); err != nil { |
| return nil, err |
| } |
| return &value, nil |
| } |
|
|
| func CreateChargeRequestFromCreateChargeUsageBasedRequest(value CreateChargeUsageBasedRequest) (CreateChargeRequest, error) { |
| value.Type = "usage_based" |
| raw, err := json.Marshal(value) |
| if err != nil { |
| return CreateChargeRequest{}, err |
| } |
| var result CreateChargeRequest |
| if err := result.UnmarshalJSON(raw); err != nil { |
| return CreateChargeRequest{}, err |
| } |
| return result, nil |
| } |
|
|
| |
| type CreateChargeUsageBasedRequest struct { |
| |
| |
| |
| Name string `json:"name"` |
| |
| |
| |
| Description *string `json:"description,omitempty"` |
| Labels *map[string]string `json:"labels,omitempty"` |
| |
| Type ChargeType `json:"type"` |
| |
| Currency string `json:"currency"` |
| |
| InvoiceAt time.Time `json:"invoice_at"` |
| |
| ServicePeriod ClosedPeriod `json:"service_period"` |
| |
| UniqueReferenceID *string `json:"unique_reference_id,omitempty"` |
| |
| SettlementMode SettlementMode `json:"settlement_mode"` |
| |
| TaxConfig *TaxConfig `json:"tax_config,omitempty"` |
| |
| Discounts *RateCardDiscounts `json:"discounts,omitempty"` |
| |
| FeatureKey string `json:"feature_key"` |
| |
| Price Price `json:"price"` |
| |
| FullServicePeriod *ClosedPeriod `json:"full_service_period,omitempty"` |
| |
| BillingPeriod *ClosedPeriod `json:"billing_period,omitempty"` |
| } |
|
|
| |
| type CreateCreditAdjustmentRequest struct { |
| |
| |
| |
| Name string `json:"name"` |
| |
| |
| |
| Description *string `json:"description,omitempty"` |
| Labels *map[string]string `json:"labels,omitempty"` |
| |
| Currency BillingCurrencyCode `json:"currency"` |
| |
| Amount Numeric `json:"amount"` |
| } |
|
|
| |
| type CreateCreditGrantFilters struct { |
| |
| |
| Features *[]string `json:"features,omitempty"` |
| } |
|
|
| |
| type CreateCreditGrantPurchase struct { |
| |
| Currency string `json:"currency"` |
| |
| |
| |
| |
| |
| |
| |
| PerUnitCostBasis *Numeric `json:"per_unit_cost_basis,omitempty"` |
| |
| |
| |
| AvailabilityPolicy *CreditAvailabilityPolicy `json:"availability_policy,omitempty"` |
| } |
|
|
| |
| type CreateCreditGrantRequest struct { |
| |
| |
| |
| Name string `json:"name"` |
| |
| |
| |
| Description *string `json:"description,omitempty"` |
| Labels *map[string]string `json:"labels,omitempty"` |
| |
| FundingMethod CreditFundingMethod `json:"funding_method"` |
| |
| Currency BillingCurrencyCode `json:"currency"` |
| |
| Amount Numeric `json:"amount"` |
| |
| Purchase *CreateCreditGrantPurchase `json:"purchase,omitempty"` |
| |
| |
| |
| |
| |
| |
| TaxConfig *CreditGrantTaxConfig `json:"tax_config,omitempty"` |
| Filters *CreateCreditGrantFilters `json:"filters,omitempty"` |
| |
| Priority *int16 `json:"priority,omitempty"` |
| |
| |
| |
| EffectiveAt *time.Time `json:"effective_at,omitempty"` |
| |
| |
| |
| ExpiresAfter *string `json:"expires_after,omitempty"` |
| |
| |
| |
| |
| Key *string `json:"key,omitempty"` |
| } |
|
|
| |
| type CreateCustomerRequest struct { |
| |
| |
| |
| Name string `json:"name"` |
| |
| |
| |
| Description *string `json:"description,omitempty"` |
| Labels *map[string]string `json:"labels,omitempty"` |
| Key string `json:"key"` |
| |
| UsageAttribution *CustomerUsageAttribution `json:"usage_attribution,omitempty"` |
| |
| PrimaryEmail *string `json:"primary_email,omitempty"` |
| |
| Currency *string `json:"currency,omitempty"` |
| |
| BillingAddress *Address `json:"billing_address,omitempty"` |
| } |
|
|
| |
| |
| |
| |
| |
| |
| type CreditAdjustment struct { |
| |
| |
| |
| Name string `json:"name"` |
| |
| |
| |
| Description *string `json:"description,omitempty"` |
| Labels map[string]string `json:"labels,omitempty"` |
| } |
|
|
| |
| |
| |
| |
| |
| type CreditAvailabilityPolicy string |
|
|
| const ( |
| CreditAvailabilityPolicyOnCreation CreditAvailabilityPolicy = "on_creation" |
| ) |
|
|
| func (value CreditAvailabilityPolicy) Valid() bool { |
| switch value { |
| case CreditAvailabilityPolicyOnCreation: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| type CreditBalance struct { |
| Currency BillingCurrencyCode `json:"currency"` |
| |
| Live Numeric `json:"live"` |
| |
| Settled Numeric `json:"settled"` |
| |
| |
| Pending Numeric `json:"pending"` |
| } |
|
|
| |
| type CreditBalances struct { |
| |
| RetrievedAt time.Time `json:"retrieved_at"` |
| |
| Balances []CreditBalance `json:"balances"` |
| } |
|
|
| |
| |
| |
| |
| |
| |
| type CreditFundingMethod string |
|
|
| const ( |
| CreditFundingMethodNone CreditFundingMethod = "none" |
| CreditFundingMethodInvoice CreditFundingMethod = "invoice" |
| CreditFundingMethodExternal CreditFundingMethod = "external" |
| ) |
|
|
| func (value CreditFundingMethod) Valid() bool { |
| switch value { |
| case CreditFundingMethodNone, CreditFundingMethodInvoice, CreditFundingMethodExternal: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| |
| |
| |
| type CreditGrant struct { |
| ID string `json:"id"` |
| |
| |
| |
| Name string `json:"name"` |
| |
| |
| |
| Description *string `json:"description,omitempty"` |
| Labels map[string]string `json:"labels,omitempty"` |
| |
| CreatedAt time.Time `json:"created_at"` |
| |
| UpdatedAt time.Time `json:"updated_at"` |
| |
| DeletedAt *time.Time `json:"deleted_at,omitempty"` |
| |
| FundingMethod CreditFundingMethod `json:"funding_method"` |
| |
| Currency BillingCurrencyCode `json:"currency"` |
| |
| Amount Numeric `json:"amount"` |
| |
| Purchase *CreditGrantPurchase `json:"purchase,omitempty"` |
| |
| |
| |
| |
| |
| |
| TaxConfig *CreditGrantTaxConfig `json:"tax_config,omitempty"` |
| |
| Invoice *CreditGrantInvoiceReference `json:"invoice,omitempty"` |
| Filters *CreditGrantFilters `json:"filters,omitempty"` |
| |
| Priority *int16 `json:"priority,omitempty"` |
| |
| |
| |
| EffectiveAt *time.Time `json:"effective_at,omitempty"` |
| |
| |
| |
| |
| Key *string `json:"key,omitempty"` |
| |
| |
| |
| ExpiresAt *time.Time `json:"expires_at,omitempty"` |
| |
| VoidedAt *time.Time `json:"voided_at,omitempty"` |
| |
| Status CreditGrantStatus `json:"status"` |
| } |
|
|
| |
| type CreditGrantFilters struct { |
| |
| |
| Features []string `json:"features,omitempty"` |
| } |
|
|
| |
| type CreditGrantInvoiceReference struct { |
| |
| ID *string `json:"id,omitempty"` |
| |
| Line *CreditGrantInvoiceReferenceLine `json:"line,omitempty"` |
| } |
|
|
| type CreditGrantInvoiceReferenceLine struct { |
| ID string `json:"id"` |
| } |
|
|
| |
| type CreditGrantPagePaginatedResponse struct { |
| Data []CreditGrant `json:"data"` |
| Meta PaginatedMeta `json:"meta"` |
| } |
|
|
| |
| type CreditGrantPurchase struct { |
| |
| Currency string `json:"currency"` |
| |
| |
| |
| |
| |
| |
| |
| PerUnitCostBasis *Numeric `json:"per_unit_cost_basis,omitempty"` |
| |
| Amount Numeric `json:"amount"` |
| |
| |
| |
| AvailabilityPolicy *CreditAvailabilityPolicy `json:"availability_policy,omitempty"` |
| |
| SettlementStatus *CreditPurchasePaymentSettlementStatus `json:"settlement_status,omitempty"` |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| type CreditGrantStatus string |
|
|
| const ( |
| CreditGrantStatusPending CreditGrantStatus = "pending" |
| CreditGrantStatusActive CreditGrantStatus = "active" |
| CreditGrantStatusExpired CreditGrantStatus = "expired" |
| CreditGrantStatusVoided CreditGrantStatus = "voided" |
| ) |
|
|
| func (value CreditGrantStatus) Valid() bool { |
| switch value { |
| case CreditGrantStatusPending, CreditGrantStatusActive, CreditGrantStatusExpired, CreditGrantStatusVoided: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| |
| |
| |
| type CreditGrantTaxConfig struct { |
| |
| Behavior *TaxBehavior `json:"behavior,omitempty"` |
| |
| TaxCode *TaxCodeReference `json:"tax_code,omitempty"` |
| } |
|
|
| |
| |
| |
| |
| type CreditGrantVoidPaymentAdjustment string |
|
|
| const ( |
| CreditGrantVoidPaymentAdjustmentNone CreditGrantVoidPaymentAdjustment = "none" |
| ) |
|
|
| func (value CreditGrantVoidPaymentAdjustment) Valid() bool { |
| switch value { |
| case CreditGrantVoidPaymentAdjustmentNone: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| |
| |
| |
| |
| type CreditPurchasePaymentSettlementStatus string |
|
|
| const ( |
| CreditPurchasePaymentSettlementStatusPending CreditPurchasePaymentSettlementStatus = "pending" |
| CreditPurchasePaymentSettlementStatusAuthorized CreditPurchasePaymentSettlementStatus = "authorized" |
| CreditPurchasePaymentSettlementStatusSettled CreditPurchasePaymentSettlementStatus = "settled" |
| ) |
|
|
| func (value CreditPurchasePaymentSettlementStatus) Valid() bool { |
| switch value { |
| case CreditPurchasePaymentSettlementStatusPending, CreditPurchasePaymentSettlementStatusAuthorized, CreditPurchasePaymentSettlementStatusSettled: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| |
| |
| |
| type CreditTransaction struct { |
| ID string `json:"id"` |
| |
| |
| |
| Name string `json:"name"` |
| |
| |
| |
| Description *string `json:"description,omitempty"` |
| Labels map[string]string `json:"labels,omitempty"` |
| |
| CreatedAt time.Time `json:"created_at"` |
| |
| BookedAt time.Time `json:"booked_at"` |
| |
| Type CreditTransactionType `json:"type"` |
| |
| Currency BillingCurrencyCode `json:"currency"` |
| |
| |
| Amount Numeric `json:"amount"` |
| |
| AvailableBalance CreditTransactionAvailableBalance `json:"available_balance"` |
| } |
|
|
| type CreditTransactionAvailableBalance struct { |
| Before Numeric `json:"before"` |
| After Numeric `json:"after"` |
| } |
|
|
| |
| type CreditTransactionPaginatedResponse struct { |
| Data []CreditTransaction `json:"data"` |
| Meta CursorMeta `json:"meta"` |
| } |
|
|
| |
| |
| |
| |
| |
| |
| type CreditTransactionType string |
|
|
| const ( |
| CreditTransactionTypeFunded CreditTransactionType = "funded" |
| CreditTransactionTypeConsumed CreditTransactionType = "consumed" |
| CreditTransactionTypeExpired CreditTransactionType = "expired" |
| CreditTransactionTypeVoided CreditTransactionType = "voided" |
| ) |
|
|
| func (value CreditTransactionType) Valid() bool { |
| switch value { |
| case CreditTransactionTypeFunded, CreditTransactionTypeConsumed, CreditTransactionTypeExpired, CreditTransactionTypeVoided: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| type CurrencyAmount struct { |
| Amount Numeric `json:"amount"` |
| Currency string `json:"currency"` |
| } |
|
|
| |
| type CustomerData struct { |
| |
| |
| |
| BillingProfile *ProfileReference `json:"billing_profile,omitempty"` |
| |
| AppData *AppCustomerData `json:"app_data,omitempty"` |
| } |
|
|
| |
| type CustomerPagePaginatedResponse struct { |
| Data []Customer `json:"data"` |
| Meta PaginatedMeta `json:"meta"` |
| } |
|
|
| |
| |
| |
| |
| |
| type CustomerStripeCreateCheckoutSessionRequest struct { |
| |
| |
| |
| |
| StripeOptions AppStripeCreateCheckoutSessionRequestOptions `json:"stripe_options"` |
| } |
|
|
| |
| |
| |
| |
| |
| |
| type CustomerStripeCreateCustomerPortalSessionRequest struct { |
| |
| StripeOptions AppStripeCreateCustomerPortalSessionOptions `json:"stripe_options"` |
| } |
|
|
| |
| type RateCardProrationConfiguration struct { |
| |
| Mode RateCardProrationMode `json:"mode"` |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| type RateCardProrationMode string |
|
|
| const ( |
| RateCardProrationModeNoProration RateCardProrationMode = "no_proration" |
| RateCardProrationModeProratePrices RateCardProrationMode = "prorate_prices" |
| ) |
|
|
| func (value RateCardProrationMode) Valid() bool { |
| switch value { |
| case RateCardProrationModeNoProration, RateCardProrationModeProratePrices: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| |
| type UpdateCreditGrantExternalSettlementRequest struct { |
| |
| Status CreditPurchasePaymentSettlementStatus `json:"status"` |
| } |
|
|
| |
| type UpsertAppCustomerDataRequest struct { |
| |
| Stripe *AppCustomerDataStripeInput `json:"stripe,omitempty"` |
| |
| ExternalInvoicing *AppCustomerDataExternalInvoicingInput `json:"external_invoicing,omitempty"` |
| } |
|
|
| |
| type UpsertCustomerBillingDataRequest struct { |
| |
| |
| |
| BillingProfile *ProfileReference `json:"billing_profile,omitempty"` |
| |
| AppData *AppCustomerDataInput `json:"app_data,omitempty"` |
| } |
|
|
| |
| type UpsertCustomerRequest struct { |
| |
| |
| |
| Name string `json:"name"` |
| |
| |
| |
| Description *string `json:"description,omitempty"` |
| Labels *map[string]string `json:"labels,omitempty"` |
| |
| UsageAttribution *CustomerUsageAttribution `json:"usage_attribution,omitempty"` |
| |
| PrimaryEmail *string `json:"primary_email,omitempty"` |
| |
| Currency *string `json:"currency,omitempty"` |
| |
| BillingAddress *Address `json:"billing_address,omitempty"` |
| } |
|
|
| |
| type VoidCreditGrantRequest struct { |
| |
| |
| |
| |
| |
| PaymentAdjustment *CreditGrantVoidPaymentAdjustment `json:"payment_adjustment,omitempty"` |
| } |
|
|