| |
|
|
| package openmeter |
|
|
| import ( |
| "encoding/json" |
| "fmt" |
| "time" |
| ) |
|
|
| |
| type AddonReference struct { |
| ID string `json:"id"` |
| } |
|
|
| |
| type Address struct { |
| |
| |
| Country *string `json:"country,omitempty"` |
| |
| PostalCode *string `json:"postal_code,omitempty"` |
| |
| State *string `json:"state,omitempty"` |
| |
| City *string `json:"city,omitempty"` |
| |
| Line1 *string `json:"line1,omitempty"` |
| |
| Line2 *string `json:"line2,omitempty"` |
| |
| PhoneNumber *string `json:"phone_number,omitempty"` |
| } |
|
|
| |
| type AppReference struct { |
| |
| ID string `json:"id"` |
| } |
|
|
| |
| type AppType string |
|
|
| const ( |
| AppTypeSandbox AppType = "sandbox" |
| AppTypeStripe AppType = "stripe" |
| AppTypeExternalInvoicing AppType = "external_invoicing" |
| ) |
|
|
| func (value AppType) Valid() bool { |
| switch value { |
| case AppTypeSandbox, AppTypeStripe, AppTypeExternalInvoicing: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| type BillingCurrencyCode string |
|
|
| |
| |
| |
| type ClosedPeriod struct { |
| |
| |
| |
| From time.Time `json:"from"` |
| |
| |
| |
| To time.Time `json:"to"` |
| } |
|
|
| |
| |
| type CollectionMethod string |
|
|
| const ( |
| CollectionMethodChargeAutomatically CollectionMethod = "charge_automatically" |
| CollectionMethodSendInvoice CollectionMethod = "send_invoice" |
| ) |
|
|
| func (value CollectionMethod) Valid() bool { |
| switch value { |
| case CollectionMethodChargeAutomatically, CollectionMethodSendInvoice: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| type CursorMeta struct { |
| |
| Page CursorMetaPage `json:"page"` |
| } |
|
|
| |
| type CursorMetaPage struct { |
| |
| First *string `json:"first,omitempty"` |
| |
| Last *string `json:"last,omitempty"` |
| |
| Next Nullable[string] `json:"next"` |
| |
| Previous Nullable[string] `json:"previous"` |
| |
| Size int64 `json:"size"` |
| } |
|
|
| |
| type CursorPaginationQueryPage struct { |
| |
| Size *int64 `json:"size,omitempty"` |
| |
| After *string `json:"after,omitempty"` |
| |
| Before *string `json:"before,omitempty"` |
| } |
|
|
| |
| |
| type Customer 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"` |
| 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 CustomerUsageAttribution struct { |
| |
| |
| SubjectKeys []string `json:"subject_keys"` |
| } |
|
|
| |
| type EntitlementType string |
|
|
| const ( |
| EntitlementTypeMetered EntitlementType = "metered" |
| EntitlementTypeStatic EntitlementType = "static" |
| EntitlementTypeBoolean EntitlementType = "boolean" |
| ) |
|
|
| func (value EntitlementType) Valid() bool { |
| switch value { |
| case EntitlementTypeMetered, EntitlementTypeStatic, EntitlementTypeBoolean: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| type FeatureReference struct { |
| ID string `json:"id"` |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| type LifecycleController string |
|
|
| const ( |
| LifecycleControllerSystem LifecycleController = "system" |
| LifecycleControllerManual LifecycleController = "manual" |
| ) |
|
|
| func (value LifecycleController) Valid() bool { |
| switch value { |
| case LifecycleControllerSystem, LifecycleControllerManual: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| type MeterQueryFilters struct { |
| |
| |
| Dimensions *map[string]QueryFilterStringMapItemInput `json:"dimensions,omitempty"` |
| } |
|
|
| |
| |
| type MeterQueryGranularity string |
|
|
| const ( |
| MeterQueryGranularityMinute MeterQueryGranularity = "PT1M" |
| MeterQueryGranularityHour MeterQueryGranularity = "PT1H" |
| MeterQueryGranularityDay MeterQueryGranularity = "P1D" |
| MeterQueryGranularityMonth MeterQueryGranularity = "P1M" |
| ) |
|
|
| func (value MeterQueryGranularity) Valid() bool { |
| switch value { |
| case MeterQueryGranularityMinute, MeterQueryGranularityHour, MeterQueryGranularityDay, MeterQueryGranularityMonth: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| type MeterQueryRequest struct { |
| |
| From *time.Time `json:"from,omitempty"` |
| |
| To *time.Time `json:"to,omitempty"` |
| |
| |
| Granularity *MeterQueryGranularity `json:"granularity,omitempty"` |
| |
| |
| |
| TimeZone *string `json:"time_zone,omitempty"` |
| |
| GroupByDimensions *[]string `json:"group_by_dimensions,omitempty"` |
| |
| Filters *MeterQueryFilters `json:"filters,omitempty"` |
| } |
|
|
| |
| type PartyAddresses struct { |
| |
| BillingAddress Address `json:"billing_address"` |
| } |
|
|
| |
| |
| type PartyTaxIdentity struct { |
| |
| Code *string `json:"code,omitempty"` |
| } |
|
|
| |
| |
| |
| |
| type Price struct { |
| Type string `json:"type"` |
| raw json.RawMessage |
| } |
|
|
| func (u *Price) 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 Price) MarshalJSON() ([]byte, error) { |
| if len(u.raw) == 0 { |
| return []byte("null"), nil |
| } |
| return append([]byte(nil), u.raw...), nil |
| } |
|
|
| func (u Price) AsPriceFree() (*PriceFree, error) { |
| if u.Type != "free" { |
| return nil, fmt.Errorf("Price: expected type %q, got %q", "free", u.Type) |
| } |
| var value PriceFree |
| if err := json.Unmarshal(u.raw, &value); err != nil { |
| return nil, err |
| } |
| return &value, nil |
| } |
|
|
| func PriceFromPriceFree(value PriceFree) (Price, error) { |
| value.Type = "free" |
| raw, err := json.Marshal(value) |
| if err != nil { |
| return Price{}, err |
| } |
| var result Price |
| if err := result.UnmarshalJSON(raw); err != nil { |
| return Price{}, err |
| } |
| return result, nil |
| } |
|
|
| func (u Price) AsPriceFlat() (*PriceFlat, error) { |
| if u.Type != "flat" { |
| return nil, fmt.Errorf("Price: expected type %q, got %q", "flat", u.Type) |
| } |
| var value PriceFlat |
| if err := json.Unmarshal(u.raw, &value); err != nil { |
| return nil, err |
| } |
| return &value, nil |
| } |
|
|
| func PriceFromPriceFlat(value PriceFlat) (Price, error) { |
| value.Type = "flat" |
| raw, err := json.Marshal(value) |
| if err != nil { |
| return Price{}, err |
| } |
| var result Price |
| if err := result.UnmarshalJSON(raw); err != nil { |
| return Price{}, err |
| } |
| return result, nil |
| } |
|
|
| func (u Price) AsPriceUnit() (*PriceUnit, error) { |
| if u.Type != "unit" { |
| return nil, fmt.Errorf("Price: expected type %q, got %q", "unit", u.Type) |
| } |
| var value PriceUnit |
| if err := json.Unmarshal(u.raw, &value); err != nil { |
| return nil, err |
| } |
| return &value, nil |
| } |
|
|
| func PriceFromPriceUnit(value PriceUnit) (Price, error) { |
| value.Type = "unit" |
| raw, err := json.Marshal(value) |
| if err != nil { |
| return Price{}, err |
| } |
| var result Price |
| if err := result.UnmarshalJSON(raw); err != nil { |
| return Price{}, err |
| } |
| return result, nil |
| } |
|
|
| func (u Price) AsPriceGraduated() (*PriceGraduated, error) { |
| if u.Type != "graduated" { |
| return nil, fmt.Errorf("Price: expected type %q, got %q", "graduated", u.Type) |
| } |
| var value PriceGraduated |
| if err := json.Unmarshal(u.raw, &value); err != nil { |
| return nil, err |
| } |
| return &value, nil |
| } |
|
|
| func PriceFromPriceGraduated(value PriceGraduated) (Price, error) { |
| value.Type = "graduated" |
| raw, err := json.Marshal(value) |
| if err != nil { |
| return Price{}, err |
| } |
| var result Price |
| if err := result.UnmarshalJSON(raw); err != nil { |
| return Price{}, err |
| } |
| return result, nil |
| } |
|
|
| func (u Price) AsPriceVolume() (*PriceVolume, error) { |
| if u.Type != "volume" { |
| return nil, fmt.Errorf("Price: expected type %q, got %q", "volume", u.Type) |
| } |
| var value PriceVolume |
| if err := json.Unmarshal(u.raw, &value); err != nil { |
| return nil, err |
| } |
| return &value, nil |
| } |
|
|
| func PriceFromPriceVolume(value PriceVolume) (Price, error) { |
| value.Type = "volume" |
| raw, err := json.Marshal(value) |
| if err != nil { |
| return Price{}, err |
| } |
| var result Price |
| if err := result.UnmarshalJSON(raw); err != nil { |
| return Price{}, err |
| } |
| return result, nil |
| } |
|
|
| |
| type PriceFlat struct { |
| |
| Type PriceType `json:"type"` |
| |
| Amount Numeric `json:"amount"` |
| } |
|
|
| |
| type PriceFree struct { |
| |
| Type PriceType `json:"type"` |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| type PriceGraduated struct { |
| |
| Type PriceType `json:"type"` |
| |
| Tiers []PriceTier `json:"tiers"` |
| } |
|
|
| |
| type PricePaymentTerm string |
|
|
| const ( |
| PricePaymentTermInAdvance PricePaymentTerm = "in_advance" |
| PricePaymentTermInArrears PricePaymentTerm = "in_arrears" |
| ) |
|
|
| func (value PricePaymentTerm) Valid() bool { |
| switch value { |
| case PricePaymentTermInAdvance, PricePaymentTermInArrears: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| |
| |
| |
| |
| type PriceTier struct { |
| |
| |
| UpToAmount *Numeric `json:"up_to_amount,omitempty"` |
| |
| FlatPrice *PriceFlat `json:"flat_price,omitempty"` |
| |
| UnitPrice *PriceUnit `json:"unit_price,omitempty"` |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| type PriceType string |
|
|
| const ( |
| PriceTypeFree PriceType = "free" |
| PriceTypeFlat PriceType = "flat" |
| PriceTypeUnit PriceType = "unit" |
| PriceTypeGraduated PriceType = "graduated" |
| PriceTypeVolume PriceType = "volume" |
| ) |
|
|
| func (value PriceType) Valid() bool { |
| switch value { |
| case PriceTypeFree, PriceTypeFlat, PriceTypeUnit, PriceTypeGraduated, PriceTypeVolume: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| |
| |
| |
| type PriceUnit struct { |
| |
| Type PriceType `json:"type"` |
| |
| Amount Numeric `json:"amount"` |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| type PriceVolume struct { |
| |
| Type PriceType `json:"type"` |
| |
| Tiers []PriceTier `json:"tiers"` |
| } |
|
|
| |
| type ProductCatalogValidationError struct { |
| |
| Code string `json:"code"` |
| |
| Message string `json:"message"` |
| |
| Attributes map[string]any `json:"attributes,omitempty"` |
| |
| Field string `json:"field"` |
| } |
|
|
| |
| type ProfileReference struct { |
| |
| ID string `json:"id"` |
| } |
|
|
| |
| |
| type QueryFilterString struct { |
| |
| Eq *string `json:"eq,omitempty"` |
| |
| Neq *string `json:"neq,omitempty"` |
| |
| In []string `json:"in,omitempty"` |
| |
| Nin []string `json:"nin,omitempty"` |
| |
| Contains *string `json:"contains,omitempty"` |
| |
| Ncontains *string `json:"ncontains,omitempty"` |
| |
| And []QueryFilterString `json:"and,omitempty"` |
| |
| Or []QueryFilterString `json:"or,omitempty"` |
| } |
|
|
| |
| |
| type QueryFilterStringInput struct { |
| |
| Eq *string `json:"eq,omitempty"` |
| |
| Neq *string `json:"neq,omitempty"` |
| |
| In *[]string `json:"in,omitempty"` |
| |
| Nin *[]string `json:"nin,omitempty"` |
| |
| Contains *string `json:"contains,omitempty"` |
| |
| Ncontains *string `json:"ncontains,omitempty"` |
| |
| And *[]QueryFilterStringInput `json:"and,omitempty"` |
| |
| Or *[]QueryFilterStringInput `json:"or,omitempty"` |
| } |
|
|
| |
| |
| type QueryFilterStringMapItem struct { |
| |
| Exists *bool `json:"exists,omitempty"` |
| |
| Eq *string `json:"eq,omitempty"` |
| |
| Neq *string `json:"neq,omitempty"` |
| |
| In []string `json:"in,omitempty"` |
| |
| Nin []string `json:"nin,omitempty"` |
| |
| Contains *string `json:"contains,omitempty"` |
| |
| Ncontains *string `json:"ncontains,omitempty"` |
| |
| And []QueryFilterString `json:"and,omitempty"` |
| |
| Or []QueryFilterString `json:"or,omitempty"` |
| } |
|
|
| |
| |
| type QueryFilterStringMapItemInput struct { |
| |
| Exists *bool `json:"exists,omitempty"` |
| |
| Eq *string `json:"eq,omitempty"` |
| |
| Neq *string `json:"neq,omitempty"` |
| |
| In *[]string `json:"in,omitempty"` |
| |
| Nin *[]string `json:"nin,omitempty"` |
| |
| Contains *string `json:"contains,omitempty"` |
| |
| Ncontains *string `json:"ncontains,omitempty"` |
| |
| And *[]QueryFilterStringInput `json:"and,omitempty"` |
| |
| Or *[]QueryFilterStringInput `json:"or,omitempty"` |
| } |
|
|
| |
| type RateCard struct { |
| |
| |
| |
| Name string `json:"name"` |
| |
| |
| |
| Description *string `json:"description,omitempty"` |
| Labels map[string]string `json:"labels,omitempty"` |
| Key string `json:"key"` |
| |
| Feature *FeatureReference `json:"feature,omitempty"` |
| |
| |
| BillingCadence *string `json:"billing_cadence,omitempty"` |
| |
| Price Price `json:"price"` |
| |
| |
| |
| |
| |
| |
| |
| |
| UnitConfig *UnitConfig `json:"unit_config,omitempty"` |
| |
| |
| PaymentTerm *PricePaymentTerm `json:"payment_term,omitempty"` |
| |
| |
| Commitments *SpendCommitments `json:"commitments,omitempty"` |
| |
| Discounts *RateCardDiscounts `json:"discounts,omitempty"` |
| |
| TaxConfig *RateCardTaxConfig `json:"tax_config,omitempty"` |
| |
| |
| Entitlement *RateCardEntitlement `json:"entitlement,omitempty"` |
| } |
|
|
| |
| type RateCardInput struct { |
| |
| |
| |
| Name string `json:"name"` |
| |
| |
| |
| Description *string `json:"description,omitempty"` |
| Labels *map[string]string `json:"labels,omitempty"` |
| Key string `json:"key"` |
| |
| Feature *FeatureReference `json:"feature,omitempty"` |
| |
| |
| BillingCadence *string `json:"billing_cadence,omitempty"` |
| |
| Price Price `json:"price"` |
| |
| |
| |
| |
| |
| |
| |
| |
| UnitConfig *UnitConfig `json:"unit_config,omitempty"` |
| |
| |
| PaymentTerm *PricePaymentTerm `json:"payment_term,omitempty"` |
| |
| |
| Commitments *SpendCommitments `json:"commitments,omitempty"` |
| |
| Discounts *RateCardDiscounts `json:"discounts,omitempty"` |
| |
| TaxConfig *RateCardTaxConfig `json:"tax_config,omitempty"` |
| |
| |
| Entitlement *RateCardEntitlement `json:"entitlement,omitempty"` |
| } |
|
|
| |
| type RateCardBooleanEntitlement struct { |
| |
| Type EntitlementType `json:"type"` |
| } |
|
|
| |
| type RateCardDiscounts struct { |
| |
| Percentage *float64 `json:"percentage,omitempty"` |
| |
| |
| |
| Usage *Numeric `json:"usage,omitempty"` |
| } |
|
|
| |
| |
| |
| |
| |
| type RateCardEntitlement struct { |
| Type string `json:"type"` |
| raw json.RawMessage |
| } |
|
|
| func (u *RateCardEntitlement) 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 RateCardEntitlement) MarshalJSON() ([]byte, error) { |
| if len(u.raw) == 0 { |
| return []byte("null"), nil |
| } |
| return append([]byte(nil), u.raw...), nil |
| } |
|
|
| func (u RateCardEntitlement) AsRateCardMeteredEntitlement() (*RateCardMeteredEntitlement, error) { |
| if u.Type != "metered" { |
| return nil, fmt.Errorf("RateCardEntitlement: expected type %q, got %q", "metered", u.Type) |
| } |
| var value RateCardMeteredEntitlement |
| if err := json.Unmarshal(u.raw, &value); err != nil { |
| return nil, err |
| } |
| return &value, nil |
| } |
|
|
| func RateCardEntitlementFromRateCardMeteredEntitlement(value RateCardMeteredEntitlement) (RateCardEntitlement, error) { |
| value.Type = "metered" |
| raw, err := json.Marshal(value) |
| if err != nil { |
| return RateCardEntitlement{}, err |
| } |
| var result RateCardEntitlement |
| if err := result.UnmarshalJSON(raw); err != nil { |
| return RateCardEntitlement{}, err |
| } |
| return result, nil |
| } |
|
|
| func (u RateCardEntitlement) AsRateCardStaticEntitlement() (*RateCardStaticEntitlement, error) { |
| if u.Type != "static" { |
| return nil, fmt.Errorf("RateCardEntitlement: expected type %q, got %q", "static", u.Type) |
| } |
| var value RateCardStaticEntitlement |
| if err := json.Unmarshal(u.raw, &value); err != nil { |
| return nil, err |
| } |
| return &value, nil |
| } |
|
|
| func RateCardEntitlementFromRateCardStaticEntitlement(value RateCardStaticEntitlement) (RateCardEntitlement, error) { |
| value.Type = "static" |
| raw, err := json.Marshal(value) |
| if err != nil { |
| return RateCardEntitlement{}, err |
| } |
| var result RateCardEntitlement |
| if err := result.UnmarshalJSON(raw); err != nil { |
| return RateCardEntitlement{}, err |
| } |
| return result, nil |
| } |
|
|
| func (u RateCardEntitlement) AsRateCardBooleanEntitlement() (*RateCardBooleanEntitlement, error) { |
| if u.Type != "boolean" { |
| return nil, fmt.Errorf("RateCardEntitlement: expected type %q, got %q", "boolean", u.Type) |
| } |
| var value RateCardBooleanEntitlement |
| if err := json.Unmarshal(u.raw, &value); err != nil { |
| return nil, err |
| } |
| return &value, nil |
| } |
|
|
| func RateCardEntitlementFromRateCardBooleanEntitlement(value RateCardBooleanEntitlement) (RateCardEntitlement, error) { |
| value.Type = "boolean" |
| raw, err := json.Marshal(value) |
| if err != nil { |
| return RateCardEntitlement{}, err |
| } |
| var result RateCardEntitlement |
| if err := result.UnmarshalJSON(raw); err != nil { |
| return RateCardEntitlement{}, err |
| } |
| return result, nil |
| } |
|
|
| |
| type RateCardMeteredEntitlement struct { |
| |
| Type EntitlementType `json:"type"` |
| |
| |
| IsSoftLimit *bool `json:"is_soft_limit,omitempty"` |
| |
| |
| |
| |
| Limit *float64 `json:"limit,omitempty"` |
| |
| |
| UsagePeriod *string `json:"usage_period,omitempty"` |
| } |
|
|
| |
| type RateCardStaticEntitlement struct { |
| |
| Type EntitlementType `json:"type"` |
| |
| |
| |
| Config any `json:"config"` |
| } |
|
|
| |
| type RateCardTaxConfig struct { |
| Behavior *TaxBehavior `json:"behavior,omitempty"` |
| Code TaxCodeReference `json:"code"` |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| type SettlementMode string |
|
|
| const ( |
| SettlementModeCreditThenInvoice SettlementMode = "credit_then_invoice" |
| SettlementModeCreditOnly SettlementMode = "credit_only" |
| ) |
|
|
| func (value SettlementMode) Valid() bool { |
| switch value { |
| case SettlementModeCreditThenInvoice, SettlementModeCreditOnly: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| |
| type SpendCommitments struct { |
| |
| MinimumAmount *Numeric `json:"minimum_amount,omitempty"` |
| |
| MaximumAmount *Numeric `json:"maximum_amount,omitempty"` |
| } |
|
|
| |
| |
| type SubscriptionReference struct { |
| |
| ID string `json:"id"` |
| |
| Phase SubscriptionReferencePhase `json:"phase"` |
| } |
|
|
| type SubscriptionReferencePhase struct { |
| |
| ID string `json:"id"` |
| |
| Item SubscriptionReferencePhaseItem `json:"item"` |
| } |
|
|
| type SubscriptionReferencePhaseItem struct { |
| |
| ID string `json:"id"` |
| } |
|
|
| |
| |
| |
| |
| type TaxBehavior string |
|
|
| const ( |
| TaxBehaviorInclusive TaxBehavior = "inclusive" |
| TaxBehaviorExclusive TaxBehavior = "exclusive" |
| ) |
|
|
| func (value TaxBehavior) Valid() bool { |
| switch value { |
| case TaxBehaviorInclusive, TaxBehaviorExclusive: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| type TaxCodeReference struct { |
| ID string `json:"id"` |
| } |
|
|
| |
| type TaxConfig struct { |
| |
| |
| |
| |
| Behavior *TaxBehavior `json:"behavior,omitempty"` |
| |
| Stripe *TaxConfigStripe `json:"stripe,omitempty"` |
| |
| ExternalInvoicing *TaxConfigExternalInvoicing `json:"external_invoicing,omitempty"` |
| |
| TaxCodeID *string `json:"tax_code_id,omitempty"` |
| |
| |
| |
| |
| |
| TaxCode *TaxCodeReference `json:"tax_code,omitempty"` |
| } |
|
|
| |
| type TaxConfigExternalInvoicing struct { |
| |
| Code string `json:"code"` |
| } |
|
|
| |
| type TaxConfigStripe struct { |
| |
| Code string `json:"code"` |
| } |
|
|
| |
| type Totals struct { |
| |
| Amount Numeric `json:"amount"` |
| |
| TaxesTotal Numeric `json:"taxes_total"` |
| |
| TaxesInclusiveTotal Numeric `json:"taxes_inclusive_total"` |
| |
| TaxesExclusiveTotal Numeric `json:"taxes_exclusive_total"` |
| |
| ChargesTotal Numeric `json:"charges_total"` |
| |
| DiscountsTotal Numeric `json:"discounts_total"` |
| |
| CreditsTotal Numeric `json:"credits_total"` |
| |
| Total Numeric `json:"total"` |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| type UnitConfig struct { |
| |
| Operation UnitConfigOperation `json:"operation"` |
| |
| |
| |
| |
| |
| |
| ConversionFactor Numeric `json:"conversion_factor"` |
| |
| |
| |
| |
| Rounding *UnitConfigRoundingMode `json:"rounding,omitempty"` |
| |
| |
| |
| |
| Precision *int64 `json:"precision,omitempty"` |
| |
| |
| |
| |
| DisplayUnit *string `json:"display_unit,omitempty"` |
| } |
|
|
| |
| |
| |
| |
| |
| |
| type UnitConfigOperation string |
|
|
| const ( |
| UnitConfigOperationDivide UnitConfigOperation = "divide" |
| UnitConfigOperationMultiply UnitConfigOperation = "multiply" |
| ) |
|
|
| func (value UnitConfigOperation) Valid() bool { |
| switch value { |
| case UnitConfigOperationDivide, UnitConfigOperationMultiply: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| type UnitConfigRoundingMode string |
|
|
| const ( |
| UnitConfigRoundingModeCeiling UnitConfigRoundingMode = "ceiling" |
| UnitConfigRoundingModeFloor UnitConfigRoundingMode = "floor" |
| UnitConfigRoundingModeHalfUp UnitConfigRoundingMode = "half_up" |
| UnitConfigRoundingModeNone UnitConfigRoundingMode = "none" |
| ) |
|
|
| func (value UnitConfigRoundingMode) Valid() bool { |
| switch value { |
| case UnitConfigRoundingModeCeiling, UnitConfigRoundingModeFloor, UnitConfigRoundingModeHalfUp, UnitConfigRoundingModeNone: |
| return true |
| default: |
| return false |
| } |
| } |
|
|
| |
| |
| type WorkflowPaymentChargeAutomaticallySettings struct { |
| |
| CollectionMethod CollectionMethod `json:"collection_method"` |
| } |
|
|
| |
| |
| type WorkflowPaymentSendInvoiceSettings struct { |
| |
| CollectionMethod CollectionMethod `json:"collection_method"` |
| |
| |
| DueAfter *string `json:"due_after,omitempty"` |
| } |
|
|
| |
| |
| |
| |
| type WorkflowPaymentSettings struct { |
| CollectionMethod string `json:"collection_method"` |
| raw json.RawMessage |
| } |
|
|
| func (u *WorkflowPaymentSettings) UnmarshalJSON(data []byte) error { |
| u.raw = append([]byte(nil), data...) |
| if string(data) == "null" { |
| u.CollectionMethod = "" |
| return nil |
| } |
|
|
| var envelope struct { |
| Value string `json:"collection_method"` |
| } |
| if err := json.Unmarshal(data, &envelope); err != nil { |
| return err |
| } |
| u.CollectionMethod = envelope.Value |
| return nil |
| } |
|
|
| func (u WorkflowPaymentSettings) MarshalJSON() ([]byte, error) { |
| if len(u.raw) == 0 { |
| return []byte("null"), nil |
| } |
| return append([]byte(nil), u.raw...), nil |
| } |
|
|
| func (u WorkflowPaymentSettings) AsWorkflowPaymentChargeAutomaticallySettings() (*WorkflowPaymentChargeAutomaticallySettings, error) { |
| if u.CollectionMethod != "charge_automatically" { |
| return nil, fmt.Errorf("WorkflowPaymentSettings: expected collection_method %q, got %q", "charge_automatically", u.CollectionMethod) |
| } |
| var value WorkflowPaymentChargeAutomaticallySettings |
| if err := json.Unmarshal(u.raw, &value); err != nil { |
| return nil, err |
| } |
| return &value, nil |
| } |
|
|
| func WorkflowPaymentSettingsFromWorkflowPaymentChargeAutomaticallySettings(value WorkflowPaymentChargeAutomaticallySettings) (WorkflowPaymentSettings, error) { |
| value.CollectionMethod = "charge_automatically" |
| raw, err := json.Marshal(value) |
| if err != nil { |
| return WorkflowPaymentSettings{}, err |
| } |
| var result WorkflowPaymentSettings |
| if err := result.UnmarshalJSON(raw); err != nil { |
| return WorkflowPaymentSettings{}, err |
| } |
| return result, nil |
| } |
|
|
| func (u WorkflowPaymentSettings) AsWorkflowPaymentSendInvoiceSettings() (*WorkflowPaymentSendInvoiceSettings, error) { |
| if u.CollectionMethod != "send_invoice" { |
| return nil, fmt.Errorf("WorkflowPaymentSettings: expected collection_method %q, got %q", "send_invoice", u.CollectionMethod) |
| } |
| var value WorkflowPaymentSendInvoiceSettings |
| if err := json.Unmarshal(u.raw, &value); err != nil { |
| return nil, err |
| } |
| return &value, nil |
| } |
|
|
| func WorkflowPaymentSettingsFromWorkflowPaymentSendInvoiceSettings(value WorkflowPaymentSendInvoiceSettings) (WorkflowPaymentSettings, error) { |
| value.CollectionMethod = "send_invoice" |
| raw, err := json.Marshal(value) |
| if err != nil { |
| return WorkflowPaymentSettings{}, err |
| } |
| var result WorkflowPaymentSettings |
| if err := result.UnmarshalJSON(raw); err != nil { |
| return WorkflowPaymentSettings{}, err |
| } |
| return result, nil |
| } |
|
|