diff --git a/billing.go b/billing.go index 7f22232..3a7aafb 100644 --- a/billing.go +++ b/billing.go @@ -119,6 +119,195 @@ type SearchBillingPricesRequest struct { Offset *int `json:"-" url:"offset,omitempty"` } +// The created resource +type BillingCouponResponseData struct { + AccountID string `json:"account_id" url:"account_id"` + AmountOff *int `json:"amount_off,omitempty" url:"amount_off,omitempty"` + Currency *string `json:"currency,omitempty" url:"currency,omitempty"` + Duration *string `json:"duration,omitempty" url:"duration,omitempty"` + DurationInMonths *int `json:"duration_in_months,omitempty" url:"duration_in_months,omitempty"` + EnvironmentID string `json:"environment_id" url:"environment_id"` + ExternalID string `json:"external_id" url:"external_id"` + ID string `json:"id" url:"id"` + IsActive bool `json:"is_active" url:"is_active"` + MaxRedemptions *int `json:"max_redemptions,omitempty" url:"max_redemptions,omitempty"` + Metadata map[string]interface{} `json:"metadata,omitempty" url:"metadata,omitempty"` + Name string `json:"name" url:"name"` + PercentOff *int `json:"percent_off,omitempty" url:"percent_off,omitempty"` + TimesRedeemed int `json:"times_redeemed" url:"times_redeemed"` + ValidFrom *time.Time `json:"valid_from,omitempty" url:"valid_from,omitempty"` + ValidUntil *time.Time `json:"valid_until,omitempty" url:"valid_until,omitempty"` + + extraProperties map[string]interface{} + rawJSON json.RawMessage +} + +func (b *BillingCouponResponseData) GetAccountID() string { + if b == nil { + return "" + } + return b.AccountID +} + +func (b *BillingCouponResponseData) GetAmountOff() *int { + if b == nil { + return nil + } + return b.AmountOff +} + +func (b *BillingCouponResponseData) GetCurrency() *string { + if b == nil { + return nil + } + return b.Currency +} + +func (b *BillingCouponResponseData) GetDuration() *string { + if b == nil { + return nil + } + return b.Duration +} + +func (b *BillingCouponResponseData) GetDurationInMonths() *int { + if b == nil { + return nil + } + return b.DurationInMonths +} + +func (b *BillingCouponResponseData) GetEnvironmentID() string { + if b == nil { + return "" + } + return b.EnvironmentID +} + +func (b *BillingCouponResponseData) GetExternalID() string { + if b == nil { + return "" + } + return b.ExternalID +} + +func (b *BillingCouponResponseData) GetID() string { + if b == nil { + return "" + } + return b.ID +} + +func (b *BillingCouponResponseData) GetIsActive() bool { + if b == nil { + return false + } + return b.IsActive +} + +func (b *BillingCouponResponseData) GetMaxRedemptions() *int { + if b == nil { + return nil + } + return b.MaxRedemptions +} + +func (b *BillingCouponResponseData) GetMetadata() map[string]interface{} { + if b == nil { + return nil + } + return b.Metadata +} + +func (b *BillingCouponResponseData) GetName() string { + if b == nil { + return "" + } + return b.Name +} + +func (b *BillingCouponResponseData) GetPercentOff() *int { + if b == nil { + return nil + } + return b.PercentOff +} + +func (b *BillingCouponResponseData) GetTimesRedeemed() int { + if b == nil { + return 0 + } + return b.TimesRedeemed +} + +func (b *BillingCouponResponseData) GetValidFrom() *time.Time { + if b == nil { + return nil + } + return b.ValidFrom +} + +func (b *BillingCouponResponseData) GetValidUntil() *time.Time { + if b == nil { + return nil + } + return b.ValidUntil +} + +func (b *BillingCouponResponseData) GetExtraProperties() map[string]interface{} { + return b.extraProperties +} + +func (b *BillingCouponResponseData) UnmarshalJSON(data []byte) error { + type embed BillingCouponResponseData + var unmarshaler = struct { + embed + ValidFrom *internal.DateTime `json:"valid_from,omitempty"` + ValidUntil *internal.DateTime `json:"valid_until,omitempty"` + }{ + embed: embed(*b), + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + *b = BillingCouponResponseData(unmarshaler.embed) + b.ValidFrom = unmarshaler.ValidFrom.TimePtr() + b.ValidUntil = unmarshaler.ValidUntil.TimePtr() + extraProperties, err := internal.ExtractExtraProperties(data, *b) + if err != nil { + return err + } + b.extraProperties = extraProperties + b.rawJSON = json.RawMessage(data) + return nil +} + +func (b *BillingCouponResponseData) MarshalJSON() ([]byte, error) { + type embed BillingCouponResponseData + var marshaler = struct { + embed + ValidFrom *internal.DateTime `json:"valid_from,omitempty"` + ValidUntil *internal.DateTime `json:"valid_until,omitempty"` + }{ + embed: embed(*b), + ValidFrom: internal.NewOptionalDateTime(b.ValidFrom), + ValidUntil: internal.NewOptionalDateTime(b.ValidUntil), + } + return json.Marshal(marshaler) +} + +func (b *BillingCouponResponseData) String() string { + if len(b.rawJSON) > 0 { + if value, err := internal.StringifyJSON(b.rawJSON); err == nil { + return value + } + } + if value, err := internal.StringifyJSON(b); err == nil { + return value + } + return fmt.Sprintf("%#v", b) +} + // The created resource type BillingCustomerResponseData struct { CompanyID *string `json:"company_id,omitempty" url:"company_id,omitempty"` @@ -800,143 +989,87 @@ func (b *BillingProductResponseData) String() string { return fmt.Sprintf("%#v", b) } -type BillingSubscriptionResponseData struct { - CompanyID *string `json:"company_id,omitempty" url:"company_id,omitempty"` - CreatedAt time.Time `json:"created_at" url:"created_at"` - Currency string `json:"currency" url:"currency"` - CustomerExternalID string `json:"customer_external_id" url:"customer_external_id"` - ExpiredAt *time.Time `json:"expired_at,omitempty" url:"expired_at,omitempty"` - ID string `json:"id" url:"id"` - Interval string `json:"interval" url:"interval"` - Metadata map[string]interface{} `json:"metadata,omitempty" url:"metadata,omitempty"` - PeriodEnd int `json:"period_end" url:"period_end"` - PeriodStart int `json:"period_start" url:"period_start"` - Status string `json:"status" url:"status"` - SubscriptionExternalID string `json:"subscription_external_id" url:"subscription_external_id"` - TotalPrice int `json:"total_price" url:"total_price"` - TrialEnd *int `json:"trial_end,omitempty" url:"trial_end,omitempty"` +type BillingSubscriptionDiscount struct { + CouponExternalID string `json:"coupon_external_id" url:"coupon_external_id"` + CustomerFacingCode *string `json:"customer_facing_code,omitempty" url:"customer_facing_code,omitempty"` + EndedAt *time.Time `json:"ended_at,omitempty" url:"ended_at,omitempty"` + ExternalID string `json:"external_id" url:"external_id"` + IsActive bool `json:"is_active" url:"is_active"` + PromoCodeExternalID *string `json:"promo_code_external_id,omitempty" url:"promo_code_external_id,omitempty"` + StartedAt time.Time `json:"started_at" url:"started_at"` extraProperties map[string]interface{} rawJSON json.RawMessage } -func (b *BillingSubscriptionResponseData) GetCompanyID() *string { - if b == nil { - return nil - } - return b.CompanyID -} - -func (b *BillingSubscriptionResponseData) GetCreatedAt() time.Time { - if b == nil { - return time.Time{} - } - return b.CreatedAt -} - -func (b *BillingSubscriptionResponseData) GetCurrency() string { - if b == nil { - return "" - } - return b.Currency -} - -func (b *BillingSubscriptionResponseData) GetCustomerExternalID() string { +func (b *BillingSubscriptionDiscount) GetCouponExternalID() string { if b == nil { return "" } - return b.CustomerExternalID + return b.CouponExternalID } -func (b *BillingSubscriptionResponseData) GetExpiredAt() *time.Time { +func (b *BillingSubscriptionDiscount) GetCustomerFacingCode() *string { if b == nil { return nil } - return b.ExpiredAt -} - -func (b *BillingSubscriptionResponseData) GetID() string { - if b == nil { - return "" - } - return b.ID + return b.CustomerFacingCode } -func (b *BillingSubscriptionResponseData) GetInterval() string { - if b == nil { - return "" - } - return b.Interval -} - -func (b *BillingSubscriptionResponseData) GetMetadata() map[string]interface{} { +func (b *BillingSubscriptionDiscount) GetEndedAt() *time.Time { if b == nil { return nil } - return b.Metadata + return b.EndedAt } -func (b *BillingSubscriptionResponseData) GetPeriodEnd() int { - if b == nil { - return 0 - } - return b.PeriodEnd -} - -func (b *BillingSubscriptionResponseData) GetPeriodStart() int { - if b == nil { - return 0 - } - return b.PeriodStart -} - -func (b *BillingSubscriptionResponseData) GetStatus() string { +func (b *BillingSubscriptionDiscount) GetExternalID() string { if b == nil { return "" } - return b.Status + return b.ExternalID } -func (b *BillingSubscriptionResponseData) GetSubscriptionExternalID() string { +func (b *BillingSubscriptionDiscount) GetIsActive() bool { if b == nil { - return "" + return false } - return b.SubscriptionExternalID + return b.IsActive } -func (b *BillingSubscriptionResponseData) GetTotalPrice() int { +func (b *BillingSubscriptionDiscount) GetPromoCodeExternalID() *string { if b == nil { - return 0 + return nil } - return b.TotalPrice + return b.PromoCodeExternalID } -func (b *BillingSubscriptionResponseData) GetTrialEnd() *int { +func (b *BillingSubscriptionDiscount) GetStartedAt() time.Time { if b == nil { - return nil + return time.Time{} } - return b.TrialEnd + return b.StartedAt } -func (b *BillingSubscriptionResponseData) GetExtraProperties() map[string]interface{} { +func (b *BillingSubscriptionDiscount) GetExtraProperties() map[string]interface{} { return b.extraProperties } -func (b *BillingSubscriptionResponseData) UnmarshalJSON(data []byte) error { - type embed BillingSubscriptionResponseData +func (b *BillingSubscriptionDiscount) UnmarshalJSON(data []byte) error { + type embed BillingSubscriptionDiscount var unmarshaler = struct { embed - CreatedAt *internal.DateTime `json:"created_at"` - ExpiredAt *internal.DateTime `json:"expired_at,omitempty"` + EndedAt *internal.DateTime `json:"ended_at,omitempty"` + StartedAt *internal.DateTime `json:"started_at"` }{ embed: embed(*b), } if err := json.Unmarshal(data, &unmarshaler); err != nil { return err } - *b = BillingSubscriptionResponseData(unmarshaler.embed) - b.CreatedAt = unmarshaler.CreatedAt.Time() - b.ExpiredAt = unmarshaler.ExpiredAt.TimePtr() + *b = BillingSubscriptionDiscount(unmarshaler.embed) + b.EndedAt = unmarshaler.EndedAt.TimePtr() + b.StartedAt = unmarshaler.StartedAt.Time() extraProperties, err := internal.ExtractExtraProperties(data, *b) if err != nil { return err @@ -946,21 +1079,21 @@ func (b *BillingSubscriptionResponseData) UnmarshalJSON(data []byte) error { return nil } -func (b *BillingSubscriptionResponseData) MarshalJSON() ([]byte, error) { - type embed BillingSubscriptionResponseData +func (b *BillingSubscriptionDiscount) MarshalJSON() ([]byte, error) { + type embed BillingSubscriptionDiscount var marshaler = struct { embed - CreatedAt *internal.DateTime `json:"created_at"` - ExpiredAt *internal.DateTime `json:"expired_at,omitempty"` + EndedAt *internal.DateTime `json:"ended_at,omitempty"` + StartedAt *internal.DateTime `json:"started_at"` }{ embed: embed(*b), - CreatedAt: internal.NewDateTime(b.CreatedAt), - ExpiredAt: internal.NewOptionalDateTime(b.ExpiredAt), + EndedAt: internal.NewOptionalDateTime(b.EndedAt), + StartedAt: internal.NewDateTime(b.StartedAt), } return json.Marshal(marshaler) } -func (b *BillingSubscriptionResponseData) String() string { +func (b *BillingSubscriptionDiscount) String() string { if len(b.rawJSON) > 0 { if value, err := internal.StringifyJSON(b.rawJSON); err == nil { return value @@ -2355,6 +2488,61 @@ func (s *SearchBillingPricesResponse) String() string { return fmt.Sprintf("%#v", s) } +type UpsertBillingCouponResponse struct { + Data *BillingCouponResponseData `json:"data,omitempty" url:"data,omitempty"` + // Input parameters + Params map[string]interface{} `json:"params,omitempty" url:"params,omitempty"` + + extraProperties map[string]interface{} + rawJSON json.RawMessage +} + +func (u *UpsertBillingCouponResponse) GetData() *BillingCouponResponseData { + if u == nil { + return nil + } + return u.Data +} + +func (u *UpsertBillingCouponResponse) GetParams() map[string]interface{} { + if u == nil { + return nil + } + return u.Params +} + +func (u *UpsertBillingCouponResponse) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *UpsertBillingCouponResponse) UnmarshalJSON(data []byte) error { + type unmarshaler UpsertBillingCouponResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UpsertBillingCouponResponse(value) + extraProperties, err := internal.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + u.rawJSON = json.RawMessage(data) + return nil +} + +func (u *UpsertBillingCouponResponse) String() string { + if len(u.rawJSON) > 0 { + if value, err := internal.StringifyJSON(u.rawJSON); err == nil { + return value + } + } + if value, err := internal.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + type UpsertBillingCustomerResponse struct { Data *BillingCustomerResponseData `json:"data,omitempty" url:"data,omitempty"` // Input parameters @@ -2740,6 +2928,18 @@ func (u *UpsertPaymentMethodResponse) String() string { return fmt.Sprintf("%#v", u) } +type CreateCouponRequestBody struct { + AmountOff int `json:"amount_off" url:"-"` + Currency *string `json:"currency,omitempty" url:"-"` + Duration string `json:"duration" url:"-"` + DurationInMonths int `json:"duration_in_months" url:"-"` + ExternalID string `json:"external_id" url:"-"` + MaxRedemptions int `json:"max_redemptions" url:"-"` + Name string `json:"name" url:"-"` + PercentOff float64 `json:"percent_off" url:"-"` + TimesRedeemed int `json:"times_redeemed" url:"-"` +} + type CreateBillingCustomerRequestBody struct { CompanyID *string `json:"company_id,omitempty" url:"-"` Email string `json:"email" url:"-"` @@ -2775,18 +2975,20 @@ type CreateBillingProductRequestBody struct { } type CreateBillingSubscriptionsRequestBody struct { - Currency string `json:"currency" url:"-"` - CustomerExternalID string `json:"customer_external_id" url:"-"` - ExpiredAt time.Time `json:"expired_at" url:"-"` - Interval *string `json:"interval,omitempty" url:"-"` - Metadata map[string]interface{} `json:"metadata,omitempty" url:"-"` - PeriodEnd *int `json:"period_end,omitempty" url:"-"` - PeriodStart *int `json:"period_start,omitempty" url:"-"` - ProductExternalIDs []*BillingProductPricing `json:"product_external_ids,omitempty" url:"-"` - Status *string `json:"status,omitempty" url:"-"` - SubscriptionExternalID string `json:"subscription_external_id" url:"-"` - TotalPrice int `json:"total_price" url:"-"` - TrialEnd *int `json:"trial_end,omitempty" url:"-"` + Currency string `json:"currency" url:"-"` + CustomerExternalID string `json:"customer_external_id" url:"-"` + Discounts []*BillingSubscriptionDiscount `json:"discounts,omitempty" url:"-"` + ExpiredAt time.Time `json:"expired_at" url:"-"` + Interval *string `json:"interval,omitempty" url:"-"` + Metadata map[string]interface{} `json:"metadata,omitempty" url:"-"` + PeriodEnd *int `json:"period_end,omitempty" url:"-"` + PeriodStart *int `json:"period_start,omitempty" url:"-"` + ProductExternalIDs []*BillingProductPricing `json:"product_external_ids,omitempty" url:"-"` + Status *string `json:"status,omitempty" url:"-"` + SubscriptionExternalID string `json:"subscription_external_id" url:"-"` + TotalPrice int `json:"total_price" url:"-"` + TrialEnd *int `json:"trial_end,omitempty" url:"-"` + TrialEndSetting *string `json:"trial_end_setting,omitempty" url:"-"` } func (c *CreateBillingSubscriptionsRequestBody) UnmarshalJSON(data []byte) error { diff --git a/billing/client.go b/billing/client.go index 1cbda87..a5947b5 100644 --- a/billing/client.go +++ b/billing/client.go @@ -31,6 +31,67 @@ func NewClient(opts ...option.RequestOption) *Client { } } +func (c *Client) UpsertBillingCoupon( + ctx context.Context, + request *schematicgo.CreateCouponRequestBody, + opts ...option.RequestOption, +) (*schematicgo.UpsertBillingCouponResponse, error) { + options := core.NewRequestOptions(opts...) + baseURL := internal.ResolveBaseURL( + options.BaseURL, + c.baseURL, + "https://api.schematichq.com", + ) + endpointURL := baseURL + "/billing/coupons" + headers := internal.MergeHeaders( + c.header.Clone(), + options.ToHeader(), + ) + headers.Set("Content-Type", "application/json") + errorCodes := internal.ErrorCodes{ + 400: func(apiError *core.APIError) error { + return &schematicgo.BadRequestError{ + APIError: apiError, + } + }, + 401: func(apiError *core.APIError) error { + return &schematicgo.UnauthorizedError{ + APIError: apiError, + } + }, + 403: func(apiError *core.APIError) error { + return &schematicgo.ForbiddenError{ + APIError: apiError, + } + }, + 500: func(apiError *core.APIError) error { + return &schematicgo.InternalServerError{ + APIError: apiError, + } + }, + } + + var response *schematicgo.UpsertBillingCouponResponse + if err := c.caller.Call( + ctx, + &internal.CallParams{ + URL: endpointURL, + Method: http.MethodPost, + Headers: headers, + MaxAttempts: options.MaxAttempts, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: request, + Response: &response, + ErrorDecoder: internal.NewErrorDecoder(errorCodes), + }, + ); err != nil { + return nil, err + } + return response, nil +} + func (c *Client) UpsertBillingCustomer( ctx context.Context, request *schematicgo.CreateBillingCustomerRequestBody, diff --git a/checkout.go b/checkout.go new file mode 100644 index 0000000..31797fb --- /dev/null +++ b/checkout.go @@ -0,0 +1,528 @@ +// This file was auto-generated by Fern from our API Definition. + +package schematichq + +import ( + json "encoding/json" + fmt "fmt" + internal "github.com/schematichq/schematic-go/internal" + time "time" +) + +type ChangeSubscriptionInternalRequestBody struct { + AddOnIDs []*UpdateAddOnRequestBody `json:"add_on_ids,omitempty" url:"add_on_ids,omitempty"` + CompanyID string `json:"company_id" url:"company_id"` + NewPlanID string `json:"new_plan_id" url:"new_plan_id"` + NewPriceID string `json:"new_price_id" url:"new_price_id"` + PayInAdvance []*UpdatePayInAdvanceRequestBody `json:"pay_in_advance,omitempty" url:"pay_in_advance,omitempty"` + PaymentMethodID *string `json:"payment_method_id,omitempty" url:"payment_method_id,omitempty"` + PromoCode *string `json:"promo_code,omitempty" url:"promo_code,omitempty"` + + extraProperties map[string]interface{} + rawJSON json.RawMessage +} + +func (c *ChangeSubscriptionInternalRequestBody) GetAddOnIDs() []*UpdateAddOnRequestBody { + if c == nil { + return nil + } + return c.AddOnIDs +} + +func (c *ChangeSubscriptionInternalRequestBody) GetCompanyID() string { + if c == nil { + return "" + } + return c.CompanyID +} + +func (c *ChangeSubscriptionInternalRequestBody) GetNewPlanID() string { + if c == nil { + return "" + } + return c.NewPlanID +} + +func (c *ChangeSubscriptionInternalRequestBody) GetNewPriceID() string { + if c == nil { + return "" + } + return c.NewPriceID +} + +func (c *ChangeSubscriptionInternalRequestBody) GetPayInAdvance() []*UpdatePayInAdvanceRequestBody { + if c == nil { + return nil + } + return c.PayInAdvance +} + +func (c *ChangeSubscriptionInternalRequestBody) GetPaymentMethodID() *string { + if c == nil { + return nil + } + return c.PaymentMethodID +} + +func (c *ChangeSubscriptionInternalRequestBody) GetPromoCode() *string { + if c == nil { + return nil + } + return c.PromoCode +} + +func (c *ChangeSubscriptionInternalRequestBody) GetExtraProperties() map[string]interface{} { + return c.extraProperties +} + +func (c *ChangeSubscriptionInternalRequestBody) UnmarshalJSON(data []byte) error { + type unmarshaler ChangeSubscriptionInternalRequestBody + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = ChangeSubscriptionInternalRequestBody(value) + extraProperties, err := internal.ExtractExtraProperties(data, *c) + if err != nil { + return err + } + c.extraProperties = extraProperties + c.rawJSON = json.RawMessage(data) + return nil +} + +func (c *ChangeSubscriptionInternalRequestBody) String() string { + if len(c.rawJSON) > 0 { + if value, err := internal.StringifyJSON(c.rawJSON); err == nil { + return value + } + } + if value, err := internal.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} + +// The requested resource +type PreviewSubscriptionChangeResponseData struct { + AmountOff int `json:"amount_off" url:"amount_off"` + DueNow int `json:"due_now" url:"due_now"` + NewCharges int `json:"new_charges" url:"new_charges"` + PercentOff float64 `json:"percent_off" url:"percent_off"` + PeriodStart time.Time `json:"period_start" url:"period_start"` + PromoCodeApplied bool `json:"promo_code_applied" url:"promo_code_applied"` + Proration int `json:"proration" url:"proration"` + TrialEnd *time.Time `json:"trial_end,omitempty" url:"trial_end,omitempty"` + + extraProperties map[string]interface{} + rawJSON json.RawMessage +} + +func (p *PreviewSubscriptionChangeResponseData) GetAmountOff() int { + if p == nil { + return 0 + } + return p.AmountOff +} + +func (p *PreviewSubscriptionChangeResponseData) GetDueNow() int { + if p == nil { + return 0 + } + return p.DueNow +} + +func (p *PreviewSubscriptionChangeResponseData) GetNewCharges() int { + if p == nil { + return 0 + } + return p.NewCharges +} + +func (p *PreviewSubscriptionChangeResponseData) GetPercentOff() float64 { + if p == nil { + return 0 + } + return p.PercentOff +} + +func (p *PreviewSubscriptionChangeResponseData) GetPeriodStart() time.Time { + if p == nil { + return time.Time{} + } + return p.PeriodStart +} + +func (p *PreviewSubscriptionChangeResponseData) GetPromoCodeApplied() bool { + if p == nil { + return false + } + return p.PromoCodeApplied +} + +func (p *PreviewSubscriptionChangeResponseData) GetProration() int { + if p == nil { + return 0 + } + return p.Proration +} + +func (p *PreviewSubscriptionChangeResponseData) GetTrialEnd() *time.Time { + if p == nil { + return nil + } + return p.TrialEnd +} + +func (p *PreviewSubscriptionChangeResponseData) GetExtraProperties() map[string]interface{} { + return p.extraProperties +} + +func (p *PreviewSubscriptionChangeResponseData) UnmarshalJSON(data []byte) error { + type embed PreviewSubscriptionChangeResponseData + var unmarshaler = struct { + embed + PeriodStart *internal.DateTime `json:"period_start"` + TrialEnd *internal.DateTime `json:"trial_end,omitempty"` + }{ + embed: embed(*p), + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + *p = PreviewSubscriptionChangeResponseData(unmarshaler.embed) + p.PeriodStart = unmarshaler.PeriodStart.Time() + p.TrialEnd = unmarshaler.TrialEnd.TimePtr() + extraProperties, err := internal.ExtractExtraProperties(data, *p) + if err != nil { + return err + } + p.extraProperties = extraProperties + p.rawJSON = json.RawMessage(data) + return nil +} + +func (p *PreviewSubscriptionChangeResponseData) MarshalJSON() ([]byte, error) { + type embed PreviewSubscriptionChangeResponseData + var marshaler = struct { + embed + PeriodStart *internal.DateTime `json:"period_start"` + TrialEnd *internal.DateTime `json:"trial_end,omitempty"` + }{ + embed: embed(*p), + PeriodStart: internal.NewDateTime(p.PeriodStart), + TrialEnd: internal.NewOptionalDateTime(p.TrialEnd), + } + return json.Marshal(marshaler) +} + +func (p *PreviewSubscriptionChangeResponseData) String() string { + if len(p.rawJSON) > 0 { + if value, err := internal.StringifyJSON(p.rawJSON); err == nil { + return value + } + } + if value, err := internal.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type UpdateAddOnRequestBody struct { + AddOnID string `json:"add_on_id" url:"add_on_id"` + PriceID string `json:"price_id" url:"price_id"` + + extraProperties map[string]interface{} + rawJSON json.RawMessage +} + +func (u *UpdateAddOnRequestBody) GetAddOnID() string { + if u == nil { + return "" + } + return u.AddOnID +} + +func (u *UpdateAddOnRequestBody) GetPriceID() string { + if u == nil { + return "" + } + return u.PriceID +} + +func (u *UpdateAddOnRequestBody) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *UpdateAddOnRequestBody) UnmarshalJSON(data []byte) error { + type unmarshaler UpdateAddOnRequestBody + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UpdateAddOnRequestBody(value) + extraProperties, err := internal.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + u.rawJSON = json.RawMessage(data) + return nil +} + +func (u *UpdateAddOnRequestBody) String() string { + if len(u.rawJSON) > 0 { + if value, err := internal.StringifyJSON(u.rawJSON); err == nil { + return value + } + } + if value, err := internal.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type UpdatePayInAdvanceRequestBody struct { + PriceID string `json:"price_id" url:"price_id"` + Quantity int `json:"quantity" url:"quantity"` + + extraProperties map[string]interface{} + rawJSON json.RawMessage +} + +func (u *UpdatePayInAdvanceRequestBody) GetPriceID() string { + if u == nil { + return "" + } + return u.PriceID +} + +func (u *UpdatePayInAdvanceRequestBody) GetQuantity() int { + if u == nil { + return 0 + } + return u.Quantity +} + +func (u *UpdatePayInAdvanceRequestBody) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *UpdatePayInAdvanceRequestBody) UnmarshalJSON(data []byte) error { + type unmarshaler UpdatePayInAdvanceRequestBody + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UpdatePayInAdvanceRequestBody(value) + extraProperties, err := internal.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + u.rawJSON = json.RawMessage(data) + return nil +} + +func (u *UpdatePayInAdvanceRequestBody) String() string { + if len(u.rawJSON) > 0 { + if value, err := internal.StringifyJSON(u.rawJSON); err == nil { + return value + } + } + if value, err := internal.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type CheckoutInternalResponse struct { + Data *BillingSubscriptionResponseData `json:"data,omitempty" url:"data,omitempty"` + // Input parameters + Params map[string]interface{} `json:"params,omitempty" url:"params,omitempty"` + + extraProperties map[string]interface{} + rawJSON json.RawMessage +} + +func (c *CheckoutInternalResponse) GetData() *BillingSubscriptionResponseData { + if c == nil { + return nil + } + return c.Data +} + +func (c *CheckoutInternalResponse) GetParams() map[string]interface{} { + if c == nil { + return nil + } + return c.Params +} + +func (c *CheckoutInternalResponse) GetExtraProperties() map[string]interface{} { + return c.extraProperties +} + +func (c *CheckoutInternalResponse) UnmarshalJSON(data []byte) error { + type unmarshaler CheckoutInternalResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = CheckoutInternalResponse(value) + extraProperties, err := internal.ExtractExtraProperties(data, *c) + if err != nil { + return err + } + c.extraProperties = extraProperties + c.rawJSON = json.RawMessage(data) + return nil +} + +func (c *CheckoutInternalResponse) String() string { + if len(c.rawJSON) > 0 { + if value, err := internal.StringifyJSON(c.rawJSON); err == nil { + return value + } + } + if value, err := internal.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} + +type PreviewCheckoutInternalResponse struct { + Data *PreviewSubscriptionChangeResponseData `json:"data,omitempty" url:"data,omitempty"` + // Input parameters + Params map[string]interface{} `json:"params,omitempty" url:"params,omitempty"` + + extraProperties map[string]interface{} + rawJSON json.RawMessage +} + +func (p *PreviewCheckoutInternalResponse) GetData() *PreviewSubscriptionChangeResponseData { + if p == nil { + return nil + } + return p.Data +} + +func (p *PreviewCheckoutInternalResponse) GetParams() map[string]interface{} { + if p == nil { + return nil + } + return p.Params +} + +func (p *PreviewCheckoutInternalResponse) GetExtraProperties() map[string]interface{} { + return p.extraProperties +} + +func (p *PreviewCheckoutInternalResponse) UnmarshalJSON(data []byte) error { + type unmarshaler PreviewCheckoutInternalResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *p = PreviewCheckoutInternalResponse(value) + extraProperties, err := internal.ExtractExtraProperties(data, *p) + if err != nil { + return err + } + p.extraProperties = extraProperties + p.rawJSON = json.RawMessage(data) + return nil +} + +func (p *PreviewCheckoutInternalResponse) String() string { + if len(p.rawJSON) > 0 { + if value, err := internal.StringifyJSON(p.rawJSON); err == nil { + return value + } + } + if value, err := internal.StringifyJSON(p); err == nil { + return value + } + return fmt.Sprintf("%#v", p) +} + +type UpdateCustomerSubscriptionTrialEndResponse struct { + Data *BillingSubscriptionView `json:"data,omitempty" url:"data,omitempty"` + // Input parameters + Params map[string]interface{} `json:"params,omitempty" url:"params,omitempty"` + + extraProperties map[string]interface{} + rawJSON json.RawMessage +} + +func (u *UpdateCustomerSubscriptionTrialEndResponse) GetData() *BillingSubscriptionView { + if u == nil { + return nil + } + return u.Data +} + +func (u *UpdateCustomerSubscriptionTrialEndResponse) GetParams() map[string]interface{} { + if u == nil { + return nil + } + return u.Params +} + +func (u *UpdateCustomerSubscriptionTrialEndResponse) GetExtraProperties() map[string]interface{} { + return u.extraProperties +} + +func (u *UpdateCustomerSubscriptionTrialEndResponse) UnmarshalJSON(data []byte) error { + type unmarshaler UpdateCustomerSubscriptionTrialEndResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UpdateCustomerSubscriptionTrialEndResponse(value) + extraProperties, err := internal.ExtractExtraProperties(data, *u) + if err != nil { + return err + } + u.extraProperties = extraProperties + u.rawJSON = json.RawMessage(data) + return nil +} + +func (u *UpdateCustomerSubscriptionTrialEndResponse) String() string { + if len(u.rawJSON) > 0 { + if value, err := internal.StringifyJSON(u.rawJSON); err == nil { + return value + } + } + if value, err := internal.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type UpdateTrialEndRequestBody struct { + TrialEnd *time.Time `json:"trial_end,omitempty" url:"-"` +} + +func (u *UpdateTrialEndRequestBody) UnmarshalJSON(data []byte) error { + type unmarshaler UpdateTrialEndRequestBody + var body unmarshaler + if err := json.Unmarshal(data, &body); err != nil { + return err + } + *u = UpdateTrialEndRequestBody(body) + return nil +} + +func (u *UpdateTrialEndRequestBody) MarshalJSON() ([]byte, error) { + type embed UpdateTrialEndRequestBody + var marshaler = struct { + embed + TrialEnd *internal.DateTime `json:"trial_end,omitempty"` + }{ + embed: embed(*u), + TrialEnd: internal.NewOptionalDateTime(u.TrialEnd), + } + return json.Marshal(marshaler) +} diff --git a/checkout/client.go b/checkout/client.go new file mode 100644 index 0000000..df2ae91 --- /dev/null +++ b/checkout/client.go @@ -0,0 +1,225 @@ +// This file was auto-generated by Fern from our API Definition. + +package checkout + +import ( + context "context" + schematicgo "github.com/schematichq/schematic-go" + core "github.com/schematichq/schematic-go/core" + internal "github.com/schematichq/schematic-go/internal" + option "github.com/schematichq/schematic-go/option" + http "net/http" +) + +type Client struct { + baseURL string + caller *internal.Caller + header http.Header +} + +func NewClient(opts ...option.RequestOption) *Client { + options := core.NewRequestOptions(opts...) + return &Client{ + baseURL: options.BaseURL, + caller: internal.NewCaller( + &internal.CallerParams{ + Client: options.HTTPClient, + MaxAttempts: options.MaxAttempts, + }, + ), + header: options.ToHeader(), + } +} + +func (c *Client) Internal( + ctx context.Context, + request *schematicgo.ChangeSubscriptionInternalRequestBody, + opts ...option.RequestOption, +) (*schematicgo.CheckoutInternalResponse, error) { + options := core.NewRequestOptions(opts...) + baseURL := internal.ResolveBaseURL( + options.BaseURL, + c.baseURL, + "https://api.schematichq.com", + ) + endpointURL := baseURL + "/checkout-internal" + headers := internal.MergeHeaders( + c.header.Clone(), + options.ToHeader(), + ) + headers.Set("Content-Type", "application/json") + errorCodes := internal.ErrorCodes{ + 400: func(apiError *core.APIError) error { + return &schematicgo.BadRequestError{ + APIError: apiError, + } + }, + 401: func(apiError *core.APIError) error { + return &schematicgo.UnauthorizedError{ + APIError: apiError, + } + }, + 403: func(apiError *core.APIError) error { + return &schematicgo.ForbiddenError{ + APIError: apiError, + } + }, + 500: func(apiError *core.APIError) error { + return &schematicgo.InternalServerError{ + APIError: apiError, + } + }, + } + + var response *schematicgo.CheckoutInternalResponse + if err := c.caller.Call( + ctx, + &internal.CallParams{ + URL: endpointURL, + Method: http.MethodPost, + Headers: headers, + MaxAttempts: options.MaxAttempts, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: request, + Response: &response, + ErrorDecoder: internal.NewErrorDecoder(errorCodes), + }, + ); err != nil { + return nil, err + } + return response, nil +} + +func (c *Client) PreviewCheckoutInternal( + ctx context.Context, + request *schematicgo.ChangeSubscriptionInternalRequestBody, + opts ...option.RequestOption, +) (*schematicgo.PreviewCheckoutInternalResponse, error) { + options := core.NewRequestOptions(opts...) + baseURL := internal.ResolveBaseURL( + options.BaseURL, + c.baseURL, + "https://api.schematichq.com", + ) + endpointURL := baseURL + "/checkout-internal/preview" + headers := internal.MergeHeaders( + c.header.Clone(), + options.ToHeader(), + ) + headers.Set("Content-Type", "application/json") + errorCodes := internal.ErrorCodes{ + 400: func(apiError *core.APIError) error { + return &schematicgo.BadRequestError{ + APIError: apiError, + } + }, + 401: func(apiError *core.APIError) error { + return &schematicgo.UnauthorizedError{ + APIError: apiError, + } + }, + 403: func(apiError *core.APIError) error { + return &schematicgo.ForbiddenError{ + APIError: apiError, + } + }, + 500: func(apiError *core.APIError) error { + return &schematicgo.InternalServerError{ + APIError: apiError, + } + }, + } + + var response *schematicgo.PreviewCheckoutInternalResponse + if err := c.caller.Call( + ctx, + &internal.CallParams{ + URL: endpointURL, + Method: http.MethodPost, + Headers: headers, + MaxAttempts: options.MaxAttempts, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: request, + Response: &response, + ErrorDecoder: internal.NewErrorDecoder(errorCodes), + }, + ); err != nil { + return nil, err + } + return response, nil +} + +func (c *Client) UpdateCustomerSubscriptionTrialEnd( + ctx context.Context, + // subscription_id + subscriptionID string, + request *schematicgo.UpdateTrialEndRequestBody, + opts ...option.RequestOption, +) (*schematicgo.UpdateCustomerSubscriptionTrialEndResponse, error) { + options := core.NewRequestOptions(opts...) + baseURL := internal.ResolveBaseURL( + options.BaseURL, + c.baseURL, + "https://api.schematichq.com", + ) + endpointURL := internal.EncodeURL( + baseURL+"/subscription/%v/edit-trial-end", + subscriptionID, + ) + headers := internal.MergeHeaders( + c.header.Clone(), + options.ToHeader(), + ) + headers.Set("Content-Type", "application/json") + errorCodes := internal.ErrorCodes{ + 400: func(apiError *core.APIError) error { + return &schematicgo.BadRequestError{ + APIError: apiError, + } + }, + 401: func(apiError *core.APIError) error { + return &schematicgo.UnauthorizedError{ + APIError: apiError, + } + }, + 403: func(apiError *core.APIError) error { + return &schematicgo.ForbiddenError{ + APIError: apiError, + } + }, + 404: func(apiError *core.APIError) error { + return &schematicgo.NotFoundError{ + APIError: apiError, + } + }, + 500: func(apiError *core.APIError) error { + return &schematicgo.InternalServerError{ + APIError: apiError, + } + }, + } + + var response *schematicgo.UpdateCustomerSubscriptionTrialEndResponse + if err := c.caller.Call( + ctx, + &internal.CallParams{ + URL: endpointURL, + Method: http.MethodPut, + Headers: headers, + MaxAttempts: options.MaxAttempts, + BodyProperties: options.BodyProperties, + QueryParameters: options.QueryParameters, + Client: options.HTTPClient, + Request: request, + Response: &response, + ErrorDecoder: internal.NewErrorDecoder(errorCodes), + }, + ); err != nil { + return nil, err + } + return response, nil +} diff --git a/client/client.go b/client/client.go index 2f3e751..90779dc 100644 --- a/client/client.go +++ b/client/client.go @@ -7,6 +7,7 @@ import ( accesstokens "github.com/schematichq/schematic-go/accesstokens" accounts "github.com/schematichq/schematic-go/accounts" billing "github.com/schematichq/schematic-go/billing" + checkout "github.com/schematichq/schematic-go/checkout" companies "github.com/schematichq/schematic-go/companies" components "github.com/schematichq/schematic-go/components" core "github.com/schematichq/schematic-go/core" @@ -30,6 +31,7 @@ type Client struct { Accounts *accounts.Client Features *features.Client Billing *billing.Client + Checkout *checkout.Client Companies *companies.Client Entitlements *entitlements.Client Components *components.Client @@ -55,6 +57,7 @@ func NewClient(opts ...option.RequestOption) *Client { Accounts: accounts.NewClient(opts...), Features: features.NewClient(opts...), Billing: billing.NewClient(opts...), + Checkout: checkout.NewClient(opts...), Companies: companies.NewClient(opts...), Entitlements: entitlements.NewClient(opts...), Components: components.NewClient(opts...), diff --git a/companies.go b/companies.go index 9f900a7..bf24337 100644 --- a/companies.go +++ b/companies.go @@ -10,9 +10,9 @@ import ( ) type CountCompaniesRequest struct { - // Filter companies by multiple company IDs (starts with comp\_) + // Filter companies by multiple company IDs (starts with comp_) IDs []*string `json:"-" url:"ids,omitempty"` - // Filter companies by plan ID (starts with plan\_) + // Filter companies by plan ID (starts with plan_) PlanID *string `json:"-" url:"plan_id,omitempty"` // Search for companies by name, keys or string traits Q *string `json:"-" url:"q,omitempty"` @@ -48,11 +48,11 @@ type CountEntityTraitDefinitionsRequest struct { } type CountUsersRequest struct { - // Filter users by company ID (starts with comp\_) + // Filter users by company ID (starts with comp_) CompanyID *string `json:"-" url:"company_id,omitempty"` - // Filter users by multiple user IDs (starts with user\_) + // Filter users by multiple user IDs (starts with user_) IDs []*string `json:"-" url:"ids,omitempty"` - // Filter users by plan ID (starts with plan\_) + // Filter users by plan ID (starts with plan_) PlanID *string `json:"-" url:"plan_id,omitempty"` // Search for users by name, keys or string traits Q *string `json:"-" url:"q,omitempty"` @@ -102,9 +102,9 @@ type CreateEntityTraitDefinitionRequestBody struct { } type ListCompaniesRequest struct { - // Filter companies by multiple company IDs (starts with comp\_) + // Filter companies by multiple company IDs (starts with comp_) IDs []*string `json:"-" url:"ids,omitempty"` - // Filter companies by plan ID (starts with plan\_) + // Filter companies by plan ID (starts with plan_) PlanID *string `json:"-" url:"plan_id,omitempty"` // Search for companies by name, keys or string traits Q *string `json:"-" url:"q,omitempty"` @@ -149,11 +149,11 @@ type ListEntityTraitDefinitionsRequest struct { } type ListUsersRequest struct { - // Filter users by company ID (starts with comp\_) + // Filter users by company ID (starts with comp_) CompanyID *string `json:"-" url:"company_id,omitempty"` - // Filter users by multiple user IDs (starts with user\_) + // Filter users by multiple user IDs (starts with user_) IDs []*string `json:"-" url:"ids,omitempty"` - // Filter users by plan ID (starts with plan\_) + // Filter users by plan ID (starts with plan_) PlanID *string `json:"-" url:"plan_id,omitempty"` // Search for users by name, keys or string traits Q *string `json:"-" url:"q,omitempty"` @@ -824,13 +824,13 @@ func (u *UpsertUserRequestBody) String() string { // Input parameters type CountCompaniesParams struct { - // Filter companies by multiple company IDs (starts with comp\_) + // Filter companies by multiple company IDs (starts with comp_) IDs []string `json:"ids,omitempty" url:"ids,omitempty"` // Page limit (default 100) Limit *int `json:"limit,omitempty" url:"limit,omitempty"` // Page offset (default 0) Offset *int `json:"offset,omitempty" url:"offset,omitempty"` - // Filter companies by plan ID (starts with plan\_) + // Filter companies by plan ID (starts with plan_) PlanID *string `json:"plan_id,omitempty" url:"plan_id,omitempty"` // Search for companies by name, keys or string traits Q *string `json:"q,omitempty" url:"q,omitempty"` @@ -1417,15 +1417,15 @@ func (c CountEntityTraitDefinitionsResponseParamsTraitType) Ptr() *CountEntityTr // Input parameters type CountUsersParams struct { - // Filter users by company ID (starts with comp\_) + // Filter users by company ID (starts with comp_) CompanyID *string `json:"company_id,omitempty" url:"company_id,omitempty"` - // Filter users by multiple user IDs (starts with user\_) + // Filter users by multiple user IDs (starts with user_) IDs []string `json:"ids,omitempty" url:"ids,omitempty"` // Page limit (default 100) Limit *int `json:"limit,omitempty" url:"limit,omitempty"` // Page offset (default 0) Offset *int `json:"offset,omitempty" url:"offset,omitempty"` - // Filter users by plan ID (starts with plan\_) + // Filter users by plan ID (starts with plan_) PlanID *string `json:"plan_id,omitempty" url:"plan_id,omitempty"` // Search for users by name, keys or string traits Q *string `json:"q,omitempty" url:"q,omitempty"` @@ -2668,13 +2668,13 @@ func (g *GetUserResponse) String() string { // Input parameters type ListCompaniesParams struct { - // Filter companies by multiple company IDs (starts with comp\_) + // Filter companies by multiple company IDs (starts with comp_) IDs []string `json:"ids,omitempty" url:"ids,omitempty"` // Page limit (default 100) Limit *int `json:"limit,omitempty" url:"limit,omitempty"` // Page offset (default 0) Offset *int `json:"offset,omitempty" url:"offset,omitempty"` - // Filter companies by plan ID (starts with plan\_) + // Filter companies by plan ID (starts with plan_) PlanID *string `json:"plan_id,omitempty" url:"plan_id,omitempty"` // Search for companies by name, keys or string traits Q *string `json:"q,omitempty" url:"q,omitempty"` @@ -3393,15 +3393,15 @@ func (l ListEntityTraitDefinitionsResponseParamsTraitType) Ptr() *ListEntityTrai // Input parameters type ListUsersParams struct { - // Filter users by company ID (starts with comp\_) + // Filter users by company ID (starts with comp_) CompanyID *string `json:"company_id,omitempty" url:"company_id,omitempty"` - // Filter users by multiple user IDs (starts with user\_) + // Filter users by multiple user IDs (starts with user_) IDs []string `json:"ids,omitempty" url:"ids,omitempty"` // Page limit (default 100) Limit *int `json:"limit,omitempty" url:"limit,omitempty"` // Page offset (default 0) Offset *int `json:"offset,omitempty" url:"offset,omitempty"` - // Filter users by plan ID (starts with plan\_) + // Filter users by plan ID (starts with plan_) PlanID *string `json:"plan_id,omitempty" url:"plan_id,omitempty"` // Search for users by name, keys or string traits Q *string `json:"q,omitempty" url:"q,omitempty"` diff --git a/components.go b/components.go index a74f4e8..b453db0 100644 --- a/components.go +++ b/components.go @@ -322,6 +322,7 @@ type ComponentPreviewResponseData struct { Invoices []*InvoiceResponseData `json:"invoices,omitempty" url:"invoices,omitempty"` StripeEmbed *StripeEmbedInfo `json:"stripe_embed,omitempty" url:"stripe_embed,omitempty"` Subscription *CompanySubscriptionResponseData `json:"subscription,omitempty" url:"subscription,omitempty"` + TrialPaymentMethodRequired *bool `json:"trial_payment_method_required,omitempty" url:"trial_payment_method_required,omitempty"` UpcomingInvoice *InvoiceResponseData `json:"upcoming_invoice,omitempty" url:"upcoming_invoice,omitempty"` extraProperties map[string]interface{} @@ -398,6 +399,13 @@ func (c *ComponentPreviewResponseData) GetSubscription() *CompanySubscriptionRes return c.Subscription } +func (c *ComponentPreviewResponseData) GetTrialPaymentMethodRequired() *bool { + if c == nil { + return nil + } + return c.TrialPaymentMethodRequired +} + func (c *ComponentPreviewResponseData) GetUpcomingInvoice() *InvoiceResponseData { if c == nil { return nil diff --git a/entitlements.go b/entitlements.go index 99e3f29..e218c28 100644 --- a/entitlements.go +++ b/entitlements.go @@ -10,16 +10,18 @@ import ( ) type CountCompanyOverridesRequest struct { - // Filter company overrides by a single company ID (starting with comp\_) + // Filter company overrides by a single company ID (starting with comp_) CompanyID *string `json:"-" url:"company_id,omitempty"` - // Filter company overrides by multiple company IDs (starting with comp\_) + // Filter company overrides by multiple company IDs (starting with comp_) CompanyIDs []*string `json:"-" url:"company_ids,omitempty"` - // Filter company overrides by a single feature ID (starting with feat\_) + // Filter company overrides by a single feature ID (starting with feat_) FeatureID *string `json:"-" url:"feature_id,omitempty"` - // Filter company overrides by multiple feature IDs (starting with feat\_) + // Filter company overrides by multiple feature IDs (starting with feat_) FeatureIDs []*string `json:"-" url:"feature_ids,omitempty"` - // Filter company overrides by multiple company override IDs (starting with cmov\_) + // Filter company overrides by multiple company override IDs (starting with cmov_) IDs []*string `json:"-" url:"ids,omitempty"` + // Filter company overrides by whether they have not expired + WithoutExpired *bool `json:"-" url:"without_expired,omitempty"` // Search for company overrides by feature or company name Q *string `json:"-" url:"q,omitempty"` // Page limit (default 100) @@ -59,15 +61,15 @@ type CountFeatureUsersRequest struct { } type CountPlanEntitlementsRequest struct { - // Filter plan entitlements by a single feature ID (starting with feat\_) + // Filter plan entitlements by a single feature ID (starting with feat_) FeatureID *string `json:"-" url:"feature_id,omitempty"` - // Filter plan entitlements by multiple feature IDs (starting with feat\_) + // Filter plan entitlements by multiple feature IDs (starting with feat_) FeatureIDs []*string `json:"-" url:"feature_ids,omitempty"` - // Filter plan entitlements by multiple plan entitlement IDs (starting with pltl\_) + // Filter plan entitlements by multiple plan entitlement IDs (starting with pltl_) IDs []*string `json:"-" url:"ids,omitempty"` - // Filter plan entitlements by a single plan ID (starting with plan\_) + // Filter plan entitlements by a single plan ID (starting with plan_) PlanID *string `json:"-" url:"plan_id,omitempty"` - // Filter plan entitlements by multiple plan IDs (starting with plan\_) + // Filter plan entitlements by multiple plan IDs (starting with plan_) PlanIDs []*string `json:"-" url:"plan_ids,omitempty"` // Search for plan entitlements by feature or company name Q *string `json:"-" url:"q,omitempty"` @@ -83,8 +85,6 @@ type CreateCompanyOverrideRequestBody struct { CompanyID string `json:"company_id" url:"-"` ExpirationDate *time.Time `json:"expiration_date,omitempty" url:"-"` FeatureID string `json:"feature_id" url:"-"` - MeteredMonthlyPriceID *string `json:"metered_monthly_price_id,omitempty" url:"-"` - MeteredYearlyPriceID *string `json:"metered_yearly_price_id,omitempty" url:"-"` MetricPeriod *CreateCompanyOverrideRequestBodyMetricPeriod `json:"metric_period,omitempty" url:"-"` MetricPeriodMonthReset *CreateCompanyOverrideRequestBodyMetricPeriodMonthReset `json:"metric_period_month_reset,omitempty" url:"-"` ValueBool *bool `json:"value_bool,omitempty" url:"-"` @@ -117,8 +117,6 @@ func (c *CreateCompanyOverrideRequestBody) MarshalJSON() ([]byte, error) { type CreatePlanEntitlementRequestBody struct { FeatureID string `json:"feature_id" url:"-"` - MeteredMonthlyPriceID *string `json:"metered_monthly_price_id,omitempty" url:"-"` - MeteredYearlyPriceID *string `json:"metered_yearly_price_id,omitempty" url:"-"` MetricPeriod *CreatePlanEntitlementRequestBodyMetricPeriod `json:"metric_period,omitempty" url:"-"` MetricPeriodMonthReset *CreatePlanEntitlementRequestBodyMetricPeriodMonthReset `json:"metric_period_month_reset,omitempty" url:"-"` MonthlyMeteredPriceID *string `json:"monthly_metered_price_id,omitempty" url:"-"` @@ -137,16 +135,18 @@ type GetFeatureUsageByCompanyRequest struct { } type ListCompanyOverridesRequest struct { - // Filter company overrides by a single company ID (starting with comp\_) + // Filter company overrides by a single company ID (starting with comp_) CompanyID *string `json:"-" url:"company_id,omitempty"` - // Filter company overrides by multiple company IDs (starting with comp\_) + // Filter company overrides by multiple company IDs (starting with comp_) CompanyIDs []*string `json:"-" url:"company_ids,omitempty"` - // Filter company overrides by a single feature ID (starting with feat\_) + // Filter company overrides by a single feature ID (starting with feat_) FeatureID *string `json:"-" url:"feature_id,omitempty"` - // Filter company overrides by multiple feature IDs (starting with feat\_) + // Filter company overrides by multiple feature IDs (starting with feat_) FeatureIDs []*string `json:"-" url:"feature_ids,omitempty"` - // Filter company overrides by multiple company override IDs (starting with cmov\_) + // Filter company overrides by multiple company override IDs (starting with cmov_) IDs []*string `json:"-" url:"ids,omitempty"` + // Filter company overrides by whether they have not expired + WithoutExpired *bool `json:"-" url:"without_expired,omitempty"` // Search for company overrides by feature or company name Q *string `json:"-" url:"q,omitempty"` // Page limit (default 100) @@ -186,15 +186,15 @@ type ListFeatureUsersRequest struct { } type ListPlanEntitlementsRequest struct { - // Filter plan entitlements by a single feature ID (starting with feat\_) + // Filter plan entitlements by a single feature ID (starting with feat_) FeatureID *string `json:"-" url:"feature_id,omitempty"` - // Filter plan entitlements by multiple feature IDs (starting with feat\_) + // Filter plan entitlements by multiple feature IDs (starting with feat_) FeatureIDs []*string `json:"-" url:"feature_ids,omitempty"` - // Filter plan entitlements by multiple plan entitlement IDs (starting with pltl\_) + // Filter plan entitlements by multiple plan entitlement IDs (starting with pltl_) IDs []*string `json:"-" url:"ids,omitempty"` - // Filter plan entitlements by a single plan ID (starting with plan\_) + // Filter plan entitlements by a single plan ID (starting with plan_) PlanID *string `json:"-" url:"plan_id,omitempty"` - // Filter plan entitlements by multiple plan IDs (starting with plan\_) + // Filter plan entitlements by multiple plan IDs (starting with plan_) PlanIDs []*string `json:"-" url:"plan_ids,omitempty"` // Search for plan entitlements by feature or company name Q *string `json:"-" url:"q,omitempty"` @@ -413,11 +413,12 @@ type FeatureCompanyResponseData struct { // The maximum amount of usage that is permitted; a null value indicates that unlimited usage is permitted. Allocation *int `json:"allocation,omitempty" url:"allocation,omitempty"` // The type of allocation that is being used. - AllocationType FeatureCompanyResponseDataAllocationType `json:"allocation_type" url:"allocation_type"` - Company *CompanyDetailResponseData `json:"company,omitempty" url:"company,omitempty"` - EntitlementID string `json:"entitlement_id" url:"entitlement_id"` - EntitlementType string `json:"entitlement_type" url:"entitlement_type"` - Feature *FeatureDetailResponseData `json:"feature,omitempty" url:"feature,omitempty"` + AllocationType FeatureCompanyResponseDataAllocationType `json:"allocation_type" url:"allocation_type"` + Company *CompanyDetailResponseData `json:"company,omitempty" url:"company,omitempty"` + EntitlementExpirationDate *time.Time `json:"entitlement_expiration_date,omitempty" url:"entitlement_expiration_date,omitempty"` + EntitlementID string `json:"entitlement_id" url:"entitlement_id"` + EntitlementType string `json:"entitlement_type" url:"entitlement_type"` + Feature *FeatureDetailResponseData `json:"feature,omitempty" url:"feature,omitempty"` // The time at which the metric will resets. MetricResetAt *time.Time `json:"metric_reset_at,omitempty" url:"metric_reset_at,omitempty"` // If the period is current_month, when the month resets. @@ -460,6 +461,13 @@ func (f *FeatureCompanyResponseData) GetCompany() *CompanyDetailResponseData { return f.Company } +func (f *FeatureCompanyResponseData) GetEntitlementExpirationDate() *time.Time { + if f == nil { + return nil + } + return f.EntitlementExpirationDate +} + func (f *FeatureCompanyResponseData) GetEntitlementID() string { if f == nil { return "" @@ -524,7 +532,8 @@ func (f *FeatureCompanyResponseData) UnmarshalJSON(data []byte) error { type embed FeatureCompanyResponseData var unmarshaler = struct { embed - MetricResetAt *internal.DateTime `json:"metric_reset_at,omitempty"` + EntitlementExpirationDate *internal.DateTime `json:"entitlement_expiration_date,omitempty"` + MetricResetAt *internal.DateTime `json:"metric_reset_at,omitempty"` }{ embed: embed(*f), } @@ -532,6 +541,7 @@ func (f *FeatureCompanyResponseData) UnmarshalJSON(data []byte) error { return err } *f = FeatureCompanyResponseData(unmarshaler.embed) + f.EntitlementExpirationDate = unmarshaler.EntitlementExpirationDate.TimePtr() f.MetricResetAt = unmarshaler.MetricResetAt.TimePtr() extraProperties, err := internal.ExtractExtraProperties(data, *f) if err != nil { @@ -546,10 +556,12 @@ func (f *FeatureCompanyResponseData) MarshalJSON() ([]byte, error) { type embed FeatureCompanyResponseData var marshaler = struct { embed - MetricResetAt *internal.DateTime `json:"metric_reset_at,omitempty"` + EntitlementExpirationDate *internal.DateTime `json:"entitlement_expiration_date,omitempty"` + MetricResetAt *internal.DateTime `json:"metric_reset_at,omitempty"` }{ - embed: embed(*f), - MetricResetAt: internal.NewOptionalDateTime(f.MetricResetAt), + embed: embed(*f), + EntitlementExpirationDate: internal.NewOptionalDateTime(f.EntitlementExpirationDate), + MetricResetAt: internal.NewOptionalDateTime(f.MetricResetAt), } return json.Marshal(marshaler) } @@ -793,15 +805,15 @@ func (f FeatureCompanyUserResponseDataAllocationType) Ptr() *FeatureCompanyUserR // Input parameters type CountCompanyOverridesParams struct { - // Filter company overrides by a single company ID (starting with comp\_) + // Filter company overrides by a single company ID (starting with comp_) CompanyID *string `json:"company_id,omitempty" url:"company_id,omitempty"` - // Filter company overrides by multiple company IDs (starting with comp\_) + // Filter company overrides by multiple company IDs (starting with comp_) CompanyIDs []string `json:"company_ids,omitempty" url:"company_ids,omitempty"` - // Filter company overrides by a single feature ID (starting with feat\_) + // Filter company overrides by a single feature ID (starting with feat_) FeatureID *string `json:"feature_id,omitempty" url:"feature_id,omitempty"` - // Filter company overrides by multiple feature IDs (starting with feat\_) + // Filter company overrides by multiple feature IDs (starting with feat_) FeatureIDs []string `json:"feature_ids,omitempty" url:"feature_ids,omitempty"` - // Filter company overrides by multiple company override IDs (starting with cmov\_) + // Filter company overrides by multiple company override IDs (starting with cmov_) IDs []string `json:"ids,omitempty" url:"ids,omitempty"` // Page limit (default 100) Limit *int `json:"limit,omitempty" url:"limit,omitempty"` @@ -809,6 +821,8 @@ type CountCompanyOverridesParams struct { Offset *int `json:"offset,omitempty" url:"offset,omitempty"` // Search for company overrides by feature or company name Q *string `json:"q,omitempty" url:"q,omitempty"` + // Filter company overrides by whether they have not expired + WithoutExpired *bool `json:"without_expired,omitempty" url:"without_expired,omitempty"` extraProperties map[string]interface{} rawJSON json.RawMessage @@ -870,6 +884,13 @@ func (c *CountCompanyOverridesParams) GetQ() *string { return c.Q } +func (c *CountCompanyOverridesParams) GetWithoutExpired() *bool { + if c == nil { + return nil + } + return c.WithoutExpired +} + func (c *CountCompanyOverridesParams) GetExtraProperties() map[string]interface{} { return c.extraProperties } @@ -1367,19 +1388,19 @@ func (c *CountFeatureUsersResponse) String() string { // Input parameters type CountPlanEntitlementsParams struct { - // Filter plan entitlements by a single feature ID (starting with feat\_) + // Filter plan entitlements by a single feature ID (starting with feat_) FeatureID *string `json:"feature_id,omitempty" url:"feature_id,omitempty"` - // Filter plan entitlements by multiple feature IDs (starting with feat\_) + // Filter plan entitlements by multiple feature IDs (starting with feat_) FeatureIDs []string `json:"feature_ids,omitempty" url:"feature_ids,omitempty"` - // Filter plan entitlements by multiple plan entitlement IDs (starting with pltl\_) + // Filter plan entitlements by multiple plan entitlement IDs (starting with pltl_) IDs []string `json:"ids,omitempty" url:"ids,omitempty"` // Page limit (default 100) Limit *int `json:"limit,omitempty" url:"limit,omitempty"` // Page offset (default 0) Offset *int `json:"offset,omitempty" url:"offset,omitempty"` - // Filter plan entitlements by a single plan ID (starting with plan\_) + // Filter plan entitlements by a single plan ID (starting with plan_) PlanID *string `json:"plan_id,omitempty" url:"plan_id,omitempty"` - // Filter plan entitlements by multiple plan IDs (starting with plan\_) + // Filter plan entitlements by multiple plan IDs (starting with plan_) PlanIDs []string `json:"plan_ids,omitempty" url:"plan_ids,omitempty"` // Search for plan entitlements by feature or company name Q *string `json:"q,omitempty" url:"q,omitempty"` @@ -1544,7 +1565,6 @@ type CreateCompanyOverrideRequestBodyMetricPeriod string const ( CreateCompanyOverrideRequestBodyMetricPeriodAllTime CreateCompanyOverrideRequestBodyMetricPeriod = "all_time" - CreateCompanyOverrideRequestBodyMetricPeriodBilling CreateCompanyOverrideRequestBodyMetricPeriod = "billing" CreateCompanyOverrideRequestBodyMetricPeriodCurrentMonth CreateCompanyOverrideRequestBodyMetricPeriod = "current_month" CreateCompanyOverrideRequestBodyMetricPeriodCurrentWeek CreateCompanyOverrideRequestBodyMetricPeriod = "current_week" CreateCompanyOverrideRequestBodyMetricPeriodCurrentDay CreateCompanyOverrideRequestBodyMetricPeriod = "current_day" @@ -1554,8 +1574,6 @@ func NewCreateCompanyOverrideRequestBodyMetricPeriodFromString(s string) (Create switch s { case "all_time": return CreateCompanyOverrideRequestBodyMetricPeriodAllTime, nil - case "billing": - return CreateCompanyOverrideRequestBodyMetricPeriodBilling, nil case "current_month": return CreateCompanyOverrideRequestBodyMetricPeriodCurrentMonth, nil case "current_week": @@ -1680,7 +1698,6 @@ type CreatePlanEntitlementRequestBodyMetricPeriod string const ( CreatePlanEntitlementRequestBodyMetricPeriodAllTime CreatePlanEntitlementRequestBodyMetricPeriod = "all_time" - CreatePlanEntitlementRequestBodyMetricPeriodBilling CreatePlanEntitlementRequestBodyMetricPeriod = "billing" CreatePlanEntitlementRequestBodyMetricPeriodCurrentMonth CreatePlanEntitlementRequestBodyMetricPeriod = "current_month" CreatePlanEntitlementRequestBodyMetricPeriodCurrentWeek CreatePlanEntitlementRequestBodyMetricPeriod = "current_week" CreatePlanEntitlementRequestBodyMetricPeriodCurrentDay CreatePlanEntitlementRequestBodyMetricPeriod = "current_day" @@ -1690,8 +1707,6 @@ func NewCreatePlanEntitlementRequestBodyMetricPeriodFromString(s string) (Create switch s { case "all_time": return CreatePlanEntitlementRequestBodyMetricPeriodAllTime, nil - case "billing": - return CreatePlanEntitlementRequestBodyMetricPeriodBilling, nil case "current_month": return CreatePlanEntitlementRequestBodyMetricPeriodCurrentMonth, nil case "current_week": @@ -2136,15 +2151,15 @@ func (g *GetPlanEntitlementResponse) String() string { // Input parameters type ListCompanyOverridesParams struct { - // Filter company overrides by a single company ID (starting with comp\_) + // Filter company overrides by a single company ID (starting with comp_) CompanyID *string `json:"company_id,omitempty" url:"company_id,omitempty"` - // Filter company overrides by multiple company IDs (starting with comp\_) + // Filter company overrides by multiple company IDs (starting with comp_) CompanyIDs []string `json:"company_ids,omitempty" url:"company_ids,omitempty"` - // Filter company overrides by a single feature ID (starting with feat\_) + // Filter company overrides by a single feature ID (starting with feat_) FeatureID *string `json:"feature_id,omitempty" url:"feature_id,omitempty"` - // Filter company overrides by multiple feature IDs (starting with feat\_) + // Filter company overrides by multiple feature IDs (starting with feat_) FeatureIDs []string `json:"feature_ids,omitempty" url:"feature_ids,omitempty"` - // Filter company overrides by multiple company override IDs (starting with cmov\_) + // Filter company overrides by multiple company override IDs (starting with cmov_) IDs []string `json:"ids,omitempty" url:"ids,omitempty"` // Page limit (default 100) Limit *int `json:"limit,omitempty" url:"limit,omitempty"` @@ -2152,6 +2167,8 @@ type ListCompanyOverridesParams struct { Offset *int `json:"offset,omitempty" url:"offset,omitempty"` // Search for company overrides by feature or company name Q *string `json:"q,omitempty" url:"q,omitempty"` + // Filter company overrides by whether they have not expired + WithoutExpired *bool `json:"without_expired,omitempty" url:"without_expired,omitempty"` extraProperties map[string]interface{} rawJSON json.RawMessage @@ -2213,6 +2230,13 @@ func (l *ListCompanyOverridesParams) GetQ() *string { return l.Q } +func (l *ListCompanyOverridesParams) GetWithoutExpired() *bool { + if l == nil { + return nil + } + return l.WithoutExpired +} + func (l *ListCompanyOverridesParams) GetExtraProperties() map[string]interface{} { return l.extraProperties } @@ -2714,19 +2738,19 @@ func (l *ListFeatureUsersResponse) String() string { // Input parameters type ListPlanEntitlementsParams struct { - // Filter plan entitlements by a single feature ID (starting with feat\_) + // Filter plan entitlements by a single feature ID (starting with feat_) FeatureID *string `json:"feature_id,omitempty" url:"feature_id,omitempty"` - // Filter plan entitlements by multiple feature IDs (starting with feat\_) + // Filter plan entitlements by multiple feature IDs (starting with feat_) FeatureIDs []string `json:"feature_ids,omitempty" url:"feature_ids,omitempty"` - // Filter plan entitlements by multiple plan entitlement IDs (starting with pltl\_) + // Filter plan entitlements by multiple plan entitlement IDs (starting with pltl_) IDs []string `json:"ids,omitempty" url:"ids,omitempty"` // Page limit (default 100) Limit *int `json:"limit,omitempty" url:"limit,omitempty"` // Page offset (default 0) Offset *int `json:"offset,omitempty" url:"offset,omitempty"` - // Filter plan entitlements by a single plan ID (starting with plan\_) + // Filter plan entitlements by a single plan ID (starting with plan_) PlanID *string `json:"plan_id,omitempty" url:"plan_id,omitempty"` - // Filter plan entitlements by multiple plan IDs (starting with plan\_) + // Filter plan entitlements by multiple plan IDs (starting with plan_) PlanIDs []string `json:"plan_ids,omitempty" url:"plan_ids,omitempty"` // Search for plan entitlements by feature or company name Q *string `json:"q,omitempty" url:"q,omitempty"` @@ -2892,7 +2916,6 @@ type UpdateCompanyOverrideRequestBodyMetricPeriod string const ( UpdateCompanyOverrideRequestBodyMetricPeriodAllTime UpdateCompanyOverrideRequestBodyMetricPeriod = "all_time" - UpdateCompanyOverrideRequestBodyMetricPeriodBilling UpdateCompanyOverrideRequestBodyMetricPeriod = "billing" UpdateCompanyOverrideRequestBodyMetricPeriodCurrentMonth UpdateCompanyOverrideRequestBodyMetricPeriod = "current_month" UpdateCompanyOverrideRequestBodyMetricPeriodCurrentWeek UpdateCompanyOverrideRequestBodyMetricPeriod = "current_week" UpdateCompanyOverrideRequestBodyMetricPeriodCurrentDay UpdateCompanyOverrideRequestBodyMetricPeriod = "current_day" @@ -2902,8 +2925,6 @@ func NewUpdateCompanyOverrideRequestBodyMetricPeriodFromString(s string) (Update switch s { case "all_time": return UpdateCompanyOverrideRequestBodyMetricPeriodAllTime, nil - case "billing": - return UpdateCompanyOverrideRequestBodyMetricPeriodBilling, nil case "current_month": return UpdateCompanyOverrideRequestBodyMetricPeriodCurrentMonth, nil case "current_week": @@ -3028,7 +3049,6 @@ type UpdatePlanEntitlementRequestBodyMetricPeriod string const ( UpdatePlanEntitlementRequestBodyMetricPeriodAllTime UpdatePlanEntitlementRequestBodyMetricPeriod = "all_time" - UpdatePlanEntitlementRequestBodyMetricPeriodBilling UpdatePlanEntitlementRequestBodyMetricPeriod = "billing" UpdatePlanEntitlementRequestBodyMetricPeriodCurrentMonth UpdatePlanEntitlementRequestBodyMetricPeriod = "current_month" UpdatePlanEntitlementRequestBodyMetricPeriodCurrentWeek UpdatePlanEntitlementRequestBodyMetricPeriod = "current_week" UpdatePlanEntitlementRequestBodyMetricPeriodCurrentDay UpdatePlanEntitlementRequestBodyMetricPeriod = "current_day" @@ -3038,8 +3058,6 @@ func NewUpdatePlanEntitlementRequestBodyMetricPeriodFromString(s string) (Update switch s { case "all_time": return UpdatePlanEntitlementRequestBodyMetricPeriodAllTime, nil - case "billing": - return UpdatePlanEntitlementRequestBodyMetricPeriodBilling, nil case "current_month": return UpdatePlanEntitlementRequestBodyMetricPeriodCurrentMonth, nil case "current_week": @@ -3162,8 +3180,6 @@ func (u *UpdatePlanEntitlementResponse) String() string { type UpdateCompanyOverrideRequestBody struct { ExpirationDate *time.Time `json:"expiration_date,omitempty" url:"-"` - MeteredMonthlyPriceID *string `json:"metered_monthly_price_id,omitempty" url:"-"` - MeteredYearlyPriceID *string `json:"metered_yearly_price_id,omitempty" url:"-"` MetricPeriod *UpdateCompanyOverrideRequestBodyMetricPeriod `json:"metric_period,omitempty" url:"-"` MetricPeriodMonthReset *UpdateCompanyOverrideRequestBodyMetricPeriodMonthReset `json:"metric_period_month_reset,omitempty" url:"-"` ValueBool *bool `json:"value_bool,omitempty" url:"-"` @@ -3195,12 +3211,13 @@ func (u *UpdateCompanyOverrideRequestBody) MarshalJSON() ([]byte, error) { } type UpdatePlanEntitlementRequestBody struct { - MeteredMonthlyPriceID *string `json:"metered_monthly_price_id,omitempty" url:"-"` - MeteredYearlyPriceID *string `json:"metered_yearly_price_id,omitempty" url:"-"` MetricPeriod *UpdatePlanEntitlementRequestBodyMetricPeriod `json:"metric_period,omitempty" url:"-"` MetricPeriodMonthReset *UpdatePlanEntitlementRequestBodyMetricPeriodMonthReset `json:"metric_period_month_reset,omitempty" url:"-"` + MonthlyMeteredPriceID *string `json:"monthly_metered_price_id,omitempty" url:"-"` + PriceBehavior *string `json:"price_behavior,omitempty" url:"-"` ValueBool *bool `json:"value_bool,omitempty" url:"-"` ValueNumeric *int `json:"value_numeric,omitempty" url:"-"` ValueTraitID *string `json:"value_trait_id,omitempty" url:"-"` ValueType UpdatePlanEntitlementRequestBodyValueType `json:"value_type" url:"-"` + YearlyMeteredPriceID *string `json:"yearly_metered_price_id,omitempty" url:"-"` } diff --git a/events.go b/events.go index d7d9abf..f8e7992 100644 --- a/events.go +++ b/events.go @@ -226,11 +226,11 @@ func (e *EventBody) Accept(visitor EventBodyVisitor) error { } type EventBodyFlagCheck struct { - // Schematic company ID (starting with 'comp\_') of the company evaluated, if any + // Schematic company ID (starting with 'comp_') of the company evaluated, if any CompanyID *string `json:"company_id,omitempty" url:"company_id,omitempty"` // Report an error that occurred during the flag check Error *string `json:"error,omitempty" url:"error,omitempty"` - // Schematic flag ID (starting with 'flag\_') for the flag matching the key, if any + // Schematic flag ID (starting with 'flag_') for the flag matching the key, if any FlagID *string `json:"flag_id,omitempty" url:"flag_id,omitempty"` // The key of the flag being checked FlagKey string `json:"flag_key" url:"flag_key"` @@ -240,9 +240,9 @@ type EventBodyFlagCheck struct { ReqCompany map[string]string `json:"req_company,omitempty" url:"req_company,omitempty"` // Key-value pairs used to to identify user for which the flag was checked ReqUser map[string]string `json:"req_user,omitempty" url:"req_user,omitempty"` - // Schematic rule ID (starting with 'rule\_') of the rule that matched for the flag, if any + // Schematic rule ID (starting with 'rule_') of the rule that matched for the flag, if any RuleID *string `json:"rule_id,omitempty" url:"rule_id,omitempty"` - // Schematic user ID (starting with 'user\_') of the user evaluated, if any + // Schematic user ID (starting with 'user_') of the user evaluated, if any UserID *string `json:"user_id,omitempty" url:"user_id,omitempty"` // The value of the flag for the given company and/or user Value bool `json:"value" url:"value"` @@ -1329,61 +1329,6 @@ func (g *GetEventSummariesResponse) String() string { return fmt.Sprintf("%#v", g) } -type GetEventSummaryBySubtypeResponse struct { - Data *EventSummaryResponseData `json:"data,omitempty" url:"data,omitempty"` - // Input parameters - Params map[string]interface{} `json:"params,omitempty" url:"params,omitempty"` - - extraProperties map[string]interface{} - rawJSON json.RawMessage -} - -func (g *GetEventSummaryBySubtypeResponse) GetData() *EventSummaryResponseData { - if g == nil { - return nil - } - return g.Data -} - -func (g *GetEventSummaryBySubtypeResponse) GetParams() map[string]interface{} { - if g == nil { - return nil - } - return g.Params -} - -func (g *GetEventSummaryBySubtypeResponse) GetExtraProperties() map[string]interface{} { - return g.extraProperties -} - -func (g *GetEventSummaryBySubtypeResponse) UnmarshalJSON(data []byte) error { - type unmarshaler GetEventSummaryBySubtypeResponse - var value unmarshaler - if err := json.Unmarshal(data, &value); err != nil { - return err - } - *g = GetEventSummaryBySubtypeResponse(value) - extraProperties, err := internal.ExtractExtraProperties(data, *g) - if err != nil { - return err - } - g.extraProperties = extraProperties - g.rawJSON = json.RawMessage(data) - return nil -} - -func (g *GetEventSummaryBySubtypeResponse) String() string { - if len(g.rawJSON) > 0 { - if value, err := internal.StringifyJSON(g.rawJSON); err == nil { - return value - } - } - if value, err := internal.StringifyJSON(g); err == nil { - return value - } - return fmt.Sprintf("%#v", g) -} - type GetSegmentIntegrationStatusResponse struct { Data *SegmentStatusResp `json:"data,omitempty" url:"data,omitempty"` // Input parameters diff --git a/events/client.go b/events/client.go index 65daf77..7ef03e4 100644 --- a/events/client.go +++ b/events/client.go @@ -158,69 +158,6 @@ func (c *Client) GetEventSummaries( return response, nil } -func (c *Client) GetEventSummaryBySubtype( - ctx context.Context, - // key - key string, - opts ...option.RequestOption, -) (*schematicgo.GetEventSummaryBySubtypeResponse, error) { - options := core.NewRequestOptions(opts...) - baseURL := internal.ResolveBaseURL( - options.BaseURL, - c.baseURL, - "https://api.schematichq.com", - ) - endpointURL := internal.EncodeURL( - baseURL+"/event-types/%v", - key, - ) - headers := internal.MergeHeaders( - c.header.Clone(), - options.ToHeader(), - ) - errorCodes := internal.ErrorCodes{ - 401: func(apiError *core.APIError) error { - return &schematicgo.UnauthorizedError{ - APIError: apiError, - } - }, - 403: func(apiError *core.APIError) error { - return &schematicgo.ForbiddenError{ - APIError: apiError, - } - }, - 404: func(apiError *core.APIError) error { - return &schematicgo.NotFoundError{ - APIError: apiError, - } - }, - 500: func(apiError *core.APIError) error { - return &schematicgo.InternalServerError{ - APIError: apiError, - } - }, - } - - var response *schematicgo.GetEventSummaryBySubtypeResponse - if err := c.caller.Call( - ctx, - &internal.CallParams{ - URL: endpointURL, - Method: http.MethodGet, - Headers: headers, - MaxAttempts: options.MaxAttempts, - BodyProperties: options.BodyProperties, - QueryParameters: options.QueryParameters, - Client: options.HTTPClient, - Response: &response, - ErrorDecoder: internal.NewErrorDecoder(errorCodes), - }, - ); err != nil { - return nil, err - } - return response, nil -} - func (c *Client) ListEvents( ctx context.Context, request *schematicgo.ListEventsRequest, diff --git a/go.mod b/go.mod index 1987f08..7db5ded 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,6 @@ require ( require ( github.com/davecgh/go-spew v1.1.0 // indirect - github.com/golang/mock v1.6.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 67e903b..b3766d4 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,5 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -9,29 +7,6 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/types.go b/types.go index 152fcce..e4f239a 100644 --- a/types.go +++ b/types.go @@ -457,6 +457,7 @@ type BillingProductForSubscriptionResponseData struct { Name string `json:"name" url:"name"` Price int `json:"price" url:"price"` PriceExternalID string `json:"price_external_id" url:"price_external_id"` + PriceID string `json:"price_id" url:"price_id"` Quantity float64 `json:"quantity" url:"quantity"` SubscriptionID string `json:"subscription_id" url:"subscription_id"` UpdatedAt time.Time `json:"updated_at" url:"updated_at"` @@ -536,6 +537,13 @@ func (b *BillingProductForSubscriptionResponseData) GetPriceExternalID() string return b.PriceExternalID } +func (b *BillingProductForSubscriptionResponseData) GetPriceID() string { + if b == nil { + return "" + } + return b.PriceID +} + func (b *BillingProductForSubscriptionResponseData) GetQuantity() float64 { if b == nil { return 0 @@ -758,11 +766,365 @@ func (b *BillingProductPriceResponseData) String() string { return fmt.Sprintf("%#v", b) } +type BillingSubscriptionDiscountView struct { + AmountOff *int `json:"amount_off,omitempty" url:"amount_off,omitempty"` + CouponID string `json:"coupon_id" url:"coupon_id"` + CouponName string `json:"coupon_name" url:"coupon_name"` + Currency *string `json:"currency,omitempty" url:"currency,omitempty"` + CustomerFacingCode *string `json:"customer_facing_code,omitempty" url:"customer_facing_code,omitempty"` + DiscountExternalID string `json:"discount_external_id" url:"discount_external_id"` + Duration string `json:"duration" url:"duration"` + DurationInMonths *int `json:"duration_in_months,omitempty" url:"duration_in_months,omitempty"` + EndedAt *time.Time `json:"ended_at,omitempty" url:"ended_at,omitempty"` + IsActive bool `json:"is_active" url:"is_active"` + PercentOff *float64 `json:"percent_off,omitempty" url:"percent_off,omitempty"` + PromoCodeExternalID *string `json:"promo_code_external_id,omitempty" url:"promo_code_external_id,omitempty"` + StartedAt time.Time `json:"started_at" url:"started_at"` + SubscriptionExternalID string `json:"subscription_external_id" url:"subscription_external_id"` + + extraProperties map[string]interface{} + rawJSON json.RawMessage +} + +func (b *BillingSubscriptionDiscountView) GetAmountOff() *int { + if b == nil { + return nil + } + return b.AmountOff +} + +func (b *BillingSubscriptionDiscountView) GetCouponID() string { + if b == nil { + return "" + } + return b.CouponID +} + +func (b *BillingSubscriptionDiscountView) GetCouponName() string { + if b == nil { + return "" + } + return b.CouponName +} + +func (b *BillingSubscriptionDiscountView) GetCurrency() *string { + if b == nil { + return nil + } + return b.Currency +} + +func (b *BillingSubscriptionDiscountView) GetCustomerFacingCode() *string { + if b == nil { + return nil + } + return b.CustomerFacingCode +} + +func (b *BillingSubscriptionDiscountView) GetDiscountExternalID() string { + if b == nil { + return "" + } + return b.DiscountExternalID +} + +func (b *BillingSubscriptionDiscountView) GetDuration() string { + if b == nil { + return "" + } + return b.Duration +} + +func (b *BillingSubscriptionDiscountView) GetDurationInMonths() *int { + if b == nil { + return nil + } + return b.DurationInMonths +} + +func (b *BillingSubscriptionDiscountView) GetEndedAt() *time.Time { + if b == nil { + return nil + } + return b.EndedAt +} + +func (b *BillingSubscriptionDiscountView) GetIsActive() bool { + if b == nil { + return false + } + return b.IsActive +} + +func (b *BillingSubscriptionDiscountView) GetPercentOff() *float64 { + if b == nil { + return nil + } + return b.PercentOff +} + +func (b *BillingSubscriptionDiscountView) GetPromoCodeExternalID() *string { + if b == nil { + return nil + } + return b.PromoCodeExternalID +} + +func (b *BillingSubscriptionDiscountView) GetStartedAt() time.Time { + if b == nil { + return time.Time{} + } + return b.StartedAt +} + +func (b *BillingSubscriptionDiscountView) GetSubscriptionExternalID() string { + if b == nil { + return "" + } + return b.SubscriptionExternalID +} + +func (b *BillingSubscriptionDiscountView) GetExtraProperties() map[string]interface{} { + return b.extraProperties +} + +func (b *BillingSubscriptionDiscountView) UnmarshalJSON(data []byte) error { + type embed BillingSubscriptionDiscountView + var unmarshaler = struct { + embed + EndedAt *internal.DateTime `json:"ended_at,omitempty"` + StartedAt *internal.DateTime `json:"started_at"` + }{ + embed: embed(*b), + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + *b = BillingSubscriptionDiscountView(unmarshaler.embed) + b.EndedAt = unmarshaler.EndedAt.TimePtr() + b.StartedAt = unmarshaler.StartedAt.Time() + extraProperties, err := internal.ExtractExtraProperties(data, *b) + if err != nil { + return err + } + b.extraProperties = extraProperties + b.rawJSON = json.RawMessage(data) + return nil +} + +func (b *BillingSubscriptionDiscountView) MarshalJSON() ([]byte, error) { + type embed BillingSubscriptionDiscountView + var marshaler = struct { + embed + EndedAt *internal.DateTime `json:"ended_at,omitempty"` + StartedAt *internal.DateTime `json:"started_at"` + }{ + embed: embed(*b), + EndedAt: internal.NewOptionalDateTime(b.EndedAt), + StartedAt: internal.NewDateTime(b.StartedAt), + } + return json.Marshal(marshaler) +} + +func (b *BillingSubscriptionDiscountView) String() string { + if len(b.rawJSON) > 0 { + if value, err := internal.StringifyJSON(b.rawJSON); err == nil { + return value + } + } + if value, err := internal.StringifyJSON(b); err == nil { + return value + } + return fmt.Sprintf("%#v", b) +} + +type BillingSubscriptionResponseData struct { + CompanyID *string `json:"company_id,omitempty" url:"company_id,omitempty"` + CreatedAt time.Time `json:"created_at" url:"created_at"` + Currency string `json:"currency" url:"currency"` + CustomerExternalID string `json:"customer_external_id" url:"customer_external_id"` + ExpiredAt *time.Time `json:"expired_at,omitempty" url:"expired_at,omitempty"` + ID string `json:"id" url:"id"` + Interval string `json:"interval" url:"interval"` + Metadata map[string]interface{} `json:"metadata,omitempty" url:"metadata,omitempty"` + PeriodEnd int `json:"period_end" url:"period_end"` + PeriodStart int `json:"period_start" url:"period_start"` + Status string `json:"status" url:"status"` + SubscriptionExternalID string `json:"subscription_external_id" url:"subscription_external_id"` + TotalPrice int `json:"total_price" url:"total_price"` + TrialEnd *int `json:"trial_end,omitempty" url:"trial_end,omitempty"` + TrialEndSetting *string `json:"trial_end_setting,omitempty" url:"trial_end_setting,omitempty"` + + extraProperties map[string]interface{} + rawJSON json.RawMessage +} + +func (b *BillingSubscriptionResponseData) GetCompanyID() *string { + if b == nil { + return nil + } + return b.CompanyID +} + +func (b *BillingSubscriptionResponseData) GetCreatedAt() time.Time { + if b == nil { + return time.Time{} + } + return b.CreatedAt +} + +func (b *BillingSubscriptionResponseData) GetCurrency() string { + if b == nil { + return "" + } + return b.Currency +} + +func (b *BillingSubscriptionResponseData) GetCustomerExternalID() string { + if b == nil { + return "" + } + return b.CustomerExternalID +} + +func (b *BillingSubscriptionResponseData) GetExpiredAt() *time.Time { + if b == nil { + return nil + } + return b.ExpiredAt +} + +func (b *BillingSubscriptionResponseData) GetID() string { + if b == nil { + return "" + } + return b.ID +} + +func (b *BillingSubscriptionResponseData) GetInterval() string { + if b == nil { + return "" + } + return b.Interval +} + +func (b *BillingSubscriptionResponseData) GetMetadata() map[string]interface{} { + if b == nil { + return nil + } + return b.Metadata +} + +func (b *BillingSubscriptionResponseData) GetPeriodEnd() int { + if b == nil { + return 0 + } + return b.PeriodEnd +} + +func (b *BillingSubscriptionResponseData) GetPeriodStart() int { + if b == nil { + return 0 + } + return b.PeriodStart +} + +func (b *BillingSubscriptionResponseData) GetStatus() string { + if b == nil { + return "" + } + return b.Status +} + +func (b *BillingSubscriptionResponseData) GetSubscriptionExternalID() string { + if b == nil { + return "" + } + return b.SubscriptionExternalID +} + +func (b *BillingSubscriptionResponseData) GetTotalPrice() int { + if b == nil { + return 0 + } + return b.TotalPrice +} + +func (b *BillingSubscriptionResponseData) GetTrialEnd() *int { + if b == nil { + return nil + } + return b.TrialEnd +} + +func (b *BillingSubscriptionResponseData) GetTrialEndSetting() *string { + if b == nil { + return nil + } + return b.TrialEndSetting +} + +func (b *BillingSubscriptionResponseData) GetExtraProperties() map[string]interface{} { + return b.extraProperties +} + +func (b *BillingSubscriptionResponseData) UnmarshalJSON(data []byte) error { + type embed BillingSubscriptionResponseData + var unmarshaler = struct { + embed + CreatedAt *internal.DateTime `json:"created_at"` + ExpiredAt *internal.DateTime `json:"expired_at,omitempty"` + }{ + embed: embed(*b), + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + *b = BillingSubscriptionResponseData(unmarshaler.embed) + b.CreatedAt = unmarshaler.CreatedAt.Time() + b.ExpiredAt = unmarshaler.ExpiredAt.TimePtr() + extraProperties, err := internal.ExtractExtraProperties(data, *b) + if err != nil { + return err + } + b.extraProperties = extraProperties + b.rawJSON = json.RawMessage(data) + return nil +} + +func (b *BillingSubscriptionResponseData) MarshalJSON() ([]byte, error) { + type embed BillingSubscriptionResponseData + var marshaler = struct { + embed + CreatedAt *internal.DateTime `json:"created_at"` + ExpiredAt *internal.DateTime `json:"expired_at,omitempty"` + }{ + embed: embed(*b), + CreatedAt: internal.NewDateTime(b.CreatedAt), + ExpiredAt: internal.NewOptionalDateTime(b.ExpiredAt), + } + return json.Marshal(marshaler) +} + +func (b *BillingSubscriptionResponseData) String() string { + if len(b.rawJSON) > 0 { + if value, err := internal.StringifyJSON(b.rawJSON); err == nil { + return value + } + } + if value, err := internal.StringifyJSON(b); err == nil { + return value + } + return fmt.Sprintf("%#v", b) +} + +// The updated resource type BillingSubscriptionView struct { CompanyID *string `json:"company_id,omitempty" url:"company_id,omitempty"` CreatedAt time.Time `json:"created_at" url:"created_at"` Currency string `json:"currency" url:"currency"` CustomerExternalID string `json:"customer_external_id" url:"customer_external_id"` + Discounts []*BillingSubscriptionDiscountView `json:"discounts,omitempty" url:"discounts,omitempty"` ExpiredAt *time.Time `json:"expired_at,omitempty" url:"expired_at,omitempty"` ID string `json:"id" url:"id"` Interval string `json:"interval" url:"interval"` @@ -776,6 +1138,7 @@ type BillingSubscriptionView struct { SubscriptionExternalID string `json:"subscription_external_id" url:"subscription_external_id"` TotalPrice int `json:"total_price" url:"total_price"` TrialEnd *int `json:"trial_end,omitempty" url:"trial_end,omitempty"` + TrialEndSetting *string `json:"trial_end_setting,omitempty" url:"trial_end_setting,omitempty"` extraProperties map[string]interface{} rawJSON json.RawMessage @@ -809,6 +1172,13 @@ func (b *BillingSubscriptionView) GetCustomerExternalID() string { return b.CustomerExternalID } +func (b *BillingSubscriptionView) GetDiscounts() []*BillingSubscriptionDiscountView { + if b == nil { + return nil + } + return b.Discounts +} + func (b *BillingSubscriptionView) GetExpiredAt() *time.Time { if b == nil { return nil @@ -900,6 +1270,13 @@ func (b *BillingSubscriptionView) GetTrialEnd() *int { return b.TrialEnd } +func (b *BillingSubscriptionView) GetTrialEndSetting() *string { + if b == nil { + return nil + } + return b.TrialEndSetting +} + func (b *BillingSubscriptionView) GetExtraProperties() map[string]interface{} { return b.extraProperties } @@ -942,32 +1319,119 @@ func (b *BillingSubscriptionView) MarshalJSON() ([]byte, error) { return json.Marshal(marshaler) } -func (b *BillingSubscriptionView) String() string { - if len(b.rawJSON) > 0 { - if value, err := internal.StringifyJSON(b.rawJSON); err == nil { +func (b *BillingSubscriptionView) String() string { + if len(b.rawJSON) > 0 { + if value, err := internal.StringifyJSON(b.rawJSON); err == nil { + return value + } + } + if value, err := internal.StringifyJSON(b); err == nil { + return value + } + return fmt.Sprintf("%#v", b) +} + +type ChangeSubscriptionRequestBody struct { + AddOnIDs []*UpdateAddOnRequestBody `json:"add_on_ids,omitempty" url:"add_on_ids,omitempty"` + NewPlanID string `json:"new_plan_id" url:"new_plan_id"` + NewPriceID string `json:"new_price_id" url:"new_price_id"` + PayInAdvance []*UpdatePayInAdvanceRequestBody `json:"pay_in_advance,omitempty" url:"pay_in_advance,omitempty"` + PaymentMethodID *string `json:"payment_method_id,omitempty" url:"payment_method_id,omitempty"` + PromoCode *string `json:"promo_code,omitempty" url:"promo_code,omitempty"` + + extraProperties map[string]interface{} + rawJSON json.RawMessage +} + +func (c *ChangeSubscriptionRequestBody) GetAddOnIDs() []*UpdateAddOnRequestBody { + if c == nil { + return nil + } + return c.AddOnIDs +} + +func (c *ChangeSubscriptionRequestBody) GetNewPlanID() string { + if c == nil { + return "" + } + return c.NewPlanID +} + +func (c *ChangeSubscriptionRequestBody) GetNewPriceID() string { + if c == nil { + return "" + } + return c.NewPriceID +} + +func (c *ChangeSubscriptionRequestBody) GetPayInAdvance() []*UpdatePayInAdvanceRequestBody { + if c == nil { + return nil + } + return c.PayInAdvance +} + +func (c *ChangeSubscriptionRequestBody) GetPaymentMethodID() *string { + if c == nil { + return nil + } + return c.PaymentMethodID +} + +func (c *ChangeSubscriptionRequestBody) GetPromoCode() *string { + if c == nil { + return nil + } + return c.PromoCode +} + +func (c *ChangeSubscriptionRequestBody) GetExtraProperties() map[string]interface{} { + return c.extraProperties +} + +func (c *ChangeSubscriptionRequestBody) UnmarshalJSON(data []byte) error { + type unmarshaler ChangeSubscriptionRequestBody + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = ChangeSubscriptionRequestBody(value) + extraProperties, err := internal.ExtractExtraProperties(data, *c) + if err != nil { + return err + } + c.extraProperties = extraProperties + c.rawJSON = json.RawMessage(data) + return nil +} + +func (c *ChangeSubscriptionRequestBody) String() string { + if len(c.rawJSON) > 0 { + if value, err := internal.StringifyJSON(c.rawJSON); err == nil { return value } } - if value, err := internal.StringifyJSON(b); err == nil { + if value, err := internal.StringifyJSON(c); err == nil { return value } - return fmt.Sprintf("%#v", b) + return fmt.Sprintf("%#v", c) } type CompanyDetailResponseData struct { - AddOns []*CompanyPlanWithBillingSubView `json:"add_ons,omitempty" url:"add_ons,omitempty"` - BillingSubscription *BillingSubscriptionView `json:"billing_subscription,omitempty" url:"billing_subscription,omitempty"` - BillingSubscriptions []*BillingSubscriptionView `json:"billing_subscriptions,omitempty" url:"billing_subscriptions,omitempty"` - CreatedAt time.Time `json:"created_at" url:"created_at"` - EntityTraits []*EntityTraitDetailResponseData `json:"entity_traits,omitempty" url:"entity_traits,omitempty"` - EnvironmentID string `json:"environment_id" url:"environment_id"` - ID string `json:"id" url:"id"` - Keys []*EntityKeyDetailResponseData `json:"keys,omitempty" url:"keys,omitempty"` - LastSeenAt *time.Time `json:"last_seen_at,omitempty" url:"last_seen_at,omitempty"` - LogoURL *string `json:"logo_url,omitempty" url:"logo_url,omitempty"` - Name string `json:"name" url:"name"` - Plan *CompanyPlanWithBillingSubView `json:"plan,omitempty" url:"plan,omitempty"` - Plans []*GenericPreviewObject `json:"plans,omitempty" url:"plans,omitempty"` + AddOns []*CompanyPlanWithBillingSubView `json:"add_ons,omitempty" url:"add_ons,omitempty"` + BillingSubscription *BillingSubscriptionView `json:"billing_subscription,omitempty" url:"billing_subscription,omitempty"` + BillingSubscriptions []*BillingSubscriptionView `json:"billing_subscriptions,omitempty" url:"billing_subscriptions,omitempty"` + CreatedAt time.Time `json:"created_at" url:"created_at"` + EntityTraits []*EntityTraitDetailResponseData `json:"entity_traits,omitempty" url:"entity_traits,omitempty"` + EnvironmentID string `json:"environment_id" url:"environment_id"` + ID string `json:"id" url:"id"` + Keys []*EntityKeyDetailResponseData `json:"keys,omitempty" url:"keys,omitempty"` + LastSeenAt *time.Time `json:"last_seen_at,omitempty" url:"last_seen_at,omitempty"` + LogoURL *string `json:"logo_url,omitempty" url:"logo_url,omitempty"` + Metrics []*CompanyEventPeriodMetricsResponseData `json:"metrics,omitempty" url:"metrics,omitempty"` + Name string `json:"name" url:"name"` + Plan *CompanyPlanWithBillingSubView `json:"plan,omitempty" url:"plan,omitempty"` + Plans []*GenericPreviewObject `json:"plans,omitempty" url:"plans,omitempty"` // A map of trait names to trait values Traits map[string]interface{} `json:"traits,omitempty" url:"traits,omitempty"` UpdatedAt time.Time `json:"updated_at" url:"updated_at"` @@ -1047,6 +1511,13 @@ func (c *CompanyDetailResponseData) GetLogoURL() *string { return c.LogoURL } +func (c *CompanyDetailResponseData) GetMetrics() []*CompanyEventPeriodMetricsResponseData { + if c == nil { + return nil + } + return c.Metrics +} + func (c *CompanyDetailResponseData) GetName() string { if c == nil { return "" @@ -1147,6 +1618,162 @@ func (c *CompanyDetailResponseData) String() string { return fmt.Sprintf("%#v", c) } +type CompanyEventPeriodMetricsResponseData struct { + AccountID string `json:"account_id" url:"account_id"` + CapturedAtMax time.Time `json:"captured_at_max" url:"captured_at_max"` + CapturedAtMin time.Time `json:"captured_at_min" url:"captured_at_min"` + CompanyID string `json:"company_id" url:"company_id"` + CreatedAt time.Time `json:"created_at" url:"created_at"` + EnvironmentID string `json:"environment_id" url:"environment_id"` + EventSubtype string `json:"event_subtype" url:"event_subtype"` + MonthReset string `json:"month_reset" url:"month_reset"` + Period string `json:"period" url:"period"` + ValidUntil *time.Time `json:"valid_until,omitempty" url:"valid_until,omitempty"` + Value int `json:"value" url:"value"` + + extraProperties map[string]interface{} + rawJSON json.RawMessage +} + +func (c *CompanyEventPeriodMetricsResponseData) GetAccountID() string { + if c == nil { + return "" + } + return c.AccountID +} + +func (c *CompanyEventPeriodMetricsResponseData) GetCapturedAtMax() time.Time { + if c == nil { + return time.Time{} + } + return c.CapturedAtMax +} + +func (c *CompanyEventPeriodMetricsResponseData) GetCapturedAtMin() time.Time { + if c == nil { + return time.Time{} + } + return c.CapturedAtMin +} + +func (c *CompanyEventPeriodMetricsResponseData) GetCompanyID() string { + if c == nil { + return "" + } + return c.CompanyID +} + +func (c *CompanyEventPeriodMetricsResponseData) GetCreatedAt() time.Time { + if c == nil { + return time.Time{} + } + return c.CreatedAt +} + +func (c *CompanyEventPeriodMetricsResponseData) GetEnvironmentID() string { + if c == nil { + return "" + } + return c.EnvironmentID +} + +func (c *CompanyEventPeriodMetricsResponseData) GetEventSubtype() string { + if c == nil { + return "" + } + return c.EventSubtype +} + +func (c *CompanyEventPeriodMetricsResponseData) GetMonthReset() string { + if c == nil { + return "" + } + return c.MonthReset +} + +func (c *CompanyEventPeriodMetricsResponseData) GetPeriod() string { + if c == nil { + return "" + } + return c.Period +} + +func (c *CompanyEventPeriodMetricsResponseData) GetValidUntil() *time.Time { + if c == nil { + return nil + } + return c.ValidUntil +} + +func (c *CompanyEventPeriodMetricsResponseData) GetValue() int { + if c == nil { + return 0 + } + return c.Value +} + +func (c *CompanyEventPeriodMetricsResponseData) GetExtraProperties() map[string]interface{} { + return c.extraProperties +} + +func (c *CompanyEventPeriodMetricsResponseData) UnmarshalJSON(data []byte) error { + type embed CompanyEventPeriodMetricsResponseData + var unmarshaler = struct { + embed + CapturedAtMax *internal.DateTime `json:"captured_at_max"` + CapturedAtMin *internal.DateTime `json:"captured_at_min"` + CreatedAt *internal.DateTime `json:"created_at"` + ValidUntil *internal.DateTime `json:"valid_until,omitempty"` + }{ + embed: embed(*c), + } + if err := json.Unmarshal(data, &unmarshaler); err != nil { + return err + } + *c = CompanyEventPeriodMetricsResponseData(unmarshaler.embed) + c.CapturedAtMax = unmarshaler.CapturedAtMax.Time() + c.CapturedAtMin = unmarshaler.CapturedAtMin.Time() + c.CreatedAt = unmarshaler.CreatedAt.Time() + c.ValidUntil = unmarshaler.ValidUntil.TimePtr() + extraProperties, err := internal.ExtractExtraProperties(data, *c) + if err != nil { + return err + } + c.extraProperties = extraProperties + c.rawJSON = json.RawMessage(data) + return nil +} + +func (c *CompanyEventPeriodMetricsResponseData) MarshalJSON() ([]byte, error) { + type embed CompanyEventPeriodMetricsResponseData + var marshaler = struct { + embed + CapturedAtMax *internal.DateTime `json:"captured_at_max"` + CapturedAtMin *internal.DateTime `json:"captured_at_min"` + CreatedAt *internal.DateTime `json:"created_at"` + ValidUntil *internal.DateTime `json:"valid_until,omitempty"` + }{ + embed: embed(*c), + CapturedAtMax: internal.NewDateTime(c.CapturedAtMax), + CapturedAtMin: internal.NewDateTime(c.CapturedAtMin), + CreatedAt: internal.NewDateTime(c.CreatedAt), + ValidUntil: internal.NewOptionalDateTime(c.ValidUntil), + } + return json.Marshal(marshaler) +} + +func (c *CompanyEventPeriodMetricsResponseData) String() string { + if len(c.rawJSON) > 0 { + if value, err := internal.StringifyJSON(c.rawJSON); err == nil { + return value + } + } + if value, err := internal.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} + type CompanyMembershipDetailResponseData struct { Company *CompanyResponseData `json:"company,omitempty" url:"company,omitempty"` CompanyID string `json:"company_id" url:"company_id"` @@ -1572,6 +2199,7 @@ func (c *CompanyResponseData) String() string { type CompanySubscriptionResponseData struct { Currency string `json:"currency" url:"currency"` CustomerExternalID string `json:"customer_external_id" url:"customer_external_id"` + Discounts []*BillingSubscriptionDiscountView `json:"discounts,omitempty" url:"discounts,omitempty"` ExpiredAt *time.Time `json:"expired_at,omitempty" url:"expired_at,omitempty"` Interval string `json:"interval" url:"interval"` LatestInvoice *InvoiceResponseData `json:"latest_invoice,omitempty" url:"latest_invoice,omitempty"` @@ -1580,6 +2208,7 @@ type CompanySubscriptionResponseData struct { Status string `json:"status" url:"status"` SubscriptionExternalID string `json:"subscription_external_id" url:"subscription_external_id"` TotalPrice int `json:"total_price" url:"total_price"` + TrialEnd *time.Time `json:"trial_end,omitempty" url:"trial_end,omitempty"` extraProperties map[string]interface{} rawJSON json.RawMessage @@ -1599,6 +2228,13 @@ func (c *CompanySubscriptionResponseData) GetCustomerExternalID() string { return c.CustomerExternalID } +func (c *CompanySubscriptionResponseData) GetDiscounts() []*BillingSubscriptionDiscountView { + if c == nil { + return nil + } + return c.Discounts +} + func (c *CompanySubscriptionResponseData) GetExpiredAt() *time.Time { if c == nil { return nil @@ -1655,6 +2291,13 @@ func (c *CompanySubscriptionResponseData) GetTotalPrice() int { return c.TotalPrice } +func (c *CompanySubscriptionResponseData) GetTrialEnd() *time.Time { + if c == nil { + return nil + } + return c.TrialEnd +} + func (c *CompanySubscriptionResponseData) GetExtraProperties() map[string]interface{} { return c.extraProperties } @@ -1664,6 +2307,7 @@ func (c *CompanySubscriptionResponseData) UnmarshalJSON(data []byte) error { var unmarshaler = struct { embed ExpiredAt *internal.DateTime `json:"expired_at,omitempty"` + TrialEnd *internal.DateTime `json:"trial_end,omitempty"` }{ embed: embed(*c), } @@ -1672,6 +2316,7 @@ func (c *CompanySubscriptionResponseData) UnmarshalJSON(data []byte) error { } *c = CompanySubscriptionResponseData(unmarshaler.embed) c.ExpiredAt = unmarshaler.ExpiredAt.TimePtr() + c.TrialEnd = unmarshaler.TrialEnd.TimePtr() extraProperties, err := internal.ExtractExtraProperties(data, *c) if err != nil { return err @@ -1686,9 +2331,11 @@ func (c *CompanySubscriptionResponseData) MarshalJSON() ([]byte, error) { var marshaler = struct { embed ExpiredAt *internal.DateTime `json:"expired_at,omitempty"` + TrialEnd *internal.DateTime `json:"trial_end,omitempty"` }{ embed: embed(*c), ExpiredAt: internal.NewOptionalDateTime(c.ExpiredAt), + TrialEnd: internal.NewOptionalDateTime(c.TrialEnd), } return json.Marshal(marshaler) } @@ -1715,6 +2362,7 @@ type ComponentHydrateResponseData struct { FeatureUsage *FeatureUsageDetailResponseData `json:"feature_usage,omitempty" url:"feature_usage,omitempty"` StripeEmbed *StripeEmbedInfo `json:"stripe_embed,omitempty" url:"stripe_embed,omitempty"` Subscription *CompanySubscriptionResponseData `json:"subscription,omitempty" url:"subscription,omitempty"` + TrialPaymentMethodRequired *bool `json:"trial_payment_method_required,omitempty" url:"trial_payment_method_required,omitempty"` UpcomingInvoice *InvoiceResponseData `json:"upcoming_invoice,omitempty" url:"upcoming_invoice,omitempty"` extraProperties map[string]interface{} @@ -1784,6 +2432,13 @@ func (c *ComponentHydrateResponseData) GetSubscription() *CompanySubscriptionRes return c.Subscription } +func (c *ComponentHydrateResponseData) GetTrialPaymentMethodRequired() *bool { + if c == nil { + return nil + } + return c.TrialPaymentMethodRequired +} + func (c *ComponentHydrateResponseData) GetUpcomingInvoice() *InvoiceResponseData { if c == nil { return nil @@ -1870,10 +2525,110 @@ func (c *CountResponse) String() string { return fmt.Sprintf("%#v", c) } +type CouponRequestBody struct { + AmountOff int `json:"amount_off" url:"amount_off"` + Currency *string `json:"currency,omitempty" url:"currency,omitempty"` + Duration string `json:"duration" url:"duration"` + DurationInMonths int `json:"duration_in_months" url:"duration_in_months"` + MaxRedemptions int `json:"max_redemptions" url:"max_redemptions"` + Name string `json:"name" url:"name"` + PercentOff float64 `json:"percent_off" url:"percent_off"` + TimesRedeemed int `json:"times_redeemed" url:"times_redeemed"` + + extraProperties map[string]interface{} + rawJSON json.RawMessage +} + +func (c *CouponRequestBody) GetAmountOff() int { + if c == nil { + return 0 + } + return c.AmountOff +} + +func (c *CouponRequestBody) GetCurrency() *string { + if c == nil { + return nil + } + return c.Currency +} + +func (c *CouponRequestBody) GetDuration() string { + if c == nil { + return "" + } + return c.Duration +} + +func (c *CouponRequestBody) GetDurationInMonths() int { + if c == nil { + return 0 + } + return c.DurationInMonths +} + +func (c *CouponRequestBody) GetMaxRedemptions() int { + if c == nil { + return 0 + } + return c.MaxRedemptions +} + +func (c *CouponRequestBody) GetName() string { + if c == nil { + return "" + } + return c.Name +} + +func (c *CouponRequestBody) GetPercentOff() float64 { + if c == nil { + return 0 + } + return c.PercentOff +} + +func (c *CouponRequestBody) GetTimesRedeemed() int { + if c == nil { + return 0 + } + return c.TimesRedeemed +} + +func (c *CouponRequestBody) GetExtraProperties() map[string]interface{} { + return c.extraProperties +} + +func (c *CouponRequestBody) UnmarshalJSON(data []byte) error { + type unmarshaler CouponRequestBody + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *c = CouponRequestBody(value) + extraProperties, err := internal.ExtractExtraProperties(data, *c) + if err != nil { + return err + } + c.extraProperties = extraProperties + c.rawJSON = json.RawMessage(data) + return nil +} + +func (c *CouponRequestBody) String() string { + if len(c.rawJSON) > 0 { + if value, err := internal.StringifyJSON(c.rawJSON); err == nil { + return value + } + } + if value, err := internal.StringifyJSON(c); err == nil { + return value + } + return fmt.Sprintf("%#v", c) +} + type CreateEntitlementReqCommon struct { FeatureID string `json:"feature_id" url:"feature_id"` - MeteredMonthlyPriceID *string `json:"metered_monthly_price_id,omitempty" url:"metered_monthly_price_id,omitempty"` - MeteredYearlyPriceID *string `json:"metered_yearly_price_id,omitempty" url:"metered_yearly_price_id,omitempty"` MetricPeriod *CreateEntitlementReqCommonMetricPeriod `json:"metric_period,omitempty" url:"metric_period,omitempty"` MetricPeriodMonthReset *CreateEntitlementReqCommonMetricPeriodMonthReset `json:"metric_period_month_reset,omitempty" url:"metric_period_month_reset,omitempty"` ValueBool *bool `json:"value_bool,omitempty" url:"value_bool,omitempty"` @@ -1892,20 +2647,6 @@ func (c *CreateEntitlementReqCommon) GetFeatureID() string { return c.FeatureID } -func (c *CreateEntitlementReqCommon) GetMeteredMonthlyPriceID() *string { - if c == nil { - return nil - } - return c.MeteredMonthlyPriceID -} - -func (c *CreateEntitlementReqCommon) GetMeteredYearlyPriceID() *string { - if c == nil { - return nil - } - return c.MeteredYearlyPriceID -} - func (c *CreateEntitlementReqCommon) GetMetricPeriod() *CreateEntitlementReqCommonMetricPeriod { if c == nil { return nil @@ -1984,7 +2725,6 @@ type CreateEntitlementReqCommonMetricPeriod string const ( CreateEntitlementReqCommonMetricPeriodAllTime CreateEntitlementReqCommonMetricPeriod = "all_time" - CreateEntitlementReqCommonMetricPeriodBilling CreateEntitlementReqCommonMetricPeriod = "billing" CreateEntitlementReqCommonMetricPeriodCurrentMonth CreateEntitlementReqCommonMetricPeriod = "current_month" CreateEntitlementReqCommonMetricPeriodCurrentWeek CreateEntitlementReqCommonMetricPeriod = "current_week" CreateEntitlementReqCommonMetricPeriodCurrentDay CreateEntitlementReqCommonMetricPeriod = "current_day" @@ -1994,8 +2734,6 @@ func NewCreateEntitlementReqCommonMetricPeriodFromString(s string) (CreateEntitl switch s { case "all_time": return CreateEntitlementReqCommonMetricPeriodAllTime, nil - case "billing": - return CreateEntitlementReqCommonMetricPeriodBilling, nil case "current_month": return CreateEntitlementReqCommonMetricPeriodCurrentMonth, nil case "current_week": @@ -2310,7 +3048,6 @@ type CreateOrUpdateConditionRequestBodyMetricPeriod string const ( CreateOrUpdateConditionRequestBodyMetricPeriodAllTime CreateOrUpdateConditionRequestBodyMetricPeriod = "all_time" - CreateOrUpdateConditionRequestBodyMetricPeriodBilling CreateOrUpdateConditionRequestBodyMetricPeriod = "billing" CreateOrUpdateConditionRequestBodyMetricPeriodCurrentMonth CreateOrUpdateConditionRequestBodyMetricPeriod = "current_month" CreateOrUpdateConditionRequestBodyMetricPeriodCurrentWeek CreateOrUpdateConditionRequestBodyMetricPeriod = "current_week" CreateOrUpdateConditionRequestBodyMetricPeriodCurrentDay CreateOrUpdateConditionRequestBodyMetricPeriod = "current_day" @@ -2320,8 +3057,6 @@ func NewCreateOrUpdateConditionRequestBodyMetricPeriodFromString(s string) (Crea switch s { case "all_time": return CreateOrUpdateConditionRequestBodyMetricPeriodAllTime, nil - case "billing": - return CreateOrUpdateConditionRequestBodyMetricPeriodBilling, nil case "current_month": return CreateOrUpdateConditionRequestBodyMetricPeriodCurrentMonth, nil case "current_week": @@ -3863,19 +4598,23 @@ type FeatureUsageResponseData struct { // The maximum amount of usage that is permitted; a null value indicates that unlimited usage is permitted. Allocation *int `json:"allocation,omitempty" url:"allocation,omitempty"` // The type of allocation that is being used. - AllocationType FeatureUsageResponseDataAllocationType `json:"allocation_type" url:"allocation_type"` - EntitlementID string `json:"entitlement_id" url:"entitlement_id"` - EntitlementType string `json:"entitlement_type" url:"entitlement_type"` - Feature *FeatureDetailResponseData `json:"feature,omitempty" url:"feature,omitempty"` - // The time at which the metric will resets. + AllocationType FeatureUsageResponseDataAllocationType `json:"allocation_type" url:"allocation_type"` + EntitlementExpirationDate *time.Time `json:"entitlement_expiration_date,omitempty" url:"entitlement_expiration_date,omitempty"` + EntitlementID string `json:"entitlement_id" url:"entitlement_id"` + EntitlementType string `json:"entitlement_type" url:"entitlement_type"` + Feature *FeatureDetailResponseData `json:"feature,omitempty" url:"feature,omitempty"` + // The time at which the metric will reset. MetricResetAt *time.Time `json:"metric_reset_at,omitempty" url:"metric_reset_at,omitempty"` // If the period is current_month, when the month resets. - MonthReset *string `json:"month_reset,omitempty" url:"month_reset,omitempty"` + MonthReset *string `json:"month_reset,omitempty" url:"month_reset,omitempty"` + MonthlyUsageBasedPrice *BillingPriceView `json:"monthly_usage_based_price,omitempty" url:"monthly_usage_based_price,omitempty"` // The period over which usage is measured. - Period *string `json:"period,omitempty" url:"period,omitempty"` - Plan *PlanResponseData `json:"plan,omitempty" url:"plan,omitempty"` + Period *string `json:"period,omitempty" url:"period,omitempty"` + Plan *PlanResponseData `json:"plan,omitempty" url:"plan,omitempty"` + PriceBehavior *string `json:"price_behavior,omitempty" url:"price_behavior,omitempty"` // The amount of usage that has been consumed; a null value indicates that usage is not being measured. - Usage *int `json:"usage,omitempty" url:"usage,omitempty"` + Usage *int `json:"usage,omitempty" url:"usage,omitempty"` + YearlyUsageBasedPrice *BillingPriceView `json:"yearly_usage_based_price,omitempty" url:"yearly_usage_based_price,omitempty"` extraProperties map[string]interface{} rawJSON json.RawMessage @@ -3902,6 +4641,13 @@ func (f *FeatureUsageResponseData) GetAllocationType() FeatureUsageResponseDataA return f.AllocationType } +func (f *FeatureUsageResponseData) GetEntitlementExpirationDate() *time.Time { + if f == nil { + return nil + } + return f.EntitlementExpirationDate +} + func (f *FeatureUsageResponseData) GetEntitlementID() string { if f == nil { return "" @@ -3937,6 +4683,13 @@ func (f *FeatureUsageResponseData) GetMonthReset() *string { return f.MonthReset } +func (f *FeatureUsageResponseData) GetMonthlyUsageBasedPrice() *BillingPriceView { + if f == nil { + return nil + } + return f.MonthlyUsageBasedPrice +} + func (f *FeatureUsageResponseData) GetPeriod() *string { if f == nil { return nil @@ -3951,6 +4704,13 @@ func (f *FeatureUsageResponseData) GetPlan() *PlanResponseData { return f.Plan } +func (f *FeatureUsageResponseData) GetPriceBehavior() *string { + if f == nil { + return nil + } + return f.PriceBehavior +} + func (f *FeatureUsageResponseData) GetUsage() *int { if f == nil { return nil @@ -3958,6 +4718,13 @@ func (f *FeatureUsageResponseData) GetUsage() *int { return f.Usage } +func (f *FeatureUsageResponseData) GetYearlyUsageBasedPrice() *BillingPriceView { + if f == nil { + return nil + } + return f.YearlyUsageBasedPrice +} + func (f *FeatureUsageResponseData) GetExtraProperties() map[string]interface{} { return f.extraProperties } @@ -3966,7 +4733,8 @@ func (f *FeatureUsageResponseData) UnmarshalJSON(data []byte) error { type embed FeatureUsageResponseData var unmarshaler = struct { embed - MetricResetAt *internal.DateTime `json:"metric_reset_at,omitempty"` + EntitlementExpirationDate *internal.DateTime `json:"entitlement_expiration_date,omitempty"` + MetricResetAt *internal.DateTime `json:"metric_reset_at,omitempty"` }{ embed: embed(*f), } @@ -3974,6 +4742,7 @@ func (f *FeatureUsageResponseData) UnmarshalJSON(data []byte) error { return err } *f = FeatureUsageResponseData(unmarshaler.embed) + f.EntitlementExpirationDate = unmarshaler.EntitlementExpirationDate.TimePtr() f.MetricResetAt = unmarshaler.MetricResetAt.TimePtr() extraProperties, err := internal.ExtractExtraProperties(data, *f) if err != nil { @@ -3988,10 +4757,12 @@ func (f *FeatureUsageResponseData) MarshalJSON() ([]byte, error) { type embed FeatureUsageResponseData var marshaler = struct { embed - MetricResetAt *internal.DateTime `json:"metric_reset_at,omitempty"` + EntitlementExpirationDate *internal.DateTime `json:"entitlement_expiration_date,omitempty"` + MetricResetAt *internal.DateTime `json:"metric_reset_at,omitempty"` }{ - embed: embed(*f), - MetricResetAt: internal.NewOptionalDateTime(f.MetricResetAt), + embed: embed(*f), + EntitlementExpirationDate: internal.NewOptionalDateTime(f.EntitlementExpirationDate), + MetricResetAt: internal.NewOptionalDateTime(f.MetricResetAt), } return json.Marshal(marshaler) } @@ -6796,8 +7567,6 @@ func (t *TemporaryAccessTokenResponseData) String() string { } type UpdateEntitlementReqCommon struct { - MeteredMonthlyPriceID *string `json:"metered_monthly_price_id,omitempty" url:"metered_monthly_price_id,omitempty"` - MeteredYearlyPriceID *string `json:"metered_yearly_price_id,omitempty" url:"metered_yearly_price_id,omitempty"` MetricPeriod *UpdateEntitlementReqCommonMetricPeriod `json:"metric_period,omitempty" url:"metric_period,omitempty"` MetricPeriodMonthReset *UpdateEntitlementReqCommonMetricPeriodMonthReset `json:"metric_period_month_reset,omitempty" url:"metric_period_month_reset,omitempty"` ValueBool *bool `json:"value_bool,omitempty" url:"value_bool,omitempty"` @@ -6809,20 +7578,6 @@ type UpdateEntitlementReqCommon struct { rawJSON json.RawMessage } -func (u *UpdateEntitlementReqCommon) GetMeteredMonthlyPriceID() *string { - if u == nil { - return nil - } - return u.MeteredMonthlyPriceID -} - -func (u *UpdateEntitlementReqCommon) GetMeteredYearlyPriceID() *string { - if u == nil { - return nil - } - return u.MeteredYearlyPriceID -} - func (u *UpdateEntitlementReqCommon) GetMetricPeriod() *UpdateEntitlementReqCommonMetricPeriod { if u == nil { return nil @@ -6901,7 +7656,6 @@ type UpdateEntitlementReqCommonMetricPeriod string const ( UpdateEntitlementReqCommonMetricPeriodAllTime UpdateEntitlementReqCommonMetricPeriod = "all_time" - UpdateEntitlementReqCommonMetricPeriodBilling UpdateEntitlementReqCommonMetricPeriod = "billing" UpdateEntitlementReqCommonMetricPeriodCurrentMonth UpdateEntitlementReqCommonMetricPeriod = "current_month" UpdateEntitlementReqCommonMetricPeriodCurrentWeek UpdateEntitlementReqCommonMetricPeriod = "current_week" UpdateEntitlementReqCommonMetricPeriodCurrentDay UpdateEntitlementReqCommonMetricPeriod = "current_day" @@ -6911,8 +7665,6 @@ func NewUpdateEntitlementReqCommonMetricPeriodFromString(s string) (UpdateEntitl switch s { case "all_time": return UpdateEntitlementReqCommonMetricPeriodAllTime, nil - case "billing": - return UpdateEntitlementReqCommonMetricPeriodBilling, nil case "current_month": return UpdateEntitlementReqCommonMetricPeriodCurrentMonth, nil case "current_week":