orb-billing 4.31.0 → 4.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/core.d.ts.map +1 -1
- package/core.js +5 -3
- package/core.js.map +1 -1
- package/core.mjs +5 -3
- package/core.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/invoices.d.ts +2 -2
- package/resources/invoices.d.ts.map +1 -1
- package/resources/subscriptions.d.ts +8933 -2955
- package/resources/subscriptions.d.ts.map +1 -1
- package/resources/subscriptions.js +153 -18
- package/resources/subscriptions.js.map +1 -1
- package/resources/subscriptions.mjs +153 -18
- package/resources/subscriptions.mjs.map +1 -1
- package/src/core.ts +7 -3
- package/src/resources/invoices.ts +2 -2
- package/src/resources/subscriptions.ts +10207 -3047
- package/src/version.ts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
|
@@ -146,38 +146,173 @@ class Subscriptions extends resource_1.APIResource {
|
|
|
146
146
|
return this._client.post(`/subscriptions/${subscriptionId}/price_intervals`, { body, ...options });
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
149
|
-
* This endpoint can be used to change
|
|
150
|
-
*
|
|
149
|
+
* This endpoint can be used to change an existing subscription's plan. It returns
|
|
150
|
+
* the serialized updated subscription object.
|
|
151
151
|
*
|
|
152
|
-
* The body parameter `change_option` determines
|
|
152
|
+
* The body parameter `change_option` determines when the plan change occurrs. Orb
|
|
153
153
|
* supports three options:
|
|
154
154
|
*
|
|
155
155
|
* - `end_of_subscription_term`: changes the plan at the end of the existing plan's
|
|
156
156
|
* term.
|
|
157
157
|
* - Issuing this plan change request for a monthly subscription will keep the
|
|
158
|
-
* existing plan active until the start of the subsequent month
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
158
|
+
* existing plan active until the start of the subsequent month. Issuing this
|
|
159
|
+
* plan change request for a yearly subscription will keep the existing plan
|
|
160
|
+
* active for the full year. Charges incurred in the remaining period will be
|
|
161
|
+
* invoiced as normal.
|
|
162
|
+
* - Example: The plan is billed monthly on the 1st of the month, the request is
|
|
163
|
+
* made on January 15th, so the plan will be changed on February 1st, and
|
|
164
|
+
* invoice will be issued on February 1st for the last month of the original
|
|
165
|
+
* plan.
|
|
166
|
+
* - `immediate`: changes the plan immediately.
|
|
167
|
+
* - Subscriptions that have their plan changed with this option will move to the
|
|
168
|
+
* new plan immediately, and be invoiced immediately.
|
|
169
|
+
* - This invoice will include any usage fees incurred in the billing period up
|
|
170
|
+
* to the change, along with any prorated recurring fees for the billing
|
|
171
|
+
* period, if applicable.
|
|
172
|
+
* - Example: The plan is billed monthly on the 1st of the month, the request is
|
|
173
|
+
* made on January 15th, so the plan will be changed on January 15th, and an
|
|
174
|
+
* invoice will be issued for the partial month, from January 1 to January 15,
|
|
175
|
+
* on the original plan.
|
|
176
|
+
* - `requested_date`: changes the plan on the requested date (`change_date`).
|
|
177
|
+
* - If no timezone is provided, the customer's timezone is used. The
|
|
178
|
+
* `change_date` body parameter is required if this option is chosen.
|
|
179
|
+
* - Example: The plan is billed monthly on the 1st of the month, the request is
|
|
180
|
+
* made on January 15th, with a requested `change_date` of February 15th, so
|
|
181
|
+
* the plan will be changed on February 15th, and invoices will be issued on
|
|
182
|
+
* February 1st and February 15th.
|
|
170
183
|
*
|
|
171
184
|
* Note that one of `plan_id` or `external_plan_id` is required in the request body
|
|
172
185
|
* for this operation.
|
|
173
186
|
*
|
|
174
|
-
* ##
|
|
187
|
+
* ## Customize your customer's subscriptions
|
|
188
|
+
*
|
|
189
|
+
* Prices and adjustments in a plan can be added, removed, or replaced on the
|
|
190
|
+
* subscription when you schedule the plan change. This is useful when a customer
|
|
191
|
+
* has prices that differ from the default prices for a specific plan.
|
|
192
|
+
*
|
|
193
|
+
* :::info This feature is only available for accounts that have migrated off of
|
|
194
|
+
* legacy subscription overrides. :::
|
|
195
|
+
*
|
|
196
|
+
* ### Adding Prices
|
|
197
|
+
*
|
|
198
|
+
* To add prices, provide a list of objects with the key `add_prices`. An object in
|
|
199
|
+
* the list must specify an existing add-on price with a `price_id` or
|
|
200
|
+
* `external_price_id` field, or create a new add-on price by including an object
|
|
201
|
+
* with the key `price`, identical to what would be used in the request body for
|
|
202
|
+
* the [create price endpoint](../reference/create-price). See the
|
|
203
|
+
* [Price resource](../reference/price) for the specification of different price
|
|
204
|
+
* model configurations possible in this object.
|
|
205
|
+
*
|
|
206
|
+
* If the plan has phases, each object in the list must include a number with
|
|
207
|
+
* `plan_phase_order` key to indicate which phase the price should be added to.
|
|
208
|
+
*
|
|
209
|
+
* An object in the list can specify an optional `start_date` and optional
|
|
210
|
+
* `end_date`. This is equivalent to creating a price interval with the
|
|
211
|
+
* [add/edit price intervals endpoint](../reference/add-edit-price-intervals). If
|
|
212
|
+
* unspecified, the start or end date of the phase or subscription will be used.
|
|
213
|
+
*
|
|
214
|
+
* An object in the list can specify an optional `minimum_amount`,
|
|
215
|
+
* `maximum_amount`, or `discounts`. This will create adjustments which apply only
|
|
216
|
+
* to this price.
|
|
217
|
+
*
|
|
218
|
+
* Additionally, an object in the list can specify an optional `reference_id`. This
|
|
219
|
+
* ID can be used to reference this price when
|
|
220
|
+
* [adding an adjustment](#adding-adjustments) in the same API call. However the ID
|
|
221
|
+
* is _transient_ and cannot be used to refer to the price in future API calls.
|
|
222
|
+
*
|
|
223
|
+
* ### Removing Prices
|
|
224
|
+
*
|
|
225
|
+
* To remove prices, provide a list of objects with the key `remove_prices`. An
|
|
226
|
+
* object in the list must specify a plan price with either a `price_id` or
|
|
227
|
+
* `external_price_id` field.
|
|
228
|
+
*
|
|
229
|
+
* ### Replacing Prices
|
|
230
|
+
*
|
|
231
|
+
* To replace prices, provide a list of objects with the key `replace_prices`. An
|
|
232
|
+
* object in the list must specify a plan price to replace with the
|
|
233
|
+
* `replaces_price_id` key, and it must specify a price to replace it with by
|
|
234
|
+
* either referencing an existing add-on price with a `price_id` or
|
|
235
|
+
* `external_price_id` field, or by creating a new add-on price by including an
|
|
236
|
+
* object with the key `price`, identical to what would be used in the request body
|
|
237
|
+
* for the [create price endpoint](../reference/create-price). See the
|
|
238
|
+
* [Price resource](../reference/price) for the specification of different price
|
|
239
|
+
* model configurations possible in this object.
|
|
240
|
+
*
|
|
241
|
+
* For fixed fees, an object in the list can supply a `fixed_price_quantity`
|
|
242
|
+
* instead of a `price`, `price_id`, or `external_price_id` field. This will update
|
|
243
|
+
* only the quantity for the price, similar to the
|
|
244
|
+
* [Update price quantity](../reference/update-fixed-fee-quantity) endpoint.
|
|
245
|
+
*
|
|
246
|
+
* The replacement price will have the same phase, if applicable, and the same
|
|
247
|
+
* start and end dates as the price it replaces.
|
|
248
|
+
*
|
|
249
|
+
* An object in the list can specify an optional `minimum_amount`,
|
|
250
|
+
* `maximum_amount`, or `discounts`. This will create adjustments which apply only
|
|
251
|
+
* to this price.
|
|
252
|
+
*
|
|
253
|
+
* Additionally, an object in the list can specify an optional `reference_id`. This
|
|
254
|
+
* ID can be used to reference the replacement price when
|
|
255
|
+
* [adding an adjustment](#adding-adjustments) in the same API call. However the ID
|
|
256
|
+
* is _transient_ and cannot be used to refer to the price in future API calls.
|
|
257
|
+
*
|
|
258
|
+
* ### Adding adjustments
|
|
259
|
+
*
|
|
260
|
+
* To add adjustments, provide a list of objects with the key `add_adjustments`. An
|
|
261
|
+
* object in the list must include an object with the key `adjustment`, identical
|
|
262
|
+
* to the adjustment object in the
|
|
263
|
+
* [add/edit price intervals endpoint](../reference/add-edit-price-intervals).
|
|
264
|
+
*
|
|
265
|
+
* If the plan has phases, each object in the list must include a number with
|
|
266
|
+
* `plan_phase_order` key to indicate which phase the adjustment should be added
|
|
267
|
+
* to.
|
|
268
|
+
*
|
|
269
|
+
* An object in the list can specify an optional `start_date` and optional
|
|
270
|
+
* `end_date`. If unspecified, the start or end date of the phase or subscription
|
|
271
|
+
* will be used.
|
|
272
|
+
*
|
|
273
|
+
* ### Removing adjustments
|
|
274
|
+
*
|
|
275
|
+
* To remove adjustments, provide a list of objects with the key
|
|
276
|
+
* `remove_adjustments`. An object in the list must include a key, `adjustment_id`,
|
|
277
|
+
* with the ID of the adjustment to be removed.
|
|
278
|
+
*
|
|
279
|
+
* ### Replacing adjustments
|
|
280
|
+
*
|
|
281
|
+
* To replace adjustments, provide a list of objects with the key
|
|
282
|
+
* `replace_adjustments`. An object in the list must specify a plan adjustment to
|
|
283
|
+
* replace with the `replaces_adjustment_id` key, and it must specify an adjustment
|
|
284
|
+
* to replace it with by including an object with the key `adjustment`, identical
|
|
285
|
+
* to the adjustment object in the
|
|
286
|
+
* [add/edit price intervals endpoint](../reference/add-edit-price-intervals).
|
|
287
|
+
*
|
|
288
|
+
* The replacement adjustment will have the same phase, if applicable, and the same
|
|
289
|
+
* start and end dates as the adjustment it replaces.
|
|
290
|
+
*
|
|
291
|
+
* ## Price overrides (DEPRECATED)
|
|
292
|
+
*
|
|
293
|
+
* :::info Price overrides are being phased out in favor adding/removing/replacing
|
|
294
|
+
* prices. (See
|
|
295
|
+
* [Customize your customer's subscriptions](../reference/schedule-plan-change#customize-your-customers-subscriptions))
|
|
296
|
+
* :::
|
|
297
|
+
*
|
|
298
|
+
* Price overrides are used to update some or all prices in a plan for the specific
|
|
299
|
+
* subscription being created. This is useful when a new customer has negotiated a
|
|
300
|
+
* rate that is unique to the customer.
|
|
301
|
+
*
|
|
302
|
+
* To override prices, provide a list of objects with the key `price_overrides`.
|
|
303
|
+
* The price object in the list of overrides is expected to contain the existing
|
|
304
|
+
* price id, the `model_type` and configuration. (See the
|
|
305
|
+
* [Price resource](../reference/price) for the specification of different price
|
|
306
|
+
* model configurations.) The numerical values can be updated, but the billable
|
|
307
|
+
* metric, cadence, type, and name of a price can not be overridden.
|
|
308
|
+
*
|
|
309
|
+
* ### Maximums, and minimums
|
|
175
310
|
*
|
|
176
311
|
* Price overrides are used to update some or all prices in the target plan.
|
|
177
312
|
* Minimums and maximums, much like price overrides, can be useful when a new
|
|
178
313
|
* customer has negotiated a new or different minimum or maximum spend cap than the
|
|
179
|
-
* default for the plan. The request format for
|
|
180
|
-
*
|
|
314
|
+
* default for the plan. The request format for maximums and minimums is the same
|
|
315
|
+
* as those in [subscription creation](create-subscription).
|
|
181
316
|
*
|
|
182
317
|
* ## Scheduling multiple plan changes
|
|
183
318
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscriptions.js","sourceRoot":"","sources":["../src/resources/subscriptions.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtF,6CAA0C;AAC1C,qCAA2C;AAE3C,qEAAoD;AAKpD,iDAAsD;AAEtD,MAAa,aAAc,SAAQ,sBAAW;
|
|
1
|
+
{"version":3,"file":"subscriptions.js","sourceRoot":"","sources":["../src/resources/subscriptions.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtF,6CAA0C;AAC1C,qCAA2C;AAE3C,qEAAoD;AAKpD,iDAAsD;AAEtD,MAAa,aAAc,SAAQ,sBAAW;IAkQ5C,MAAM,CACJ,OAAuD,EAAE,EACzD,OAA6B;QAE7B,IAAI,IAAA,uBAAgB,EAAC,IAAI,CAAC,EAAE;YAC1B,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;SAC9B;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACnE,CAAC;IAaD,MAAM,CACJ,cAAsB,EACtB,OAAuD,EAAE,EACzD,OAA6B;QAE7B,IAAI,IAAA,uBAAgB,EAAC,IAAI,CAAC,EAAE;YAC1B,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,EA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ACrF,IAAI;YACJ,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,WAAW,CACT,cAAsB,EACtB,IAAmC,EACnC,OAA6B;QAE7B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,kBAAkB,cAAc,eAAe,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAClG,CAAC;CACF;AA7iCD,sCA6iCC;AAED,MAAa,iBAAkB,SAAQ,iBAAkB;CAAG;AAA5D,8CAA4D;AAE5D,MAAa,sCAAuC,SAAQ,iBAAuC;CAAG;AAAtG,wFAAsG;AAkwctG,WAAiB,aAAa;IAGd,2BAAa,GAAG,gBAAgB,CAAC,aAAa,CAAC;IAG/C,+BAAiB,GAAG,gBAAgB,CAAC,iBAAiB,CAAC;IACvD,oDAAsC,GAAG,gBAAgB,CAAC,sCAAsC,CAAC;AAcjH,CAAC,EArBgB,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAqB7B"}
|
|
@@ -120,38 +120,173 @@ export class Subscriptions extends APIResource {
|
|
|
120
120
|
return this._client.post(`/subscriptions/${subscriptionId}/price_intervals`, { body, ...options });
|
|
121
121
|
}
|
|
122
122
|
/**
|
|
123
|
-
* This endpoint can be used to change
|
|
124
|
-
*
|
|
123
|
+
* This endpoint can be used to change an existing subscription's plan. It returns
|
|
124
|
+
* the serialized updated subscription object.
|
|
125
125
|
*
|
|
126
|
-
* The body parameter `change_option` determines
|
|
126
|
+
* The body parameter `change_option` determines when the plan change occurrs. Orb
|
|
127
127
|
* supports three options:
|
|
128
128
|
*
|
|
129
129
|
* - `end_of_subscription_term`: changes the plan at the end of the existing plan's
|
|
130
130
|
* term.
|
|
131
131
|
* - Issuing this plan change request for a monthly subscription will keep the
|
|
132
|
-
* existing plan active until the start of the subsequent month
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
132
|
+
* existing plan active until the start of the subsequent month. Issuing this
|
|
133
|
+
* plan change request for a yearly subscription will keep the existing plan
|
|
134
|
+
* active for the full year. Charges incurred in the remaining period will be
|
|
135
|
+
* invoiced as normal.
|
|
136
|
+
* - Example: The plan is billed monthly on the 1st of the month, the request is
|
|
137
|
+
* made on January 15th, so the plan will be changed on February 1st, and
|
|
138
|
+
* invoice will be issued on February 1st for the last month of the original
|
|
139
|
+
* plan.
|
|
140
|
+
* - `immediate`: changes the plan immediately.
|
|
141
|
+
* - Subscriptions that have their plan changed with this option will move to the
|
|
142
|
+
* new plan immediately, and be invoiced immediately.
|
|
143
|
+
* - This invoice will include any usage fees incurred in the billing period up
|
|
144
|
+
* to the change, along with any prorated recurring fees for the billing
|
|
145
|
+
* period, if applicable.
|
|
146
|
+
* - Example: The plan is billed monthly on the 1st of the month, the request is
|
|
147
|
+
* made on January 15th, so the plan will be changed on January 15th, and an
|
|
148
|
+
* invoice will be issued for the partial month, from January 1 to January 15,
|
|
149
|
+
* on the original plan.
|
|
150
|
+
* - `requested_date`: changes the plan on the requested date (`change_date`).
|
|
151
|
+
* - If no timezone is provided, the customer's timezone is used. The
|
|
152
|
+
* `change_date` body parameter is required if this option is chosen.
|
|
153
|
+
* - Example: The plan is billed monthly on the 1st of the month, the request is
|
|
154
|
+
* made on January 15th, with a requested `change_date` of February 15th, so
|
|
155
|
+
* the plan will be changed on February 15th, and invoices will be issued on
|
|
156
|
+
* February 1st and February 15th.
|
|
144
157
|
*
|
|
145
158
|
* Note that one of `plan_id` or `external_plan_id` is required in the request body
|
|
146
159
|
* for this operation.
|
|
147
160
|
*
|
|
148
|
-
* ##
|
|
161
|
+
* ## Customize your customer's subscriptions
|
|
162
|
+
*
|
|
163
|
+
* Prices and adjustments in a plan can be added, removed, or replaced on the
|
|
164
|
+
* subscription when you schedule the plan change. This is useful when a customer
|
|
165
|
+
* has prices that differ from the default prices for a specific plan.
|
|
166
|
+
*
|
|
167
|
+
* :::info This feature is only available for accounts that have migrated off of
|
|
168
|
+
* legacy subscription overrides. :::
|
|
169
|
+
*
|
|
170
|
+
* ### Adding Prices
|
|
171
|
+
*
|
|
172
|
+
* To add prices, provide a list of objects with the key `add_prices`. An object in
|
|
173
|
+
* the list must specify an existing add-on price with a `price_id` or
|
|
174
|
+
* `external_price_id` field, or create a new add-on price by including an object
|
|
175
|
+
* with the key `price`, identical to what would be used in the request body for
|
|
176
|
+
* the [create price endpoint](../reference/create-price). See the
|
|
177
|
+
* [Price resource](../reference/price) for the specification of different price
|
|
178
|
+
* model configurations possible in this object.
|
|
179
|
+
*
|
|
180
|
+
* If the plan has phases, each object in the list must include a number with
|
|
181
|
+
* `plan_phase_order` key to indicate which phase the price should be added to.
|
|
182
|
+
*
|
|
183
|
+
* An object in the list can specify an optional `start_date` and optional
|
|
184
|
+
* `end_date`. This is equivalent to creating a price interval with the
|
|
185
|
+
* [add/edit price intervals endpoint](../reference/add-edit-price-intervals). If
|
|
186
|
+
* unspecified, the start or end date of the phase or subscription will be used.
|
|
187
|
+
*
|
|
188
|
+
* An object in the list can specify an optional `minimum_amount`,
|
|
189
|
+
* `maximum_amount`, or `discounts`. This will create adjustments which apply only
|
|
190
|
+
* to this price.
|
|
191
|
+
*
|
|
192
|
+
* Additionally, an object in the list can specify an optional `reference_id`. This
|
|
193
|
+
* ID can be used to reference this price when
|
|
194
|
+
* [adding an adjustment](#adding-adjustments) in the same API call. However the ID
|
|
195
|
+
* is _transient_ and cannot be used to refer to the price in future API calls.
|
|
196
|
+
*
|
|
197
|
+
* ### Removing Prices
|
|
198
|
+
*
|
|
199
|
+
* To remove prices, provide a list of objects with the key `remove_prices`. An
|
|
200
|
+
* object in the list must specify a plan price with either a `price_id` or
|
|
201
|
+
* `external_price_id` field.
|
|
202
|
+
*
|
|
203
|
+
* ### Replacing Prices
|
|
204
|
+
*
|
|
205
|
+
* To replace prices, provide a list of objects with the key `replace_prices`. An
|
|
206
|
+
* object in the list must specify a plan price to replace with the
|
|
207
|
+
* `replaces_price_id` key, and it must specify a price to replace it with by
|
|
208
|
+
* either referencing an existing add-on price with a `price_id` or
|
|
209
|
+
* `external_price_id` field, or by creating a new add-on price by including an
|
|
210
|
+
* object with the key `price`, identical to what would be used in the request body
|
|
211
|
+
* for the [create price endpoint](../reference/create-price). See the
|
|
212
|
+
* [Price resource](../reference/price) for the specification of different price
|
|
213
|
+
* model configurations possible in this object.
|
|
214
|
+
*
|
|
215
|
+
* For fixed fees, an object in the list can supply a `fixed_price_quantity`
|
|
216
|
+
* instead of a `price`, `price_id`, or `external_price_id` field. This will update
|
|
217
|
+
* only the quantity for the price, similar to the
|
|
218
|
+
* [Update price quantity](../reference/update-fixed-fee-quantity) endpoint.
|
|
219
|
+
*
|
|
220
|
+
* The replacement price will have the same phase, if applicable, and the same
|
|
221
|
+
* start and end dates as the price it replaces.
|
|
222
|
+
*
|
|
223
|
+
* An object in the list can specify an optional `minimum_amount`,
|
|
224
|
+
* `maximum_amount`, or `discounts`. This will create adjustments which apply only
|
|
225
|
+
* to this price.
|
|
226
|
+
*
|
|
227
|
+
* Additionally, an object in the list can specify an optional `reference_id`. This
|
|
228
|
+
* ID can be used to reference the replacement price when
|
|
229
|
+
* [adding an adjustment](#adding-adjustments) in the same API call. However the ID
|
|
230
|
+
* is _transient_ and cannot be used to refer to the price in future API calls.
|
|
231
|
+
*
|
|
232
|
+
* ### Adding adjustments
|
|
233
|
+
*
|
|
234
|
+
* To add adjustments, provide a list of objects with the key `add_adjustments`. An
|
|
235
|
+
* object in the list must include an object with the key `adjustment`, identical
|
|
236
|
+
* to the adjustment object in the
|
|
237
|
+
* [add/edit price intervals endpoint](../reference/add-edit-price-intervals).
|
|
238
|
+
*
|
|
239
|
+
* If the plan has phases, each object in the list must include a number with
|
|
240
|
+
* `plan_phase_order` key to indicate which phase the adjustment should be added
|
|
241
|
+
* to.
|
|
242
|
+
*
|
|
243
|
+
* An object in the list can specify an optional `start_date` and optional
|
|
244
|
+
* `end_date`. If unspecified, the start or end date of the phase or subscription
|
|
245
|
+
* will be used.
|
|
246
|
+
*
|
|
247
|
+
* ### Removing adjustments
|
|
248
|
+
*
|
|
249
|
+
* To remove adjustments, provide a list of objects with the key
|
|
250
|
+
* `remove_adjustments`. An object in the list must include a key, `adjustment_id`,
|
|
251
|
+
* with the ID of the adjustment to be removed.
|
|
252
|
+
*
|
|
253
|
+
* ### Replacing adjustments
|
|
254
|
+
*
|
|
255
|
+
* To replace adjustments, provide a list of objects with the key
|
|
256
|
+
* `replace_adjustments`. An object in the list must specify a plan adjustment to
|
|
257
|
+
* replace with the `replaces_adjustment_id` key, and it must specify an adjustment
|
|
258
|
+
* to replace it with by including an object with the key `adjustment`, identical
|
|
259
|
+
* to the adjustment object in the
|
|
260
|
+
* [add/edit price intervals endpoint](../reference/add-edit-price-intervals).
|
|
261
|
+
*
|
|
262
|
+
* The replacement adjustment will have the same phase, if applicable, and the same
|
|
263
|
+
* start and end dates as the adjustment it replaces.
|
|
264
|
+
*
|
|
265
|
+
* ## Price overrides (DEPRECATED)
|
|
266
|
+
*
|
|
267
|
+
* :::info Price overrides are being phased out in favor adding/removing/replacing
|
|
268
|
+
* prices. (See
|
|
269
|
+
* [Customize your customer's subscriptions](../reference/schedule-plan-change#customize-your-customers-subscriptions))
|
|
270
|
+
* :::
|
|
271
|
+
*
|
|
272
|
+
* Price overrides are used to update some or all prices in a plan for the specific
|
|
273
|
+
* subscription being created. This is useful when a new customer has negotiated a
|
|
274
|
+
* rate that is unique to the customer.
|
|
275
|
+
*
|
|
276
|
+
* To override prices, provide a list of objects with the key `price_overrides`.
|
|
277
|
+
* The price object in the list of overrides is expected to contain the existing
|
|
278
|
+
* price id, the `model_type` and configuration. (See the
|
|
279
|
+
* [Price resource](../reference/price) for the specification of different price
|
|
280
|
+
* model configurations.) The numerical values can be updated, but the billable
|
|
281
|
+
* metric, cadence, type, and name of a price can not be overridden.
|
|
282
|
+
*
|
|
283
|
+
* ### Maximums, and minimums
|
|
149
284
|
*
|
|
150
285
|
* Price overrides are used to update some or all prices in the target plan.
|
|
151
286
|
* Minimums and maximums, much like price overrides, can be useful when a new
|
|
152
287
|
* customer has negotiated a new or different minimum or maximum spend cap than the
|
|
153
|
-
* default for the plan. The request format for
|
|
154
|
-
*
|
|
288
|
+
* default for the plan. The request format for maximums and minimums is the same
|
|
289
|
+
* as those in [subscription creation](create-subscription).
|
|
155
290
|
*
|
|
156
291
|
* ## Scheduling multiple plan changes
|
|
157
292
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscriptions.mjs","sourceRoot":"","sources":["../src/resources/subscriptions.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OACf,EAAE,gBAAgB,EAAE;OAEpB,KAAK,gBAAgB;OAKrB,EAAE,IAAI,EAAmB;AAEhC,MAAM,OAAO,aAAc,SAAQ,WAAW;
|
|
1
|
+
{"version":3,"file":"subscriptions.mjs","sourceRoot":"","sources":["../src/resources/subscriptions.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OACf,EAAE,gBAAgB,EAAE;OAEpB,KAAK,gBAAgB;OAKrB,EAAE,IAAI,EAAmB;AAEhC,MAAM,OAAO,aAAc,SAAQ,WAAW;IAkQ5C,MAAM,CACJ,OAAuD,EAAE,EACzD,OAA6B;QAE7B,IAAI,gBAAgB,CAAC,IAAI,CAAC,EAAE;YAC1B,OAAO,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;SAC9B;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACnE,CAAC;IAaD,MAAM,CACJ,cAAsB,EACtB,OAAuD,EAAE,EACzD,OAA6B;QAE7B,IAAI,gBAAg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IAAI,CAAC,kBAAkB,cAAc,4BAA4B,EAAE;YACrF,IAAI;YACJ,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACH,WAAW,CACT,cAAsB,EACtB,IAAmC,EACnC,OAA6B;QAE7B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,kBAAkB,cAAc,eAAe,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAClG,CAAC;CACF;AAED,MAAM,OAAO,iBAAkB,SAAQ,IAAkB;CAAG;AAE5D,MAAM,OAAO,sCAAuC,SAAQ,IAAuC;CAAG;AAkwctG,WAAiB,aAAa;IAGd,2BAAa,GAAG,gBAAgB,CAAC,aAAa,CAAC;IAG/C,+BAAiB,GAAG,gBAAgB,CAAC,iBAAiB,CAAC;IACvD,oDAAsC,GAAG,gBAAgB,CAAC,sCAAsC,CAAC;AAcjH,CAAC,EArBgB,aAAa,KAAb,aAAa,QAqB7B"}
|
package/src/core.ts
CHANGED
|
@@ -351,9 +351,13 @@ export abstract class APIClient {
|
|
|
351
351
|
delete reqHeaders['content-type'];
|
|
352
352
|
}
|
|
353
353
|
|
|
354
|
-
// Don't set the retry count header if it was already set or removed
|
|
355
|
-
// which can contain nulls, instead of `reqHeaders` to
|
|
356
|
-
|
|
354
|
+
// Don't set the retry count header if it was already set or removed through default headers or by the
|
|
355
|
+
// caller. We check `defaultHeaders` and `headers`, which can contain nulls, instead of `reqHeaders` to
|
|
356
|
+
// account for the removal case.
|
|
357
|
+
if (
|
|
358
|
+
getHeader(defaultHeaders, 'x-stainless-retry-count') === undefined &&
|
|
359
|
+
getHeader(headers, 'x-stainless-retry-count') === undefined
|
|
360
|
+
) {
|
|
357
361
|
reqHeaders['x-stainless-retry-count'] = String(retryCount);
|
|
358
362
|
}
|
|
359
363
|
|
|
@@ -301,7 +301,7 @@ export interface Invoice {
|
|
|
301
301
|
* list is provided, the first discount in the list will be returned. If the list
|
|
302
302
|
* is empty, `None` will be returned.
|
|
303
303
|
*/
|
|
304
|
-
discount:
|
|
304
|
+
discount: unknown | null;
|
|
305
305
|
|
|
306
306
|
discounts: Array<Shared.InvoiceLevelDiscount>;
|
|
307
307
|
|
|
@@ -1475,7 +1475,7 @@ export interface InvoiceFetchUpcomingResponse {
|
|
|
1475
1475
|
* list is provided, the first discount in the list will be returned. If the list
|
|
1476
1476
|
* is empty, `None` will be returned.
|
|
1477
1477
|
*/
|
|
1478
|
-
discount:
|
|
1478
|
+
discount: unknown | null;
|
|
1479
1479
|
|
|
1480
1480
|
discounts: Array<Shared.InvoiceLevelDiscount>;
|
|
1481
1481
|
|