get-bill-payment.tool.ts•1.47 kB
import { getQuickbooksBillPayment } from "../handlers/get-quickbooks-bill-payment.handler.js";
import { ToolDefinition } from "../types/tool-definition.js";
import { z } from "zod";
// Define the tool metadata
const toolName = "get_bill_payment";
const toolTitle = "Get Bill Payment";
const toolDescription = "Get a bill payment by Id from QuickBooks Online.";
// Define the expected input schema for getting a bill payment
const inputSchema = {
id: z.string(),
};
const outputSchema = {
success: z.boolean().describe("Whether the operation was successful"),
data: z.any().optional().describe("The result data"),
error: z.string().optional().describe("Error message if operation failed"),
};
// Define the tool handler
const toolHandler = async (params: z.infer<z.ZodObject<typeof inputSchema>>) => {
const response = await getQuickbooksBillPayment(params.id);
if (response.isError) {
return {
content: [
{ type: "text" as const, text: `Error getting bill payment: ${response.error}` },
],
};
}
return {
content: [
{ type: "text" as const, text: `Bill payment retrieved:` },
{ type: "text" as const, text: JSON.stringify(response.result) },
],
};
};
export const GetBillPaymentTool: ToolDefinition<typeof inputSchema, typeof outputSchema> = {
name: toolName,
title: toolTitle,
description: toolDescription,
inputSchema: inputSchema,
outputSchema: outputSchema,
handler: toolHandler,
};