@paygentic/sdk 0.9.7 → 0.9.9
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/dist/commonjs/funcs/customersList.js +2 -2
- package/dist/commonjs/funcs/customersList.js.map +1 -1
- package/dist/commonjs/funcs/subscriptionsCreateSubscriptionAdjustment.d.ts +1 -1
- package/dist/commonjs/funcs/subscriptionsCreateSubscriptionAdjustment.js +1 -1
- package/dist/commonjs/funcs/subscriptionsReconcileSubscriptionFeatures.js +2 -2
- package/dist/commonjs/funcs/subscriptionsReconcileSubscriptionFeatures.js.map +1 -1
- package/dist/commonjs/lib/config.d.ts +2 -2
- package/dist/commonjs/lib/config.js +2 -2
- package/dist/commonjs/models/createpercentagediscountadjustment.d.ts +40 -0
- package/dist/commonjs/models/createpercentagediscountadjustment.d.ts.map +1 -0
- package/dist/commonjs/models/createpercentagediscountadjustment.js +54 -0
- package/dist/commonjs/models/createpercentagediscountadjustment.js.map +1 -0
- package/dist/commonjs/models/createsubscriptionadjustmentrequest.d.ts +5 -45
- package/dist/commonjs/models/createsubscriptionadjustmentrequest.d.ts.map +1 -1
- package/dist/commonjs/models/createsubscriptionadjustmentrequest.js +7 -18
- package/dist/commonjs/models/createsubscriptionadjustmentrequest.js.map +1 -1
- package/dist/commonjs/models/createusagediscountadjustment.d.ts +45 -0
- package/dist/commonjs/models/createusagediscountadjustment.d.ts.map +1 -0
- package/dist/commonjs/models/createusagediscountadjustment.js +55 -0
- package/dist/commonjs/models/createusagediscountadjustment.js.map +1 -0
- package/dist/commonjs/models/index.d.ts +4 -0
- package/dist/commonjs/models/index.d.ts.map +1 -1
- package/dist/commonjs/models/index.js +4 -0
- package/dist/commonjs/models/index.js.map +1 -1
- package/dist/commonjs/models/lineitem.d.ts +4 -0
- package/dist/commonjs/models/lineitem.d.ts.map +1 -1
- package/dist/commonjs/models/lineitem.js +1 -0
- package/dist/commonjs/models/lineitem.js.map +1 -1
- package/dist/commonjs/models/operations/createprice.d.ts +15 -0
- package/dist/commonjs/models/operations/createprice.d.ts.map +1 -1
- package/dist/commonjs/models/operations/createprice.js +3 -0
- package/dist/commonjs/models/operations/createprice.js.map +1 -1
- package/dist/commonjs/models/operations/updateprice.d.ts +15 -0
- package/dist/commonjs/models/operations/updateprice.d.ts.map +1 -1
- package/dist/commonjs/models/operations/updateprice.js +3 -0
- package/dist/commonjs/models/operations/updateprice.js.map +1 -1
- package/dist/commonjs/models/planversionpriceslot.d.ts +30 -0
- package/dist/commonjs/models/planversionpriceslot.d.ts.map +1 -1
- package/dist/commonjs/models/planversionpriceslot.js +15 -1
- package/dist/commonjs/models/planversionpriceslot.js.map +1 -1
- package/dist/commonjs/models/price.d.ts +30 -0
- package/dist/commonjs/models/price.d.ts.map +1 -1
- package/dist/commonjs/models/price.js +15 -1
- package/dist/commonjs/models/price.js.map +1 -1
- package/dist/commonjs/models/priceproperties.d.ts +3 -3
- package/dist/commonjs/models/pricetax.d.ts +58 -0
- package/dist/commonjs/models/pricetax.d.ts.map +1 -0
- package/dist/commonjs/models/pricetax.js +82 -0
- package/dist/commonjs/models/pricetax.js.map +1 -0
- package/dist/commonjs/models/ratetype.d.ts +18 -0
- package/dist/commonjs/models/ratetype.d.ts.map +1 -0
- package/dist/commonjs/models/ratetype.js +53 -0
- package/dist/commonjs/models/ratetype.js.map +1 -0
- package/dist/commonjs/models/schemasprice.d.ts +14 -0
- package/dist/commonjs/models/schemasprice.d.ts.map +1 -1
- package/dist/commonjs/models/schemasprice.js +5 -0
- package/dist/commonjs/models/schemasprice.js.map +1 -1
- package/dist/commonjs/models/subscriptionadjustment.d.ts +14 -5
- package/dist/commonjs/models/subscriptionadjustment.d.ts.map +1 -1
- package/dist/commonjs/models/subscriptionadjustment.js +4 -1
- package/dist/commonjs/models/subscriptionadjustment.js.map +1 -1
- package/dist/commonjs/sdk/subscriptions.d.ts +1 -1
- package/dist/commonjs/sdk/subscriptions.js +1 -1
- package/dist/esm/funcs/customersList.js +2 -2
- package/dist/esm/funcs/customersList.js.map +1 -1
- package/dist/esm/funcs/subscriptionsCreateSubscriptionAdjustment.d.ts +1 -1
- package/dist/esm/funcs/subscriptionsCreateSubscriptionAdjustment.js +1 -1
- package/dist/esm/funcs/subscriptionsReconcileSubscriptionFeatures.js +2 -2
- package/dist/esm/funcs/subscriptionsReconcileSubscriptionFeatures.js.map +1 -1
- package/dist/esm/lib/config.d.ts +2 -2
- package/dist/esm/lib/config.js +2 -2
- package/dist/esm/models/createpercentagediscountadjustment.d.ts +40 -0
- package/dist/esm/models/createpercentagediscountadjustment.d.ts.map +1 -0
- package/dist/esm/models/createpercentagediscountadjustment.js +17 -0
- package/dist/esm/models/createpercentagediscountadjustment.js.map +1 -0
- package/dist/esm/models/createsubscriptionadjustmentrequest.d.ts +5 -45
- package/dist/esm/models/createsubscriptionadjustmentrequest.d.ts.map +1 -1
- package/dist/esm/models/createsubscriptionadjustmentrequest.js +6 -17
- package/dist/esm/models/createsubscriptionadjustmentrequest.js.map +1 -1
- package/dist/esm/models/createusagediscountadjustment.d.ts +45 -0
- package/dist/esm/models/createusagediscountadjustment.d.ts.map +1 -0
- package/dist/esm/models/createusagediscountadjustment.js +18 -0
- package/dist/esm/models/createusagediscountadjustment.js.map +1 -0
- package/dist/esm/models/index.d.ts +4 -0
- package/dist/esm/models/index.d.ts.map +1 -1
- package/dist/esm/models/index.js +4 -0
- package/dist/esm/models/index.js.map +1 -1
- package/dist/esm/models/lineitem.d.ts +4 -0
- package/dist/esm/models/lineitem.d.ts.map +1 -1
- package/dist/esm/models/lineitem.js +1 -0
- package/dist/esm/models/lineitem.js.map +1 -1
- package/dist/esm/models/operations/createprice.d.ts +15 -0
- package/dist/esm/models/operations/createprice.d.ts.map +1 -1
- package/dist/esm/models/operations/createprice.js +3 -0
- package/dist/esm/models/operations/createprice.js.map +1 -1
- package/dist/esm/models/operations/updateprice.d.ts +15 -0
- package/dist/esm/models/operations/updateprice.d.ts.map +1 -1
- package/dist/esm/models/operations/updateprice.js +3 -0
- package/dist/esm/models/operations/updateprice.js.map +1 -1
- package/dist/esm/models/planversionpriceslot.d.ts +30 -0
- package/dist/esm/models/planversionpriceslot.d.ts.map +1 -1
- package/dist/esm/models/planversionpriceslot.js +14 -0
- package/dist/esm/models/planversionpriceslot.js.map +1 -1
- package/dist/esm/models/price.d.ts +30 -0
- package/dist/esm/models/price.d.ts.map +1 -1
- package/dist/esm/models/price.js +14 -0
- package/dist/esm/models/price.js.map +1 -1
- package/dist/esm/models/priceproperties.d.ts +3 -3
- package/dist/esm/models/pricetax.d.ts +58 -0
- package/dist/esm/models/pricetax.d.ts.map +1 -0
- package/dist/esm/models/pricetax.js +44 -0
- package/dist/esm/models/pricetax.js.map +1 -0
- package/dist/esm/models/ratetype.d.ts +18 -0
- package/dist/esm/models/ratetype.d.ts.map +1 -0
- package/dist/esm/models/ratetype.js +17 -0
- package/dist/esm/models/ratetype.js.map +1 -0
- package/dist/esm/models/schemasprice.d.ts +14 -0
- package/dist/esm/models/schemasprice.d.ts.map +1 -1
- package/dist/esm/models/schemasprice.js +5 -0
- package/dist/esm/models/schemasprice.js.map +1 -1
- package/dist/esm/models/subscriptionadjustment.d.ts +14 -5
- package/dist/esm/models/subscriptionadjustment.d.ts.map +1 -1
- package/dist/esm/models/subscriptionadjustment.js +4 -1
- package/dist/esm/models/subscriptionadjustment.js.map +1 -1
- package/dist/esm/sdk/subscriptions.d.ts +1 -1
- package/dist/esm/sdk/subscriptions.js +1 -1
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/funcs/customersList.ts +2 -2
- package/src/funcs/subscriptionsCreateSubscriptionAdjustment.ts +1 -1
- package/src/funcs/subscriptionsReconcileSubscriptionFeatures.ts +2 -2
- package/src/lib/config.ts +2 -2
- package/src/models/createpercentagediscountadjustment.ts +66 -0
- package/src/models/createsubscriptionadjustmentrequest.ts +21 -59
- package/src/models/createusagediscountadjustment.ts +72 -0
- package/src/models/index.ts +4 -0
- package/src/models/lineitem.ts +5 -0
- package/src/models/operations/createprice.ts +18 -0
- package/src/models/operations/updateprice.ts +18 -0
- package/src/models/planversionpriceslot.ts +40 -0
- package/src/models/price.ts +38 -0
- package/src/models/priceproperties.ts +3 -3
- package/src/models/pricetax.ts +100 -0
- package/src/models/ratetype.ts +25 -0
- package/src/models/schemasprice.ts +17 -0
- package/src/models/subscriptionadjustment.ts +17 -6
- package/src/sdk/subscriptions.ts +1 -1
|
@@ -30,7 +30,7 @@ import { Result } from "../types/fp.js";
|
|
|
30
30
|
* Create Adjustment
|
|
31
31
|
*
|
|
32
32
|
* @remarks
|
|
33
|
-
* Attaches
|
|
33
|
+
* Attaches an adjustment to the subscription for a dated window. A percentageDiscount reduces every discountable charge by a rate and carries one discount line per charge on the invoice. A usageDiscount takes a number of usage units off one metered price's billable quantity before that line is priced, so the line re-slots on a volume ladder and shows the corrected quantity; it emits no line of its own. Tax is assessed on the reduced amount either way. An invoice that already exists is not changed, including one still in draft — the adjustment reaches the periods that close after it is created. There is no update operation, and a window cannot be changed after it is created. To change an adjustment before any invoice has issued under it, delete it and create a replacement. Once an invoice has issued the adjustment is permanent, so set effectiveTo at creation time whenever the deal has a known end date.
|
|
34
34
|
*/
|
|
35
35
|
export function subscriptionsCreateSubscriptionAdjustment(
|
|
36
36
|
client: PaygenticCore,
|
|
@@ -143,7 +143,7 @@ async function $do(
|
|
|
143
143
|
|
|
144
144
|
const doResult = await client._do(req, {
|
|
145
145
|
context,
|
|
146
|
-
errorCodes: ["400", "401", "403", "404", "4XX", "500", "5XX"],
|
|
146
|
+
errorCodes: ["400", "401", "403", "404", "429", "4XX", "500", "5XX"],
|
|
147
147
|
retryConfig: context.retryConfig,
|
|
148
148
|
retryCodes: context.retryCodes,
|
|
149
149
|
});
|
|
@@ -171,7 +171,7 @@ async function $do(
|
|
|
171
171
|
>(
|
|
172
172
|
M.json([200, 201], models.SubscriptionReconciliation$inboundSchema),
|
|
173
173
|
M.jsonErr(400, errors.BadRequest$inboundSchema),
|
|
174
|
-
M.jsonErr([401, 403, 404], errors.ErrorT$inboundSchema),
|
|
174
|
+
M.jsonErr([401, 403, 404, 429], errors.ErrorT$inboundSchema),
|
|
175
175
|
M.jsonErr(500, errors.ErrorT$inboundSchema),
|
|
176
176
|
M.fail("4XX"),
|
|
177
177
|
M.fail("5XX"),
|
package/src/lib/config.ts
CHANGED
|
@@ -65,7 +65,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
|
|
|
65
65
|
export const SDK_METADATA = {
|
|
66
66
|
language: "typescript",
|
|
67
67
|
openapiDocVersion: "0.1.0",
|
|
68
|
-
sdkVersion: "0.9.
|
|
68
|
+
sdkVersion: "0.9.9",
|
|
69
69
|
genVersion: "2.879.13",
|
|
70
|
-
userAgent: "speakeasy-sdk/typescript 0.9.
|
|
70
|
+
userAgent: "speakeasy-sdk/typescript 0.9.9 2.879.13 0.1.0 @paygentic/sdk",
|
|
71
71
|
} as const;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
|
|
7
|
+
export type CreatePercentageDiscountAdjustment = {
|
|
8
|
+
/**
|
|
9
|
+
* Reduces every discountable charge on the invoice by a rate.
|
|
10
|
+
*/
|
|
11
|
+
type: "percentageDiscount";
|
|
12
|
+
/**
|
|
13
|
+
* The discount rate as a decimal fraction between 0 and 1, sent as a string. "0.35" means 35 percent. "1" means 100 percent, not 1 percent. At most 6 decimal places. A value of 0 or above 1 is rejected.
|
|
14
|
+
*/
|
|
15
|
+
percentageDiscount: string;
|
|
16
|
+
/**
|
|
17
|
+
* The first instant the discount applies. Inclusive.
|
|
18
|
+
*/
|
|
19
|
+
effectiveFrom: Date;
|
|
20
|
+
/**
|
|
21
|
+
* The instant the discount stops applying. Exclusive, so a window ending on the same date another begins neither overlaps nor leaves a gap. Null means the discount never stops, and it cannot be ended later — set an instant whenever the deal has a known end date. Must be after effectiveFrom.
|
|
22
|
+
*/
|
|
23
|
+
effectiveTo?: Date | null | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* The deal's own name, shown on each discount line of the invoice.
|
|
26
|
+
*/
|
|
27
|
+
description?: string | null | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* A key of your choosing that makes a retry safe. Sending the same key against the same subscription returns the adjustment already created and creates no second one. Without a key a retried request creates a second adjustment, and two percentage discounts compound — two of 0.35 bill 57.75 percent off, not 35 percent.
|
|
30
|
+
*/
|
|
31
|
+
idempotencyKey?: string | undefined;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/** @internal */
|
|
35
|
+
export type CreatePercentageDiscountAdjustment$Outbound = {
|
|
36
|
+
type: "percentageDiscount";
|
|
37
|
+
percentageDiscount: string;
|
|
38
|
+
effectiveFrom: string;
|
|
39
|
+
effectiveTo?: string | null | undefined;
|
|
40
|
+
description?: string | null | undefined;
|
|
41
|
+
idempotencyKey?: string | undefined;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** @internal */
|
|
45
|
+
export const CreatePercentageDiscountAdjustment$outboundSchema: z.ZodType<
|
|
46
|
+
CreatePercentageDiscountAdjustment$Outbound,
|
|
47
|
+
z.ZodTypeDef,
|
|
48
|
+
CreatePercentageDiscountAdjustment
|
|
49
|
+
> = z.object({
|
|
50
|
+
type: z.literal("percentageDiscount"),
|
|
51
|
+
percentageDiscount: z.string(),
|
|
52
|
+
effectiveFrom: z.date().transform(v => v.toISOString()),
|
|
53
|
+
effectiveTo: z.nullable(z.date().transform(v => v.toISOString())).optional(),
|
|
54
|
+
description: z.nullable(z.string()).optional(),
|
|
55
|
+
idempotencyKey: z.string().optional(),
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export function createPercentageDiscountAdjustmentToJSON(
|
|
59
|
+
createPercentageDiscountAdjustment: CreatePercentageDiscountAdjustment,
|
|
60
|
+
): string {
|
|
61
|
+
return JSON.stringify(
|
|
62
|
+
CreatePercentageDiscountAdjustment$outboundSchema.parse(
|
|
63
|
+
createPercentageDiscountAdjustment,
|
|
64
|
+
),
|
|
65
|
+
);
|
|
66
|
+
}
|
|
@@ -3,76 +3,38 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import * as z from "zod/v3";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
CreatePercentageDiscountAdjustment,
|
|
8
|
+
CreatePercentageDiscountAdjustment$Outbound,
|
|
9
|
+
CreatePercentageDiscountAdjustment$outboundSchema,
|
|
10
|
+
} from "./createpercentagediscountadjustment.js";
|
|
11
|
+
import {
|
|
12
|
+
CreateUsageDiscountAdjustment,
|
|
13
|
+
CreateUsageDiscountAdjustment$Outbound,
|
|
14
|
+
CreateUsageDiscountAdjustment$outboundSchema,
|
|
15
|
+
} from "./createusagediscountadjustment.js";
|
|
7
16
|
|
|
8
17
|
/**
|
|
9
|
-
*
|
|
18
|
+
* One adjustment to attach to the subscription. The type decides which number the body carries: a rate for percentageDiscount, a unit count and one target price for usageDiscount.
|
|
10
19
|
*/
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The kind of adjustment. `percentageDiscount` reduces every discountable charge by a rate.
|
|
16
|
-
*/
|
|
17
|
-
export type CreateSubscriptionAdjustmentRequestType = ClosedEnum<
|
|
18
|
-
typeof CreateSubscriptionAdjustmentRequestType
|
|
19
|
-
>;
|
|
20
|
-
|
|
21
|
-
export type CreateSubscriptionAdjustmentRequest = {
|
|
22
|
-
/**
|
|
23
|
-
* The kind of adjustment. `percentageDiscount` reduces every discountable charge by a rate.
|
|
24
|
-
*/
|
|
25
|
-
type: CreateSubscriptionAdjustmentRequestType;
|
|
26
|
-
/**
|
|
27
|
-
* The discount rate as a decimal fraction between 0 and 1, sent as a string. "0.35" means 35 percent. "1" means 100 percent, not 1 percent. At most 6 decimal places. A value of 0 or above 1 is rejected.
|
|
28
|
-
*/
|
|
29
|
-
percentageDiscount: string;
|
|
30
|
-
/**
|
|
31
|
-
* The first instant the discount applies. Inclusive.
|
|
32
|
-
*/
|
|
33
|
-
effectiveFrom: Date;
|
|
34
|
-
/**
|
|
35
|
-
* The instant the discount stops applying. Exclusive, so a window ending on the same date another begins neither overlaps nor leaves a gap. Null means the discount never stops, and it cannot be ended later — set an instant whenever the deal has a known end date. Must be after effectiveFrom.
|
|
36
|
-
*/
|
|
37
|
-
effectiveTo?: Date | null | undefined;
|
|
38
|
-
/**
|
|
39
|
-
* The deal's own name, shown on each discount line of the invoice.
|
|
40
|
-
*/
|
|
41
|
-
description?: string | null | undefined;
|
|
42
|
-
/**
|
|
43
|
-
* A key of your choosing that makes a retry safe. Sending the same key against the same subscription returns the adjustment already created and creates no second one. Without a key a retried request creates a second adjustment, and two percentage discounts compound — two of 0.35 bill 57.75 percent off, not 35 percent.
|
|
44
|
-
*/
|
|
45
|
-
idempotencyKey?: string | undefined;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/** @internal */
|
|
49
|
-
export const CreateSubscriptionAdjustmentRequestType$outboundSchema:
|
|
50
|
-
z.ZodNativeEnum<typeof CreateSubscriptionAdjustmentRequestType> = z
|
|
51
|
-
.nativeEnum(CreateSubscriptionAdjustmentRequestType);
|
|
20
|
+
export type CreateSubscriptionAdjustmentRequest =
|
|
21
|
+
| CreatePercentageDiscountAdjustment
|
|
22
|
+
| CreateUsageDiscountAdjustment;
|
|
52
23
|
|
|
53
24
|
/** @internal */
|
|
54
|
-
export type CreateSubscriptionAdjustmentRequest$Outbound =
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
effectiveFrom: string;
|
|
58
|
-
effectiveTo?: string | null | undefined;
|
|
59
|
-
description?: string | null | undefined;
|
|
60
|
-
idempotencyKey?: string | undefined;
|
|
61
|
-
};
|
|
25
|
+
export type CreateSubscriptionAdjustmentRequest$Outbound =
|
|
26
|
+
| CreatePercentageDiscountAdjustment$Outbound
|
|
27
|
+
| CreateUsageDiscountAdjustment$Outbound;
|
|
62
28
|
|
|
63
29
|
/** @internal */
|
|
64
30
|
export const CreateSubscriptionAdjustmentRequest$outboundSchema: z.ZodType<
|
|
65
31
|
CreateSubscriptionAdjustmentRequest$Outbound,
|
|
66
32
|
z.ZodTypeDef,
|
|
67
33
|
CreateSubscriptionAdjustmentRequest
|
|
68
|
-
> = z.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
effectiveTo: z.nullable(z.date().transform(v => v.toISOString())).optional(),
|
|
73
|
-
description: z.nullable(z.string()).optional(),
|
|
74
|
-
idempotencyKey: z.string().optional(),
|
|
75
|
-
});
|
|
34
|
+
> = z.union([
|
|
35
|
+
CreatePercentageDiscountAdjustment$outboundSchema,
|
|
36
|
+
CreateUsageDiscountAdjustment$outboundSchema,
|
|
37
|
+
]);
|
|
76
38
|
|
|
77
39
|
export function createSubscriptionAdjustmentRequestToJSON(
|
|
78
40
|
createSubscriptionAdjustmentRequest: CreateSubscriptionAdjustmentRequest,
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
|
|
7
|
+
export type CreateUsageDiscountAdjustment = {
|
|
8
|
+
/**
|
|
9
|
+
* Reduces one metered price's billable quantity by a number of usage units, before the line is priced.
|
|
10
|
+
*/
|
|
11
|
+
type: "usageDiscount";
|
|
12
|
+
/**
|
|
13
|
+
* The number of usage units to take off the billable quantity, sent as a plain decimal string. "300" waives 300 units. Greater than 0, at most 6 decimal places, fewer than 35 digits before the point. Plain notation only — no sign, exponent, hex or digit separators, so "1_000" and "1e3" are rejected rather than read as 1000. Applied in full or not at all — a unit count is never prorated across a partial window — and once per matching line, so an invoice bundling several periods is corrected on each of them. The line is floored at 0, so a discount larger than the billable quantity zeroes it rather than crediting. On a volume ladder the corrected quantity also re-selects the band, so a waiver that crosses a boundary can bill more than the uncorrected line did: waiving 300 of 1000 units on a ladder of 2.00 up to 999 and 1.00 beyond bills 700 at 2.00 for 1400.00, where the 1000 units billed 1000.00. That is the ladder's price for the corrected usage — what a customer who genuinely used 700 units pays — so check the ladder before waiving units near a band boundary.
|
|
14
|
+
*/
|
|
15
|
+
usageDiscount: string;
|
|
16
|
+
/**
|
|
17
|
+
* Exactly one metered price of this subscription, priced as standard or volume. Usage units are not comparable across metrics, so a usage discount names the one price it reduces. A dynamic or percentage price is refused: its quantity is a monetary amount rather than a unit count. A price billing at a negative rate (a usage-scaled rebate) is refused too, because removing its units would raise the invoice.
|
|
18
|
+
*/
|
|
19
|
+
targetPriceIds: Array<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Opens the window. Exclusive for this type: a metered line is corrected when its period END falls after this instant, so a window opening exactly when a period ends belongs to the next period, not that one. Set it to the start of the period you are correcting.
|
|
22
|
+
*/
|
|
23
|
+
effectiveFrom: Date;
|
|
24
|
+
/**
|
|
25
|
+
* Closes the window. INCLUSIVE for this type, unlike percentageDiscount: a metered line bills in arrears, so set this to the exact period end you are correcting and that period is covered. Null means the discount never stops — it then takes its full unit count off this price on EVERY later invoice, so set both bounds whenever you are correcting one period. Must be after effectiveFrom.
|
|
26
|
+
*/
|
|
27
|
+
effectiveTo?: Date | null | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Your own name for this correction. A usageDiscount emits no invoice line, so this is printed nowhere on the invoice — it is returned on the adjustment for your own records.
|
|
30
|
+
*/
|
|
31
|
+
description?: string | null | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* A key of your choosing that makes a retry safe. Sending the same key against the same subscription returns the adjustment already created and creates no second one. Without a key a retried request creates a second adjustment, and usage discounts against one price SUM — two of "300" waive 600 units, not 300. Nothing else detects a duplicate.
|
|
34
|
+
*/
|
|
35
|
+
idempotencyKey?: string | undefined;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** @internal */
|
|
39
|
+
export type CreateUsageDiscountAdjustment$Outbound = {
|
|
40
|
+
type: "usageDiscount";
|
|
41
|
+
usageDiscount: string;
|
|
42
|
+
targetPriceIds: Array<string>;
|
|
43
|
+
effectiveFrom: string;
|
|
44
|
+
effectiveTo?: string | null | undefined;
|
|
45
|
+
description?: string | null | undefined;
|
|
46
|
+
idempotencyKey?: string | undefined;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/** @internal */
|
|
50
|
+
export const CreateUsageDiscountAdjustment$outboundSchema: z.ZodType<
|
|
51
|
+
CreateUsageDiscountAdjustment$Outbound,
|
|
52
|
+
z.ZodTypeDef,
|
|
53
|
+
CreateUsageDiscountAdjustment
|
|
54
|
+
> = z.object({
|
|
55
|
+
type: z.literal("usageDiscount"),
|
|
56
|
+
usageDiscount: z.string(),
|
|
57
|
+
targetPriceIds: z.array(z.string()),
|
|
58
|
+
effectiveFrom: z.date().transform(v => v.toISOString()),
|
|
59
|
+
effectiveTo: z.nullable(z.date().transform(v => v.toISOString())).optional(),
|
|
60
|
+
description: z.nullable(z.string()).optional(),
|
|
61
|
+
idempotencyKey: z.string().optional(),
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
export function createUsageDiscountAdjustmentToJSON(
|
|
65
|
+
createUsageDiscountAdjustment: CreateUsageDiscountAdjustment,
|
|
66
|
+
): string {
|
|
67
|
+
return JSON.stringify(
|
|
68
|
+
CreateUsageDiscountAdjustment$outboundSchema.parse(
|
|
69
|
+
createUsageDiscountAdjustment,
|
|
70
|
+
),
|
|
71
|
+
);
|
|
72
|
+
}
|
package/src/models/index.ts
CHANGED
|
@@ -21,8 +21,10 @@ export * from "./createmanuallineitemrequest.js";
|
|
|
21
21
|
export * from "./createorderapprovalrequest.js";
|
|
22
22
|
export * from "./createorderlineitemrequest.js";
|
|
23
23
|
export * from "./createorderrequest.js";
|
|
24
|
+
export * from "./createpercentagediscountadjustment.js";
|
|
24
25
|
export * from "./createrulerequest.js";
|
|
25
26
|
export * from "./createsubscriptionadjustmentrequest.js";
|
|
27
|
+
export * from "./createusagediscountadjustment.js";
|
|
26
28
|
export * from "./currencybreakdownentry.js";
|
|
27
29
|
export * from "./customer.js";
|
|
28
30
|
export * from "./entitlementdetail.js";
|
|
@@ -77,12 +79,14 @@ export * from "./pricefeatureinput.js";
|
|
|
77
79
|
export * from "./pricemodel.js";
|
|
78
80
|
export * from "./pricemodelinput.js";
|
|
79
81
|
export * from "./priceproperties.js";
|
|
82
|
+
export * from "./pricetax.js";
|
|
80
83
|
export * from "./product.js";
|
|
81
84
|
export * from "./profitabilityrow.js";
|
|
82
85
|
export * from "./profitabilitysummaryresponse.js";
|
|
83
86
|
export * from "./profitabilitytrend.js";
|
|
84
87
|
export * from "./purchasegrantrequest.js";
|
|
85
88
|
export * from "./purchasegrantresponse.js";
|
|
89
|
+
export * from "./ratetype.js";
|
|
86
90
|
export * from "./reconciledfeatureadded.js";
|
|
87
91
|
export * from "./reconciledfeaturefailed.js";
|
|
88
92
|
export * from "./reconciledfeatureremoved.js";
|
package/src/models/lineitem.ts
CHANGED
|
@@ -120,6 +120,10 @@ export type LineItem = {
|
|
|
120
120
|
* Raw metered usage. Null for fee/manual lines
|
|
121
121
|
*/
|
|
122
122
|
meteredQuantity?: string | null | undefined;
|
|
123
|
+
/**
|
|
124
|
+
* The subscription adjustments of type `usageDiscount` that reduced this line's billable `quantity`. Empty for every other line. Where this is non-empty, `quantity` is below `meteredQuantity` because an operator waived units, rather than because a grant covered them.
|
|
125
|
+
*/
|
|
126
|
+
usageDiscountIds?: Array<string> | undefined;
|
|
123
127
|
/**
|
|
124
128
|
* When the line falls due relative to the window it covers. A fee line carries its price's term; a metered line is stamped `in_arrears`, though metered rows predating that rule carry `null`. Manual, grant-discount and adjustment lines are billed on no term of their own and are `null`. `null` is listed in the enum as well as via `nullable` because OpenAPI 3.0 validators check the enum independently — `nullable: true` alone does not admit it, and createLineItem (which always returns null here) was emitting a schema-violating body.
|
|
125
129
|
*/
|
|
@@ -196,6 +200,7 @@ export const LineItem$inboundSchema: z.ZodType<
|
|
|
196
200
|
quantity: z.nullable(z.string()).optional(),
|
|
197
201
|
unitPrice: z.string(),
|
|
198
202
|
meteredQuantity: z.nullable(z.string()).optional(),
|
|
203
|
+
usageDiscountIds: z.array(z.string()).optional(),
|
|
199
204
|
paymentTerm: z.nullable(LineItemPaymentTerm$inboundSchema).optional(),
|
|
200
205
|
subtotal: z.string().optional(),
|
|
201
206
|
taxesTotal: z.nullable(z.string()).optional(),
|
|
@@ -39,6 +39,10 @@ export type CreatePriceRequest = {
|
|
|
39
39
|
* Line item label shown on customer invoices. Sample values: 'Claude Token Consumption', 'Storage Usage (GB)', 'Inference API Calls', 'Image Generation Count', 'Training Compute Hours', 'Data Transfer (TB)'
|
|
40
40
|
*/
|
|
41
41
|
invoiceDisplayName: string;
|
|
42
|
+
/**
|
|
43
|
+
* Presentation only. Prices sharing this value, within one billing period, print as a single row on the rendered invoice PDF and are described by this string. Every member still bills its own line item on the ledger, this API and the compliance document. The combined row's rate is derived from the members' own rates. Requires the 'standard' pricing model. Sample values: 'Cross Border Fees', 'FX Fees'
|
|
44
|
+
*/
|
|
45
|
+
invoiceDisplayGroup?: string | null | undefined;
|
|
42
46
|
/**
|
|
43
47
|
* Billing timing preference: 'in_advance' (prepaid — charged upfront or drawn from a prepaid commitment) or 'in_arrears' (charged at period end).
|
|
44
48
|
*/
|
|
@@ -57,6 +61,14 @@ export type CreatePriceRequest = {
|
|
|
57
61
|
* A fixed amount owed whole rather than a per-period rate. An obligation is not prorated over a partial first period: when a subscription starts before its billing anchor, no truncated stub is billed and the first charge is the full amount at the next anchor. An obligation also refuses an interval boundary that falls strictly inside one of its own billing periods, since part of an amount owed whole is not a thing to bill. Defaults to false, which is a rate and is today's behaviour for every price. Not supported on a metered price, whose amount resolves from usage at close.
|
|
58
62
|
*/
|
|
59
63
|
isObligation?: boolean | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* What properties.unitPrice is denominated in. 'amount' (the default) is an amount of the invoice currency for each unit metered, so the quantity is the multiplier. 'proportion' is the reverse: a dimensionless share of a currency-denominated quantity, so '0.02' is 2% and the invoice prints '2.00%'. Presentation only. Requires a standard metered price in real currency.
|
|
66
|
+
*/
|
|
67
|
+
rateType?: models.RateType | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* A price's tax declaration. Optional on write — a price that declares nothing is `IN_SCOPE`, and is billed and taxed exactly as it was before this object existed. Always present on read. Replaced as a whole on update: send the object to change it, omit it to leave it alone.
|
|
70
|
+
*/
|
|
71
|
+
tax?: models.PriceTax | undefined;
|
|
60
72
|
/**
|
|
61
73
|
* Quantity for invoice line items. Total per period = quantity × unitPrice. Only supported for fee prices; metered prices derive quantity from usage. Defaults to 1.
|
|
62
74
|
*/
|
|
@@ -75,12 +87,15 @@ export type CreatePriceRequest$Outbound = {
|
|
|
75
87
|
pricingUnitId?: string | undefined;
|
|
76
88
|
model?: string | undefined;
|
|
77
89
|
invoiceDisplayName: string;
|
|
90
|
+
invoiceDisplayGroup?: string | null | undefined;
|
|
78
91
|
paymentTerm: string;
|
|
79
92
|
billingCadence?: string | null | undefined;
|
|
80
93
|
properties: models.PriceProperties$Outbound;
|
|
81
94
|
feature?: models.PriceFeatureInput$Outbound | undefined;
|
|
82
95
|
grantDiscountEnabled: boolean;
|
|
83
96
|
isObligation: boolean;
|
|
97
|
+
rateType?: string | undefined;
|
|
98
|
+
tax?: models.PriceTax$Outbound | undefined;
|
|
84
99
|
quantity?: number | undefined;
|
|
85
100
|
};
|
|
86
101
|
|
|
@@ -95,12 +110,15 @@ export const CreatePriceRequest$outboundSchema: z.ZodType<
|
|
|
95
110
|
pricingUnitId: z.string().optional(),
|
|
96
111
|
model: models.PriceModelInput$outboundSchema.optional(),
|
|
97
112
|
invoiceDisplayName: z.string(),
|
|
113
|
+
invoiceDisplayGroup: z.nullable(z.string()).optional(),
|
|
98
114
|
paymentTerm: CreatePricePaymentTerm$outboundSchema,
|
|
99
115
|
billingCadence: z.nullable(z.string()).optional(),
|
|
100
116
|
properties: models.PriceProperties$outboundSchema,
|
|
101
117
|
feature: models.PriceFeatureInput$outboundSchema.optional(),
|
|
102
118
|
grantDiscountEnabled: z.boolean().default(false),
|
|
103
119
|
isObligation: z.boolean().default(false),
|
|
120
|
+
rateType: models.RateType$outboundSchema.optional(),
|
|
121
|
+
tax: models.PriceTax$outboundSchema.optional(),
|
|
104
122
|
quantity: z.number().int().optional(),
|
|
105
123
|
});
|
|
106
124
|
|
|
@@ -35,6 +35,10 @@ export type UpdatePriceRequestBody = {
|
|
|
35
35
|
* Updated invoice line item label. Sample values: 'LLM Token Usage', 'Storage Charges', 'API Call Fees'
|
|
36
36
|
*/
|
|
37
37
|
invoiceDisplayName?: string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Presentation only. Prices sharing this value, within one billing period, print as a single row on the rendered invoice PDF and are described by this string. Every member still bills its own line item on the ledger, this API and the compliance document. The combined row's rate is derived from the members' own rates. Requires the 'standard' pricing model. Sample values: 'Cross Border Fees', 'FX Fees'
|
|
40
|
+
*/
|
|
41
|
+
invoiceDisplayGroup?: string | null | undefined;
|
|
38
42
|
/**
|
|
39
43
|
* The pricing model to set. 'standard' and 'volume' are accepted. Legacy 'dynamic'/'percentage' prices can still be edited (other fields) but cannot be switched back to those models. Percentage/revenue-share is expressed via 'standard' with a unit-price multiplier.
|
|
40
44
|
*/
|
|
@@ -60,6 +64,14 @@ export type UpdatePriceRequestBody = {
|
|
|
60
64
|
* A fixed amount owed whole rather than a per-period rate. An obligation is not prorated over a partial first period: when a subscription starts before its billing anchor, no truncated stub is billed and the first charge is the full amount at the next anchor. An obligation also refuses an interval boundary that falls strictly inside one of its own billing periods, since part of an amount owed whole is not a thing to bill. Defaults to false, which is a rate and is today's behaviour for every price. Not supported on a metered price, whose amount resolves from usage at close.
|
|
61
65
|
*/
|
|
62
66
|
isObligation?: boolean | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* What properties.unitPrice is denominated in. 'amount' (the default) is an amount of the invoice currency for each unit metered, so the quantity is the multiplier. 'proportion' is the reverse: a dimensionless share of a currency-denominated quantity, so '0.02' is 2% and the invoice prints '2.00%'. Presentation only. Requires a standard metered price in real currency.
|
|
69
|
+
*/
|
|
70
|
+
rateType?: models.RateType | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* A price's tax declaration. Optional on write — a price that declares nothing is `IN_SCOPE`, and is billed and taxed exactly as it was before this object existed. Always present on read. Replaced as a whole on update: send the object to change it, omit it to leave it alone.
|
|
73
|
+
*/
|
|
74
|
+
tax?: models.PriceTax | undefined;
|
|
63
75
|
/**
|
|
64
76
|
* Quantity for invoice line items. Total per period = quantity × unitPrice. Only supported for fee prices; metered prices derive quantity from usage. Defaults to 1.
|
|
65
77
|
*/
|
|
@@ -90,6 +102,7 @@ export type UpdatePriceRequestBody$Outbound = {
|
|
|
90
102
|
billableMetricId?: string | undefined;
|
|
91
103
|
pricingUnitId?: string | null | undefined;
|
|
92
104
|
invoiceDisplayName?: string | undefined;
|
|
105
|
+
invoiceDisplayGroup?: string | null | undefined;
|
|
93
106
|
model?: string | undefined;
|
|
94
107
|
properties?: models.PriceProperties$Outbound | undefined;
|
|
95
108
|
paymentTerm?: string | undefined;
|
|
@@ -97,6 +110,8 @@ export type UpdatePriceRequestBody$Outbound = {
|
|
|
97
110
|
feature?: models.PriceFeatureInput$Outbound | null | undefined;
|
|
98
111
|
grantDiscountEnabled?: boolean | undefined;
|
|
99
112
|
isObligation?: boolean | undefined;
|
|
113
|
+
rateType?: string | undefined;
|
|
114
|
+
tax?: models.PriceTax$Outbound | undefined;
|
|
100
115
|
quantity?: number | undefined;
|
|
101
116
|
};
|
|
102
117
|
|
|
@@ -109,6 +124,7 @@ export const UpdatePriceRequestBody$outboundSchema: z.ZodType<
|
|
|
109
124
|
billableMetricId: z.string().optional(),
|
|
110
125
|
pricingUnitId: z.nullable(z.string()).optional(),
|
|
111
126
|
invoiceDisplayName: z.string().optional(),
|
|
127
|
+
invoiceDisplayGroup: z.nullable(z.string()).optional(),
|
|
112
128
|
model: models.PriceModelInput$outboundSchema.optional(),
|
|
113
129
|
properties: models.PriceProperties$outboundSchema.optional(),
|
|
114
130
|
paymentTerm: UpdatePricePaymentTerm$outboundSchema.optional(),
|
|
@@ -116,6 +132,8 @@ export const UpdatePriceRequestBody$outboundSchema: z.ZodType<
|
|
|
116
132
|
feature: z.nullable(models.PriceFeatureInput$outboundSchema).optional(),
|
|
117
133
|
grantDiscountEnabled: z.boolean().optional(),
|
|
118
134
|
isObligation: z.boolean().optional(),
|
|
135
|
+
rateType: models.RateType$outboundSchema.optional(),
|
|
136
|
+
tax: models.PriceTax$outboundSchema.optional(),
|
|
119
137
|
quantity: z.number().int().optional(),
|
|
120
138
|
});
|
|
121
139
|
|
|
@@ -8,6 +8,7 @@ import { ClosedEnum } from "../types/enums.js";
|
|
|
8
8
|
import { Result as SafeParseResult } from "../types/fp.js";
|
|
9
9
|
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
10
10
|
import { PriceFeature, PriceFeature$inboundSchema } from "./pricefeature.js";
|
|
11
|
+
import { PriceTax, PriceTax$inboundSchema } from "./pricetax.js";
|
|
11
12
|
|
|
12
13
|
export const PlanVersionPriceSlotObject = {
|
|
13
14
|
Price: "price",
|
|
@@ -34,6 +35,20 @@ export type PlanVersionPriceSlotPaymentTerm = ClosedEnum<
|
|
|
34
35
|
typeof PlanVersionPriceSlotPaymentTerm
|
|
35
36
|
>;
|
|
36
37
|
|
|
38
|
+
/**
|
|
39
|
+
* What properties.unitPrice is denominated in. 'amount' (the default) is an amount of the invoice currency for each unit metered, so the quantity is the multiplier. 'proportion' is the reverse: a dimensionless share of a currency-denominated quantity, so '0.02' is 2% and the invoice prints '2.00%'. Presentation only. Requires a standard metered price in real currency.
|
|
40
|
+
*/
|
|
41
|
+
export const PlanVersionPriceSlotRateType = {
|
|
42
|
+
Amount: "amount",
|
|
43
|
+
Proportion: "proportion",
|
|
44
|
+
} as const;
|
|
45
|
+
/**
|
|
46
|
+
* What properties.unitPrice is denominated in. 'amount' (the default) is an amount of the invoice currency for each unit metered, so the quantity is the multiplier. 'proportion' is the reverse: a dimensionless share of a currency-denominated quantity, so '0.02' is 2% and the invoice prints '2.00%'. Presentation only. Requires a standard metered price in real currency.
|
|
47
|
+
*/
|
|
48
|
+
export type PlanVersionPriceSlotRateType = ClosedEnum<
|
|
49
|
+
typeof PlanVersionPriceSlotRateType
|
|
50
|
+
>;
|
|
51
|
+
|
|
37
52
|
/**
|
|
38
53
|
* One price slot on a plan version. Every `Price` field is present, plus `priceDeleted` layered on top.
|
|
39
54
|
*/
|
|
@@ -77,6 +92,22 @@ export type PlanVersionPriceSlot = {
|
|
|
77
92
|
* A fixed amount owed whole rather than a per-period rate. An obligation is not prorated over a partial first period: when a subscription starts before its billing anchor, no truncated stub is billed and the first charge is the full amount at the next anchor. An obligation also refuses an interval boundary that falls strictly inside one of its own billing periods, since part of an amount owed whole is not a thing to bill. Defaults to false, which is a rate and is today's behaviour for every price. Not supported on a metered price, whose amount resolves from usage at close.
|
|
78
93
|
*/
|
|
79
94
|
isObligation: boolean;
|
|
95
|
+
/**
|
|
96
|
+
* What properties.unitPrice is denominated in. 'amount' (the default) is an amount of the invoice currency for each unit metered, so the quantity is the multiplier. 'proportion' is the reverse: a dimensionless share of a currency-denominated quantity, so '0.02' is 2% and the invoice prints '2.00%'. Presentation only. Requires a standard metered price in real currency.
|
|
97
|
+
*/
|
|
98
|
+
rateType: PlanVersionPriceSlotRateType;
|
|
99
|
+
/**
|
|
100
|
+
* Presentation only. Prices sharing this value, within one billing period, print as a single row on the rendered invoice PDF and are described by this string. Every member still bills its own line item on the ledger, this API and the compliance document. The combined row's rate is derived from the members' own rates. Requires the 'standard' pricing model. Sample values: 'Cross Border Fees', 'FX Fees'
|
|
101
|
+
*/
|
|
102
|
+
invoiceDisplayGroup?: string | null | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Unique identifier for a pricing unit
|
|
105
|
+
*/
|
|
106
|
+
pricingUnitId?: string | undefined;
|
|
107
|
+
/**
|
|
108
|
+
* A price's tax declaration. Optional on write — a price that declares nothing is `IN_SCOPE`, and is billed and taxed exactly as it was before this object existed. Always present on read. Replaced as a whole on update: send the object to change it, omit it to leave it alone.
|
|
109
|
+
*/
|
|
110
|
+
tax: PriceTax;
|
|
80
111
|
/**
|
|
81
112
|
* Quantity used when generating invoice line items for this price. Total per period = quantity × unitPrice. Only supported for fee prices; metered prices derive quantity from usage. Defaults to 1.
|
|
82
113
|
*/
|
|
@@ -102,6 +133,11 @@ export const PlanVersionPriceSlotPaymentTerm$inboundSchema: z.ZodNativeEnum<
|
|
|
102
133
|
typeof PlanVersionPriceSlotPaymentTerm
|
|
103
134
|
> = z.nativeEnum(PlanVersionPriceSlotPaymentTerm);
|
|
104
135
|
|
|
136
|
+
/** @internal */
|
|
137
|
+
export const PlanVersionPriceSlotRateType$inboundSchema: z.ZodNativeEnum<
|
|
138
|
+
typeof PlanVersionPriceSlotRateType
|
|
139
|
+
> = z.nativeEnum(PlanVersionPriceSlotRateType);
|
|
140
|
+
|
|
105
141
|
/** @internal */
|
|
106
142
|
export const PlanVersionPriceSlot$inboundSchema: z.ZodType<
|
|
107
143
|
PlanVersionPriceSlot,
|
|
@@ -126,6 +162,10 @@ export const PlanVersionPriceSlot$inboundSchema: z.ZodType<
|
|
|
126
162
|
features: z.array(PriceFeature$inboundSchema).optional(),
|
|
127
163
|
grantDiscountEnabled: z.boolean().default(false),
|
|
128
164
|
isObligation: z.boolean().default(false),
|
|
165
|
+
rateType: PlanVersionPriceSlotRateType$inboundSchema.default("amount"),
|
|
166
|
+
invoiceDisplayGroup: z.nullable(z.string()).optional(),
|
|
167
|
+
pricingUnitId: z.string().optional(),
|
|
168
|
+
tax: PriceTax$inboundSchema,
|
|
129
169
|
quantity: z.number().int().default(1),
|
|
130
170
|
priceDeleted: z.boolean(),
|
|
131
171
|
});
|
package/src/models/price.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { ClosedEnum } from "../types/enums.js";
|
|
|
8
8
|
import { Result as SafeParseResult } from "../types/fp.js";
|
|
9
9
|
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
|
|
10
10
|
import { PriceFeature, PriceFeature$inboundSchema } from "./pricefeature.js";
|
|
11
|
+
import { PriceTax, PriceTax$inboundSchema } from "./pricetax.js";
|
|
11
12
|
|
|
12
13
|
export const PriceObject = {
|
|
13
14
|
Price: "price",
|
|
@@ -28,6 +29,18 @@ export const PricePaymentTerm = {
|
|
|
28
29
|
} as const;
|
|
29
30
|
export type PricePaymentTerm = ClosedEnum<typeof PricePaymentTerm>;
|
|
30
31
|
|
|
32
|
+
/**
|
|
33
|
+
* What properties.unitPrice is denominated in. 'amount' (the default) is an amount of the invoice currency for each unit metered, so the quantity is the multiplier. 'proportion' is the reverse: a dimensionless share of a currency-denominated quantity, so '0.02' is 2% and the invoice prints '2.00%'. Presentation only. Requires a standard metered price in real currency.
|
|
34
|
+
*/
|
|
35
|
+
export const PriceRateType = {
|
|
36
|
+
Amount: "amount",
|
|
37
|
+
Proportion: "proportion",
|
|
38
|
+
} as const;
|
|
39
|
+
/**
|
|
40
|
+
* What properties.unitPrice is denominated in. 'amount' (the default) is an amount of the invoice currency for each unit metered, so the quantity is the multiplier. 'proportion' is the reverse: a dimensionless share of a currency-denominated quantity, so '0.02' is 2% and the invoice prints '2.00%'. Presentation only. Requires a standard metered price in real currency.
|
|
41
|
+
*/
|
|
42
|
+
export type PriceRateType = ClosedEnum<typeof PriceRateType>;
|
|
43
|
+
|
|
31
44
|
export type Price = {
|
|
32
45
|
/**
|
|
33
46
|
* Unique identifier for a price
|
|
@@ -68,6 +81,22 @@ export type Price = {
|
|
|
68
81
|
* A fixed amount owed whole rather than a per-period rate. An obligation is not prorated over a partial first period: when a subscription starts before its billing anchor, no truncated stub is billed and the first charge is the full amount at the next anchor. An obligation also refuses an interval boundary that falls strictly inside one of its own billing periods, since part of an amount owed whole is not a thing to bill. Defaults to false, which is a rate and is today's behaviour for every price. Not supported on a metered price, whose amount resolves from usage at close.
|
|
69
82
|
*/
|
|
70
83
|
isObligation: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* What properties.unitPrice is denominated in. 'amount' (the default) is an amount of the invoice currency for each unit metered, so the quantity is the multiplier. 'proportion' is the reverse: a dimensionless share of a currency-denominated quantity, so '0.02' is 2% and the invoice prints '2.00%'. Presentation only. Requires a standard metered price in real currency.
|
|
86
|
+
*/
|
|
87
|
+
rateType: PriceRateType;
|
|
88
|
+
/**
|
|
89
|
+
* Presentation only. Prices sharing this value, within one billing period, print as a single row on the rendered invoice PDF and are described by this string. Every member still bills its own line item on the ledger, this API and the compliance document. The combined row's rate is derived from the members' own rates. Requires the 'standard' pricing model. Sample values: 'Cross Border Fees', 'FX Fees'
|
|
90
|
+
*/
|
|
91
|
+
invoiceDisplayGroup?: string | null | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Unique identifier for a pricing unit
|
|
94
|
+
*/
|
|
95
|
+
pricingUnitId?: string | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* A price's tax declaration. Optional on write — a price that declares nothing is `IN_SCOPE`, and is billed and taxed exactly as it was before this object existed. Always present on read. Replaced as a whole on update: send the object to change it, omit it to leave it alone.
|
|
98
|
+
*/
|
|
99
|
+
tax: PriceTax;
|
|
71
100
|
/**
|
|
72
101
|
* Quantity used when generating invoice line items for this price. Total per period = quantity × unitPrice. Only supported for fee prices; metered prices derive quantity from usage. Defaults to 1.
|
|
73
102
|
*/
|
|
@@ -87,6 +116,11 @@ export const PricePaymentTerm$inboundSchema: z.ZodNativeEnum<
|
|
|
87
116
|
typeof PricePaymentTerm
|
|
88
117
|
> = z.nativeEnum(PricePaymentTerm);
|
|
89
118
|
|
|
119
|
+
/** @internal */
|
|
120
|
+
export const PriceRateType$inboundSchema: z.ZodNativeEnum<
|
|
121
|
+
typeof PriceRateType
|
|
122
|
+
> = z.nativeEnum(PriceRateType);
|
|
123
|
+
|
|
90
124
|
/** @internal */
|
|
91
125
|
export const Price$inboundSchema: z.ZodType<Price, z.ZodTypeDef, unknown> = z
|
|
92
126
|
.object({
|
|
@@ -112,6 +146,10 @@ export const Price$inboundSchema: z.ZodType<Price, z.ZodTypeDef, unknown> = z
|
|
|
112
146
|
features: z.array(PriceFeature$inboundSchema).optional(),
|
|
113
147
|
grantDiscountEnabled: z.boolean().default(false),
|
|
114
148
|
isObligation: z.boolean().default(false),
|
|
149
|
+
rateType: PriceRateType$inboundSchema.default("amount"),
|
|
150
|
+
invoiceDisplayGroup: z.nullable(z.string()).optional(),
|
|
151
|
+
pricingUnitId: z.string().optional(),
|
|
152
|
+
tax: PriceTax$inboundSchema,
|
|
115
153
|
quantity: z.number().int().default(1),
|
|
116
154
|
});
|
|
117
155
|
|
|
@@ -27,11 +27,11 @@ export type PercentagePriceProperties = {
|
|
|
27
27
|
|
|
28
28
|
export type VolumeTier = {
|
|
29
29
|
/**
|
|
30
|
-
* Inclusive upper bound of the band, as a decimal string. Null on the last band only, which carries the remainder. Sample values: '100' bounds the band at 100 units, null leaves the top open.
|
|
30
|
+
* Inclusive upper bound of the band, as a decimal string greater than 0, capped at 6 decimal places, and less than 1e65 in magnitude. Bounds must strictly ascend across the ladder. Null on the last band only, which carries the remainder. Sample values: '100' bounds the band at 100 units, null leaves the top open.
|
|
31
31
|
*/
|
|
32
32
|
upTo: string | null;
|
|
33
33
|
/**
|
|
34
|
-
* Per-unit cost inside this band, as a decimal string, capped at 6 decimal places. Sample values: '5' represents $5 per unit, '0.004' represents $0.004 per unit.
|
|
34
|
+
* Per-unit cost inside this band, as a decimal string, capped at 6 decimal places and less than 1e65 in magnitude. Must be zero or greater. Unlike StandardPriceProperties.unitPrice, a band rate cannot be negative. To bill a usage-scaled rebate, use model 'standard' with a negative unitPrice. Sample values: '5' represents $5 per unit, '0.004' represents $0.004 per unit.
|
|
35
35
|
*/
|
|
36
36
|
unitPrice: string;
|
|
37
37
|
};
|
|
@@ -41,7 +41,7 @@ export type VolumeTier = {
|
|
|
41
41
|
*/
|
|
42
42
|
export type VolumePriceProperties = {
|
|
43
43
|
/**
|
|
44
|
-
* Ordered ladder of bands. The band is selected by the period's total metered usage, and its rate applies to every billed unit. A band matches when the quantity is less than or equal to its `upTo`, and the first matching band wins; the previous band's `upTo` is the exclusive lower bound, and the first band's floor is 0.
|
|
44
|
+
* Ordered ladder of bands. The band is selected by the period's total metered usage, and its rate applies to every billed unit. A band matches when the quantity is less than or equal to its `upTo`, and the first matching band wins; the previous band's `upTo` is the exclusive lower bound, and the first band's floor is 0. Exactly one band carries `upTo: null` and it must be the last. Bounds must strictly ascend. The API refuses a ladder whose bounds are out of order rather than sorting it. Because one rate applies to every unit, a total can fall as usage rises: on a ladder of '100' at '5' then null at '3', 100 units bill 500 and 101 units bill 303.
|
|
45
45
|
*/
|
|
46
46
|
tiers: Array<VolumeTier>;
|
|
47
47
|
};
|