File size: 6,800 Bytes
04f1444
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
// Code generated by @openmeter/typespec-go. DO NOT EDIT.

package openmeter

import "time"

// Plan create request.
type CreatePlanRequest struct {
	// Display name of the resource.
	//
	// Between 1 and 256 characters.
	Name string `json:"name"`
	// Optional description of the resource.
	//
	// Maximum 1024 characters.
	Description *string            `json:"description,omitempty"`
	Labels      *map[string]string `json:"labels,omitempty"`
	// A key is a semi-unique string that is used to identify the plan. It is used to
	// reference the latest `active` version of the plan and is unique with the version
	// number.
	Key string `json:"key"`
	// The currency code of the plan.
	Currency string `json:"currency"`
	// The billing cadence for subscriptions using this plan.
	BillingCadence string `json:"billing_cadence"`
	// Whether pro-rating is enabled for this plan.
	ProRatingEnabled *bool `json:"pro_rating_enabled,omitempty"`
	// The plan phases define the pricing ramp for a subscription. A phase switch
	// occurs only at the end of a billing period. At least one phase is required.
	Phases []PlanPhaseInput `json:"phases"`
}

// Plans provide a template for subscriptions.
type Plan struct {
	ID string `json:"id"`
	// Display name of the resource.
	//
	// Between 1 and 256 characters.
	Name string `json:"name"`
	// Optional description of the resource.
	//
	// Maximum 1024 characters.
	Description *string           `json:"description,omitempty"`
	Labels      map[string]string `json:"labels,omitempty"`
	// An ISO-8601 timestamp representation of entity creation date.
	CreatedAt time.Time `json:"created_at"`
	// An ISO-8601 timestamp representation of entity last update date.
	UpdatedAt time.Time `json:"updated_at"`
	// An ISO-8601 timestamp representation of entity deletion date.
	DeletedAt *time.Time `json:"deleted_at,omitempty"`
	// A key is a semi-unique string that is used to identify the plan. It is used to
	// reference the latest `active` version of the plan and is unique with the version
	// number.
	Key string `json:"key"`
	// Plans are versioned to allow you to make changes without affecting running
	// subscriptions.
	Version int64 `json:"version"`
	// The currency code of the plan.
	Currency string `json:"currency"`
	// The billing cadence for subscriptions using this plan.
	BillingCadence string `json:"billing_cadence"`
	// Whether pro-rating is enabled for this plan.
	ProRatingEnabled *bool `json:"pro_rating_enabled,omitempty"`
	// The date and time when the plan becomes `active`. When not specified, the plan
	// is in `draft` status.
	EffectiveFrom *time.Time `json:"effective_from,omitempty"`
	// A scheduled date and time when the plan becomes `archived`. When not specified,
	// the plan is in `active` status indefinitely.
	EffectiveTo *time.Time `json:"effective_to,omitempty"`
	// The status of the plan. Computed based on the effective start and end dates:
	//
	// - `draft`: `effective_from` is not set.
	// - `scheduled`: `now < effective_from`.
	// - `active`: `effective_from <= now` and (`effective_to` is not set or
	// `now < effective_to`).
	// - `archived`: `effective_to <= now`.
	Status PlanStatus `json:"status"`
	// The plan phases define the pricing ramp for a subscription. A phase switch
	// occurs only at the end of a billing period. At least one phase is required.
	Phases []PlanPhase `json:"phases"`
	// Settlement mode for plan.
	//
	// Values:
	//
	// - `credit_then_invoice`: Credits are applied first, then any remainder is
	// invoiced.
	// - `credit_only`: Usage is settled exclusively against credits.
	SettlementMode *SettlementMode `json:"settlement_mode,omitempty"`
	// List of validation errors in `draft` state that prevent the plan from being
	// published.
	ValidationErrors []ProductCatalogValidationError `json:"validation_errors,omitempty"`
}

// Page paginated response.
type PlanPagePaginatedResponse struct {
	Data []Plan        `json:"data"`
	Meta PaginatedMeta `json:"meta"`
}

// The plan phase or pricing ramp allows changing a plan's rate cards over time as
// a subscription progresses.
type PlanPhase struct {
	// Display name of the resource.
	//
	// Between 1 and 256 characters.
	Name string `json:"name"`
	// Optional description of the resource.
	//
	// Maximum 1024 characters.
	Description *string           `json:"description,omitempty"`
	Labels      map[string]string `json:"labels,omitempty"`
	Key         string            `json:"key"`
	// The duration of the phase. When not specified, the phase runs indefinitely. Only
	// the last phase may omit the duration.
	Duration *string `json:"duration,omitempty"`
	// The rate cards of the plan.
	RateCards []RateCard `json:"rate_cards"`
}

// The plan phase or pricing ramp allows changing a plan's rate cards over time as
// a subscription progresses.
type PlanPhaseInput struct {
	// Display name of the resource.
	//
	// Between 1 and 256 characters.
	Name string `json:"name"`
	// Optional description of the resource.
	//
	// Maximum 1024 characters.
	Description *string            `json:"description,omitempty"`
	Labels      *map[string]string `json:"labels,omitempty"`
	Key         string             `json:"key"`
	// The duration of the phase. When not specified, the phase runs indefinitely. Only
	// the last phase may omit the duration.
	Duration *string `json:"duration,omitempty"`
	// The rate cards of the plan.
	RateCards []RateCardInput `json:"rate_cards"`
}

// The status of a plan.
//
// - `draft`: The plan has not yet been published and can be edited.
// - `active`: The plan is published and can be used in subscriptions.
// - `archived`: The plan is no longer available for use.
// - `scheduled`: The plan is scheduled to be published at a future date.
type PlanStatus string

const (
	PlanStatusDraft     PlanStatus = "draft"
	PlanStatusActive    PlanStatus = "active"
	PlanStatusArchived  PlanStatus = "archived"
	PlanStatusScheduled PlanStatus = "scheduled"
)

func (value PlanStatus) Valid() bool {
	switch value {
	case PlanStatusDraft, PlanStatusActive, PlanStatusArchived, PlanStatusScheduled:
		return true
	default:
		return false
	}
}

// Plan upsert request.
type UpsertPlanRequest struct {
	// Display name of the resource.
	//
	// Between 1 and 256 characters.
	Name string `json:"name"`
	// Optional description of the resource.
	//
	// Maximum 1024 characters.
	Description *string            `json:"description,omitempty"`
	Labels      *map[string]string `json:"labels,omitempty"`
	// Whether pro-rating is enabled for this plan.
	ProRatingEnabled *bool `json:"pro_rating_enabled,omitempty"`
	// The plan phases define the pricing ramp for a subscription. A phase switch
	// occurs only at the end of a billing period. At least one phase is required.
	Phases []PlanPhaseInput `json:"phases"`
}