@felipechavaa/pulse-mcp-server 1.0.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.
Files changed (28) hide show
  1. package/README.md +201 -0
  2. package/dist/index.js +75 -0
  3. package/dist/tools/pulse-api/hospitality/cancel-transaction-hospitality.js +54 -0
  4. package/dist/tools/pulse-api/hospitality/cancel-transaction-item-hospitality.js +50 -0
  5. package/dist/tools/pulse-api/hospitality/hold-transaction-hospitality.js +51 -0
  6. package/dist/tools/pulse-api/hospitality/lookup-quote-hospitality.js +55 -0
  7. package/dist/tools/pulse-api/hospitality/lookup-sale-hospitality.js +56 -0
  8. package/dist/tools/pulse-api/hospitality/new-payment-hospitality.js +57 -0
  9. package/dist/tools/pulse-api/hospitality/new-quote-hospitality.js +79 -0
  10. package/dist/tools/pulse-api/hospitality/new-sale-hospitality.js +83 -0
  11. package/dist/tools/pulse-api/hospitality/update-customer-details-hospitality.js +58 -0
  12. package/dist/tools/pulse-api/hospitality/update-customers-hospitality.js +71 -0
  13. package/dist/tools/pulse-api/hospitality/update-event-date-hospitality.js +62 -0
  14. package/dist/tools/pulse-api/hospitality/update-quote-hospitality.js +88 -0
  15. package/dist/tools/pulse-api/hospitality/update-sale-hospitality.js +82 -0
  16. package/dist/tools/pulse-api/hospitality/update-sale-items-hospitality.js +63 -0
  17. package/dist/tools/pulse-api/hospitality/update-sale-status-hospitality.js +58 -0
  18. package/dist/tools/pulse-api/hospitality/update-transaction-item-status-hospitality.js +56 -0
  19. package/dist/tools/pulse-api/hospitality/update-transaction-items-hospitality.js +56 -0
  20. package/dist/tools/pulse-api/hospitality/update-transaction-status-hospitality.js +55 -0
  21. package/dist/tools/pulse-react/pulse-react.content.js +48 -0
  22. package/dist/tools/pulse-react/pulse-react.install.js +56 -0
  23. package/dist/tools/pulse-react/pulse-react.quote.js +46 -0
  24. package/dist/tools/pulse-react/pulse-react.sale.js +73 -0
  25. package/dist/tools/pulse-widget/pulse-widget-installation.js +40 -0
  26. package/dist/tools/pulse-widget/pulse-widget-render.js +36 -0
  27. package/dist/types/toolResponse.js +1 -0
  28. package/package.json +39 -0
@@ -0,0 +1,79 @@
1
+ import { z } from "zod";
2
+ export const newQuoteHospitalityTool = [
3
+ "pulse-api-create-new-quote-hospitality",
4
+ "This is a quote API contract Protect Group Pulse API in hospitality vertical." +
5
+ "Use the tool to implements services in any programming language that can make HTTP requests." +
6
+ "Follow this API contract to create the services.",
7
+ {
8
+ currencyCode: z.string().describe("The currency code for the quote"),
9
+ displayCurrencyCode: z.string().describe("The display currency code for the quote"),
10
+ eventTravelDateTime: z.string().describe("The travel date and time in ISO 8601 format"),
11
+ fields: z.object({
12
+ accommodationType: z.string().describe("The type of accommodation"),
13
+ chainId: z.string().describe("The hotel chain ID"),
14
+ roomClass: z.string().describe("The class of the room"),
15
+ roomBedType: z.string().describe("The bed type in the room"),
16
+ starRating: z.string().describe("The star rating of the hotel"),
17
+ hotelCity: z.string().describe("The city where the hotel is located"),
18
+ hotelCountry: z.string().describe("The country where the hotel is located"),
19
+ policyInformation: z.string().describe("Information about the cancellation policy"),
20
+ extras: z.string().describe("Any extra services included"),
21
+ lengthOfStay: z.string().describe("The length of stay at the hotel")
22
+ }).describe("The fields related to the accommodation"),
23
+ languageCode: z.string().describe("The language code for the request"),
24
+ member: z.string().describe("The client ID or the client ID of the client being represented"),
25
+ returnHtml: z.boolean().describe("Whether to return HTML content"),
26
+ values: z.array(z.object({
27
+ numberOfTickets: z.number().describe("The number of tickets"),
28
+ value: z.number().describe("The total value for this group of tickets")
29
+ })).describe("Array of ticket groups with their values")
30
+ },
31
+ async ({ currencyCode, displayCurrencyCode, eventTravelDateTime, fields, languageCode, member, returnHtml, values }) => {
32
+ const url = 'https://api.protectgroup.com/test/dynamic/quote';
33
+ const clientId = ''; // will be provided by the user
34
+ const clientSecret = ''; // will be provided by the user
35
+ const body = {
36
+ currencyCode,
37
+ displayCurrencyCode,
38
+ eventTravelDateTime,
39
+ fields,
40
+ languageCode,
41
+ member,
42
+ returnHtml,
43
+ values
44
+ };
45
+ try {
46
+ const response = await fetch(url, {
47
+ method: 'POST',
48
+ headers: {
49
+ 'x-pg-client-id': clientId,
50
+ 'x-pg-client-secret': clientSecret,
51
+ 'Content-Type': 'application/json'
52
+ },
53
+ body: JSON.stringify(body)
54
+ });
55
+ if (!response.ok) {
56
+ const errorData = await response.json();
57
+ throw new Error(JSON.stringify(errorData));
58
+ }
59
+ const data = await response.json();
60
+ const toolResponse = {
61
+ content: [{
62
+ type: "text",
63
+ text: JSON.stringify(data, null, 2)
64
+ }]
65
+ };
66
+ return toolResponse;
67
+ }
68
+ catch (error) {
69
+ console.error('Error creating a new quote:', error);
70
+ const toolResponse = {
71
+ content: [{
72
+ type: "text",
73
+ text: `Error creating a new quote: ${error instanceof Error ? error.message : JSON.stringify(error)}`
74
+ }]
75
+ };
76
+ return toolResponse;
77
+ }
78
+ }
79
+ ];
@@ -0,0 +1,83 @@
1
+ import { z } from "zod";
2
+ export const newSaleHospitalityTool = [
3
+ "pulse-api-create-new-sale-hospitality",
4
+ "This is a new sale API contract Protect Group Pulse API in hospitality vertical." +
5
+ "Use the tool to implements services in any programming language that can make HTTP requests." +
6
+ "Follow this API contract to create the services.",
7
+ {
8
+ bookingReference: z.string().describe("Your custom unique booking reference"),
9
+ customers: z.array(z.object({
10
+ email: z.string().describe("Customer email"),
11
+ firstName: z.string().describe("Customer first name"),
12
+ lastName: z.string().describe("Customer last name"),
13
+ telephone: z.string().describe("Customer telephone")
14
+ })).describe("Array of customer objects"),
15
+ isPaidInFull: z.boolean().describe("Indicates if the transaction is paid in full"),
16
+ member: z.string().describe("Your client ID or the client ID of the client you are integrating on behalf of"),
17
+ products: z.array(z.object({
18
+ productCode: z.string().describe("The product code (e.g. 'TKT')"),
19
+ productId: z.number().describe("ID of the product"),
20
+ sold: z.boolean().describe("Indicates if the product is sold"),
21
+ items: z.array(z.object({
22
+ customerName: z.string().describe("Name of the customer"),
23
+ description: z.string().describe("Description of the item"),
24
+ reference: z.string().describe("Reference of the item"),
25
+ value: z.number().describe("Value of the item")
26
+ })).describe("Array of items associated with the product")
27
+ })).describe("Array of product objects"),
28
+ quoteId: z.string().describe("Quote ID from the New Quote - POST response"),
29
+ transactionDate: z.string().describe("The date of the transaction in ISO 8601 format")
30
+ },
31
+ async ({ bookingReference, customers, isPaidInFull, member, products, quoteId, transactionDate }) => {
32
+ const url = 'https://api.protectgroup.com/test/dynamic/sale';
33
+ const clientId = ''; // will be provided by the user
34
+ const clientSecret = ''; // will be provided by the user
35
+ const body = {
36
+ bookingReference,
37
+ customers,
38
+ isPaidInFull,
39
+ member,
40
+ products,
41
+ quoteId,
42
+ transactionDate
43
+ };
44
+ try {
45
+ // Set up headers for the request
46
+ const headers = {
47
+ 'x-pg-client-id': clientId,
48
+ 'x-pg-client-secret': clientSecret,
49
+ 'Content-Type': 'application/json'
50
+ };
51
+ // Perform the fetch request
52
+ const response = await fetch(url, {
53
+ method: 'POST',
54
+ headers,
55
+ body: JSON.stringify(body)
56
+ });
57
+ // Check if the response was successful
58
+ if (!response.ok) {
59
+ const errorData = await response.json();
60
+ throw new Error(JSON.stringify(errorData));
61
+ }
62
+ // Parse and return the response data
63
+ const data = await response.json();
64
+ const toolResponse = {
65
+ content: [{
66
+ type: "text",
67
+ text: JSON.stringify(data, null, 2)
68
+ }]
69
+ };
70
+ return toolResponse;
71
+ }
72
+ catch (error) {
73
+ console.error('Error creating transaction:', error);
74
+ const toolResponse = {
75
+ content: [{
76
+ type: "text",
77
+ text: `Error creating transaction: ${error instanceof Error ? error.message : JSON.stringify(error)}`
78
+ }]
79
+ };
80
+ return toolResponse;
81
+ }
82
+ }
83
+ ];
@@ -0,0 +1,58 @@
1
+ import { z } from "zod";
2
+ export const updateCustomerDetailsHospitalityTool = [
3
+ "pulse-api-update-customer-details-hospitality",
4
+ "This is the update customer details API contract Protect Group Pulse API in hospitality vertical." +
5
+ "Use the tool to implements services in any programming language that can make HTTP requests." +
6
+ "Follow this API contract to create the services.",
7
+ {
8
+ saleId: z.string().describe("The ID of the sale to update customer details for"),
9
+ customers: z.array(z.object({
10
+ firstName: z.string().describe("Customer first name"),
11
+ lastName: z.string().describe("Customer last name")
12
+ })).describe("Array of customers with updated details"),
13
+ member: z.string().describe("Your client ID or the client ID of the client being represented")
14
+ },
15
+ async ({ saleId, customers, member }) => {
16
+ const baseUrl = 'https://api.protectgroup.com/test/dynamic/sale';
17
+ const clientId = ''; // will be provided by the user
18
+ const clientSecret = ''; // will be provided by the user
19
+ const body = {
20
+ customers,
21
+ member
22
+ };
23
+ try {
24
+ const url = `${baseUrl}/${saleId}/customers`;
25
+ const response = await fetch(url, {
26
+ method: 'PUT',
27
+ headers: {
28
+ 'x-pg-client-id': clientId,
29
+ 'x-pg-client-secret': clientSecret,
30
+ 'Content-Type': 'application/json'
31
+ },
32
+ body: JSON.stringify(body)
33
+ });
34
+ if (!response.ok) {
35
+ const errorData = await response.json();
36
+ throw new Error(JSON.stringify(errorData));
37
+ }
38
+ const data = await response.json();
39
+ const toolResponse = {
40
+ content: [{
41
+ type: "text",
42
+ text: JSON.stringify(data, null, 2)
43
+ }]
44
+ };
45
+ return toolResponse;
46
+ }
47
+ catch (error) {
48
+ console.error('Error updating customer details:', error);
49
+ const toolResponse = {
50
+ content: [{
51
+ type: "text",
52
+ text: `Error updating customer details: ${error instanceof Error ? error.message : JSON.stringify(error)}`
53
+ }]
54
+ };
55
+ return toolResponse;
56
+ }
57
+ }
58
+ ];
@@ -0,0 +1,71 @@
1
+ import { z } from "zod";
2
+ export const updateCustomersHospitalityTool = [
3
+ "pulse-api-update-customers-hospitality",
4
+ "This is the update customers API contract for the Protect Group Pulse API in the hospitality vertical." +
5
+ " Use the tool to implement services in any programming language that can make HTTP requests." +
6
+ " Follow this API contract to update customer details on an existing sale.",
7
+ {
8
+ saleId: z.string().describe("The ID of the sale to update"),
9
+ member: z.string().describe("Your member ID or the member ID of the client you are integrating on behalf of"),
10
+ memberClient: z.object({
11
+ id: z.string().describe("Member client ID"),
12
+ name: z.string().describe("Member client name")
13
+ }).optional().describe("Optional sub-client details when integrating on behalf of another client"),
14
+ reference: z.string().optional().describe("Sale item reference to scope the update to a specific item"),
15
+ customers: z.array(z.object({
16
+ email: z.string().describe("Customer email address"),
17
+ firstName: z.string().describe("Customer first name"),
18
+ lastName: z.string().describe("Customer last name"),
19
+ telephone: z.string().describe("Customer telephone number"),
20
+ addressLine1: z.string().optional().describe("Address line 1"),
21
+ addressLine2: z.string().optional().describe("Address line 2"),
22
+ addressLine3: z.string().optional().describe("Address line 3"),
23
+ city: z.string().optional().describe("City"),
24
+ country: z.string().optional().describe("Country"),
25
+ dateOfBirth: z.string().optional().describe("Date of birth in ISO 8601 format"),
26
+ nationality: z.string().optional().describe("Nationality"),
27
+ postCode: z.string().optional().describe("Post / zip code"),
28
+ })).describe("Updated customer details"),
29
+ },
30
+ async ({ saleId, member, memberClient, reference, customers }) => {
31
+ const url = `https://api.protectgroup.com/test/dynamic/sale/${saleId}/customers`;
32
+ const clientId = ""; // will be provided by the user
33
+ const clientSecret = ""; // will be provided by the user
34
+ const body = {
35
+ saleId,
36
+ member,
37
+ customers,
38
+ ...(memberClient && { memberClient }),
39
+ ...(reference && { reference }),
40
+ };
41
+ try {
42
+ const response = await fetch(url, {
43
+ method: "PUT",
44
+ headers: {
45
+ "x-pg-client-id": clientId,
46
+ "x-pg-client-secret": clientSecret,
47
+ "Content-Type": "application/json",
48
+ },
49
+ body: JSON.stringify(body),
50
+ });
51
+ if (!response.ok) {
52
+ const errorData = await response.json();
53
+ throw new Error(JSON.stringify(errorData));
54
+ }
55
+ const data = await response.json();
56
+ const toolResponse = {
57
+ content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
58
+ };
59
+ return toolResponse;
60
+ }
61
+ catch (error) {
62
+ const toolResponse = {
63
+ content: [{
64
+ type: "text",
65
+ text: `Error updating customers: ${error instanceof Error ? error.message : JSON.stringify(error)}`,
66
+ }],
67
+ };
68
+ return toolResponse;
69
+ }
70
+ },
71
+ ];
@@ -0,0 +1,62 @@
1
+ import { z } from "zod";
2
+ export const updateEventDateHospitalityTool = [
3
+ "pulse-api-update-event-date-hospitality",
4
+ "This is the update event date API contract Protect Group Pulse API in hospitality vertical." +
5
+ "Use the tool to implements services in any programming language that can make HTTP requests." +
6
+ "Follow this API contract to create the services.",
7
+ {
8
+ saleId: z.string().describe("The ID of the sale to update"),
9
+ eventTravelDateTime: z.string().describe("The new event travel date and time in ISO 8601 format"),
10
+ member: z.string().describe("Your client ID or the client ID of the client being represented")
11
+ },
12
+ async ({ saleId, eventTravelDateTime, member }) => {
13
+ const baseUrl = 'https://api.protectgroup.com/test/dynamic/sale';
14
+ const clientId = ''; // will be provided by the user
15
+ const clientSecret = ''; // will be provided by the user
16
+ try {
17
+ // Construct the URL for the request
18
+ const url = `${baseUrl}/${saleId}/event-date`;
19
+ // Set up headers for the request
20
+ const headers = {
21
+ 'x-pg-client-id': clientId,
22
+ 'x-pg-client-secret': clientSecret,
23
+ 'Content-Type': 'application/json'
24
+ };
25
+ // Create the request body
26
+ const body = JSON.stringify({
27
+ eventTravelDateTime,
28
+ member
29
+ });
30
+ // Perform the fetch request
31
+ const response = await fetch(url, {
32
+ method: 'PUT',
33
+ headers,
34
+ body
35
+ });
36
+ // Check if the response was successful
37
+ if (!response.ok) {
38
+ const errorData = await response.json();
39
+ throw new Error(JSON.stringify(errorData));
40
+ }
41
+ // Parse and return the response data
42
+ const data = await response.json();
43
+ const toolResponse = {
44
+ content: [{
45
+ type: "text",
46
+ text: JSON.stringify(data, null, 2)
47
+ }]
48
+ };
49
+ return toolResponse;
50
+ }
51
+ catch (error) {
52
+ console.error('Error updating event date:', error);
53
+ const toolResponse = {
54
+ content: [{
55
+ type: "text",
56
+ text: `Error updating event date: ${error instanceof Error ? error.message : JSON.stringify(error)}`
57
+ }]
58
+ };
59
+ return toolResponse;
60
+ }
61
+ }
62
+ ];
@@ -0,0 +1,88 @@
1
+ import { z } from "zod";
2
+ export const updateQuoteHospitalityTool = [
3
+ "pulse-api-update-quote-hospitality",
4
+ "This is the update quote API contract Protect Group Pulse API in hospitality vertical." +
5
+ "Use the tool to implements services in any programming language that can make HTTP requests." +
6
+ "Follow this API contract to create the services.",
7
+ {
8
+ quoteId: z.string().describe("The ID of the quote to be updated"),
9
+ currencyCode: z.string().describe("The currency code for the quote"),
10
+ bookingReference: z.string().describe("Your custom booking reference"),
11
+ eventTravelDateTime: z.string().describe("The travel date and time in ISO 8601 format"),
12
+ languageCode: z.string().describe("The language code for the request"),
13
+ maintainExistingRate: z.boolean().describe("Whether to maintain the existing rate"),
14
+ member: z.string().describe("Your client ID or the client ID you are integrating on behalf of"),
15
+ returnHtml: z.boolean().describe("Whether to return HTML content"),
16
+ values: z.array(z.object({
17
+ numberOfTickets: z.number().describe("The number of tickets"),
18
+ value: z.number().describe("The total value for this group of tickets")
19
+ })).describe("Array of ticket groups with their values"),
20
+ fields: z.object({
21
+ accommodationType: z.string().optional().describe("The type of accommodation"),
22
+ chainId: z.string().optional().describe("The hotel chain ID"),
23
+ roomClass: z.string().optional().describe("The class of the room"),
24
+ roomBedType: z.string().optional().describe("The bed type in the room"),
25
+ starRating: z.string().optional().describe("The star rating of the hotel"),
26
+ hotelCity: z.string().optional().describe("The city where the hotel is located"),
27
+ hotelCountry: z.string().optional().describe("The country where the hotel is located"),
28
+ policyInformation: z.string().optional().describe("Information about the cancellation policy"),
29
+ extras: z.string().optional().describe("Any extra services included"),
30
+ lengthOfStay: z.string().optional().describe("The length of stay at the hotel")
31
+ }).optional().describe("Additional fields required for the quote update")
32
+ },
33
+ async ({ quoteId, currencyCode, bookingReference, eventTravelDateTime, languageCode, maintainExistingRate, member, returnHtml, values, fields }) => {
34
+ const url = 'https://api.protectgroup.com/test/dynamic/quote';
35
+ const clientId = ''; // will be provided by the user
36
+ const clientSecret = ''; // will be provided by the user
37
+ const body = {
38
+ quoteId,
39
+ currencyCode,
40
+ bookingReference,
41
+ eventTravelDateTime,
42
+ fields,
43
+ languageCode,
44
+ maintainExistingRate,
45
+ member,
46
+ returnHtml,
47
+ values
48
+ };
49
+ try {
50
+ // Set up headers for the request
51
+ const headers = {
52
+ 'x-pg-client-id': clientId,
53
+ 'x-pg-client-secret': clientSecret,
54
+ 'Content-Type': 'application/json'
55
+ };
56
+ // Perform the fetch request
57
+ const response = await fetch(url, {
58
+ method: 'PATCH',
59
+ headers,
60
+ body: JSON.stringify(body)
61
+ });
62
+ // Check if the response was successful
63
+ if (!response.ok) {
64
+ const errorData = await response.json();
65
+ throw new Error(JSON.stringify(errorData));
66
+ }
67
+ // Parse and return the response data
68
+ const data = await response.json();
69
+ const toolResponse = {
70
+ content: [{
71
+ type: "text",
72
+ text: JSON.stringify(data, null, 2)
73
+ }]
74
+ };
75
+ return toolResponse;
76
+ }
77
+ catch (error) {
78
+ console.error('Error updating quote:', error);
79
+ const toolResponse = {
80
+ content: [{
81
+ type: "text",
82
+ text: `Error updating quote: ${error instanceof Error ? error.message : JSON.stringify(error)}`
83
+ }]
84
+ };
85
+ return toolResponse;
86
+ }
87
+ }
88
+ ];
@@ -0,0 +1,82 @@
1
+ import { z } from "zod";
2
+ export const updateSaleHospitalityTool = [
3
+ "pulse-api-update-sale-hospitality",
4
+ "This is the update sale API contract Protect Group Pulse API in hospitality vertical." +
5
+ "Use the tool to implements services in any programming language that can make HTTP requests." +
6
+ "Follow this API contract to create the services.",
7
+ {
8
+ bookingReference: z.string().describe("Your custom unique booking reference"),
9
+ customers: z.array(z.object({
10
+ email: z.string().describe("Customer email"),
11
+ firstName: z.string().describe("Customer first name"),
12
+ lastName: z.string().describe("Customer last name"),
13
+ telephone: z.string().describe("Customer telephone in format +(prefix)(number)")
14
+ })).describe("List of customer details"),
15
+ isPaidInFull: z.boolean().describe("Indicates if the transaction is paid in full"),
16
+ member: z.string().describe("Your client ID"),
17
+ products: z.array(z.object({
18
+ productId: z.number().describe("Product ID"),
19
+ sold: z.boolean().describe("Indicates if the product is sold"),
20
+ items: z.array(z.object({
21
+ customerName: z.string().describe("Customer name"),
22
+ description: z.string().describe("Item description"),
23
+ reference: z.string().describe("Item reference"),
24
+ value: z.number().describe("Total value of the item")
25
+ })).describe("List of items associated with the product")
26
+ })).describe("List of products associated with the transaction"),
27
+ quoteId: z.string().describe("Quote ID from the New Quote - POST response"),
28
+ transactionDate: z.string().describe("Date of the transaction in ISO 8601 format")
29
+ },
30
+ async ({ bookingReference, customers, isPaidInFull, member, products, quoteId, transactionDate }) => {
31
+ const url = 'https://api.protectgroup.com/test/dynamic/sale';
32
+ const clientId = ''; // will be provided by the user
33
+ const clientSecret = ''; // will be provided by the user
34
+ const body = {
35
+ bookingReference,
36
+ customers,
37
+ isPaidInFull,
38
+ member,
39
+ products,
40
+ quoteId,
41
+ transactionDate
42
+ };
43
+ try {
44
+ // Set up headers for the request
45
+ const headers = {
46
+ 'x-pg-client-id': clientId,
47
+ 'x-pg-client-secret': clientSecret,
48
+ 'Content-Type': 'application/json'
49
+ };
50
+ // Perform the fetch request
51
+ const response = await fetch(url, {
52
+ method: 'PATCH',
53
+ headers,
54
+ body: JSON.stringify(body)
55
+ });
56
+ // Check if the response was successful
57
+ if (!response.ok) {
58
+ const errorData = await response.json();
59
+ throw new Error(JSON.stringify(errorData));
60
+ }
61
+ // Parse and return the response data
62
+ const data = await response.json();
63
+ const toolResponse = {
64
+ content: [{
65
+ type: "text",
66
+ text: JSON.stringify(data, null, 2)
67
+ }]
68
+ };
69
+ return toolResponse;
70
+ }
71
+ catch (error) {
72
+ console.error('Error updating transaction:', error);
73
+ const toolResponse = {
74
+ content: [{
75
+ type: "text",
76
+ text: `Error updating transaction: ${error instanceof Error ? error.message : JSON.stringify(error)}`
77
+ }]
78
+ };
79
+ return toolResponse;
80
+ }
81
+ }
82
+ ];
@@ -0,0 +1,63 @@
1
+ import { z } from "zod";
2
+ export const updateSaleItemsHospitalityTool = [
3
+ "pulse-api-update-sale-items-hospitality",
4
+ "This is the update sale items API contract for the Protect Group Pulse API in the hospitality vertical." +
5
+ " Use the tool to implement services in any programming language that can make HTTP requests." +
6
+ " Follow this API contract to update the items on an existing sale.",
7
+ {
8
+ saleId: z.string().describe("The ID of the sale to update"),
9
+ member: z.string().describe("Your member ID or the member ID of the client you are integrating on behalf of"),
10
+ memberClient: z.object({
11
+ id: z.string().describe("Member client ID"),
12
+ name: z.string().describe("Member client name")
13
+ }).optional().describe("Optional sub-client details when integrating on behalf of another client"),
14
+ reference: z.string().optional().describe("Sale reference to scope the update"),
15
+ items: z.array(z.object({
16
+ customerName: z.string().optional().describe("Customer name for this item"),
17
+ description: z.string().optional().describe("Item description"),
18
+ reference: z.string().describe("Unique item reference"),
19
+ oldReference: z.string().optional().describe("Previous reference if renaming an existing item"),
20
+ })).describe("Array of items to update"),
21
+ },
22
+ async ({ saleId, member, memberClient, reference, items }) => {
23
+ const url = `https://api.protectgroup.com/test/dynamic/sale/${saleId}/items`;
24
+ const clientId = ""; // will be provided by the user
25
+ const clientSecret = ""; // will be provided by the user
26
+ const body = {
27
+ saleId,
28
+ member,
29
+ items,
30
+ ...(memberClient && { memberClient }),
31
+ ...(reference && { reference }),
32
+ };
33
+ try {
34
+ const response = await fetch(url, {
35
+ method: "PUT",
36
+ headers: {
37
+ "x-pg-client-id": clientId,
38
+ "x-pg-client-secret": clientSecret,
39
+ "Content-Type": "application/json",
40
+ },
41
+ body: JSON.stringify(body),
42
+ });
43
+ if (!response.ok) {
44
+ const errorData = await response.json();
45
+ throw new Error(JSON.stringify(errorData));
46
+ }
47
+ const data = await response.json();
48
+ const toolResponse = {
49
+ content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
50
+ };
51
+ return toolResponse;
52
+ }
53
+ catch (error) {
54
+ const toolResponse = {
55
+ content: [{
56
+ type: "text",
57
+ text: `Error updating sale items: ${error instanceof Error ? error.message : JSON.stringify(error)}`,
58
+ }],
59
+ };
60
+ return toolResponse;
61
+ }
62
+ },
63
+ ];
@@ -0,0 +1,58 @@
1
+ import { z } from "zod";
2
+ export const updateSaleStatusHospitalityTool = [
3
+ "pulse-api-update-sale-status-hospitality",
4
+ "This is the update sale status API contract for the Protect Group Pulse API in the hospitality vertical." +
5
+ " Use the tool to implement services in any programming language that can make HTTP requests." +
6
+ " Follow this API contract to update the transaction status on an existing sale.",
7
+ {
8
+ saleId: z.string().describe("The ID of the sale to update"),
9
+ member: z.string().describe("Your member ID or the member ID of the client you are integrating on behalf of"),
10
+ memberClient: z.object({
11
+ id: z.string().describe("Member client ID"),
12
+ name: z.string().describe("Member client name")
13
+ }).optional().describe("Optional sub-client details when integrating on behalf of another client"),
14
+ reference: z.string().optional().describe("Sale item reference to update the status of a specific item"),
15
+ status: z.string().describe("The new status value (e.g. 'Active', 'Cancelled', 'Refunded')"),
16
+ },
17
+ async ({ saleId, member, memberClient, reference, status }) => {
18
+ const url = `https://api.protectgroup.com/test/dynamic/sale/${saleId}/status`;
19
+ const clientId = ""; // will be provided by the user
20
+ const clientSecret = ""; // will be provided by the user
21
+ const body = {
22
+ saleId,
23
+ member,
24
+ status,
25
+ ...(memberClient && { memberClient }),
26
+ ...(reference && { reference }),
27
+ };
28
+ try {
29
+ const response = await fetch(url, {
30
+ method: "PUT",
31
+ headers: {
32
+ "x-pg-client-id": clientId,
33
+ "x-pg-client-secret": clientSecret,
34
+ "Content-Type": "application/json",
35
+ },
36
+ body: JSON.stringify(body),
37
+ });
38
+ if (!response.ok) {
39
+ const errorData = await response.json();
40
+ throw new Error(JSON.stringify(errorData));
41
+ }
42
+ const data = await response.json();
43
+ const toolResponse = {
44
+ content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
45
+ };
46
+ return toolResponse;
47
+ }
48
+ catch (error) {
49
+ const toolResponse = {
50
+ content: [{
51
+ type: "text",
52
+ text: `Error updating sale status: ${error instanceof Error ? error.message : JSON.stringify(error)}`,
53
+ }],
54
+ };
55
+ return toolResponse;
56
+ }
57
+ },
58
+ ];