@flexprice/sdk 2.1.18 → 2.1.20
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/docs/sdk/models/coupon-filter.md +1 -0
- package/docs/sdk/models/get-coupon-by-code-request.md +17 -0
- package/docs/sdk/models/get-usage-request.md +2 -1
- package/docs/sdk/models/point-bucket.md +16 -0
- package/docs/sdk/models/secret-response.md +2 -0
- package/docs/sdk/models/sub-modify-coupon-params.md +2 -3
- package/docs/sdk/models/sub-modify-tax-params.md +1 -1
- package/docs/sdk/models/usage-analytic-point.md +10 -11
- package/docs/sdks/coupons/README.md +72 -0
- package/esm/funcs/coupons-get-coupon-by-code.d.ts +17 -0
- package/esm/funcs/coupons-get-coupon-by-code.d.ts.map +1 -0
- package/esm/funcs/coupons-get-coupon-by-code.js +91 -0
- package/esm/funcs/coupons-get-coupon-by-code.js.map +1 -0
- package/esm/lib/config.d.ts +3 -3
- package/esm/lib/config.js +3 -3
- package/esm/lib/retries.js +7 -0
- package/esm/lib/retries.js.map +1 -1
- package/esm/sdk/coupons.d.ts +7 -0
- package/esm/sdk/coupons.d.ts.map +1 -1
- package/esm/sdk/coupons.js +10 -0
- package/esm/sdk/coupons.js.map +1 -1
- package/esm/sdk/models/coupon-filter.d.ts +2 -0
- package/esm/sdk/models/coupon-filter.d.ts.map +1 -1
- package/esm/sdk/models/coupon-filter.js +2 -0
- package/esm/sdk/models/coupon-filter.js.map +1 -1
- package/esm/sdk/models/get-coupon-by-code-op.d.ts +15 -0
- package/esm/sdk/models/get-coupon-by-code-op.d.ts.map +1 -0
- package/esm/sdk/models/get-coupon-by-code-op.js +12 -0
- package/esm/sdk/models/get-coupon-by-code-op.js.map +1 -0
- package/esm/sdk/models/get-usage-request.d.ts +13 -0
- package/esm/sdk/models/get-usage-request.d.ts.map +1 -1
- package/esm/sdk/models/get-usage-request.js +2 -0
- package/esm/sdk/models/get-usage-request.js.map +1 -1
- package/esm/sdk/models/index.d.ts +2 -0
- package/esm/sdk/models/index.d.ts.map +1 -1
- package/esm/sdk/models/index.js +2 -0
- package/esm/sdk/models/index.js.map +1 -1
- package/esm/sdk/models/point-bucket.d.ts +11 -0
- package/esm/sdk/models/point-bucket.d.ts.map +1 -0
- package/esm/sdk/models/point-bucket.js +22 -0
- package/esm/sdk/models/point-bucket.js.map +1 -0
- package/esm/sdk/models/secret-response.d.ts +8 -0
- package/esm/sdk/models/secret-response.d.ts.map +1 -1
- package/esm/sdk/models/secret-response.js +4 -0
- package/esm/sdk/models/secret-response.js.map +1 -1
- package/esm/sdk/models/sub-modify-coupon-params.d.ts +3 -8
- package/esm/sdk/models/sub-modify-coupon-params.d.ts.map +1 -1
- package/esm/sdk/models/sub-modify-coupon-params.js +2 -4
- package/esm/sdk/models/sub-modify-coupon-params.js.map +1 -1
- package/esm/sdk/models/sub-modify-tax-params.d.ts +5 -5
- package/esm/sdk/models/sub-modify-tax-params.d.ts.map +1 -1
- package/esm/sdk/models/sub-modify-tax-params.js +2 -2
- package/esm/sdk/models/sub-modify-tax-params.js.map +1 -1
- package/esm/sdk/models/usage-analytic-point.d.ts +9 -4
- package/esm/sdk/models/usage-analytic-point.d.ts.map +1 -1
- package/esm/sdk/models/usage-analytic-point.js +2 -4
- package/esm/sdk/models/usage-analytic-point.js.map +1 -1
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/funcs/coupons-get-coupon-by-code.ts +181 -0
- package/src/lib/config.ts +3 -3
- package/src/lib/retries.ts +8 -0
- package/src/sdk/coupons.ts +18 -0
- package/src/sdk/models/coupon-filter.ts +4 -0
- package/src/sdk/models/get-coupon-by-code-op.ts +33 -0
- package/src/sdk/models/get-usage-request.ts +15 -0
- package/src/sdk/models/index.ts +2 -0
- package/src/sdk/models/point-bucket.ts +40 -0
- package/src/sdk/models/secret-response.ts +12 -0
- package/src/sdk/models/sub-modify-coupon-params.ts +5 -14
- package/src/sdk/models/sub-modify-tax-params.ts +7 -7
- package/src/sdk/models/usage-analytic-point.ts +10 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage-analytic-point.d.ts","sourceRoot":"","sources":["../../../src/sdk/models/usage-analytic-point.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AAGjC,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,MAAM,MAAM,kBAAkB,GAAG;IAC/B
|
|
1
|
+
{"version":3,"file":"usage-analytic-point.d.ts","sourceRoot":"","sources":["../../../src/sdk/models/usage-analytic-point.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AAGjC,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAE9D,OAAO,EAAE,WAAW,EAA6B,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,MAAM,MAAM,kBAAkB,GAAG;IAC/B;;;;;;;;;;OAUG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,GAAG,SAAS,CAAC;IACzC;;OAEG;IACH,gCAAgC,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACtD,qBAAqB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3C,oBAAoB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B,CAAC;AAEF,gBAAgB;AAChB,eAAO,MAAM,gCAAgC,EAAE,CAAC,CAAC,WAAW,CAC1D,kBAAkB,EAClB,OAAO,CAoBR,CAAC;AAEF,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,MAAM,GACjB,eAAe,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAMzD"}
|
|
@@ -5,10 +5,10 @@ import * as z from "zod/v4-mini";
|
|
|
5
5
|
import { remap as remap$ } from "../../lib/primitives.js";
|
|
6
6
|
import { safeParse } from "../../lib/schemas.js";
|
|
7
7
|
import * as types from "../../types/primitives.js";
|
|
8
|
+
import { PointBucket$inboundSchema } from "./point-bucket.js";
|
|
8
9
|
/** @internal */
|
|
9
10
|
export const UsageAnalyticPoint$inboundSchema = z.pipe(z.object({
|
|
10
|
-
|
|
11
|
-
bucket_price_id: types.optional(types.string()),
|
|
11
|
+
buckets: types.optional(z.array(PointBucket$inboundSchema)),
|
|
12
12
|
computed_commitment_utilized_amount: types.optional(types.string()),
|
|
13
13
|
computed_overage_amount: types.optional(types.string()),
|
|
14
14
|
computed_true_up_amount: types.optional(types.string()),
|
|
@@ -18,8 +18,6 @@ export const UsageAnalyticPoint$inboundSchema = z.pipe(z.object({
|
|
|
18
18
|
usage: types.optional(types.string()),
|
|
19
19
|
}), z.transform((v) => {
|
|
20
20
|
return remap$(v, {
|
|
21
|
-
"bucket_id": "bucketId",
|
|
22
|
-
"bucket_price_id": "bucketPriceId",
|
|
23
21
|
"computed_commitment_utilized_amount": "computedCommitmentUtilizedAmount",
|
|
24
22
|
"computed_overage_amount": "computedOverageAmount",
|
|
25
23
|
"computed_true_up_amount": "computedTrueUpAmount",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage-analytic-point.js","sourceRoot":"","sources":["../../../src/sdk/models/usage-analytic-point.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,KAAK,IAAI,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,KAAK,KAAK,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"usage-analytic-point.js","sourceRoot":"","sources":["../../../src/sdk/models/usage-analytic-point.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,KAAK,IAAI,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,KAAK,KAAK,MAAM,2BAA2B,CAAC;AACnD,OAAO,EAAe,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AA+B3E,gBAAgB;AAChB,MAAM,CAAC,MAAM,gCAAgC,GAGzC,CAAC,CAAC,IAAI,CACR,CAAC,CAAC,MAAM,CAAC;IACP,OAAO,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC3D,mCAAmC,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;IACnE,uBAAuB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;IACvD,uBAAuB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;IACvD,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;IACpC,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;IAC3C,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;IACzC,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;CACtC,CAAC,EACF,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IACjB,OAAO,MAAM,CAAC,CAAC,EAAE;QACf,qCAAqC,EAAE,kCAAkC;QACzE,yBAAyB,EAAE,uBAAuB;QAClD,yBAAyB,EAAE,sBAAsB;QACjD,aAAa,EAAE,YAAY;KAC5B,CAAC,CAAC;AAAA,CACJ,CAAC,CACH,CAAC;AAEF,MAAM,UAAU,0BAA0B,CACxC,UAAkB,EACuC;IACzD,OAAO,SAAS,CACd,UAAU,EACV,CAAC,CAAC,EAAE,EAAE,CAAC,gCAAgC,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAC5D,gDAAgD,CACjD,CAAC;AAAA,CACH"}
|
package/jsr.json
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v4-mini";
|
|
6
|
+
import { FlexpriceCore } from "../core.js";
|
|
7
|
+
import { encodeSimple } from "../lib/encodings.js";
|
|
8
|
+
import { matchStatusCode } from "../lib/http.js";
|
|
9
|
+
import * as M from "../lib/matchers.js";
|
|
10
|
+
import { compactMap } from "../lib/primitives.js";
|
|
11
|
+
import { safeParse } from "../lib/schemas.js";
|
|
12
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
13
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
14
|
+
import { pathToFunc } from "../lib/url.js";
|
|
15
|
+
import { FlexPriceError } from "../sdk/models/flex-price-error.js";
|
|
16
|
+
import {
|
|
17
|
+
ConnectionError,
|
|
18
|
+
InvalidRequestError,
|
|
19
|
+
RequestAbortedError,
|
|
20
|
+
RequestTimeoutError,
|
|
21
|
+
UnexpectedClientError,
|
|
22
|
+
} from "../sdk/models/http-client-errors.js";
|
|
23
|
+
import * as models from "../sdk/models/index.js";
|
|
24
|
+
import { ResponseValidationError } from "../sdk/models/response-validation-error.js";
|
|
25
|
+
import { SDKValidationError } from "../sdk/models/sdk-validation-error.js";
|
|
26
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
27
|
+
import { Result } from "../types/fp.js";
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get coupon by code
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* Use when resolving a coupon by promo code (e.g. checkout or validation).
|
|
34
|
+
*/
|
|
35
|
+
export function couponsGetCouponByCode(
|
|
36
|
+
client: FlexpriceCore,
|
|
37
|
+
code: string,
|
|
38
|
+
options?: RequestOptions,
|
|
39
|
+
): APIPromise<
|
|
40
|
+
Result<
|
|
41
|
+
models.CouponResponse,
|
|
42
|
+
| models.ErrorsErrorResponse
|
|
43
|
+
| FlexPriceError
|
|
44
|
+
| ResponseValidationError
|
|
45
|
+
| ConnectionError
|
|
46
|
+
| RequestAbortedError
|
|
47
|
+
| RequestTimeoutError
|
|
48
|
+
| InvalidRequestError
|
|
49
|
+
| UnexpectedClientError
|
|
50
|
+
| SDKValidationError
|
|
51
|
+
>
|
|
52
|
+
> {
|
|
53
|
+
return new APIPromise($do(
|
|
54
|
+
client,
|
|
55
|
+
code,
|
|
56
|
+
options,
|
|
57
|
+
));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function $do(
|
|
61
|
+
client: FlexpriceCore,
|
|
62
|
+
code: string,
|
|
63
|
+
options?: RequestOptions,
|
|
64
|
+
): Promise<
|
|
65
|
+
[
|
|
66
|
+
Result<
|
|
67
|
+
models.CouponResponse,
|
|
68
|
+
| models.ErrorsErrorResponse
|
|
69
|
+
| FlexPriceError
|
|
70
|
+
| ResponseValidationError
|
|
71
|
+
| ConnectionError
|
|
72
|
+
| RequestAbortedError
|
|
73
|
+
| RequestTimeoutError
|
|
74
|
+
| InvalidRequestError
|
|
75
|
+
| UnexpectedClientError
|
|
76
|
+
| SDKValidationError
|
|
77
|
+
>,
|
|
78
|
+
APICall,
|
|
79
|
+
]
|
|
80
|
+
> {
|
|
81
|
+
const input: models.GetCouponByCodeRequest = {
|
|
82
|
+
code: code,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const parsed = safeParse(
|
|
86
|
+
input,
|
|
87
|
+
(value) => z.parse(models.GetCouponByCodeRequest$outboundSchema, value),
|
|
88
|
+
"Input validation failed",
|
|
89
|
+
);
|
|
90
|
+
if (!parsed.ok) {
|
|
91
|
+
return [parsed, { status: "invalid" }];
|
|
92
|
+
}
|
|
93
|
+
const payload = parsed.value;
|
|
94
|
+
const body = null;
|
|
95
|
+
|
|
96
|
+
const pathParams = {
|
|
97
|
+
code: encodeSimple("code", payload.code, {
|
|
98
|
+
explode: false,
|
|
99
|
+
charEncoding: "percent",
|
|
100
|
+
}),
|
|
101
|
+
};
|
|
102
|
+
const path = pathToFunc("/coupons/code/{code}")(pathParams);
|
|
103
|
+
|
|
104
|
+
const headers = new Headers(compactMap({
|
|
105
|
+
Accept: "application/json",
|
|
106
|
+
}));
|
|
107
|
+
|
|
108
|
+
const secConfig = await extractSecurity(client._options.apiKeyAuth);
|
|
109
|
+
const securityInput = secConfig == null ? {} : { apiKeyAuth: secConfig };
|
|
110
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
111
|
+
|
|
112
|
+
const context = {
|
|
113
|
+
options: client._options,
|
|
114
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
115
|
+
operationID: "getCouponByCode",
|
|
116
|
+
oAuth2Scopes: null,
|
|
117
|
+
|
|
118
|
+
resolvedSecurity: requestSecurity,
|
|
119
|
+
|
|
120
|
+
securitySource: client._options.apiKeyAuth,
|
|
121
|
+
retryConfig: options?.retries
|
|
122
|
+
|| client._options.retryConfig
|
|
123
|
+
|| { strategy: "none" },
|
|
124
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const requestRes = client._createRequest(context, {
|
|
128
|
+
security: requestSecurity,
|
|
129
|
+
method: "GET",
|
|
130
|
+
baseURL: options?.serverURL,
|
|
131
|
+
path: path,
|
|
132
|
+
headers: headers,
|
|
133
|
+
body: body,
|
|
134
|
+
userAgent: client._options.userAgent,
|
|
135
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
136
|
+
}, options);
|
|
137
|
+
if (!requestRes.ok) {
|
|
138
|
+
return [requestRes, { status: "invalid" }];
|
|
139
|
+
}
|
|
140
|
+
const req = requestRes.value;
|
|
141
|
+
|
|
142
|
+
const doResult = await client._do(req, {
|
|
143
|
+
context,
|
|
144
|
+
isErrorStatusCode: (statusCode: number) =>
|
|
145
|
+
matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
|
|
146
|
+
retryConfig: context.retryConfig,
|
|
147
|
+
retryCodes: context.retryCodes,
|
|
148
|
+
});
|
|
149
|
+
if (!doResult.ok) {
|
|
150
|
+
return [doResult, { status: "request-error", request: req }];
|
|
151
|
+
}
|
|
152
|
+
const response = doResult.value;
|
|
153
|
+
|
|
154
|
+
const responseFields = {
|
|
155
|
+
HttpMeta: { Response: response, Request: req },
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const [result] = await M.match<
|
|
159
|
+
models.CouponResponse,
|
|
160
|
+
| models.ErrorsErrorResponse
|
|
161
|
+
| FlexPriceError
|
|
162
|
+
| ResponseValidationError
|
|
163
|
+
| ConnectionError
|
|
164
|
+
| RequestAbortedError
|
|
165
|
+
| RequestTimeoutError
|
|
166
|
+
| InvalidRequestError
|
|
167
|
+
| UnexpectedClientError
|
|
168
|
+
| SDKValidationError
|
|
169
|
+
>(
|
|
170
|
+
M.json(200, models.CouponResponse$inboundSchema),
|
|
171
|
+
M.jsonErr([400, 404], models.ErrorsErrorResponse$inboundSchema),
|
|
172
|
+
M.jsonErr(500, models.ErrorsErrorResponse$inboundSchema),
|
|
173
|
+
M.fail("4XX"),
|
|
174
|
+
M.fail("5XX"),
|
|
175
|
+
)(response, req, { extraFields: responseFields });
|
|
176
|
+
if (!result.ok) {
|
|
177
|
+
return [result, { status: "complete", request: req, response }];
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return [result, { status: "complete", request: req, response }];
|
|
181
|
+
}
|
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: "1.0",
|
|
68
|
-
sdkVersion: "2.1.
|
|
69
|
-
genVersion: "2.
|
|
70
|
-
userAgent: "speakeasy-sdk/typescript 2.1.
|
|
68
|
+
sdkVersion: "2.1.20",
|
|
69
|
+
genVersion: "2.911.0",
|
|
70
|
+
userAgent: "speakeasy-sdk/typescript 2.1.20 2.911.0 1.0 @flexprice/sdk",
|
|
71
71
|
} as const;
|
package/src/lib/retries.ts
CHANGED
|
@@ -194,6 +194,14 @@ async function retryBackoff(
|
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
function retryIntervalFromResponse(res: Response): number {
|
|
197
|
+
const retryAfterMsVal = res.headers.get("retry-after-ms");
|
|
198
|
+
if (retryAfterMsVal) {
|
|
199
|
+
const parsedMs = Number(retryAfterMsVal);
|
|
200
|
+
if (Number.isFinite(parsedMs) && parsedMs >= 0) {
|
|
201
|
+
return parsedMs;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
197
205
|
const retryVal = res.headers.get("retry-after") || "";
|
|
198
206
|
if (!retryVal) {
|
|
199
207
|
return 0;
|
package/src/sdk/coupons.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { couponsCreateCoupon } from "../funcs/coupons-create-coupon.js";
|
|
6
6
|
import { couponsDeleteCoupon } from "../funcs/coupons-delete-coupon.js";
|
|
7
|
+
import { couponsGetCouponByCode } from "../funcs/coupons-get-coupon-by-code.js";
|
|
7
8
|
import { couponsGetCoupon } from "../funcs/coupons-get-coupon.js";
|
|
8
9
|
import { couponsQueryCoupon } from "../funcs/coupons-query-coupon.js";
|
|
9
10
|
import { couponsUpdateCoupon } from "../funcs/coupons-update-coupon.js";
|
|
@@ -29,6 +30,23 @@ export class Coupons extends ClientSDK {
|
|
|
29
30
|
));
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Get coupon by code
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* Use when resolving a coupon by promo code (e.g. checkout or validation).
|
|
38
|
+
*/
|
|
39
|
+
async getCouponByCode(
|
|
40
|
+
code: string,
|
|
41
|
+
options?: RequestOptions,
|
|
42
|
+
): Promise<models.CouponResponse> {
|
|
43
|
+
return unwrapAsync(couponsGetCouponByCode(
|
|
44
|
+
this,
|
|
45
|
+
code,
|
|
46
|
+
options,
|
|
47
|
+
));
|
|
48
|
+
}
|
|
49
|
+
|
|
32
50
|
/**
|
|
33
51
|
* Query coupons
|
|
34
52
|
*
|
|
@@ -24,6 +24,7 @@ export const CouponFilterOrder = {
|
|
|
24
24
|
export type CouponFilterOrder = ClosedEnum<typeof CouponFilterOrder>;
|
|
25
25
|
|
|
26
26
|
export type CouponFilter = {
|
|
27
|
+
couponCodes?: Array<string> | undefined;
|
|
27
28
|
couponIds?: Array<string> | undefined;
|
|
28
29
|
expand?: string | undefined;
|
|
29
30
|
filters?: Array<FilterCondition> | undefined;
|
|
@@ -41,6 +42,7 @@ export const CouponFilterOrder$outboundSchema: z.ZodMiniEnum<
|
|
|
41
42
|
|
|
42
43
|
/** @internal */
|
|
43
44
|
export type CouponFilter$Outbound = {
|
|
45
|
+
coupon_codes?: Array<string> | undefined;
|
|
44
46
|
coupon_ids?: Array<string> | undefined;
|
|
45
47
|
expand?: string | undefined;
|
|
46
48
|
filters?: Array<FilterCondition$Outbound> | undefined;
|
|
@@ -57,6 +59,7 @@ export const CouponFilter$outboundSchema: z.ZodMiniType<
|
|
|
57
59
|
CouponFilter
|
|
58
60
|
> = z.pipe(
|
|
59
61
|
z.object({
|
|
62
|
+
couponCodes: z.optional(z.array(z.string())),
|
|
60
63
|
couponIds: z.optional(z.array(z.string())),
|
|
61
64
|
expand: z.optional(z.string()),
|
|
62
65
|
filters: z.optional(z.array(FilterCondition$outboundSchema)),
|
|
@@ -68,6 +71,7 @@ export const CouponFilter$outboundSchema: z.ZodMiniType<
|
|
|
68
71
|
}),
|
|
69
72
|
z.transform((v) => {
|
|
70
73
|
return remap$(v, {
|
|
74
|
+
couponCodes: "coupon_codes",
|
|
71
75
|
couponIds: "coupon_ids",
|
|
72
76
|
});
|
|
73
77
|
}),
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v4-mini";
|
|
6
|
+
|
|
7
|
+
export type GetCouponByCodeRequest = {
|
|
8
|
+
/**
|
|
9
|
+
* Coupon code
|
|
10
|
+
*/
|
|
11
|
+
code: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/** @internal */
|
|
15
|
+
export type GetCouponByCodeRequest$Outbound = {
|
|
16
|
+
code: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** @internal */
|
|
20
|
+
export const GetCouponByCodeRequest$outboundSchema: z.ZodMiniType<
|
|
21
|
+
GetCouponByCodeRequest$Outbound,
|
|
22
|
+
GetCouponByCodeRequest
|
|
23
|
+
> = z.object({
|
|
24
|
+
code: z.string(),
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export function getCouponByCodeRequestToJSON(
|
|
28
|
+
getCouponByCodeRequest: GetCouponByCodeRequest,
|
|
29
|
+
): string {
|
|
30
|
+
return JSON.stringify(
|
|
31
|
+
GetCouponByCodeRequest$outboundSchema.parse(getCouponByCodeRequest),
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -38,12 +38,24 @@ export type GetUsageRequest = {
|
|
|
38
38
|
eventName: string;
|
|
39
39
|
externalCustomerId?: string | undefined;
|
|
40
40
|
filters?: { [k: string]: Array<string> } | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* GroupBy lists the analytics group_by dimensions.
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* - "source" — group by event source column
|
|
46
|
+
* - "properties.X" — group by JSON property X
|
|
47
|
+
*/
|
|
48
|
+
groupBy?: Array<string> | undefined;
|
|
41
49
|
/**
|
|
42
50
|
* GroupByProperty is the property name in event.properties to group by before aggregating.
|
|
43
51
|
*
|
|
44
52
|
* @remarks
|
|
45
53
|
* When set, aggregation is applied per unique value of this property within each bucket,
|
|
46
54
|
* then the per-group results are summed to produce the bucket total.
|
|
55
|
+
*
|
|
56
|
+
* Deprecated: prefer GroupBy []string{"properties.<X>"} for parity with
|
|
57
|
+
* other analytics endpoints. ToUsageParams translates this field into
|
|
58
|
+
* GroupBy when GroupBy is otherwise empty.
|
|
47
59
|
*/
|
|
48
60
|
groupByProperty?: string | undefined;
|
|
49
61
|
multiplier?: string | undefined;
|
|
@@ -65,6 +77,7 @@ export type GetUsageRequest$Outbound = {
|
|
|
65
77
|
event_name: string;
|
|
66
78
|
external_customer_id?: string | undefined;
|
|
67
79
|
filters?: { [k: string]: Array<string> } | undefined;
|
|
80
|
+
group_by?: Array<string> | undefined;
|
|
68
81
|
group_by_property?: string | undefined;
|
|
69
82
|
multiplier?: string | undefined;
|
|
70
83
|
property_name?: string | undefined;
|
|
@@ -88,6 +101,7 @@ export const GetUsageRequest$outboundSchema: z.ZodMiniType<
|
|
|
88
101
|
eventName: z.string(),
|
|
89
102
|
externalCustomerId: z.optional(z.string()),
|
|
90
103
|
filters: z.optional(z.record(z.string(), z.array(z.string()))),
|
|
104
|
+
groupBy: z.optional(z.array(z.string())),
|
|
91
105
|
groupByProperty: z.optional(z.string()),
|
|
92
106
|
multiplier: z.optional(z.string()),
|
|
93
107
|
propertyName: z.optional(z.string()),
|
|
@@ -103,6 +117,7 @@ export const GetUsageRequest$outboundSchema: z.ZodMiniType<
|
|
|
103
117
|
endTime: "end_time",
|
|
104
118
|
eventName: "event_name",
|
|
105
119
|
externalCustomerId: "external_customer_id",
|
|
120
|
+
groupBy: "group_by",
|
|
106
121
|
groupByProperty: "group_by_property",
|
|
107
122
|
propertyName: "property_name",
|
|
108
123
|
startTime: "start_time",
|
package/src/sdk/models/index.ts
CHANGED
|
@@ -206,6 +206,7 @@ export * from "./get-cost-analytics-request.js";
|
|
|
206
206
|
export * from "./get-costsheet-op.js";
|
|
207
207
|
export * from "./get-costsheet-response.js";
|
|
208
208
|
export * from "./get-coupon-association-op.js";
|
|
209
|
+
export * from "./get-coupon-by-code-op.js";
|
|
209
210
|
export * from "./get-coupon-op.js";
|
|
210
211
|
export * from "./get-credit-grant-op.js";
|
|
211
212
|
export * from "./get-credit-note-op.js";
|
|
@@ -352,6 +353,7 @@ export * from "./plan-filter.js";
|
|
|
352
353
|
export * from "./plan-response.js";
|
|
353
354
|
export * from "./plan-summary.js";
|
|
354
355
|
export * from "./plan.js";
|
|
356
|
+
export * from "./point-bucket.js";
|
|
355
357
|
export * from "./preview-subscription-change-op.js";
|
|
356
358
|
export * from "./preview-subscription-modify-op.js";
|
|
357
359
|
export * from "./price-entity-type.js";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v4-mini";
|
|
6
|
+
import { remap as remap$ } from "../../lib/primitives.js";
|
|
7
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
8
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
9
|
+
import * as types from "../../types/primitives.js";
|
|
10
|
+
import { SDKValidationError } from "./sdk-validation-error.js";
|
|
11
|
+
|
|
12
|
+
export type PointBucket = {
|
|
13
|
+
bucketId?: string | undefined;
|
|
14
|
+
priceId?: string | undefined;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** @internal */
|
|
18
|
+
export const PointBucket$inboundSchema: z.ZodMiniType<PointBucket, unknown> = z
|
|
19
|
+
.pipe(
|
|
20
|
+
z.object({
|
|
21
|
+
bucket_id: types.optional(types.string()),
|
|
22
|
+
price_id: types.optional(types.string()),
|
|
23
|
+
}),
|
|
24
|
+
z.transform((v) => {
|
|
25
|
+
return remap$(v, {
|
|
26
|
+
"bucket_id": "bucketId",
|
|
27
|
+
"price_id": "priceId",
|
|
28
|
+
});
|
|
29
|
+
}),
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
export function pointBucketFromJSON(
|
|
33
|
+
jsonString: string,
|
|
34
|
+
): SafeParseResult<PointBucket, SDKValidationError> {
|
|
35
|
+
return safeParse(
|
|
36
|
+
jsonString,
|
|
37
|
+
(x) => PointBucket$inboundSchema.parse(JSON.parse(x)),
|
|
38
|
+
`Failed to parse 'PointBucket' from JSON`,
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -28,9 +28,17 @@ export type SecretResponse = {
|
|
|
28
28
|
* RBAC roles
|
|
29
29
|
*/
|
|
30
30
|
roles?: Array<string> | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* name of the service account (populated for service_account user_type)
|
|
33
|
+
*/
|
|
34
|
+
serviceAccountName?: string | undefined;
|
|
31
35
|
status?: Status | undefined;
|
|
32
36
|
type?: SecretType | undefined;
|
|
33
37
|
updatedAt?: Date | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* user or service account this key belongs to
|
|
40
|
+
*/
|
|
41
|
+
userId?: string | undefined;
|
|
34
42
|
userType?: UserType | undefined;
|
|
35
43
|
};
|
|
36
44
|
|
|
@@ -48,9 +56,11 @@ export const SecretResponse$inboundSchema: z.ZodMiniType<
|
|
|
48
56
|
name: types.optional(types.string()),
|
|
49
57
|
provider: types.optional(SecretProvider$inboundSchema),
|
|
50
58
|
roles: types.optional(z.array(types.string())),
|
|
59
|
+
service_account_name: types.optional(types.string()),
|
|
51
60
|
status: types.optional(Status$inboundSchema),
|
|
52
61
|
type: types.optional(SecretType$inboundSchema),
|
|
53
62
|
updated_at: types.optional(types.date()),
|
|
63
|
+
user_id: types.optional(types.string()),
|
|
54
64
|
user_type: types.optional(UserType$inboundSchema),
|
|
55
65
|
}),
|
|
56
66
|
z.transform((v) => {
|
|
@@ -59,7 +69,9 @@ export const SecretResponse$inboundSchema: z.ZodMiniType<
|
|
|
59
69
|
"display_id": "displayId",
|
|
60
70
|
"expires_at": "expiresAt",
|
|
61
71
|
"last_used_at": "lastUsedAt",
|
|
72
|
+
"service_account_name": "serviceAccountName",
|
|
62
73
|
"updated_at": "updatedAt",
|
|
74
|
+
"user_id": "userId",
|
|
63
75
|
"user_type": "userType",
|
|
64
76
|
});
|
|
65
77
|
}),
|
|
@@ -14,21 +14,17 @@ export type SubModifyCouponParams = {
|
|
|
14
14
|
/**
|
|
15
15
|
* Required when action="remove". ID of the CouponAssociation to soft-delete.
|
|
16
16
|
*/
|
|
17
|
-
|
|
17
|
+
couponAssociationId?: string | undefined;
|
|
18
18
|
/**
|
|
19
19
|
* Required for action="add". Coupon code of the coupon to attach.
|
|
20
20
|
*/
|
|
21
21
|
couponCode?: string | undefined;
|
|
22
|
-
/**
|
|
23
|
-
* Optional. When to apply the change; defaults to now if omitted.
|
|
24
|
-
*/
|
|
25
|
-
effectiveDate?: Date | undefined;
|
|
26
22
|
/**
|
|
27
23
|
* Optional. When the coupon association ends.
|
|
28
24
|
*/
|
|
29
25
|
endDate?: Date | undefined;
|
|
30
26
|
/**
|
|
31
|
-
* Optional. When the coupon association starts; defaults to
|
|
27
|
+
* Optional. When the coupon association starts; defaults to now.
|
|
32
28
|
*/
|
|
33
29
|
startDate?: Date | undefined;
|
|
34
30
|
/**
|
|
@@ -44,9 +40,8 @@ export type SubModifyCouponParams = {
|
|
|
44
40
|
/** @internal */
|
|
45
41
|
export type SubModifyCouponParams$Outbound = {
|
|
46
42
|
action: string;
|
|
47
|
-
|
|
43
|
+
coupon_association_id?: string | undefined;
|
|
48
44
|
coupon_code?: string | undefined;
|
|
49
|
-
effective_date?: string | undefined;
|
|
50
45
|
end_date?: string | undefined;
|
|
51
46
|
start_date?: string | undefined;
|
|
52
47
|
subscription_id?: string | undefined;
|
|
@@ -60,11 +55,8 @@ export const SubModifyCouponParams$outboundSchema: z.ZodMiniType<
|
|
|
60
55
|
> = z.pipe(
|
|
61
56
|
z.object({
|
|
62
57
|
action: SubModifyCouponAction$outboundSchema,
|
|
63
|
-
|
|
58
|
+
couponAssociationId: z.optional(z.string()),
|
|
64
59
|
couponCode: z.optional(z.string()),
|
|
65
|
-
effectiveDate: z.optional(
|
|
66
|
-
z.pipe(z.date(), z.transform(v => v.toISOString())),
|
|
67
|
-
),
|
|
68
60
|
endDate: z.optional(z.pipe(z.date(), z.transform(v => v.toISOString()))),
|
|
69
61
|
startDate: z.optional(z.pipe(z.date(), z.transform(v => v.toISOString()))),
|
|
70
62
|
subscriptionId: z.optional(z.string()),
|
|
@@ -72,9 +64,8 @@ export const SubModifyCouponParams$outboundSchema: z.ZodMiniType<
|
|
|
72
64
|
}),
|
|
73
65
|
z.transform((v) => {
|
|
74
66
|
return remap$(v, {
|
|
75
|
-
|
|
67
|
+
couponAssociationId: "coupon_association_id",
|
|
76
68
|
couponCode: "coupon_code",
|
|
77
|
-
effectiveDate: "effective_date",
|
|
78
69
|
endDate: "end_date",
|
|
79
70
|
startDate: "start_date",
|
|
80
71
|
subscriptionId: "subscription_id",
|
|
@@ -11,14 +11,14 @@ import {
|
|
|
11
11
|
|
|
12
12
|
export type SubModifyTaxParams = {
|
|
13
13
|
action: SubModifyTaxAction;
|
|
14
|
-
/**
|
|
15
|
-
* Required when action="remove". ID of the TaxAssociation to soft-delete.
|
|
16
|
-
*/
|
|
17
|
-
associationId?: string | undefined;
|
|
18
14
|
/**
|
|
19
15
|
* Optional. When to apply the change; defaults to now if omitted.
|
|
20
16
|
*/
|
|
21
17
|
effectiveDate?: Date | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Required when action="remove". ID of the TaxAssociation to soft-delete.
|
|
20
|
+
*/
|
|
21
|
+
taxAssociationId?: string | undefined;
|
|
22
22
|
/**
|
|
23
23
|
* Required when action="add". ID of the active tax rate to attach.
|
|
24
24
|
*/
|
|
@@ -28,8 +28,8 @@ export type SubModifyTaxParams = {
|
|
|
28
28
|
/** @internal */
|
|
29
29
|
export type SubModifyTaxParams$Outbound = {
|
|
30
30
|
action: string;
|
|
31
|
-
association_id?: string | undefined;
|
|
32
31
|
effective_date?: string | undefined;
|
|
32
|
+
tax_association_id?: string | undefined;
|
|
33
33
|
tax_rate_id?: string | undefined;
|
|
34
34
|
};
|
|
35
35
|
|
|
@@ -40,16 +40,16 @@ export const SubModifyTaxParams$outboundSchema: z.ZodMiniType<
|
|
|
40
40
|
> = z.pipe(
|
|
41
41
|
z.object({
|
|
42
42
|
action: SubModifyTaxAction$outboundSchema,
|
|
43
|
-
associationId: z.optional(z.string()),
|
|
44
43
|
effectiveDate: z.optional(
|
|
45
44
|
z.pipe(z.date(), z.transform(v => v.toISOString())),
|
|
46
45
|
),
|
|
46
|
+
taxAssociationId: z.optional(z.string()),
|
|
47
47
|
taxRateId: z.optional(z.string()),
|
|
48
48
|
}),
|
|
49
49
|
z.transform((v) => {
|
|
50
50
|
return remap$(v, {
|
|
51
|
-
associationId: "association_id",
|
|
52
51
|
effectiveDate: "effective_date",
|
|
52
|
+
taxAssociationId: "tax_association_id",
|
|
53
53
|
taxRateId: "tax_rate_id",
|
|
54
54
|
});
|
|
55
55
|
}),
|
|
@@ -7,17 +7,22 @@ import { remap as remap$ } from "../../lib/primitives.js";
|
|
|
7
7
|
import { safeParse } from "../../lib/schemas.js";
|
|
8
8
|
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
9
9
|
import * as types from "../../types/primitives.js";
|
|
10
|
+
import { PointBucket, PointBucket$inboundSchema } from "./point-bucket.js";
|
|
10
11
|
import { SDKValidationError } from "./sdk-validation-error.js";
|
|
11
12
|
|
|
12
13
|
export type UsageAnalyticPoint = {
|
|
13
14
|
/**
|
|
14
|
-
*
|
|
15
|
+
* Buckets lists every commitment bucket this (possibly rolled-up) window
|
|
15
16
|
*
|
|
16
17
|
* @remarks
|
|
17
|
-
*
|
|
18
|
+
* overlaps — only populated when BreakdownBucket=true and the line item has
|
|
19
|
+
* CommitmentTimeBuckets. A coarse window can overlap more than one bucket, and
|
|
20
|
+
* only partially, so this is a list. Empty when the window touches no bucket.
|
|
21
|
+
* It is an informational HINT only: the point's single cost/computed_* totals
|
|
22
|
+
* mix all overlapped buckets and out-of-bucket time and CANNOT be split per
|
|
23
|
+
* bucket — read bucket_summaries for exact per-bucket cost.
|
|
18
24
|
*/
|
|
19
|
-
|
|
20
|
-
bucketPriceId?: string | undefined;
|
|
25
|
+
buckets?: Array<PointBucket> | undefined;
|
|
21
26
|
/**
|
|
22
27
|
* Commitment breakdown (only populated for windowed commitments)
|
|
23
28
|
*/
|
|
@@ -39,8 +44,7 @@ export const UsageAnalyticPoint$inboundSchema: z.ZodMiniType<
|
|
|
39
44
|
unknown
|
|
40
45
|
> = z.pipe(
|
|
41
46
|
z.object({
|
|
42
|
-
|
|
43
|
-
bucket_price_id: types.optional(types.string()),
|
|
47
|
+
buckets: types.optional(z.array(PointBucket$inboundSchema)),
|
|
44
48
|
computed_commitment_utilized_amount: types.optional(types.string()),
|
|
45
49
|
computed_overage_amount: types.optional(types.string()),
|
|
46
50
|
computed_true_up_amount: types.optional(types.string()),
|
|
@@ -51,8 +55,6 @@ export const UsageAnalyticPoint$inboundSchema: z.ZodMiniType<
|
|
|
51
55
|
}),
|
|
52
56
|
z.transform((v) => {
|
|
53
57
|
return remap$(v, {
|
|
54
|
-
"bucket_id": "bucketId",
|
|
55
|
-
"bucket_price_id": "bucketPriceId",
|
|
56
58
|
"computed_commitment_utilized_amount": "computedCommitmentUtilizedAmount",
|
|
57
59
|
"computed_overage_amount": "computedOverageAmount",
|
|
58
60
|
"computed_true_up_amount": "computedTrueUpAmount",
|