146 lines
5.6 KiB
JavaScript
146 lines
5.6 KiB
JavaScript
import { z } from 'zod';
|
|
export function registerCustomersTools(client) {
|
|
return [
|
|
{
|
|
name: 'toast_list_customers',
|
|
description: 'List all customers',
|
|
inputSchema: z.object({
|
|
page: z.number().optional().describe('Page number (default: 1)'),
|
|
pageSize: z.number().optional().describe('Items per page (default: 100)'),
|
|
}),
|
|
execute: async (args) => {
|
|
const result = await client.customers.list({
|
|
page: args.page,
|
|
pageSize: args.pageSize,
|
|
});
|
|
return {
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: JSON.stringify(result, null, 2),
|
|
},
|
|
],
|
|
};
|
|
},
|
|
},
|
|
{
|
|
name: 'toast_get_customer',
|
|
description: 'Get details of a specific customer',
|
|
inputSchema: z.object({
|
|
customerGuid: z.string().describe('Customer GUID'),
|
|
}),
|
|
execute: async (args) => {
|
|
const result = await client.customers.get(args.customerGuid);
|
|
return {
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: JSON.stringify(result, null, 2),
|
|
},
|
|
],
|
|
};
|
|
},
|
|
},
|
|
{
|
|
name: 'toast_create_customer',
|
|
description: 'Create a new customer',
|
|
inputSchema: z.object({
|
|
firstName: z.string().describe('First name'),
|
|
lastName: z.string().describe('Last name'),
|
|
email: z.string().optional().describe('Email address'),
|
|
phone: z.string().optional().describe('Phone number'),
|
|
company: z.string().optional().describe('Company name'),
|
|
}),
|
|
execute: async (args) => {
|
|
const customerData = {
|
|
firstName: args.firstName,
|
|
lastName: args.lastName,
|
|
...(args.email && { email: args.email }),
|
|
...(args.phone && { phone: args.phone }),
|
|
...(args.company && { company: args.company }),
|
|
};
|
|
const result = await client.customers.create(customerData);
|
|
return {
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: JSON.stringify(result, null, 2),
|
|
},
|
|
],
|
|
};
|
|
},
|
|
},
|
|
{
|
|
name: 'toast_update_customer',
|
|
description: 'Update an existing customer',
|
|
inputSchema: z.object({
|
|
customerGuid: z.string().describe('Customer GUID'),
|
|
firstName: z.string().optional().describe('First name'),
|
|
lastName: z.string().optional().describe('Last name'),
|
|
email: z.string().optional().describe('Email address'),
|
|
phone: z.string().optional().describe('Phone number'),
|
|
company: z.string().optional().describe('Company name'),
|
|
}),
|
|
execute: async (args) => {
|
|
const updateData = {};
|
|
if (args.firstName)
|
|
updateData.firstName = args.firstName;
|
|
if (args.lastName)
|
|
updateData.lastName = args.lastName;
|
|
if (args.email)
|
|
updateData.email = args.email;
|
|
if (args.phone)
|
|
updateData.phone = args.phone;
|
|
if (args.company)
|
|
updateData.company = args.company;
|
|
const result = await client.customers.update(args.customerGuid, updateData);
|
|
return {
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: JSON.stringify(result, null, 2),
|
|
},
|
|
],
|
|
};
|
|
},
|
|
},
|
|
{
|
|
name: 'toast_list_customer_loyalty',
|
|
description: 'List loyalty information for a customer',
|
|
inputSchema: z.object({
|
|
customerGuid: z.string().describe('Customer GUID'),
|
|
}),
|
|
execute: async (args) => {
|
|
const result = await client.customers.listLoyalty(args.customerGuid);
|
|
return {
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: JSON.stringify(result, null, 2),
|
|
},
|
|
],
|
|
};
|
|
},
|
|
},
|
|
{
|
|
name: 'toast_add_loyalty_points',
|
|
description: 'Add loyalty points to a customer account',
|
|
inputSchema: z.object({
|
|
customerGuid: z.string().describe('Customer GUID'),
|
|
points: z.number().describe('Points to add'),
|
|
}),
|
|
execute: async (args) => {
|
|
const result = await client.customers.addLoyaltyPoints(args.customerGuid, args.points);
|
|
return {
|
|
content: [
|
|
{
|
|
type: 'text',
|
|
text: JSON.stringify(result, null, 2),
|
|
},
|
|
],
|
|
};
|
|
},
|
|
},
|
|
];
|
|
}
|
|
//# sourceMappingURL=customers-tools.js.map
|