recurly-mcp 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +61 -0
- package/LICENSE +21 -0
- package/README.md +179 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +19 -0
- package/dist/bin.js.map +1 -0
- package/dist/client/errors.d.ts +16 -0
- package/dist/client/errors.js +44 -0
- package/dist/client/errors.js.map +1 -0
- package/dist/client/pagination.d.ts +8 -0
- package/dist/client/pagination.js +33 -0
- package/dist/client/pagination.js.map +1 -0
- package/dist/client/recurly.d.ts +19 -0
- package/dist/client/recurly.js +277 -0
- package/dist/client/recurly.js.map +1 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.js +99 -0
- package/dist/config.js.map +1 -0
- package/dist/responseGuard.d.ts +1 -0
- package/dist/responseGuard.js +124 -0
- package/dist/responseGuard.js.map +1 -0
- package/dist/server.d.ts +7 -0
- package/dist/server.js +119 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/accounts.d.ts +217 -0
- package/dist/tools/accounts.js +71 -0
- package/dist/tools/accounts.js.map +1 -0
- package/dist/tools/addOns.d.ts +46 -0
- package/dist/tools/addOns.js +24 -0
- package/dist/tools/addOns.js.map +1 -0
- package/dist/tools/billingInfo.d.ts +57 -0
- package/dist/tools/billingInfo.js +31 -0
- package/dist/tools/billingInfo.js.map +1 -0
- package/dist/tools/businessEntities.d.ts +80 -0
- package/dist/tools/businessEntities.js +32 -0
- package/dist/tools/businessEntities.js.map +1 -0
- package/dist/tools/couponRedemptions.d.ts +135 -0
- package/dist/tools/couponRedemptions.js +57 -0
- package/dist/tools/couponRedemptions.js.map +1 -0
- package/dist/tools/coupons.d.ts +86 -0
- package/dist/tools/coupons.js +37 -0
- package/dist/tools/coupons.js.map +1 -0
- package/dist/tools/creditPayments.d.ts +73 -0
- package/dist/tools/creditPayments.js +28 -0
- package/dist/tools/creditPayments.js.map +1 -0
- package/dist/tools/customFieldDefinitions.d.ts +46 -0
- package/dist/tools/customFieldDefinitions.js +32 -0
- package/dist/tools/customFieldDefinitions.js.map +1 -0
- package/dist/tools/dunningCampaigns.d.ts +42 -0
- package/dist/tools/dunningCampaigns.js +21 -0
- package/dist/tools/dunningCampaigns.js.map +1 -0
- package/dist/tools/exports.d.ts +20 -0
- package/dist/tools/exports.js +21 -0
- package/dist/tools/exports.js.map +1 -0
- package/dist/tools/externalAccounts.d.ts +48 -0
- package/dist/tools/externalAccounts.js +28 -0
- package/dist/tools/externalAccounts.js.map +1 -0
- package/dist/tools/externalInvoices.d.ts +73 -0
- package/dist/tools/externalInvoices.js +28 -0
- package/dist/tools/externalInvoices.js.map +1 -0
- package/dist/tools/externalProducts.d.ts +85 -0
- package/dist/tools/externalProducts.js +34 -0
- package/dist/tools/externalProducts.js.map +1 -0
- package/dist/tools/externalSubscriptions.d.ts +147 -0
- package/dist/tools/externalSubscriptions.js +47 -0
- package/dist/tools/externalSubscriptions.js.map +1 -0
- package/dist/tools/generalLedgerAccounts.d.ts +46 -0
- package/dist/tools/generalLedgerAccounts.js +32 -0
- package/dist/tools/generalLedgerAccounts.js.map +1 -0
- package/dist/tools/giftCards.d.ts +42 -0
- package/dist/tools/giftCards.js +21 -0
- package/dist/tools/giftCards.js.map +1 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.js +68 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/invoiceTemplates.d.ts +83 -0
- package/dist/tools/invoiceTemplates.js +39 -0
- package/dist/tools/invoiceTemplates.js.map +1 -0
- package/dist/tools/invoices.d.ts +168 -0
- package/dist/tools/invoices.js +58 -0
- package/dist/tools/invoices.js.map +1 -0
- package/dist/tools/items.d.ts +46 -0
- package/dist/tools/items.js +24 -0
- package/dist/tools/items.js.map +1 -0
- package/dist/tools/lineItems.d.ts +93 -0
- package/dist/tools/lineItems.js +37 -0
- package/dist/tools/lineItems.js.map +1 -0
- package/dist/tools/measuredUnits.d.ts +46 -0
- package/dist/tools/measuredUnits.js +24 -0
- package/dist/tools/measuredUnits.js.map +1 -0
- package/dist/tools/performanceObligations.d.ts +42 -0
- package/dist/tools/performanceObligations.js +24 -0
- package/dist/tools/performanceObligations.js.map +1 -0
- package/dist/tools/plans.d.ts +93 -0
- package/dist/tools/plans.js +34 -0
- package/dist/tools/plans.js.map +1 -0
- package/dist/tools/priceSegments.d.ts +42 -0
- package/dist/tools/priceSegments.js +21 -0
- package/dist/tools/priceSegments.js.map +1 -0
- package/dist/tools/request.d.ts +17 -0
- package/dist/tools/request.js +55 -0
- package/dist/tools/request.js.map +1 -0
- package/dist/tools/shared.d.ts +32 -0
- package/dist/tools/shared.js +73 -0
- package/dist/tools/shared.js.map +1 -0
- package/dist/tools/shippingAddresses.d.ts +48 -0
- package/dist/tools/shippingAddresses.js +28 -0
- package/dist/tools/shippingAddresses.js.map +1 -0
- package/dist/tools/shippingMethods.d.ts +42 -0
- package/dist/tools/shippingMethods.js +21 -0
- package/dist/tools/shippingMethods.js.map +1 -0
- package/dist/tools/sites.d.ts +46 -0
- package/dist/tools/sites.js +24 -0
- package/dist/tools/sites.js.map +1 -0
- package/dist/tools/subscriptions.d.ts +178 -0
- package/dist/tools/subscriptions.js +68 -0
- package/dist/tools/subscriptions.js.map +1 -0
- package/dist/tools/transactions.d.ts +87 -0
- package/dist/tools/transactions.js +36 -0
- package/dist/tools/transactions.js.map +1 -0
- package/dist/tools/types.d.ts +13 -0
- package/dist/tools/types.js +2 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/tools/usage.d.ts +52 -0
- package/dist/tools/usage.js +33 -0
- package/dist/tools/usage.js.map +1 -0
- package/package.json +77 -0
package/dist/server.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
+
import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
+
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
6
|
+
import { RecurlyClient } from './client/recurly.js';
|
|
7
|
+
import { loadConfig } from './config.js';
|
|
8
|
+
import { shapeResult } from './responseGuard.js';
|
|
9
|
+
import { allTools } from './tools/index.js';
|
|
10
|
+
// Read version from package.json at runtime so it can never drift from the
|
|
11
|
+
// published version. Resolution: `../package.json` from src/server.ts (dev via
|
|
12
|
+
// tsx) and from dist/server.js (published) both land on the package root's
|
|
13
|
+
// package.json, which npm always ships.
|
|
14
|
+
const require = createRequire(import.meta.url);
|
|
15
|
+
const { version: PKG_VERSION } = require('../package.json');
|
|
16
|
+
function mergeAnyOf(branches) {
|
|
17
|
+
const properties = {};
|
|
18
|
+
const requiredCounts = {};
|
|
19
|
+
let total = 0;
|
|
20
|
+
for (const branch of branches) {
|
|
21
|
+
if (!branch || typeof branch !== 'object')
|
|
22
|
+
continue;
|
|
23
|
+
const b = branch;
|
|
24
|
+
if (b.type !== 'object')
|
|
25
|
+
continue;
|
|
26
|
+
total++;
|
|
27
|
+
const branchProps = b.properties ?? {};
|
|
28
|
+
for (const [name, propSchema] of Object.entries(branchProps)) {
|
|
29
|
+
if (!(name in properties)) {
|
|
30
|
+
properties[name] = JSON.parse(JSON.stringify(propSchema));
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (name === 'action') {
|
|
34
|
+
const existing = properties[name];
|
|
35
|
+
const incoming = propSchema;
|
|
36
|
+
const incomingVal = incoming.const;
|
|
37
|
+
if (incomingVal === undefined)
|
|
38
|
+
continue;
|
|
39
|
+
if (Array.isArray(existing.enum)) {
|
|
40
|
+
if (!existing.enum.includes(incomingVal))
|
|
41
|
+
existing.enum.push(incomingVal);
|
|
42
|
+
}
|
|
43
|
+
else if (existing.const !== undefined) {
|
|
44
|
+
const old = existing.const;
|
|
45
|
+
delete existing.const;
|
|
46
|
+
existing.enum = [old, incomingVal];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
for (const name of b.required ?? []) {
|
|
51
|
+
requiredCounts[name] = (requiredCounts[name] ?? 0) + 1;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const required = Object.entries(requiredCounts)
|
|
55
|
+
.filter(([, count]) => count === total)
|
|
56
|
+
.map(([name]) => name);
|
|
57
|
+
const result = { type: 'object', properties, additionalProperties: false };
|
|
58
|
+
if (required.length > 0)
|
|
59
|
+
result.required = required;
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
export function toMcpInputSchema(schema) {
|
|
63
|
+
const json = zodToJsonSchema(schema, {
|
|
64
|
+
target: 'jsonSchema7',
|
|
65
|
+
$refStrategy: 'none',
|
|
66
|
+
});
|
|
67
|
+
if (Array.isArray(json.anyOf))
|
|
68
|
+
return mergeAnyOf(json.anyOf);
|
|
69
|
+
if (json.type === 'object')
|
|
70
|
+
return json;
|
|
71
|
+
return { type: 'object', ...json };
|
|
72
|
+
}
|
|
73
|
+
export async function createServer(env = process.env) {
|
|
74
|
+
const config = loadConfig(env);
|
|
75
|
+
if (!config.apiKey) {
|
|
76
|
+
// Silently accepting an empty key means every request 401s with no startup
|
|
77
|
+
// signal — surface it once so misconfigured deployments notice immediately.
|
|
78
|
+
process.stderr.write('recurly-mcp: warning: RECURLY_API_KEY is not set — all API calls will fail with 401\n');
|
|
79
|
+
}
|
|
80
|
+
const client = new RecurlyClient(config);
|
|
81
|
+
const ctx = { client, config };
|
|
82
|
+
const server = new Server({ name: 'recurly-mcp', version: PKG_VERSION }, { capabilities: { tools: {} } });
|
|
83
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
84
|
+
tools: allTools.map((t) => ({
|
|
85
|
+
name: t.name,
|
|
86
|
+
description: t.description,
|
|
87
|
+
inputSchema: toMcpInputSchema(t.inputSchema),
|
|
88
|
+
})),
|
|
89
|
+
}));
|
|
90
|
+
server.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
91
|
+
const tool = allTools.find((t) => t.name === req.params.name);
|
|
92
|
+
if (!tool) {
|
|
93
|
+
return {
|
|
94
|
+
isError: true,
|
|
95
|
+
content: [{ type: 'text', text: `unknown tool: ${req.params.name}` }],
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
const result = await tool.handler(ctx, req.params.arguments ?? {});
|
|
100
|
+
return { content: [{ type: 'text', text: shapeResult(result, config.maxOutputBytes) }] };
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
// Cap the error text too: the success path goes through shapeResult, but
|
|
104
|
+
// an error message can also carry upstream content, so bound it the same way.
|
|
105
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
106
|
+
const text = message.length > config.maxOutputBytes
|
|
107
|
+
? `${message.slice(0, config.maxOutputBytes)}…[truncated]`
|
|
108
|
+
: message;
|
|
109
|
+
return { isError: true, content: [{ type: 'text', text }] };
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
return server;
|
|
113
|
+
}
|
|
114
|
+
export async function startStdioServer() {
|
|
115
|
+
const server = await createServer();
|
|
116
|
+
const transport = new StdioServerTransport();
|
|
117
|
+
await server.connect(transport);
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAEnG,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OA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EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QAC9D,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,MAAM,MAAM,GAAG,MAAM,YAAY,EAAE,CAAC;IACpC,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ToolDefinition } from './types.js';
|
|
3
|
+
declare const inputSchema: z.ZodDiscriminatedUnion<"action", [z.ZodObject<{
|
|
4
|
+
action: z.ZodLiteral<"list">;
|
|
5
|
+
} & {
|
|
6
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
7
|
+
order: z.ZodOptional<z.ZodEnum<["asc", "desc"]>>;
|
|
8
|
+
sort: z.ZodOptional<z.ZodString>;
|
|
9
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
10
|
+
ids: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
11
|
+
begin_time: z.ZodOptional<z.ZodString>;
|
|
12
|
+
end_time: z.ZodOptional<z.ZodString>;
|
|
13
|
+
} & {
|
|
14
|
+
email: z.ZodOptional<z.ZodString>;
|
|
15
|
+
subscriber: z.ZodOptional<z.ZodBoolean>;
|
|
16
|
+
past_due: z.ZodOptional<z.ZodString>;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
action: "list";
|
|
19
|
+
cursor?: string | undefined;
|
|
20
|
+
limit?: number | undefined;
|
|
21
|
+
order?: "asc" | "desc" | undefined;
|
|
22
|
+
sort?: string | undefined;
|
|
23
|
+
ids?: string[] | undefined;
|
|
24
|
+
begin_time?: string | undefined;
|
|
25
|
+
end_time?: string | undefined;
|
|
26
|
+
email?: string | undefined;
|
|
27
|
+
subscriber?: boolean | undefined;
|
|
28
|
+
past_due?: string | undefined;
|
|
29
|
+
}, {
|
|
30
|
+
action: "list";
|
|
31
|
+
cursor?: string | undefined;
|
|
32
|
+
limit?: number | undefined;
|
|
33
|
+
order?: "asc" | "desc" | undefined;
|
|
34
|
+
sort?: string | undefined;
|
|
35
|
+
ids?: string[] | undefined;
|
|
36
|
+
begin_time?: string | undefined;
|
|
37
|
+
end_time?: string | undefined;
|
|
38
|
+
email?: string | undefined;
|
|
39
|
+
subscriber?: boolean | undefined;
|
|
40
|
+
past_due?: string | undefined;
|
|
41
|
+
}>, z.ZodObject<{
|
|
42
|
+
action: z.ZodLiteral<"get">;
|
|
43
|
+
account_id: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, string, string>;
|
|
44
|
+
}, "strip", z.ZodTypeAny, {
|
|
45
|
+
action: "get";
|
|
46
|
+
account_id: string;
|
|
47
|
+
}, {
|
|
48
|
+
action: "get";
|
|
49
|
+
account_id: string;
|
|
50
|
+
}>, z.ZodObject<{
|
|
51
|
+
action: z.ZodLiteral<"get_balance">;
|
|
52
|
+
account_id: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, string, string>;
|
|
53
|
+
}, "strip", z.ZodTypeAny, {
|
|
54
|
+
action: "get_balance";
|
|
55
|
+
account_id: string;
|
|
56
|
+
}, {
|
|
57
|
+
action: "get_balance";
|
|
58
|
+
account_id: string;
|
|
59
|
+
}>, z.ZodObject<{
|
|
60
|
+
action: z.ZodLiteral<"get_acquisition">;
|
|
61
|
+
account_id: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, string, string>;
|
|
62
|
+
}, "strip", z.ZodTypeAny, {
|
|
63
|
+
action: "get_acquisition";
|
|
64
|
+
account_id: string;
|
|
65
|
+
}, {
|
|
66
|
+
action: "get_acquisition";
|
|
67
|
+
account_id: string;
|
|
68
|
+
}>, z.ZodObject<{
|
|
69
|
+
action: z.ZodLiteral<"list_acquisitions">;
|
|
70
|
+
} & {
|
|
71
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
72
|
+
order: z.ZodOptional<z.ZodEnum<["asc", "desc"]>>;
|
|
73
|
+
sort: z.ZodOptional<z.ZodString>;
|
|
74
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
75
|
+
ids: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
76
|
+
begin_time: z.ZodOptional<z.ZodString>;
|
|
77
|
+
end_time: z.ZodOptional<z.ZodString>;
|
|
78
|
+
}, "strip", z.ZodTypeAny, {
|
|
79
|
+
action: "list_acquisitions";
|
|
80
|
+
cursor?: string | undefined;
|
|
81
|
+
limit?: number | undefined;
|
|
82
|
+
order?: "asc" | "desc" | undefined;
|
|
83
|
+
sort?: string | undefined;
|
|
84
|
+
ids?: string[] | undefined;
|
|
85
|
+
begin_time?: string | undefined;
|
|
86
|
+
end_time?: string | undefined;
|
|
87
|
+
}, {
|
|
88
|
+
action: "list_acquisitions";
|
|
89
|
+
cursor?: string | undefined;
|
|
90
|
+
limit?: number | undefined;
|
|
91
|
+
order?: "asc" | "desc" | undefined;
|
|
92
|
+
sort?: string | undefined;
|
|
93
|
+
ids?: string[] | undefined;
|
|
94
|
+
begin_time?: string | undefined;
|
|
95
|
+
end_time?: string | undefined;
|
|
96
|
+
}>, z.ZodObject<{
|
|
97
|
+
action: z.ZodLiteral<"list_child_accounts">;
|
|
98
|
+
account_id: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, string, string>;
|
|
99
|
+
} & {
|
|
100
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
101
|
+
order: z.ZodOptional<z.ZodEnum<["asc", "desc"]>>;
|
|
102
|
+
sort: z.ZodOptional<z.ZodString>;
|
|
103
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
104
|
+
ids: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
105
|
+
begin_time: z.ZodOptional<z.ZodString>;
|
|
106
|
+
end_time: z.ZodOptional<z.ZodString>;
|
|
107
|
+
} & {
|
|
108
|
+
email: z.ZodOptional<z.ZodString>;
|
|
109
|
+
subscriber: z.ZodOptional<z.ZodBoolean>;
|
|
110
|
+
past_due: z.ZodOptional<z.ZodString>;
|
|
111
|
+
}, "strip", z.ZodTypeAny, {
|
|
112
|
+
action: "list_child_accounts";
|
|
113
|
+
account_id: string;
|
|
114
|
+
cursor?: string | undefined;
|
|
115
|
+
limit?: number | undefined;
|
|
116
|
+
order?: "asc" | "desc" | undefined;
|
|
117
|
+
sort?: string | undefined;
|
|
118
|
+
ids?: string[] | undefined;
|
|
119
|
+
begin_time?: string | undefined;
|
|
120
|
+
end_time?: string | undefined;
|
|
121
|
+
email?: string | undefined;
|
|
122
|
+
subscriber?: boolean | undefined;
|
|
123
|
+
past_due?: string | undefined;
|
|
124
|
+
}, {
|
|
125
|
+
action: "list_child_accounts";
|
|
126
|
+
account_id: string;
|
|
127
|
+
cursor?: string | undefined;
|
|
128
|
+
limit?: number | undefined;
|
|
129
|
+
order?: "asc" | "desc" | undefined;
|
|
130
|
+
sort?: string | undefined;
|
|
131
|
+
ids?: string[] | undefined;
|
|
132
|
+
begin_time?: string | undefined;
|
|
133
|
+
end_time?: string | undefined;
|
|
134
|
+
email?: string | undefined;
|
|
135
|
+
subscriber?: boolean | undefined;
|
|
136
|
+
past_due?: string | undefined;
|
|
137
|
+
}>, z.ZodObject<{
|
|
138
|
+
action: z.ZodLiteral<"list_notes">;
|
|
139
|
+
account_id: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, string, string>;
|
|
140
|
+
} & {
|
|
141
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
142
|
+
order: z.ZodOptional<z.ZodEnum<["asc", "desc"]>>;
|
|
143
|
+
sort: z.ZodOptional<z.ZodString>;
|
|
144
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
145
|
+
ids: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
146
|
+
begin_time: z.ZodOptional<z.ZodString>;
|
|
147
|
+
end_time: z.ZodOptional<z.ZodString>;
|
|
148
|
+
}, "strip", z.ZodTypeAny, {
|
|
149
|
+
action: "list_notes";
|
|
150
|
+
account_id: string;
|
|
151
|
+
cursor?: string | undefined;
|
|
152
|
+
limit?: number | undefined;
|
|
153
|
+
order?: "asc" | "desc" | undefined;
|
|
154
|
+
sort?: string | undefined;
|
|
155
|
+
ids?: string[] | undefined;
|
|
156
|
+
begin_time?: string | undefined;
|
|
157
|
+
end_time?: string | undefined;
|
|
158
|
+
}, {
|
|
159
|
+
action: "list_notes";
|
|
160
|
+
account_id: string;
|
|
161
|
+
cursor?: string | undefined;
|
|
162
|
+
limit?: number | undefined;
|
|
163
|
+
order?: "asc" | "desc" | undefined;
|
|
164
|
+
sort?: string | undefined;
|
|
165
|
+
ids?: string[] | undefined;
|
|
166
|
+
begin_time?: string | undefined;
|
|
167
|
+
end_time?: string | undefined;
|
|
168
|
+
}>, z.ZodObject<{
|
|
169
|
+
action: z.ZodLiteral<"get_note">;
|
|
170
|
+
account_id: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, string, string>;
|
|
171
|
+
account_note_id: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, string, string>;
|
|
172
|
+
}, "strip", z.ZodTypeAny, {
|
|
173
|
+
action: "get_note";
|
|
174
|
+
account_id: string;
|
|
175
|
+
account_note_id: string;
|
|
176
|
+
}, {
|
|
177
|
+
action: "get_note";
|
|
178
|
+
account_id: string;
|
|
179
|
+
account_note_id: string;
|
|
180
|
+
}>, z.ZodObject<{
|
|
181
|
+
action: z.ZodLiteral<"list_entitlements">;
|
|
182
|
+
account_id: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, string, string>;
|
|
183
|
+
} & {
|
|
184
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
185
|
+
order: z.ZodOptional<z.ZodEnum<["asc", "desc"]>>;
|
|
186
|
+
sort: z.ZodOptional<z.ZodString>;
|
|
187
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
188
|
+
ids: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
189
|
+
begin_time: z.ZodOptional<z.ZodString>;
|
|
190
|
+
end_time: z.ZodOptional<z.ZodString>;
|
|
191
|
+
} & {
|
|
192
|
+
state: z.ZodOptional<z.ZodString>;
|
|
193
|
+
}, "strip", z.ZodTypeAny, {
|
|
194
|
+
action: "list_entitlements";
|
|
195
|
+
account_id: string;
|
|
196
|
+
cursor?: string | undefined;
|
|
197
|
+
limit?: number | undefined;
|
|
198
|
+
order?: "asc" | "desc" | undefined;
|
|
199
|
+
sort?: string | undefined;
|
|
200
|
+
ids?: string[] | undefined;
|
|
201
|
+
begin_time?: string | undefined;
|
|
202
|
+
end_time?: string | undefined;
|
|
203
|
+
state?: string | undefined;
|
|
204
|
+
}, {
|
|
205
|
+
action: "list_entitlements";
|
|
206
|
+
account_id: string;
|
|
207
|
+
cursor?: string | undefined;
|
|
208
|
+
limit?: number | undefined;
|
|
209
|
+
order?: "asc" | "desc" | undefined;
|
|
210
|
+
sort?: string | undefined;
|
|
211
|
+
ids?: string[] | undefined;
|
|
212
|
+
begin_time?: string | undefined;
|
|
213
|
+
end_time?: string | undefined;
|
|
214
|
+
state?: string | undefined;
|
|
215
|
+
}>]>;
|
|
216
|
+
export declare const accountsTool: ToolDefinition<typeof inputSchema>;
|
|
217
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { enc, fetchList, idParam, listParamsSchema } from './shared.js';
|
|
3
|
+
const accountId = idParam('account_id');
|
|
4
|
+
const accountFilters = {
|
|
5
|
+
email: z.string().optional().describe('Filter for accounts with this exact email address.'),
|
|
6
|
+
subscriber: z
|
|
7
|
+
.boolean()
|
|
8
|
+
.optional()
|
|
9
|
+
.describe('Filter for accounts with (true) or without (false) a subscription.'),
|
|
10
|
+
past_due: z
|
|
11
|
+
.string()
|
|
12
|
+
.optional()
|
|
13
|
+
.describe('Filter for accounts with an invoice in the past_due state ("true"/"false").'),
|
|
14
|
+
};
|
|
15
|
+
const inputSchema = z.discriminatedUnion('action', [
|
|
16
|
+
z
|
|
17
|
+
.object({ action: z.literal('list') })
|
|
18
|
+
.merge(listParamsSchema)
|
|
19
|
+
.extend(accountFilters),
|
|
20
|
+
z.object({ action: z.literal('get'), account_id: accountId }),
|
|
21
|
+
z.object({ action: z.literal('get_balance'), account_id: accountId }),
|
|
22
|
+
z.object({ action: z.literal('get_acquisition'), account_id: accountId }),
|
|
23
|
+
z.object({ action: z.literal('list_acquisitions') }).merge(listParamsSchema),
|
|
24
|
+
z
|
|
25
|
+
.object({ action: z.literal('list_child_accounts'), account_id: accountId })
|
|
26
|
+
.merge(listParamsSchema)
|
|
27
|
+
.extend(accountFilters),
|
|
28
|
+
z.object({ action: z.literal('list_notes'), account_id: accountId }).merge(listParamsSchema),
|
|
29
|
+
z.object({
|
|
30
|
+
action: z.literal('get_note'),
|
|
31
|
+
account_id: accountId,
|
|
32
|
+
account_note_id: idParam('account_note_id'),
|
|
33
|
+
}),
|
|
34
|
+
z
|
|
35
|
+
.object({ action: z.literal('list_entitlements'), account_id: accountId })
|
|
36
|
+
.merge(listParamsSchema)
|
|
37
|
+
.extend({ state: z.string().optional().describe('Filter by state, e.g. subscribed.') }),
|
|
38
|
+
]);
|
|
39
|
+
export const accountsTool = {
|
|
40
|
+
name: 'recurly_accounts',
|
|
41
|
+
description: 'Recurly accounts (read-only). Actions: list, get, get_balance, get_acquisition (acquisition cost for an account), list_acquisitions (site-wide acquisition data), list_child_accounts, list_notes, get_note, list_entitlements. account_id accepts a Recurly ID or `code-<your_code>`. Returns raw Recurly JSON; list actions add a _pagination cursor hint.',
|
|
42
|
+
inputSchema,
|
|
43
|
+
handler: async (ctx, input) => {
|
|
44
|
+
const parsed = inputSchema.parse(input);
|
|
45
|
+
switch (parsed.action) {
|
|
46
|
+
case 'list':
|
|
47
|
+
return fetchList(ctx, '/accounts', parsed);
|
|
48
|
+
case 'get':
|
|
49
|
+
return ctx.client.request('GET', `/accounts/${enc(parsed.account_id)}`);
|
|
50
|
+
case 'get_balance':
|
|
51
|
+
return ctx.client.request('GET', `/accounts/${enc(parsed.account_id)}/balance`);
|
|
52
|
+
case 'get_acquisition':
|
|
53
|
+
return ctx.client.request('GET', `/accounts/${enc(parsed.account_id)}/acquisition`);
|
|
54
|
+
case 'list_acquisitions':
|
|
55
|
+
return fetchList(ctx, '/acquisitions', parsed);
|
|
56
|
+
case 'list_child_accounts':
|
|
57
|
+
return fetchList(ctx, `/accounts/${enc(parsed.account_id)}/accounts`, parsed, [
|
|
58
|
+
'account_id',
|
|
59
|
+
]);
|
|
60
|
+
case 'list_notes':
|
|
61
|
+
return fetchList(ctx, `/accounts/${enc(parsed.account_id)}/notes`, parsed, ['account_id']);
|
|
62
|
+
case 'get_note':
|
|
63
|
+
return ctx.client.request('GET', `/accounts/${enc(parsed.account_id)}/notes/${enc(parsed.account_note_id)}`);
|
|
64
|
+
case 'list_entitlements':
|
|
65
|
+
return fetchList(ctx, `/accounts/${enc(parsed.account_id)}/entitlements`, parsed, [
|
|
66
|
+
'account_id',
|
|
67
|
+
]);
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=accounts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../src/tools/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EA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CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,aAAa,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;YAClF,KAAK,iBAAiB;gBACpB,OAAO,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,aAAa,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;YACtF,KAAK,mBAAmB;gBACtB,OAAO,SAAS,CAAC,GAAG,EAAE,eAAe,EAAE,MAAM,CAAC,CAAC;YACjD,KAAK,qBAAqB;gBACxB,OAAO,SAAS,CAAC,GAAG,EAAE,aAAa,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE;oBAC5E,YAAY;iBACb,CAAC,CAAC;YACL,KAAK,YAAY;gBACf,OAAO,SAAS,CAAC,GAAG,EAAE,aAAa,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;YAC7F,KAAK,UAAU;gBACb,OAAO,GAAG,CAAC,MAAM,CAAC,OAAO,CACvB,KAAK,EACL,aAAa,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,CAC3E,CAAC;YACJ,KAAK,mBAAmB;gBACtB,OAAO,SAAS,CAAC,GAAG,EAAE,aAAa,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,eAAe,EAAE,MAAM,EAAE;oBAChF,YAAY;iBACb,CAAC,CAAC;QACP,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ToolDefinition } from './types.js';
|
|
3
|
+
declare const inputSchema: z.ZodDiscriminatedUnion<"action", [z.ZodObject<{
|
|
4
|
+
action: z.ZodLiteral<"list">;
|
|
5
|
+
} & {
|
|
6
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
7
|
+
order: z.ZodOptional<z.ZodEnum<["asc", "desc"]>>;
|
|
8
|
+
sort: z.ZodOptional<z.ZodString>;
|
|
9
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
10
|
+
ids: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
11
|
+
begin_time: z.ZodOptional<z.ZodString>;
|
|
12
|
+
end_time: z.ZodOptional<z.ZodString>;
|
|
13
|
+
} & {
|
|
14
|
+
state: z.ZodOptional<z.ZodString>;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
action: "list";
|
|
17
|
+
cursor?: string | undefined;
|
|
18
|
+
limit?: number | undefined;
|
|
19
|
+
order?: "asc" | "desc" | undefined;
|
|
20
|
+
sort?: string | undefined;
|
|
21
|
+
ids?: string[] | undefined;
|
|
22
|
+
begin_time?: string | undefined;
|
|
23
|
+
end_time?: string | undefined;
|
|
24
|
+
state?: string | undefined;
|
|
25
|
+
}, {
|
|
26
|
+
action: "list";
|
|
27
|
+
cursor?: string | undefined;
|
|
28
|
+
limit?: number | undefined;
|
|
29
|
+
order?: "asc" | "desc" | undefined;
|
|
30
|
+
sort?: string | undefined;
|
|
31
|
+
ids?: string[] | undefined;
|
|
32
|
+
begin_time?: string | undefined;
|
|
33
|
+
end_time?: string | undefined;
|
|
34
|
+
state?: string | undefined;
|
|
35
|
+
}>, z.ZodObject<{
|
|
36
|
+
action: z.ZodLiteral<"get">;
|
|
37
|
+
add_on_id: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, string, string>;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
action: "get";
|
|
40
|
+
add_on_id: string;
|
|
41
|
+
}, {
|
|
42
|
+
action: "get";
|
|
43
|
+
add_on_id: string;
|
|
44
|
+
}>]>;
|
|
45
|
+
export declare const addOnsTool: ToolDefinition<typeof inputSchema>;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { enc, fetchList, idParam, listParamsSchema } from './shared.js';
|
|
3
|
+
const inputSchema = z.discriminatedUnion('action', [
|
|
4
|
+
z
|
|
5
|
+
.object({ action: z.literal('list') })
|
|
6
|
+
.merge(listParamsSchema)
|
|
7
|
+
.extend({ state: z.string().optional().describe('Filter by state, e.g. active.') }),
|
|
8
|
+
z.object({ action: z.literal('get'), add_on_id: idParam('add_on_id') }),
|
|
9
|
+
]);
|
|
10
|
+
export const addOnsTool = {
|
|
11
|
+
name: 'recurly_add_ons',
|
|
12
|
+
description: 'Recurly add-ons (read-only), site-wide across all plans. Actions: list, get. For a specific plan’s add-ons use recurly_plans.list_add_ons. Returns raw Recurly JSON; list adds a _pagination cursor hint.',
|
|
13
|
+
inputSchema,
|
|
14
|
+
handler: async (ctx, input) => {
|
|
15
|
+
const parsed = inputSchema.parse(input);
|
|
16
|
+
switch (parsed.action) {
|
|
17
|
+
case 'list':
|
|
18
|
+
return fetchList(ctx, '/add_ons', parsed);
|
|
19
|
+
case 'get':
|
|
20
|
+
return ctx.client.request('GET', `/add_ons/${enc(parsed.add_on_id)}`);
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=addOns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"addOns.js","sourceRoot":"","sources":["../../src/tools/addOns.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAGxE,MAAM,WAAW,GAAG,CAAC,CAAC,kBAAkB,CAAC,QAAQ,EAAE;IACjD,CAAC;SACE,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;SACrC,KAAK,CAAC,gBAAgB,CAAC;SACvB,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,+BAA+B,CAAC,EAAE,CAAC;IACrF,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;CACxE,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,UAAU,GAAuC;IAC5D,IAAI,EAAE,iBAAiB;IACvB,WAAW,EACT,2MAA2M;IAC7M,WAAW;IACX,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE;QAC5B,MAAM,MAAM,GAAG,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACxC,QAAQ,MAAM,CAAC,MAAM,EAAE,CAAC;YACtB,KAAK,MAAM;gBACT,OAAO,SAAS,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;YAC5C,KAAK,KAAK;gBACR,OAAO,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;QAC1E,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ToolDefinition } from './types.js';
|
|
3
|
+
declare const inputSchema: z.ZodDiscriminatedUnion<"action", [z.ZodObject<{
|
|
4
|
+
action: z.ZodLiteral<"get">;
|
|
5
|
+
account_id: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, string, string>;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
action: "get";
|
|
8
|
+
account_id: string;
|
|
9
|
+
}, {
|
|
10
|
+
action: "get";
|
|
11
|
+
account_id: string;
|
|
12
|
+
}>, z.ZodObject<{
|
|
13
|
+
action: z.ZodLiteral<"list">;
|
|
14
|
+
account_id: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, string, string>;
|
|
15
|
+
} & {
|
|
16
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
order: z.ZodOptional<z.ZodEnum<["asc", "desc"]>>;
|
|
18
|
+
sort: z.ZodOptional<z.ZodString>;
|
|
19
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
20
|
+
ids: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
|
|
21
|
+
begin_time: z.ZodOptional<z.ZodString>;
|
|
22
|
+
end_time: z.ZodOptional<z.ZodString>;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
action: "list";
|
|
25
|
+
account_id: string;
|
|
26
|
+
cursor?: string | undefined;
|
|
27
|
+
limit?: number | undefined;
|
|
28
|
+
order?: "asc" | "desc" | undefined;
|
|
29
|
+
sort?: string | undefined;
|
|
30
|
+
ids?: string[] | undefined;
|
|
31
|
+
begin_time?: string | undefined;
|
|
32
|
+
end_time?: string | undefined;
|
|
33
|
+
}, {
|
|
34
|
+
action: "list";
|
|
35
|
+
account_id: string;
|
|
36
|
+
cursor?: string | undefined;
|
|
37
|
+
limit?: number | undefined;
|
|
38
|
+
order?: "asc" | "desc" | undefined;
|
|
39
|
+
sort?: string | undefined;
|
|
40
|
+
ids?: string[] | undefined;
|
|
41
|
+
begin_time?: string | undefined;
|
|
42
|
+
end_time?: string | undefined;
|
|
43
|
+
}>, z.ZodObject<{
|
|
44
|
+
action: z.ZodLiteral<"get_one">;
|
|
45
|
+
account_id: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, string, string>;
|
|
46
|
+
billing_info_id: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, string, string>;
|
|
47
|
+
}, "strip", z.ZodTypeAny, {
|
|
48
|
+
action: "get_one";
|
|
49
|
+
account_id: string;
|
|
50
|
+
billing_info_id: string;
|
|
51
|
+
}, {
|
|
52
|
+
action: "get_one";
|
|
53
|
+
account_id: string;
|
|
54
|
+
billing_info_id: string;
|
|
55
|
+
}>]>;
|
|
56
|
+
export declare const billingInfoTool: ToolDefinition<typeof inputSchema>;
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { enc, fetchList, idParam, listParamsSchema } from './shared.js';
|
|
3
|
+
const accountId = idParam('account_id');
|
|
4
|
+
const inputSchema = z.discriminatedUnion('action', [
|
|
5
|
+
z.object({ action: z.literal('get'), account_id: accountId }),
|
|
6
|
+
z.object({ action: z.literal('list'), account_id: accountId }).merge(listParamsSchema),
|
|
7
|
+
z.object({
|
|
8
|
+
action: z.literal('get_one'),
|
|
9
|
+
account_id: accountId,
|
|
10
|
+
billing_info_id: idParam('billing_info_id'),
|
|
11
|
+
}),
|
|
12
|
+
]);
|
|
13
|
+
export const billingInfoTool = {
|
|
14
|
+
name: 'recurly_billing_info',
|
|
15
|
+
description: "Recurly billing info (read-only), scoped to an account. Actions: get (the account's primary billing info), list (all billing infos on the account), get_one (a specific billing info by ID). Returns raw Recurly JSON; list adds a _pagination cursor hint.",
|
|
16
|
+
inputSchema,
|
|
17
|
+
handler: async (ctx, input) => {
|
|
18
|
+
const parsed = inputSchema.parse(input);
|
|
19
|
+
switch (parsed.action) {
|
|
20
|
+
case 'get':
|
|
21
|
+
return ctx.client.request('GET', `/accounts/${enc(parsed.account_id)}/billing_info`);
|
|
22
|
+
case 'list':
|
|
23
|
+
return fetchList(ctx, `/accounts/${enc(parsed.account_id)}/billing_infos`, parsed, [
|
|
24
|
+
'account_id',
|
|
25
|
+
]);
|
|
26
|
+
case 'get_one':
|
|
27
|
+
return ctx.client.request('GET', `/accounts/${enc(parsed.account_id)}/billing_infos/${enc(parsed.billing_info_id)}`);
|
|
28
|
+
}
|
|
29
|
+
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