@paygentic/sdk 0.6.11 → 0.6.13
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/README.md +16 -5
- package/dist/commonjs/funcs/billableMetricsMeter.d.ts +19 -0
- package/dist/commonjs/funcs/billableMetricsMeter.d.ts.map +1 -0
- package/dist/commonjs/funcs/billableMetricsMeter.js +133 -0
- package/dist/commonjs/funcs/billableMetricsMeter.js.map +1 -0
- package/dist/commonjs/funcs/customersDelete.d.ts +15 -0
- package/dist/commonjs/funcs/customersDelete.d.ts.map +1 -0
- package/dist/commonjs/funcs/customersDelete.js +121 -0
- package/dist/commonjs/funcs/customersDelete.js.map +1 -0
- package/dist/commonjs/funcs/entitlementsList.js +1 -0
- package/dist/commonjs/funcs/entitlementsList.js.map +1 -1
- package/dist/commonjs/funcs/paymentsCreate.d.ts +19 -0
- package/dist/commonjs/funcs/paymentsCreate.d.ts.map +1 -0
- package/dist/commonjs/funcs/paymentsCreate.js +119 -0
- package/dist/commonjs/funcs/paymentsCreate.js.map +1 -0
- package/dist/commonjs/funcs/paymentsGet.d.ts +19 -0
- package/dist/commonjs/funcs/paymentsGet.d.ts.map +1 -0
- package/dist/commonjs/funcs/paymentsGet.js +124 -0
- package/dist/commonjs/funcs/paymentsGet.js.map +1 -0
- package/dist/commonjs/funcs/paymentsList.d.ts +18 -0
- package/dist/commonjs/funcs/paymentsList.d.ts.map +1 -0
- package/dist/commonjs/funcs/paymentsList.js +125 -0
- package/dist/commonjs/funcs/paymentsList.js.map +1 -0
- package/dist/commonjs/lib/config.d.ts +3 -3
- package/dist/commonjs/lib/config.js +3 -3
- package/dist/commonjs/lib/config.js.map +1 -1
- package/dist/commonjs/lib/matchers.d.ts.map +1 -1
- package/dist/commonjs/lib/matchers.js +0 -1
- package/dist/commonjs/lib/matchers.js.map +1 -1
- package/dist/commonjs/lib/security.d.ts.map +1 -1
- package/dist/commonjs/lib/security.js +1 -2
- package/dist/commonjs/lib/security.js.map +1 -1
- package/dist/commonjs/models/index.d.ts +2 -0
- package/dist/commonjs/models/index.d.ts.map +1 -1
- package/dist/commonjs/models/index.js +2 -0
- package/dist/commonjs/models/index.js.map +1 -1
- package/dist/commonjs/models/operations/createpayment.d.ts +113 -0
- package/dist/commonjs/models/operations/createpayment.d.ts.map +1 -0
- package/dist/commonjs/models/operations/createpayment.js +82 -0
- package/dist/commonjs/models/operations/createpayment.js.map +1 -0
- package/dist/commonjs/models/operations/createpaymentsession.d.ts +113 -0
- package/dist/commonjs/models/operations/createpaymentsession.d.ts.map +1 -0
- package/dist/commonjs/models/operations/createpaymentsession.js +82 -0
- package/dist/commonjs/models/operations/createpaymentsession.js.map +1 -0
- package/dist/commonjs/models/operations/createplan.d.ts +18 -0
- package/dist/commonjs/models/operations/createplan.d.ts.map +1 -1
- package/dist/commonjs/models/operations/createplan.js +11 -1
- package/dist/commonjs/models/operations/createplan.js.map +1 -1
- package/dist/commonjs/models/operations/getbillablemetricmeter.d.ts +57 -0
- package/dist/commonjs/models/operations/getbillablemetricmeter.d.ts.map +1 -0
- package/dist/commonjs/models/operations/getbillablemetricmeter.js +66 -0
- package/dist/commonjs/models/operations/getbillablemetricmeter.js.map +1 -0
- package/dist/commonjs/models/operations/getpayment.d.ts +15 -0
- package/dist/commonjs/models/operations/getpayment.d.ts.map +1 -0
- package/dist/commonjs/models/operations/getpayment.js +49 -0
- package/dist/commonjs/models/operations/getpayment.js.map +1 -0
- package/dist/commonjs/models/operations/getpaymentsession.d.ts +15 -0
- package/dist/commonjs/models/operations/getpaymentsession.d.ts.map +1 -0
- package/dist/commonjs/models/operations/getpaymentsession.js +49 -0
- package/dist/commonjs/models/operations/getpaymentsession.js.map +1 -0
- package/dist/commonjs/models/operations/index.d.ts +4 -0
- package/dist/commonjs/models/operations/index.d.ts.map +1 -1
- package/dist/commonjs/models/operations/index.js +4 -0
- package/dist/commonjs/models/operations/index.js.map +1 -1
- package/dist/commonjs/models/operations/listentitlements.d.ts +5 -0
- package/dist/commonjs/models/operations/listentitlements.d.ts.map +1 -1
- package/dist/commonjs/models/operations/listentitlements.js +1 -0
- package/dist/commonjs/models/operations/listentitlements.js.map +1 -1
- package/dist/commonjs/models/operations/listpayments.d.ts +75 -0
- package/dist/commonjs/models/operations/listpayments.d.ts.map +1 -0
- package/dist/commonjs/models/operations/listpayments.js +82 -0
- package/dist/commonjs/models/operations/listpayments.js.map +1 -0
- package/dist/commonjs/models/operations/listpaymentsessions.d.ts +75 -0
- package/dist/commonjs/models/operations/listpaymentsessions.d.ts.map +1 -0
- package/dist/commonjs/models/operations/listpaymentsessions.js +82 -0
- package/dist/commonjs/models/operations/listpaymentsessions.js.map +1 -0
- package/dist/commonjs/models/payment.d.ts +91 -0
- package/dist/commonjs/models/payment.d.ts.map +1 -0
- package/dist/commonjs/models/payment.js +90 -0
- package/dist/commonjs/models/payment.js.map +1 -0
- package/dist/commonjs/models/subscription.d.ts +8 -4
- package/dist/commonjs/models/subscription.d.ts.map +1 -1
- package/dist/commonjs/models/subscription.js +7 -6
- package/dist/commonjs/models/subscription.js.map +1 -1
- package/dist/commonjs/models/usageresponse.d.ts +50 -0
- package/dist/commonjs/models/usageresponse.d.ts.map +1 -0
- package/dist/commonjs/models/usageresponse.js +78 -0
- package/dist/commonjs/models/usageresponse.js.map +1 -0
- package/dist/commonjs/sdk/billablemetrics.d.ts +7 -0
- package/dist/commonjs/sdk/billablemetrics.d.ts.map +1 -1
- package/dist/commonjs/sdk/billablemetrics.js +10 -0
- package/dist/commonjs/sdk/billablemetrics.js.map +1 -1
- package/dist/commonjs/sdk/customers.d.ts +1 -1
- package/dist/commonjs/sdk/customers.d.ts.map +1 -1
- package/dist/commonjs/sdk/customers.js +3 -3
- package/dist/commonjs/sdk/customers.js.map +1 -1
- package/dist/commonjs/sdk/payments.d.ts +27 -0
- package/dist/commonjs/sdk/payments.d.ts.map +1 -0
- package/dist/commonjs/sdk/payments.js +42 -0
- package/dist/commonjs/sdk/payments.js.map +1 -0
- package/dist/commonjs/sdk/sdk.d.ts +3 -0
- package/dist/commonjs/sdk/sdk.d.ts.map +1 -1
- package/dist/commonjs/sdk/sdk.js +4 -0
- package/dist/commonjs/sdk/sdk.js.map +1 -1
- package/dist/esm/funcs/billableMetricsMeter.d.ts +19 -0
- package/dist/esm/funcs/billableMetricsMeter.d.ts.map +1 -0
- package/dist/esm/funcs/billableMetricsMeter.js +97 -0
- package/dist/esm/funcs/billableMetricsMeter.js.map +1 -0
- package/dist/esm/funcs/customersDelete.d.ts +15 -0
- package/dist/esm/funcs/customersDelete.d.ts.map +1 -0
- package/dist/esm/funcs/customersDelete.js +85 -0
- package/dist/esm/funcs/customersDelete.js.map +1 -0
- package/dist/esm/funcs/entitlementsList.js +1 -0
- package/dist/esm/funcs/entitlementsList.js.map +1 -1
- package/dist/esm/funcs/paymentsCreate.d.ts +19 -0
- package/dist/esm/funcs/paymentsCreate.d.ts.map +1 -0
- package/dist/esm/funcs/paymentsCreate.js +83 -0
- package/dist/esm/funcs/paymentsCreate.js.map +1 -0
- package/dist/esm/funcs/paymentsGet.d.ts +19 -0
- package/dist/esm/funcs/paymentsGet.d.ts.map +1 -0
- package/dist/esm/funcs/paymentsGet.js +88 -0
- package/dist/esm/funcs/paymentsGet.js.map +1 -0
- package/dist/esm/funcs/paymentsList.d.ts +18 -0
- package/dist/esm/funcs/paymentsList.d.ts.map +1 -0
- package/dist/esm/funcs/paymentsList.js +89 -0
- package/dist/esm/funcs/paymentsList.js.map +1 -0
- package/dist/esm/lib/config.d.ts +3 -3
- package/dist/esm/lib/config.js +3 -3
- package/dist/esm/lib/config.js.map +1 -1
- package/dist/esm/lib/matchers.d.ts.map +1 -1
- package/dist/esm/lib/matchers.js +0 -1
- package/dist/esm/lib/matchers.js.map +1 -1
- package/dist/esm/lib/security.d.ts.map +1 -1
- package/dist/esm/lib/security.js +1 -2
- package/dist/esm/lib/security.js.map +1 -1
- package/dist/esm/models/index.d.ts +2 -0
- package/dist/esm/models/index.d.ts.map +1 -1
- package/dist/esm/models/index.js +2 -0
- package/dist/esm/models/index.js.map +1 -1
- package/dist/esm/models/operations/createpayment.d.ts +113 -0
- package/dist/esm/models/operations/createpayment.d.ts.map +1 -0
- package/dist/esm/models/operations/createpayment.js +44 -0
- package/dist/esm/models/operations/createpayment.js.map +1 -0
- package/dist/esm/models/operations/createpaymentsession.d.ts +113 -0
- package/dist/esm/models/operations/createpaymentsession.d.ts.map +1 -0
- package/dist/esm/models/operations/createpaymentsession.js +44 -0
- package/dist/esm/models/operations/createpaymentsession.js.map +1 -0
- package/dist/esm/models/operations/createplan.d.ts +18 -0
- package/dist/esm/models/operations/createplan.d.ts.map +1 -1
- package/dist/esm/models/operations/createplan.js +10 -0
- package/dist/esm/models/operations/createplan.js.map +1 -1
- package/dist/esm/models/operations/getbillablemetricmeter.d.ts +57 -0
- package/dist/esm/models/operations/getbillablemetricmeter.d.ts.map +1 -0
- package/dist/esm/models/operations/getbillablemetricmeter.js +29 -0
- package/dist/esm/models/operations/getbillablemetricmeter.js.map +1 -0
- package/dist/esm/models/operations/getpayment.d.ts +15 -0
- package/dist/esm/models/operations/getpayment.d.ts.map +1 -0
- package/dist/esm/models/operations/getpayment.js +12 -0
- package/dist/esm/models/operations/getpayment.js.map +1 -0
- package/dist/esm/models/operations/getpaymentsession.d.ts +15 -0
- package/dist/esm/models/operations/getpaymentsession.d.ts.map +1 -0
- package/dist/esm/models/operations/getpaymentsession.js +12 -0
- package/dist/esm/models/operations/getpaymentsession.js.map +1 -0
- package/dist/esm/models/operations/index.d.ts +4 -0
- package/dist/esm/models/operations/index.d.ts.map +1 -1
- package/dist/esm/models/operations/index.js +4 -0
- package/dist/esm/models/operations/index.js.map +1 -1
- package/dist/esm/models/operations/listentitlements.d.ts +5 -0
- package/dist/esm/models/operations/listentitlements.d.ts.map +1 -1
- package/dist/esm/models/operations/listentitlements.js +1 -0
- package/dist/esm/models/operations/listentitlements.js.map +1 -1
- package/dist/esm/models/operations/listpayments.d.ts +75 -0
- package/dist/esm/models/operations/listpayments.d.ts.map +1 -0
- package/dist/esm/models/operations/listpayments.js +44 -0
- package/dist/esm/models/operations/listpayments.js.map +1 -0
- package/dist/esm/models/operations/listpaymentsessions.d.ts +75 -0
- package/dist/esm/models/operations/listpaymentsessions.d.ts.map +1 -0
- package/dist/esm/models/operations/listpaymentsessions.js +44 -0
- package/dist/esm/models/operations/listpaymentsessions.js.map +1 -0
- package/dist/esm/models/payment.d.ts +91 -0
- package/dist/esm/models/payment.d.ts.map +1 -0
- package/dist/esm/models/payment.js +52 -0
- package/dist/esm/models/payment.js.map +1 -0
- package/dist/esm/models/subscription.d.ts +8 -4
- package/dist/esm/models/subscription.d.ts.map +1 -1
- package/dist/esm/models/subscription.js +5 -4
- package/dist/esm/models/subscription.js.map +1 -1
- package/dist/esm/models/usageresponse.d.ts +50 -0
- package/dist/esm/models/usageresponse.d.ts.map +1 -0
- package/dist/esm/models/usageresponse.js +39 -0
- package/dist/esm/models/usageresponse.js.map +1 -0
- package/dist/esm/sdk/billablemetrics.d.ts +7 -0
- package/dist/esm/sdk/billablemetrics.d.ts.map +1 -1
- package/dist/esm/sdk/billablemetrics.js +10 -0
- package/dist/esm/sdk/billablemetrics.js.map +1 -1
- package/dist/esm/sdk/customers.d.ts +1 -1
- package/dist/esm/sdk/customers.d.ts.map +1 -1
- package/dist/esm/sdk/customers.js +3 -3
- package/dist/esm/sdk/customers.js.map +1 -1
- package/dist/esm/sdk/payments.d.ts +27 -0
- package/dist/esm/sdk/payments.d.ts.map +1 -0
- package/dist/esm/sdk/payments.js +38 -0
- package/dist/esm/sdk/payments.js.map +1 -0
- package/dist/esm/sdk/sdk.d.ts +3 -0
- package/dist/esm/sdk/sdk.d.ts.map +1 -1
- package/dist/esm/sdk/sdk.js +4 -0
- package/dist/esm/sdk/sdk.js.map +1 -1
- package/jsr.json +1 -1
- package/package.json +2 -2
- package/src/funcs/billableMetricsMeter.ts +192 -0
- package/src/funcs/customersDelete.ts +178 -0
- package/src/funcs/entitlementsList.ts +1 -0
- package/src/funcs/paymentsCreate.ts +175 -0
- package/src/funcs/paymentsGet.ts +177 -0
- package/src/funcs/paymentsList.ts +179 -0
- package/src/lib/config.ts +3 -3
- package/src/lib/matchers.ts +3 -2
- package/src/lib/security.ts +1 -2
- package/src/models/index.ts +2 -0
- package/src/models/operations/createpayment.ts +156 -0
- package/src/models/operations/createpaymentsession.ts +158 -0
- package/src/models/operations/createplan.ts +23 -0
- package/src/models/operations/getbillablemetricmeter.ts +87 -0
- package/src/models/operations/getpayment.ts +34 -0
- package/src/models/operations/getpaymentsession.ts +34 -0
- package/src/models/operations/index.ts +4 -0
- package/src/models/operations/listentitlements.ts +6 -0
- package/src/models/operations/listpayments.ts +126 -0
- package/src/models/operations/listpaymentsessions.ts +130 -0
- package/src/models/payment.ts +149 -0
- package/src/models/subscription.ts +24 -16
- package/src/models/usageresponse.ts +116 -0
- package/src/sdk/billablemetrics.ts +18 -0
- package/src/sdk/customers.ts +3 -3
- package/src/sdk/payments.ts +64 -0
- package/src/sdk/sdk.ts +6 -0
- package/.devcontainer/devcontainer.json +0 -45
- package/examples/package-lock.json +0 -612
- package/examples/package.json +0 -18
- package/tsconfig.json +0 -40
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { PaygenticCore } from "../core.js";
|
|
6
|
+
import { encodeSimple } from "../lib/encodings.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
11
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
12
|
+
import { pathToFunc } from "../lib/url.js";
|
|
13
|
+
import {
|
|
14
|
+
ConnectionError,
|
|
15
|
+
InvalidRequestError,
|
|
16
|
+
RequestAbortedError,
|
|
17
|
+
RequestTimeoutError,
|
|
18
|
+
UnexpectedClientError,
|
|
19
|
+
} from "../models/errors/httpclienterrors.js";
|
|
20
|
+
import * as errors from "../models/errors/index.js";
|
|
21
|
+
import { PaygenticError } from "../models/errors/paygenticerror.js";
|
|
22
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
23
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
24
|
+
import * as models from "../models/index.js";
|
|
25
|
+
import * as operations from "../models/operations/index.js";
|
|
26
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
27
|
+
import { Result } from "../types/fp.js";
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Get Payment
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* Retrieve a single payment by ID.
|
|
34
|
+
*/
|
|
35
|
+
export function paymentsGet(
|
|
36
|
+
client: PaygenticCore,
|
|
37
|
+
request: operations.GetPaymentRequest,
|
|
38
|
+
options?: RequestOptions,
|
|
39
|
+
): APIPromise<
|
|
40
|
+
Result<
|
|
41
|
+
models.Payment,
|
|
42
|
+
| errors.ErrorT
|
|
43
|
+
| PaygenticError
|
|
44
|
+
| ResponseValidationError
|
|
45
|
+
| ConnectionError
|
|
46
|
+
| RequestAbortedError
|
|
47
|
+
| RequestTimeoutError
|
|
48
|
+
| InvalidRequestError
|
|
49
|
+
| UnexpectedClientError
|
|
50
|
+
| SDKValidationError
|
|
51
|
+
>
|
|
52
|
+
> {
|
|
53
|
+
return new APIPromise($do(
|
|
54
|
+
client,
|
|
55
|
+
request,
|
|
56
|
+
options,
|
|
57
|
+
));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function $do(
|
|
61
|
+
client: PaygenticCore,
|
|
62
|
+
request: operations.GetPaymentRequest,
|
|
63
|
+
options?: RequestOptions,
|
|
64
|
+
): Promise<
|
|
65
|
+
[
|
|
66
|
+
Result<
|
|
67
|
+
models.Payment,
|
|
68
|
+
| errors.ErrorT
|
|
69
|
+
| PaygenticError
|
|
70
|
+
| ResponseValidationError
|
|
71
|
+
| ConnectionError
|
|
72
|
+
| RequestAbortedError
|
|
73
|
+
| RequestTimeoutError
|
|
74
|
+
| InvalidRequestError
|
|
75
|
+
| UnexpectedClientError
|
|
76
|
+
| SDKValidationError
|
|
77
|
+
>,
|
|
78
|
+
APICall,
|
|
79
|
+
]
|
|
80
|
+
> {
|
|
81
|
+
const parsed = safeParse(
|
|
82
|
+
request,
|
|
83
|
+
(value) => operations.GetPaymentRequest$outboundSchema.parse(value),
|
|
84
|
+
"Input validation failed",
|
|
85
|
+
);
|
|
86
|
+
if (!parsed.ok) {
|
|
87
|
+
return [parsed, { status: "invalid" }];
|
|
88
|
+
}
|
|
89
|
+
const payload = parsed.value;
|
|
90
|
+
const body = null;
|
|
91
|
+
|
|
92
|
+
const pathParams = {
|
|
93
|
+
id: encodeSimple("id", payload.id, {
|
|
94
|
+
explode: false,
|
|
95
|
+
charEncoding: "percent",
|
|
96
|
+
}),
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const path = pathToFunc("/v0/payments/{id}")(pathParams);
|
|
100
|
+
|
|
101
|
+
const headers = new Headers(compactMap({
|
|
102
|
+
Accept: "application/json",
|
|
103
|
+
}));
|
|
104
|
+
|
|
105
|
+
const secConfig = await extractSecurity(client._options.bearerAuth);
|
|
106
|
+
const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
|
|
107
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
108
|
+
|
|
109
|
+
const context = {
|
|
110
|
+
options: client._options,
|
|
111
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
112
|
+
operationID: "getPayment",
|
|
113
|
+
oAuth2Scopes: null,
|
|
114
|
+
|
|
115
|
+
resolvedSecurity: requestSecurity,
|
|
116
|
+
|
|
117
|
+
securitySource: client._options.bearerAuth,
|
|
118
|
+
retryConfig: options?.retries
|
|
119
|
+
|| client._options.retryConfig
|
|
120
|
+
|| { strategy: "none" },
|
|
121
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const requestRes = client._createRequest(context, {
|
|
125
|
+
security: requestSecurity,
|
|
126
|
+
method: "GET",
|
|
127
|
+
baseURL: options?.serverURL,
|
|
128
|
+
path: path,
|
|
129
|
+
headers: headers,
|
|
130
|
+
body: body,
|
|
131
|
+
userAgent: client._options.userAgent,
|
|
132
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
133
|
+
}, options);
|
|
134
|
+
if (!requestRes.ok) {
|
|
135
|
+
return [requestRes, { status: "invalid" }];
|
|
136
|
+
}
|
|
137
|
+
const req = requestRes.value;
|
|
138
|
+
|
|
139
|
+
const doResult = await client._do(req, {
|
|
140
|
+
context,
|
|
141
|
+
errorCodes: ["401", "403", "404", "4XX", "500", "5XX"],
|
|
142
|
+
retryConfig: context.retryConfig,
|
|
143
|
+
retryCodes: context.retryCodes,
|
|
144
|
+
});
|
|
145
|
+
if (!doResult.ok) {
|
|
146
|
+
return [doResult, { status: "request-error", request: req }];
|
|
147
|
+
}
|
|
148
|
+
const response = doResult.value;
|
|
149
|
+
|
|
150
|
+
const responseFields = {
|
|
151
|
+
HttpMeta: { Response: response, Request: req },
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const [result] = await M.match<
|
|
155
|
+
models.Payment,
|
|
156
|
+
| errors.ErrorT
|
|
157
|
+
| PaygenticError
|
|
158
|
+
| ResponseValidationError
|
|
159
|
+
| ConnectionError
|
|
160
|
+
| RequestAbortedError
|
|
161
|
+
| RequestTimeoutError
|
|
162
|
+
| InvalidRequestError
|
|
163
|
+
| UnexpectedClientError
|
|
164
|
+
| SDKValidationError
|
|
165
|
+
>(
|
|
166
|
+
M.json(200, models.Payment$inboundSchema),
|
|
167
|
+
M.jsonErr([401, 403, 404], errors.ErrorT$inboundSchema),
|
|
168
|
+
M.jsonErr(500, errors.ErrorT$inboundSchema),
|
|
169
|
+
M.fail("4XX"),
|
|
170
|
+
M.fail("5XX"),
|
|
171
|
+
)(response, req, { extraFields: responseFields });
|
|
172
|
+
if (!result.ok) {
|
|
173
|
+
return [result, { status: "complete", request: req, response }];
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return [result, { status: "complete", request: req, response }];
|
|
177
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { PaygenticCore } from "../core.js";
|
|
6
|
+
import { encodeFormQuery } from "../lib/encodings.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
11
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
12
|
+
import { pathToFunc } from "../lib/url.js";
|
|
13
|
+
import {
|
|
14
|
+
ConnectionError,
|
|
15
|
+
InvalidRequestError,
|
|
16
|
+
RequestAbortedError,
|
|
17
|
+
RequestTimeoutError,
|
|
18
|
+
UnexpectedClientError,
|
|
19
|
+
} from "../models/errors/httpclienterrors.js";
|
|
20
|
+
import * as errors from "../models/errors/index.js";
|
|
21
|
+
import { PaygenticError } from "../models/errors/paygenticerror.js";
|
|
22
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
23
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
24
|
+
import * as operations from "../models/operations/index.js";
|
|
25
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
26
|
+
import { Result } from "../types/fp.js";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* List Payments
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* List payments for the authenticated merchant with optional filters.
|
|
33
|
+
*/
|
|
34
|
+
export function paymentsList(
|
|
35
|
+
client: PaygenticCore,
|
|
36
|
+
request?: operations.ListPaymentsRequest | undefined,
|
|
37
|
+
options?: RequestOptions,
|
|
38
|
+
): APIPromise<
|
|
39
|
+
Result<
|
|
40
|
+
operations.ListPaymentsResponse,
|
|
41
|
+
| errors.ErrorT
|
|
42
|
+
| PaygenticError
|
|
43
|
+
| ResponseValidationError
|
|
44
|
+
| ConnectionError
|
|
45
|
+
| RequestAbortedError
|
|
46
|
+
| RequestTimeoutError
|
|
47
|
+
| InvalidRequestError
|
|
48
|
+
| UnexpectedClientError
|
|
49
|
+
| SDKValidationError
|
|
50
|
+
>
|
|
51
|
+
> {
|
|
52
|
+
return new APIPromise($do(
|
|
53
|
+
client,
|
|
54
|
+
request,
|
|
55
|
+
options,
|
|
56
|
+
));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function $do(
|
|
60
|
+
client: PaygenticCore,
|
|
61
|
+
request?: operations.ListPaymentsRequest | undefined,
|
|
62
|
+
options?: RequestOptions,
|
|
63
|
+
): Promise<
|
|
64
|
+
[
|
|
65
|
+
Result<
|
|
66
|
+
operations.ListPaymentsResponse,
|
|
67
|
+
| errors.ErrorT
|
|
68
|
+
| PaygenticError
|
|
69
|
+
| ResponseValidationError
|
|
70
|
+
| ConnectionError
|
|
71
|
+
| RequestAbortedError
|
|
72
|
+
| RequestTimeoutError
|
|
73
|
+
| InvalidRequestError
|
|
74
|
+
| UnexpectedClientError
|
|
75
|
+
| SDKValidationError
|
|
76
|
+
>,
|
|
77
|
+
APICall,
|
|
78
|
+
]
|
|
79
|
+
> {
|
|
80
|
+
const parsed = safeParse(
|
|
81
|
+
request,
|
|
82
|
+
(value) =>
|
|
83
|
+
operations.ListPaymentsRequest$outboundSchema.optional().parse(value),
|
|
84
|
+
"Input validation failed",
|
|
85
|
+
);
|
|
86
|
+
if (!parsed.ok) {
|
|
87
|
+
return [parsed, { status: "invalid" }];
|
|
88
|
+
}
|
|
89
|
+
const payload = parsed.value;
|
|
90
|
+
const body = null;
|
|
91
|
+
|
|
92
|
+
const path = pathToFunc("/v0/payments")();
|
|
93
|
+
|
|
94
|
+
const query = encodeFormQuery({
|
|
95
|
+
"customerId": payload?.customerId,
|
|
96
|
+
"limit": payload?.limit,
|
|
97
|
+
"merchantId": payload?.merchantId,
|
|
98
|
+
"offset": payload?.offset,
|
|
99
|
+
"status": payload?.status,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const headers = new Headers(compactMap({
|
|
103
|
+
Accept: "application/json",
|
|
104
|
+
}));
|
|
105
|
+
|
|
106
|
+
const secConfig = await extractSecurity(client._options.bearerAuth);
|
|
107
|
+
const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
|
|
108
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
109
|
+
|
|
110
|
+
const context = {
|
|
111
|
+
options: client._options,
|
|
112
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
113
|
+
operationID: "listPayments",
|
|
114
|
+
oAuth2Scopes: null,
|
|
115
|
+
|
|
116
|
+
resolvedSecurity: requestSecurity,
|
|
117
|
+
|
|
118
|
+
securitySource: client._options.bearerAuth,
|
|
119
|
+
retryConfig: options?.retries
|
|
120
|
+
|| client._options.retryConfig
|
|
121
|
+
|| { strategy: "none" },
|
|
122
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const requestRes = client._createRequest(context, {
|
|
126
|
+
security: requestSecurity,
|
|
127
|
+
method: "GET",
|
|
128
|
+
baseURL: options?.serverURL,
|
|
129
|
+
path: path,
|
|
130
|
+
headers: headers,
|
|
131
|
+
query: query,
|
|
132
|
+
body: body,
|
|
133
|
+
userAgent: client._options.userAgent,
|
|
134
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
135
|
+
}, options);
|
|
136
|
+
if (!requestRes.ok) {
|
|
137
|
+
return [requestRes, { status: "invalid" }];
|
|
138
|
+
}
|
|
139
|
+
const req = requestRes.value;
|
|
140
|
+
|
|
141
|
+
const doResult = await client._do(req, {
|
|
142
|
+
context,
|
|
143
|
+
errorCodes: ["401", "403", "4XX", "500", "5XX"],
|
|
144
|
+
retryConfig: context.retryConfig,
|
|
145
|
+
retryCodes: context.retryCodes,
|
|
146
|
+
});
|
|
147
|
+
if (!doResult.ok) {
|
|
148
|
+
return [doResult, { status: "request-error", request: req }];
|
|
149
|
+
}
|
|
150
|
+
const response = doResult.value;
|
|
151
|
+
|
|
152
|
+
const responseFields = {
|
|
153
|
+
HttpMeta: { Response: response, Request: req },
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const [result] = await M.match<
|
|
157
|
+
operations.ListPaymentsResponse,
|
|
158
|
+
| errors.ErrorT
|
|
159
|
+
| PaygenticError
|
|
160
|
+
| ResponseValidationError
|
|
161
|
+
| ConnectionError
|
|
162
|
+
| RequestAbortedError
|
|
163
|
+
| RequestTimeoutError
|
|
164
|
+
| InvalidRequestError
|
|
165
|
+
| UnexpectedClientError
|
|
166
|
+
| SDKValidationError
|
|
167
|
+
>(
|
|
168
|
+
M.json(200, operations.ListPaymentsResponse$inboundSchema),
|
|
169
|
+
M.jsonErr([401, 403], errors.ErrorT$inboundSchema),
|
|
170
|
+
M.jsonErr(500, errors.ErrorT$inboundSchema),
|
|
171
|
+
M.fail("4XX"),
|
|
172
|
+
M.fail("5XX"),
|
|
173
|
+
)(response, req, { extraFields: responseFields });
|
|
174
|
+
if (!result.ok) {
|
|
175
|
+
return [result, { status: "complete", request: req, response }];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
return [result, { status: "complete", request: req, response }];
|
|
179
|
+
}
|
package/src/lib/config.ts
CHANGED
|
@@ -61,7 +61,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
|
|
|
61
61
|
export const SDK_METADATA = {
|
|
62
62
|
language: "typescript",
|
|
63
63
|
openapiDocVersion: "0.1.0",
|
|
64
|
-
sdkVersion: "0.6.
|
|
65
|
-
genVersion: "2.
|
|
66
|
-
userAgent: "speakeasy-sdk/typescript 0.6.
|
|
64
|
+
sdkVersion: "0.6.12",
|
|
65
|
+
genVersion: "2.849.10",
|
|
66
|
+
userAgent: "speakeasy-sdk/typescript 0.6.12 2.849.10 0.1.0 @paygentic/sdk",
|
|
67
67
|
} as const;
|
package/src/lib/matchers.ts
CHANGED
|
@@ -251,8 +251,9 @@ export function match<T, E>(
|
|
|
251
251
|
raw = body;
|
|
252
252
|
break;
|
|
253
253
|
default:
|
|
254
|
-
|
|
255
|
-
|
|
254
|
+
throw new Error(
|
|
255
|
+
`Unsupported response type: ${encoding satisfies never}`,
|
|
256
|
+
);
|
|
256
257
|
}
|
|
257
258
|
|
|
258
259
|
if (matcher.enc === "fail") {
|
package/src/lib/security.ts
CHANGED
|
@@ -198,8 +198,7 @@ export function resolveSecurity(
|
|
|
198
198
|
applyBearer(state, spec);
|
|
199
199
|
break;
|
|
200
200
|
default:
|
|
201
|
-
spec satisfies never;
|
|
202
|
-
throw SecurityError.unrecognizedType(type);
|
|
201
|
+
throw SecurityError.unrecognizedType((spec satisfies never, type));
|
|
203
202
|
}
|
|
204
203
|
});
|
|
205
204
|
|
package/src/models/index.ts
CHANGED
|
@@ -28,6 +28,7 @@ export * from "./invoicelineitemsresponse.js";
|
|
|
28
28
|
export * from "./issueentitlementrequest.js";
|
|
29
29
|
export * from "./meteredentitlementdetail.js";
|
|
30
30
|
export * from "./offsetpagination.js";
|
|
31
|
+
export * from "./payment.js";
|
|
31
32
|
export * from "./plan.js";
|
|
32
33
|
export * from "./price.js";
|
|
33
34
|
export * from "./pricefeature.js";
|
|
@@ -50,6 +51,7 @@ export * from "./subscriptionportal.js";
|
|
|
50
51
|
export * from "./testclock.js";
|
|
51
52
|
export * from "./updaterulerequest.js";
|
|
52
53
|
export * from "./usageevent.js";
|
|
54
|
+
export * from "./usageresponse.js";
|
|
53
55
|
export * from "./user.js";
|
|
54
56
|
export * from "./validationerror.js";
|
|
55
57
|
export * from "./validtaxaddress.js";
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
import { ClosedEnum } from "../../types/enums.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* ISO 4217 currency code.
|
|
10
|
+
*/
|
|
11
|
+
export const Currency = {
|
|
12
|
+
Usd: "USD",
|
|
13
|
+
Eur: "EUR",
|
|
14
|
+
Gbp: "GBP",
|
|
15
|
+
Aud: "AUD",
|
|
16
|
+
} as const;
|
|
17
|
+
/**
|
|
18
|
+
* ISO 4217 currency code.
|
|
19
|
+
*/
|
|
20
|
+
export type Currency = ClosedEnum<typeof Currency>;
|
|
21
|
+
|
|
22
|
+
export type LineItem = {
|
|
23
|
+
/**
|
|
24
|
+
* Line item description.
|
|
25
|
+
*/
|
|
26
|
+
description: string;
|
|
27
|
+
/**
|
|
28
|
+
* Line item amount in decimal format (e.g. '5.00').
|
|
29
|
+
*/
|
|
30
|
+
amount: string;
|
|
31
|
+
/**
|
|
32
|
+
* Quantity of this line item. Defaults to 1.
|
|
33
|
+
*/
|
|
34
|
+
quantity?: number | undefined;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type CreatePaymentRequest = {
|
|
38
|
+
/**
|
|
39
|
+
* Payment amount in decimal format (e.g. '10.50'). Minimum 1.00, maximum 5,000.00. Contact support for higher limits.
|
|
40
|
+
*/
|
|
41
|
+
amount: string;
|
|
42
|
+
/**
|
|
43
|
+
* ISO 4217 currency code.
|
|
44
|
+
*/
|
|
45
|
+
currency: Currency;
|
|
46
|
+
/**
|
|
47
|
+
* Merchant organization ID. Required when using an API key that is not scoped to a single merchant.
|
|
48
|
+
*/
|
|
49
|
+
merchantId?: string | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Optional customer ID. Must belong to this merchant.
|
|
52
|
+
*/
|
|
53
|
+
customerId?: string | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Client-provided key for safe retries. If a payment with the same key already exists, the existing payment is returned.
|
|
56
|
+
*/
|
|
57
|
+
idempotencyKey?: string | undefined;
|
|
58
|
+
/**
|
|
59
|
+
* Merchant-defined reference for this payment (e.g. order ID, invoice number).
|
|
60
|
+
*/
|
|
61
|
+
reference?: string | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Arbitrary key-value string pairs to attach to the payment.
|
|
64
|
+
*/
|
|
65
|
+
metadata?: { [k: string]: string } | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Optional breakdown of what the customer is being charged for.
|
|
68
|
+
*/
|
|
69
|
+
lineItems?: Array<LineItem> | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* URL to redirect the customer to after a successful payment.
|
|
72
|
+
*/
|
|
73
|
+
successRedirectUrl?: string | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* URL to redirect the customer to after a failed payment.
|
|
76
|
+
*/
|
|
77
|
+
failureRedirectUrl?: string | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Whether to save the customer's payment method for future use. Defaults to false.
|
|
80
|
+
*/
|
|
81
|
+
savePaymentMethod?: boolean | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* ISO 8601 duration for the payment lifetime. Defaults to P30D (30 days). Maximum is P31D (31 days). Examples: PT1H, P1D, P7D, P30D.
|
|
84
|
+
*/
|
|
85
|
+
expiresIn?: string | undefined;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/** @internal */
|
|
89
|
+
export const Currency$outboundSchema: z.ZodNativeEnum<typeof Currency> = z
|
|
90
|
+
.nativeEnum(Currency);
|
|
91
|
+
|
|
92
|
+
/** @internal */
|
|
93
|
+
export type LineItem$Outbound = {
|
|
94
|
+
description: string;
|
|
95
|
+
amount: string;
|
|
96
|
+
quantity: number;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/** @internal */
|
|
100
|
+
export const LineItem$outboundSchema: z.ZodType<
|
|
101
|
+
LineItem$Outbound,
|
|
102
|
+
z.ZodTypeDef,
|
|
103
|
+
LineItem
|
|
104
|
+
> = z.object({
|
|
105
|
+
description: z.string(),
|
|
106
|
+
amount: z.string(),
|
|
107
|
+
quantity: z.number().int().default(1),
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
export function lineItemToJSON(lineItem: LineItem): string {
|
|
111
|
+
return JSON.stringify(LineItem$outboundSchema.parse(lineItem));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** @internal */
|
|
115
|
+
export type CreatePaymentRequest$Outbound = {
|
|
116
|
+
amount: string;
|
|
117
|
+
currency: string;
|
|
118
|
+
merchantId?: string | undefined;
|
|
119
|
+
customerId?: string | undefined;
|
|
120
|
+
idempotencyKey?: string | undefined;
|
|
121
|
+
reference?: string | undefined;
|
|
122
|
+
metadata?: { [k: string]: string } | undefined;
|
|
123
|
+
lineItems?: Array<LineItem$Outbound> | undefined;
|
|
124
|
+
successRedirectUrl?: string | undefined;
|
|
125
|
+
failureRedirectUrl?: string | undefined;
|
|
126
|
+
savePaymentMethod: boolean;
|
|
127
|
+
expiresIn?: string | undefined;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/** @internal */
|
|
131
|
+
export const CreatePaymentRequest$outboundSchema: z.ZodType<
|
|
132
|
+
CreatePaymentRequest$Outbound,
|
|
133
|
+
z.ZodTypeDef,
|
|
134
|
+
CreatePaymentRequest
|
|
135
|
+
> = z.object({
|
|
136
|
+
amount: z.string(),
|
|
137
|
+
currency: Currency$outboundSchema,
|
|
138
|
+
merchantId: z.string().optional(),
|
|
139
|
+
customerId: z.string().optional(),
|
|
140
|
+
idempotencyKey: z.string().optional(),
|
|
141
|
+
reference: z.string().optional(),
|
|
142
|
+
metadata: z.record(z.string()).optional(),
|
|
143
|
+
lineItems: z.array(z.lazy(() => LineItem$outboundSchema)).optional(),
|
|
144
|
+
successRedirectUrl: z.string().optional(),
|
|
145
|
+
failureRedirectUrl: z.string().optional(),
|
|
146
|
+
savePaymentMethod: z.boolean().default(false),
|
|
147
|
+
expiresIn: z.string().optional(),
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
export function createPaymentRequestToJSON(
|
|
151
|
+
createPaymentRequest: CreatePaymentRequest,
|
|
152
|
+
): string {
|
|
153
|
+
return JSON.stringify(
|
|
154
|
+
CreatePaymentRequest$outboundSchema.parse(createPaymentRequest),
|
|
155
|
+
);
|
|
156
|
+
}
|