@polar-sh/sdk 0.35.1 → 0.35.3
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 +25 -23
- package/bin/mcp-server.js +806 -635
- package/bin/mcp-server.js.map +15 -11
- package/dist/commonjs/funcs/customerPortalCustomersAddPaymentMethod.d.ts +2 -2
- package/dist/commonjs/funcs/customerPortalCustomersAddPaymentMethod.d.ts.map +1 -1
- package/dist/commonjs/funcs/customerPortalCustomersAddPaymentMethod.js +2 -2
- package/dist/commonjs/funcs/customerPortalCustomersAddPaymentMethod.js.map +1 -1
- package/dist/commonjs/funcs/customerPortalCustomersConfirmPaymentMethod.d.ts +23 -0
- package/dist/commonjs/funcs/customerPortalCustomersConfirmPaymentMethod.d.ts.map +1 -0
- package/dist/commonjs/funcs/customerPortalCustomersConfirmPaymentMethod.js +126 -0
- package/dist/commonjs/funcs/customerPortalCustomersConfirmPaymentMethod.js.map +1 -0
- package/dist/commonjs/funcs/customersGetBalance.d.ts +22 -0
- package/dist/commonjs/funcs/customersGetBalance.d.ts.map +1 -0
- package/dist/commonjs/funcs/customersGetBalance.js +127 -0
- package/dist/commonjs/funcs/customersGetBalance.js.map +1 -0
- package/dist/commonjs/funcs/metersQuantities.js +1 -0
- package/dist/commonjs/funcs/metersQuantities.js.map +1 -1
- 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/url.js +1 -1
- package/dist/commonjs/lib/url.js.map +1 -1
- package/dist/commonjs/mcp-server/mcp-server.js +1 -1
- package/dist/commonjs/mcp-server/server.d.ts.map +1 -1
- package/dist/commonjs/mcp-server/server.js +3 -1
- package/dist/commonjs/mcp-server/server.js.map +1 -1
- package/dist/commonjs/mcp-server/tools/customersGetBalance.d.ts +7 -0
- package/dist/commonjs/mcp-server/tools/customersGetBalance.d.ts.map +1 -0
- package/dist/commonjs/mcp-server/tools/customersGetBalance.js +34 -0
- package/dist/commonjs/mcp-server/tools/customersGetBalance.js.map +1 -0
- package/dist/commonjs/models/components/address.d.ts +664 -664
- package/dist/commonjs/models/components/address.js +221 -221
- package/dist/commonjs/models/components/addressinput.d.ts +650 -650
- package/dist/commonjs/models/components/addressinput.js +216 -216
- package/dist/commonjs/models/components/aggregationfunction.d.ts +40 -0
- package/dist/commonjs/models/components/aggregationfunction.d.ts.map +1 -0
- package/dist/commonjs/models/components/aggregationfunction.js +64 -0
- package/dist/commonjs/models/components/aggregationfunction.js.map +1 -0
- package/dist/commonjs/models/components/customerbalance.d.ts +40 -0
- package/dist/commonjs/models/components/customerbalance.d.ts.map +1 -0
- package/dist/commonjs/models/components/customerbalance.js +71 -0
- package/dist/commonjs/models/components/customerbalance.js.map +1 -0
- package/dist/commonjs/models/components/customerorder.d.ts +5 -0
- package/dist/commonjs/models/components/customerorder.d.ts.map +1 -1
- package/dist/commonjs/models/components/customerorder.js +4 -0
- package/dist/commonjs/models/components/customerorder.js.map +1 -1
- package/dist/commonjs/models/components/customerpaymentmethodconfirm.d.ts +31 -0
- package/dist/commonjs/models/components/customerpaymentmethodconfirm.d.ts.map +1 -0
- package/dist/commonjs/models/components/customerpaymentmethodconfirm.js +82 -0
- package/dist/commonjs/models/components/customerpaymentmethodconfirm.js.map +1 -0
- package/dist/commonjs/models/components/customerpaymentmethodcreaterequiresactionresponse.d.ts +31 -0
- package/dist/commonjs/models/components/customerpaymentmethodcreaterequiresactionresponse.d.ts.map +1 -0
- package/dist/commonjs/models/components/customerpaymentmethodcreaterequiresactionresponse.js +80 -0
- package/dist/commonjs/models/components/customerpaymentmethodcreaterequiresactionresponse.js.map +1 -0
- package/dist/commonjs/models/components/customerpaymentmethodcreateresponse.d.ts +35 -0
- package/dist/commonjs/models/components/customerpaymentmethodcreateresponse.d.ts.map +1 -0
- package/dist/commonjs/models/components/customerpaymentmethodcreateresponse.js +81 -0
- package/dist/commonjs/models/components/customerpaymentmethodcreateresponse.js.map +1 -0
- package/dist/commonjs/models/components/customerpaymentmethodcreatesucceededresponse.d.ts +32 -0
- package/dist/commonjs/models/components/customerpaymentmethodcreatesucceededresponse.d.ts.map +1 -0
- package/dist/commonjs/models/components/customerpaymentmethodcreatesucceededresponse.js +81 -0
- package/dist/commonjs/models/components/customerpaymentmethodcreatesucceededresponse.js.map +1 -0
- package/dist/commonjs/models/components/customerstatesubscription.d.ts +38 -2
- package/dist/commonjs/models/components/customerstatesubscription.d.ts.map +1 -1
- package/dist/commonjs/models/components/customerstatesubscription.js +30 -3
- package/dist/commonjs/models/components/customerstatesubscription.js.map +1 -1
- package/dist/commonjs/models/components/customersubscription.d.ts +5 -0
- package/dist/commonjs/models/components/customersubscription.d.ts.map +1 -1
- package/dist/commonjs/models/components/customersubscription.js +4 -0
- package/dist/commonjs/models/components/customersubscription.js.map +1 -1
- package/dist/commonjs/models/components/order.d.ts +5 -0
- package/dist/commonjs/models/components/order.d.ts.map +1 -1
- package/dist/commonjs/models/components/order.js +4 -0
- package/dist/commonjs/models/components/order.js.map +1 -1
- package/dist/commonjs/models/errors/customernotready.d.ts +39 -0
- package/dist/commonjs/models/errors/customernotready.d.ts.map +1 -0
- package/dist/commonjs/models/errors/customernotready.js +88 -0
- package/dist/commonjs/models/errors/customernotready.js.map +1 -0
- package/dist/commonjs/models/operations/customerportalcustomersconfirmpaymentmethod.d.ts +29 -0
- package/dist/commonjs/models/operations/customerportalcustomersconfirmpaymentmethod.d.ts.map +1 -0
- package/dist/commonjs/models/operations/customerportalcustomersconfirmpaymentmethod.js +78 -0
- package/dist/commonjs/models/operations/customerportalcustomersconfirmpaymentmethod.js.map +1 -0
- package/dist/commonjs/models/operations/customersgetbalance.d.ts +32 -0
- package/dist/commonjs/models/operations/customersgetbalance.d.ts.map +1 -0
- package/dist/commonjs/models/operations/customersgetbalance.js +69 -0
- package/dist/commonjs/models/operations/customersgetbalance.js.map +1 -0
- package/dist/commonjs/models/operations/metersquantities.d.ts +6 -0
- package/dist/commonjs/models/operations/metersquantities.d.ts.map +1 -1
- package/dist/commonjs/models/operations/metersquantities.js +7 -0
- package/dist/commonjs/models/operations/metersquantities.js.map +1 -1
- package/dist/commonjs/sdk/customers.d.ts +11 -0
- package/dist/commonjs/sdk/customers.d.ts.map +1 -1
- package/dist/commonjs/sdk/customers.js +12 -0
- package/dist/commonjs/sdk/customers.js.map +1 -1
- package/dist/commonjs/sdk/polarcustomers.d.ts +13 -2
- package/dist/commonjs/sdk/polarcustomers.d.ts.map +1 -1
- package/dist/commonjs/sdk/polarcustomers.js +12 -0
- package/dist/commonjs/sdk/polarcustomers.js.map +1 -1
- package/dist/esm/funcs/customerPortalCustomersAddPaymentMethod.d.ts +2 -2
- package/dist/esm/funcs/customerPortalCustomersAddPaymentMethod.d.ts.map +1 -1
- package/dist/esm/funcs/customerPortalCustomersAddPaymentMethod.js +2 -2
- package/dist/esm/funcs/customerPortalCustomersAddPaymentMethod.js.map +1 -1
- package/dist/esm/funcs/customerPortalCustomersConfirmPaymentMethod.d.ts +23 -0
- package/dist/esm/funcs/customerPortalCustomersConfirmPaymentMethod.d.ts.map +1 -0
- package/dist/esm/funcs/customerPortalCustomersConfirmPaymentMethod.js +90 -0
- package/dist/esm/funcs/customerPortalCustomersConfirmPaymentMethod.js.map +1 -0
- package/dist/esm/funcs/customersGetBalance.d.ts +22 -0
- package/dist/esm/funcs/customersGetBalance.d.ts.map +1 -0
- package/dist/esm/funcs/customersGetBalance.js +91 -0
- package/dist/esm/funcs/customersGetBalance.js.map +1 -0
- package/dist/esm/funcs/metersQuantities.js +1 -0
- package/dist/esm/funcs/metersQuantities.js.map +1 -1
- 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/url.js +1 -1
- package/dist/esm/lib/url.js.map +1 -1
- package/dist/esm/mcp-server/mcp-server.js +1 -1
- package/dist/esm/mcp-server/server.d.ts.map +1 -1
- package/dist/esm/mcp-server/server.js +3 -1
- package/dist/esm/mcp-server/server.js.map +1 -1
- package/dist/esm/mcp-server/tools/customersGetBalance.d.ts +7 -0
- package/dist/esm/mcp-server/tools/customersGetBalance.d.ts.map +1 -0
- package/dist/esm/mcp-server/tools/customersGetBalance.js +31 -0
- package/dist/esm/mcp-server/tools/customersGetBalance.js.map +1 -0
- package/dist/esm/models/components/address.d.ts +664 -664
- package/dist/esm/models/components/address.js +221 -221
- package/dist/esm/models/components/addressinput.d.ts +650 -650
- package/dist/esm/models/components/addressinput.js +216 -216
- package/dist/esm/models/components/aggregationfunction.d.ts +40 -0
- package/dist/esm/models/components/aggregationfunction.d.ts.map +1 -0
- package/dist/esm/models/components/aggregationfunction.js +28 -0
- package/dist/esm/models/components/aggregationfunction.js.map +1 -0
- package/dist/esm/models/components/customerbalance.d.ts +40 -0
- package/dist/esm/models/components/customerbalance.d.ts.map +1 -0
- package/dist/esm/models/components/customerbalance.js +33 -0
- package/dist/esm/models/components/customerbalance.js.map +1 -0
- package/dist/esm/models/components/customerorder.d.ts +5 -0
- package/dist/esm/models/components/customerorder.d.ts.map +1 -1
- package/dist/esm/models/components/customerorder.js +4 -0
- package/dist/esm/models/components/customerorder.js.map +1 -1
- package/dist/esm/models/components/customerpaymentmethodconfirm.d.ts +31 -0
- package/dist/esm/models/components/customerpaymentmethodconfirm.d.ts.map +1 -0
- package/dist/esm/models/components/customerpaymentmethodconfirm.js +44 -0
- package/dist/esm/models/components/customerpaymentmethodconfirm.js.map +1 -0
- package/dist/esm/models/components/customerpaymentmethodcreaterequiresactionresponse.d.ts +31 -0
- package/dist/esm/models/components/customerpaymentmethodcreaterequiresactionresponse.d.ts.map +1 -0
- package/dist/esm/models/components/customerpaymentmethodcreaterequiresactionresponse.js +42 -0
- package/dist/esm/models/components/customerpaymentmethodcreaterequiresactionresponse.js.map +1 -0
- package/dist/esm/models/components/customerpaymentmethodcreateresponse.d.ts +35 -0
- package/dist/esm/models/components/customerpaymentmethodcreateresponse.d.ts.map +1 -0
- package/dist/esm/models/components/customerpaymentmethodcreateresponse.js +43 -0
- package/dist/esm/models/components/customerpaymentmethodcreateresponse.js.map +1 -0
- package/dist/esm/models/components/customerpaymentmethodcreatesucceededresponse.d.ts +32 -0
- package/dist/esm/models/components/customerpaymentmethodcreatesucceededresponse.d.ts.map +1 -0
- package/dist/esm/models/components/customerpaymentmethodcreatesucceededresponse.js +43 -0
- package/dist/esm/models/components/customerpaymentmethodcreatesucceededresponse.js.map +1 -0
- package/dist/esm/models/components/customerstatesubscription.d.ts +38 -2
- package/dist/esm/models/components/customerstatesubscription.d.ts.map +1 -1
- package/dist/esm/models/components/customerstatesubscription.js +29 -2
- package/dist/esm/models/components/customerstatesubscription.js.map +1 -1
- package/dist/esm/models/components/customersubscription.d.ts +5 -0
- package/dist/esm/models/components/customersubscription.d.ts.map +1 -1
- package/dist/esm/models/components/customersubscription.js +4 -0
- package/dist/esm/models/components/customersubscription.js.map +1 -1
- package/dist/esm/models/components/order.d.ts +5 -0
- package/dist/esm/models/components/order.d.ts.map +1 -1
- package/dist/esm/models/components/order.js +4 -0
- package/dist/esm/models/components/order.js.map +1 -1
- package/dist/esm/models/errors/customernotready.d.ts +39 -0
- package/dist/esm/models/errors/customernotready.d.ts.map +1 -0
- package/dist/esm/models/errors/customernotready.js +51 -0
- package/dist/esm/models/errors/customernotready.js.map +1 -0
- package/dist/esm/models/operations/customerportalcustomersconfirmpaymentmethod.d.ts +29 -0
- package/dist/esm/models/operations/customerportalcustomersconfirmpaymentmethod.d.ts.map +1 -0
- package/dist/esm/models/operations/customerportalcustomersconfirmpaymentmethod.js +40 -0
- package/dist/esm/models/operations/customerportalcustomersconfirmpaymentmethod.js.map +1 -0
- package/dist/esm/models/operations/customersgetbalance.d.ts +32 -0
- package/dist/esm/models/operations/customersgetbalance.d.ts.map +1 -0
- package/dist/esm/models/operations/customersgetbalance.js +31 -0
- package/dist/esm/models/operations/customersgetbalance.js.map +1 -0
- package/dist/esm/models/operations/metersquantities.d.ts +6 -0
- package/dist/esm/models/operations/metersquantities.d.ts.map +1 -1
- package/dist/esm/models/operations/metersquantities.js +7 -0
- package/dist/esm/models/operations/metersquantities.js.map +1 -1
- package/dist/esm/sdk/customers.d.ts +11 -0
- package/dist/esm/sdk/customers.d.ts.map +1 -1
- package/dist/esm/sdk/customers.js +12 -0
- package/dist/esm/sdk/customers.js.map +1 -1
- package/dist/esm/sdk/polarcustomers.d.ts +13 -2
- package/dist/esm/sdk/polarcustomers.d.ts.map +1 -1
- package/dist/esm/sdk/polarcustomers.js +12 -0
- package/dist/esm/sdk/polarcustomers.js.map +1 -1
- package/docs/sdks/customers/README.md +78 -0
- package/docs/sdks/polarcustomers/README.md +82 -1
- package/examples/package-lock.json +1 -1
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/funcs/customerPortalCustomersAddPaymentMethod.ts +8 -8
- package/src/funcs/customerPortalCustomersConfirmPaymentMethod.ts +201 -0
- package/src/funcs/customersGetBalance.ts +195 -0
- package/src/funcs/metersQuantities.ts +1 -0
- package/src/lib/config.ts +3 -3
- package/src/lib/url.ts +1 -1
- package/src/mcp-server/mcp-server.ts +1 -1
- package/src/mcp-server/server.ts +3 -1
- package/src/mcp-server/tools/customersGetBalance.ts +40 -0
- package/src/models/components/address.ts +221 -221
- package/src/models/components/addressinput.ts +216 -216
- package/src/models/components/aggregationfunction.ts +37 -0
- package/src/models/components/customerbalance.ts +77 -0
- package/src/models/components/customerorder.ts +9 -0
- package/src/models/components/customerpaymentmethodconfirm.ts +83 -0
- package/src/models/components/customerpaymentmethodcreaterequiresactionresponse.ts +93 -0
- package/src/models/components/customerpaymentmethodcreateresponse.ts +107 -0
- package/src/models/components/customerpaymentmethodcreatesucceededresponse.ts +98 -0
- package/src/models/components/customerstatesubscription.ts +56 -4
- package/src/models/components/customersubscription.ts +9 -0
- package/src/models/components/order.ts +9 -0
- package/src/models/errors/customernotready.ts +85 -0
- package/src/models/operations/customerportalcustomersconfirmpaymentmethod.ts +89 -0
- package/src/models/operations/customersgetbalance.ts +69 -0
- package/src/models/operations/metersquantities.ts +16 -0
- package/src/sdk/customers.ts +22 -0
- package/src/sdk/polarcustomers.ts +26 -2
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { PolarCore } from "../core.js";
|
|
6
|
+
import { encodeJSON } 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 { resolveSecurity } from "../lib/security.js";
|
|
12
|
+
import { pathToFunc } from "../lib/url.js";
|
|
13
|
+
import {
|
|
14
|
+
CustomerPaymentMethodConfirm,
|
|
15
|
+
CustomerPaymentMethodConfirm$outboundSchema,
|
|
16
|
+
} from "../models/components/customerpaymentmethodconfirm.js";
|
|
17
|
+
import {
|
|
18
|
+
CustomerPaymentMethodCreateResponse,
|
|
19
|
+
CustomerPaymentMethodCreateResponse$inboundSchema,
|
|
20
|
+
} from "../models/components/customerpaymentmethodcreateresponse.js";
|
|
21
|
+
import {
|
|
22
|
+
CustomerNotReady,
|
|
23
|
+
CustomerNotReady$inboundSchema,
|
|
24
|
+
} from "../models/errors/customernotready.js";
|
|
25
|
+
import {
|
|
26
|
+
ConnectionError,
|
|
27
|
+
InvalidRequestError,
|
|
28
|
+
RequestAbortedError,
|
|
29
|
+
RequestTimeoutError,
|
|
30
|
+
UnexpectedClientError,
|
|
31
|
+
} from "../models/errors/httpclienterrors.js";
|
|
32
|
+
import {
|
|
33
|
+
HTTPValidationError,
|
|
34
|
+
HTTPValidationError$inboundSchema,
|
|
35
|
+
} from "../models/errors/httpvalidationerror.js";
|
|
36
|
+
import { PolarError } from "../models/errors/polarerror.js";
|
|
37
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
38
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
39
|
+
import { CustomerPortalCustomersConfirmPaymentMethodSecurity } from "../models/operations/customerportalcustomersconfirmpaymentmethod.js";
|
|
40
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
41
|
+
import { Result } from "../types/fp.js";
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Confirm Customer Payment Method
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* Confirm a payment method for the authenticated customer.
|
|
48
|
+
*
|
|
49
|
+
* **Scopes**: `customer_portal:read` `customer_portal:write`
|
|
50
|
+
*/
|
|
51
|
+
export function customerPortalCustomersConfirmPaymentMethod(
|
|
52
|
+
client: PolarCore,
|
|
53
|
+
security: CustomerPortalCustomersConfirmPaymentMethodSecurity,
|
|
54
|
+
request: CustomerPaymentMethodConfirm,
|
|
55
|
+
options?: RequestOptions,
|
|
56
|
+
): APIPromise<
|
|
57
|
+
Result<
|
|
58
|
+
CustomerPaymentMethodCreateResponse,
|
|
59
|
+
| CustomerNotReady
|
|
60
|
+
| HTTPValidationError
|
|
61
|
+
| PolarError
|
|
62
|
+
| ResponseValidationError
|
|
63
|
+
| ConnectionError
|
|
64
|
+
| RequestAbortedError
|
|
65
|
+
| RequestTimeoutError
|
|
66
|
+
| InvalidRequestError
|
|
67
|
+
| UnexpectedClientError
|
|
68
|
+
| SDKValidationError
|
|
69
|
+
>
|
|
70
|
+
> {
|
|
71
|
+
return new APIPromise($do(
|
|
72
|
+
client,
|
|
73
|
+
security,
|
|
74
|
+
request,
|
|
75
|
+
options,
|
|
76
|
+
));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async function $do(
|
|
80
|
+
client: PolarCore,
|
|
81
|
+
security: CustomerPortalCustomersConfirmPaymentMethodSecurity,
|
|
82
|
+
request: CustomerPaymentMethodConfirm,
|
|
83
|
+
options?: RequestOptions,
|
|
84
|
+
): Promise<
|
|
85
|
+
[
|
|
86
|
+
Result<
|
|
87
|
+
CustomerPaymentMethodCreateResponse,
|
|
88
|
+
| CustomerNotReady
|
|
89
|
+
| HTTPValidationError
|
|
90
|
+
| PolarError
|
|
91
|
+
| ResponseValidationError
|
|
92
|
+
| ConnectionError
|
|
93
|
+
| RequestAbortedError
|
|
94
|
+
| RequestTimeoutError
|
|
95
|
+
| InvalidRequestError
|
|
96
|
+
| UnexpectedClientError
|
|
97
|
+
| SDKValidationError
|
|
98
|
+
>,
|
|
99
|
+
APICall,
|
|
100
|
+
]
|
|
101
|
+
> {
|
|
102
|
+
const parsed = safeParse(
|
|
103
|
+
request,
|
|
104
|
+
(value) => CustomerPaymentMethodConfirm$outboundSchema.parse(value),
|
|
105
|
+
"Input validation failed",
|
|
106
|
+
);
|
|
107
|
+
if (!parsed.ok) {
|
|
108
|
+
return [parsed, { status: "invalid" }];
|
|
109
|
+
}
|
|
110
|
+
const payload = parsed.value;
|
|
111
|
+
const body = encodeJSON("body", payload, { explode: true });
|
|
112
|
+
|
|
113
|
+
const path = pathToFunc(
|
|
114
|
+
"/v1/customer-portal/customers/me/payment-methods/confirm",
|
|
115
|
+
)();
|
|
116
|
+
|
|
117
|
+
const headers = new Headers(compactMap({
|
|
118
|
+
"Content-Type": "application/json",
|
|
119
|
+
Accept: "application/json",
|
|
120
|
+
}));
|
|
121
|
+
|
|
122
|
+
const requestSecurity = resolveSecurity(
|
|
123
|
+
[
|
|
124
|
+
{
|
|
125
|
+
fieldName: "Authorization",
|
|
126
|
+
type: "http:bearer",
|
|
127
|
+
value: security?.customerSession,
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
const context = {
|
|
133
|
+
options: client._options,
|
|
134
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
135
|
+
operationID: "customer_portal:customers:confirm_payment_method",
|
|
136
|
+
oAuth2Scopes: null,
|
|
137
|
+
|
|
138
|
+
resolvedSecurity: requestSecurity,
|
|
139
|
+
|
|
140
|
+
securitySource: security,
|
|
141
|
+
retryConfig: options?.retries
|
|
142
|
+
|| client._options.retryConfig
|
|
143
|
+
|| { strategy: "none" },
|
|
144
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const requestRes = client._createRequest(context, {
|
|
148
|
+
security: requestSecurity,
|
|
149
|
+
method: "POST",
|
|
150
|
+
baseURL: options?.serverURL,
|
|
151
|
+
path: path,
|
|
152
|
+
headers: headers,
|
|
153
|
+
body: body,
|
|
154
|
+
userAgent: client._options.userAgent,
|
|
155
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
156
|
+
}, options);
|
|
157
|
+
if (!requestRes.ok) {
|
|
158
|
+
return [requestRes, { status: "invalid" }];
|
|
159
|
+
}
|
|
160
|
+
const req = requestRes.value;
|
|
161
|
+
|
|
162
|
+
const doResult = await client._do(req, {
|
|
163
|
+
context,
|
|
164
|
+
errorCodes: ["400", "422", "4XX", "5XX"],
|
|
165
|
+
retryConfig: context.retryConfig,
|
|
166
|
+
retryCodes: context.retryCodes,
|
|
167
|
+
});
|
|
168
|
+
if (!doResult.ok) {
|
|
169
|
+
return [doResult, { status: "request-error", request: req }];
|
|
170
|
+
}
|
|
171
|
+
const response = doResult.value;
|
|
172
|
+
|
|
173
|
+
const responseFields = {
|
|
174
|
+
HttpMeta: { Response: response, Request: req },
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const [result] = await M.match<
|
|
178
|
+
CustomerPaymentMethodCreateResponse,
|
|
179
|
+
| CustomerNotReady
|
|
180
|
+
| HTTPValidationError
|
|
181
|
+
| PolarError
|
|
182
|
+
| ResponseValidationError
|
|
183
|
+
| ConnectionError
|
|
184
|
+
| RequestAbortedError
|
|
185
|
+
| RequestTimeoutError
|
|
186
|
+
| InvalidRequestError
|
|
187
|
+
| UnexpectedClientError
|
|
188
|
+
| SDKValidationError
|
|
189
|
+
>(
|
|
190
|
+
M.json(201, CustomerPaymentMethodCreateResponse$inboundSchema),
|
|
191
|
+
M.jsonErr(400, CustomerNotReady$inboundSchema),
|
|
192
|
+
M.jsonErr(422, HTTPValidationError$inboundSchema),
|
|
193
|
+
M.fail("4XX"),
|
|
194
|
+
M.fail("5XX"),
|
|
195
|
+
)(response, req, { extraFields: responseFields });
|
|
196
|
+
if (!result.ok) {
|
|
197
|
+
return [result, { status: "complete", request: req, response }];
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return [result, { status: "complete", request: req, response }];
|
|
201
|
+
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { PolarCore } 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
|
+
CustomerBalance,
|
|
15
|
+
CustomerBalance$inboundSchema,
|
|
16
|
+
} from "../models/components/customerbalance.js";
|
|
17
|
+
import {
|
|
18
|
+
ConnectionError,
|
|
19
|
+
InvalidRequestError,
|
|
20
|
+
RequestAbortedError,
|
|
21
|
+
RequestTimeoutError,
|
|
22
|
+
UnexpectedClientError,
|
|
23
|
+
} from "../models/errors/httpclienterrors.js";
|
|
24
|
+
import {
|
|
25
|
+
HTTPValidationError,
|
|
26
|
+
HTTPValidationError$inboundSchema,
|
|
27
|
+
} from "../models/errors/httpvalidationerror.js";
|
|
28
|
+
import { PolarError } from "../models/errors/polarerror.js";
|
|
29
|
+
import {
|
|
30
|
+
ResourceNotFound,
|
|
31
|
+
ResourceNotFound$inboundSchema,
|
|
32
|
+
} from "../models/errors/resourcenotfound.js";
|
|
33
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
34
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
35
|
+
import {
|
|
36
|
+
CustomersGetBalanceRequest,
|
|
37
|
+
CustomersGetBalanceRequest$outboundSchema,
|
|
38
|
+
} from "../models/operations/customersgetbalance.js";
|
|
39
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
40
|
+
import { Result } from "../types/fp.js";
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Get Customer Balance
|
|
44
|
+
*
|
|
45
|
+
* @remarks
|
|
46
|
+
* Get customer balance information.
|
|
47
|
+
*
|
|
48
|
+
* **Scopes**: `customers:read` `customers:write`
|
|
49
|
+
*/
|
|
50
|
+
export function customersGetBalance(
|
|
51
|
+
client: PolarCore,
|
|
52
|
+
request: CustomersGetBalanceRequest,
|
|
53
|
+
options?: RequestOptions,
|
|
54
|
+
): APIPromise<
|
|
55
|
+
Result<
|
|
56
|
+
CustomerBalance,
|
|
57
|
+
| ResourceNotFound
|
|
58
|
+
| HTTPValidationError
|
|
59
|
+
| PolarError
|
|
60
|
+
| ResponseValidationError
|
|
61
|
+
| ConnectionError
|
|
62
|
+
| RequestAbortedError
|
|
63
|
+
| RequestTimeoutError
|
|
64
|
+
| InvalidRequestError
|
|
65
|
+
| UnexpectedClientError
|
|
66
|
+
| SDKValidationError
|
|
67
|
+
>
|
|
68
|
+
> {
|
|
69
|
+
return new APIPromise($do(
|
|
70
|
+
client,
|
|
71
|
+
request,
|
|
72
|
+
options,
|
|
73
|
+
));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function $do(
|
|
77
|
+
client: PolarCore,
|
|
78
|
+
request: CustomersGetBalanceRequest,
|
|
79
|
+
options?: RequestOptions,
|
|
80
|
+
): Promise<
|
|
81
|
+
[
|
|
82
|
+
Result<
|
|
83
|
+
CustomerBalance,
|
|
84
|
+
| ResourceNotFound
|
|
85
|
+
| HTTPValidationError
|
|
86
|
+
| PolarError
|
|
87
|
+
| ResponseValidationError
|
|
88
|
+
| ConnectionError
|
|
89
|
+
| RequestAbortedError
|
|
90
|
+
| RequestTimeoutError
|
|
91
|
+
| InvalidRequestError
|
|
92
|
+
| UnexpectedClientError
|
|
93
|
+
| SDKValidationError
|
|
94
|
+
>,
|
|
95
|
+
APICall,
|
|
96
|
+
]
|
|
97
|
+
> {
|
|
98
|
+
const parsed = safeParse(
|
|
99
|
+
request,
|
|
100
|
+
(value) => CustomersGetBalanceRequest$outboundSchema.parse(value),
|
|
101
|
+
"Input validation failed",
|
|
102
|
+
);
|
|
103
|
+
if (!parsed.ok) {
|
|
104
|
+
return [parsed, { status: "invalid" }];
|
|
105
|
+
}
|
|
106
|
+
const payload = parsed.value;
|
|
107
|
+
const body = null;
|
|
108
|
+
|
|
109
|
+
const pathParams = {
|
|
110
|
+
id: encodeSimple("id", payload.id, {
|
|
111
|
+
explode: false,
|
|
112
|
+
charEncoding: "percent",
|
|
113
|
+
}),
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const path = pathToFunc("/v1/customers/{id}/balance")(pathParams);
|
|
117
|
+
|
|
118
|
+
const headers = new Headers(compactMap({
|
|
119
|
+
Accept: "application/json",
|
|
120
|
+
}));
|
|
121
|
+
|
|
122
|
+
const secConfig = await extractSecurity(client._options.accessToken);
|
|
123
|
+
const securityInput = secConfig == null ? {} : { accessToken: secConfig };
|
|
124
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
125
|
+
|
|
126
|
+
const context = {
|
|
127
|
+
options: client._options,
|
|
128
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
129
|
+
operationID: "customers:get_balance",
|
|
130
|
+
oAuth2Scopes: [],
|
|
131
|
+
|
|
132
|
+
resolvedSecurity: requestSecurity,
|
|
133
|
+
|
|
134
|
+
securitySource: client._options.accessToken,
|
|
135
|
+
retryConfig: options?.retries
|
|
136
|
+
|| client._options.retryConfig
|
|
137
|
+
|| { strategy: "none" },
|
|
138
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const requestRes = client._createRequest(context, {
|
|
142
|
+
security: requestSecurity,
|
|
143
|
+
method: "GET",
|
|
144
|
+
baseURL: options?.serverURL,
|
|
145
|
+
path: path,
|
|
146
|
+
headers: headers,
|
|
147
|
+
body: body,
|
|
148
|
+
userAgent: client._options.userAgent,
|
|
149
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
150
|
+
}, options);
|
|
151
|
+
if (!requestRes.ok) {
|
|
152
|
+
return [requestRes, { status: "invalid" }];
|
|
153
|
+
}
|
|
154
|
+
const req = requestRes.value;
|
|
155
|
+
|
|
156
|
+
const doResult = await client._do(req, {
|
|
157
|
+
context,
|
|
158
|
+
errorCodes: ["404", "422", "4XX", "5XX"],
|
|
159
|
+
retryConfig: context.retryConfig,
|
|
160
|
+
retryCodes: context.retryCodes,
|
|
161
|
+
});
|
|
162
|
+
if (!doResult.ok) {
|
|
163
|
+
return [doResult, { status: "request-error", request: req }];
|
|
164
|
+
}
|
|
165
|
+
const response = doResult.value;
|
|
166
|
+
|
|
167
|
+
const responseFields = {
|
|
168
|
+
HttpMeta: { Response: response, Request: req },
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const [result] = await M.match<
|
|
172
|
+
CustomerBalance,
|
|
173
|
+
| ResourceNotFound
|
|
174
|
+
| HTTPValidationError
|
|
175
|
+
| PolarError
|
|
176
|
+
| ResponseValidationError
|
|
177
|
+
| ConnectionError
|
|
178
|
+
| RequestAbortedError
|
|
179
|
+
| RequestTimeoutError
|
|
180
|
+
| InvalidRequestError
|
|
181
|
+
| UnexpectedClientError
|
|
182
|
+
| SDKValidationError
|
|
183
|
+
>(
|
|
184
|
+
M.json(200, CustomerBalance$inboundSchema),
|
|
185
|
+
M.jsonErr(404, ResourceNotFound$inboundSchema),
|
|
186
|
+
M.jsonErr(422, HTTPValidationError$inboundSchema),
|
|
187
|
+
M.fail("4XX"),
|
|
188
|
+
M.fail("5XX"),
|
|
189
|
+
)(response, req, { extraFields: responseFields });
|
|
190
|
+
if (!result.ok) {
|
|
191
|
+
return [result, { status: "complete", request: req, response }];
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return [result, { status: "complete", request: req, response }];
|
|
195
|
+
}
|
|
@@ -125,6 +125,7 @@ async function $do(
|
|
|
125
125
|
"metadata": payload.metadata,
|
|
126
126
|
}),
|
|
127
127
|
encodeFormQuery({
|
|
128
|
+
"customer_aggregation_function": payload.customer_aggregation_function,
|
|
128
129
|
"customer_id": payload.customer_id,
|
|
129
130
|
"end_timestamp": payload.end_timestamp,
|
|
130
131
|
"external_customer_id": payload.external_customer_id,
|
package/src/lib/config.ts
CHANGED
|
@@ -64,7 +64,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
|
|
|
64
64
|
export const SDK_METADATA = {
|
|
65
65
|
language: "typescript",
|
|
66
66
|
openapiDocVersion: "0.1.0",
|
|
67
|
-
sdkVersion: "0.35.
|
|
68
|
-
genVersion: "2.
|
|
69
|
-
userAgent: "speakeasy-sdk/typescript 0.35.
|
|
67
|
+
sdkVersion: "0.35.3",
|
|
68
|
+
genVersion: "2.716.16",
|
|
69
|
+
userAgent: "speakeasy-sdk/typescript 0.35.3 2.716.16 0.1.0 @polar-sh/sdk",
|
|
70
70
|
} as const;
|
package/src/lib/url.ts
CHANGED
|
@@ -10,7 +10,7 @@ export function pathToFunc(
|
|
|
10
10
|
pathPattern: string,
|
|
11
11
|
options?: { charEncoding?: "percent" | "none" },
|
|
12
12
|
): (params?: Params) => string {
|
|
13
|
-
const paramRE = /\{([a-zA-Z0-9_]
|
|
13
|
+
const paramRE = /\{([a-zA-Z0-9_][a-zA-Z0-9_-]*?)\}/g;
|
|
14
14
|
|
|
15
15
|
return function buildURLPath(params: Record<string, unknown> = {}): string {
|
|
16
16
|
return pathPattern.replace(paramRE, function (_, placeholder) {
|
package/src/mcp-server/server.ts
CHANGED
|
@@ -20,6 +20,7 @@ import { tool$customersDelete } from "./tools/customersDelete.js";
|
|
|
20
20
|
import { tool$customersDeleteExternal } from "./tools/customersDeleteExternal.js";
|
|
21
21
|
import { tool$customersExport } from "./tools/customersExport.js";
|
|
22
22
|
import { tool$customersGet } from "./tools/customersGet.js";
|
|
23
|
+
import { tool$customersGetBalance } from "./tools/customersGetBalance.js";
|
|
23
24
|
import { tool$customersGetExternal } from "./tools/customersGetExternal.js";
|
|
24
25
|
import { tool$customersGetState } from "./tools/customersGetState.js";
|
|
25
26
|
import { tool$customersGetStateExternal } from "./tools/customersGetStateExternal.js";
|
|
@@ -56,7 +57,7 @@ export function createMCPServer(deps: {
|
|
|
56
57
|
}) {
|
|
57
58
|
const server = new McpServer({
|
|
58
59
|
name: "Polar",
|
|
59
|
-
version: "0.35.
|
|
60
|
+
version: "0.35.3",
|
|
60
61
|
});
|
|
61
62
|
|
|
62
63
|
const client = new PolarCore({
|
|
@@ -114,6 +115,7 @@ export function createMCPServer(deps: {
|
|
|
114
115
|
tool(tool$customersDeleteExternal);
|
|
115
116
|
tool(tool$customersGetState);
|
|
116
117
|
tool(tool$customersGetStateExternal);
|
|
118
|
+
tool(tool$customersGetBalance);
|
|
117
119
|
tool(tool$customerMetersList);
|
|
118
120
|
tool(tool$customerMetersGet);
|
|
119
121
|
tool(tool$paymentsList);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { customersGetBalance } from "../../funcs/customersGetBalance.js";
|
|
6
|
+
import { CustomersGetBalanceRequest$inboundSchema } from "../../models/operations/customersgetbalance.js";
|
|
7
|
+
import { formatResult, ToolDefinition } from "../tools.js";
|
|
8
|
+
|
|
9
|
+
const args = {
|
|
10
|
+
request: CustomersGetBalanceRequest$inboundSchema,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const tool$customersGetBalance: ToolDefinition<typeof args> = {
|
|
14
|
+
name: "customers-get-balance",
|
|
15
|
+
description: `Get Customer Balance
|
|
16
|
+
|
|
17
|
+
Get customer balance information.
|
|
18
|
+
|
|
19
|
+
**Scopes**: \`customers:read\` \`customers:write\``,
|
|
20
|
+
scopes: ["read", "customers"],
|
|
21
|
+
args,
|
|
22
|
+
tool: async (client, args, ctx) => {
|
|
23
|
+
const [result, apiCall] = await customersGetBalance(
|
|
24
|
+
client,
|
|
25
|
+
args.request,
|
|
26
|
+
{ fetchOptions: { signal: ctx.signal } },
|
|
27
|
+
).$inspect();
|
|
28
|
+
|
|
29
|
+
if (!result.ok) {
|
|
30
|
+
return {
|
|
31
|
+
content: [{ type: "text", text: result.error.message }],
|
|
32
|
+
isError: true,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const value = result.value;
|
|
37
|
+
|
|
38
|
+
return formatResult(value, apiCall);
|
|
39
|
+
},
|
|
40
|
+
};
|