Skip to content

Commit 3d8b871

Browse files
committed
Gorgias ticket messages functionality
1 parent 47412d2 commit 3d8b871

File tree

3 files changed

+118
-0
lines changed

3 files changed

+118
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { defineAction } from "@pipedream/types";
2+
import gorgiasOAuth from "../../gorgias_oauth.app.mjs";
3+
4+
export default defineAction({
5+
name: "Get Ticket Message",
6+
description: "Get a specific message from a ticket [See docs here](https://developers.gorgias.com/reference/get-ticket-message)",
7+
key: "gorgias_oauth-get-ticket-message",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
gorgiasOAuth,
12+
ticketId: {
13+
propDefinition: [
14+
gorgiasOAuth,
15+
"ticketId",
16+
],
17+
},
18+
messageId: {
19+
type: "integer",
20+
label: "Message ID",
21+
description: "The ID of the message to retrieve",
22+
},
23+
},
24+
async run({ $ }) {
25+
const response = await this.gorgiasOAuth.getTicketMessage({
26+
$,
27+
ticketId: this.ticketId,
28+
messageId: this.messageId,
29+
});
30+
31+
return response;
32+
},
33+
});
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { defineAction } from "@pipedream/types";
2+
import gorgiasOAuth from "../../gorgias_oauth.app.mjs";
3+
4+
export default defineAction({
5+
name: "List Ticket Messages",
6+
description: "List all messages for a specific ticket [See docs here](https://developers.gorgias.com/reference/list-ticket-messages)",
7+
key: "gorgias_oauth-list-ticket-messages",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
gorgiasOAuth,
12+
ticketId: {
13+
propDefinition: [
14+
gorgiasOAuth,
15+
"ticketId",
16+
],
17+
},
18+
limit: {
19+
type: "integer",
20+
label: "Limit",
21+
description: "Maximum number of messages to return (1-100)",
22+
min: 1,
23+
max: 100,
24+
default: 50,
25+
},
26+
cursor: {
27+
type: "string",
28+
label: "Cursor",
29+
description: "Cursor for pagination (get from the meta.next_cursor of the previous response)",
30+
optional: true,
31+
},
32+
},
33+
async run({ $ }) {
34+
const params = {
35+
limit: this.limit,
36+
};
37+
38+
if (this.cursor) {
39+
params.cursor = this.cursor;
40+
}
41+
42+
const response = await this.gorgiasOAuth.listTicketMessages({
43+
$,
44+
ticketId: this.ticketId,
45+
params,
46+
});
47+
48+
// Return the data and pagination info
49+
return {
50+
data: response.data,
51+
meta: response.meta,
52+
};
53+
},
54+
});

components/gorgias_oauth/gorgias_oauth.app.mjs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,37 @@ export default {
226226
},
227227
},
228228
methods: {
229+
/**
230+
* List all messages for a specific ticket
231+
* @param {Object} params - Parameters for the request
232+
* @param {number} params.ticketId - The ID of the ticket
233+
* @param {Object} params.params - Optional query parameters (cursor, limit, etc.)
234+
* @returns {Promise<Object>} - Returns the list of messages and pagination info
235+
*/
236+
listTicketMessages({ $, ticketId, params = {} }) {
237+
return this._makeRequest({
238+
$,
239+
path: `/api/tickets/${ticketId}/messages`,
240+
method: 'get',
241+
params,
242+
});
243+
},
244+
245+
/**
246+
* Get a specific message by ID
247+
* @param {Object} params - Parameters for the request
248+
* @param {number} params.ticketId - The ID of the ticket
249+
* @param {number} params.messageId - The ID of the message to retrieve
250+
* @returns {Promise<Object>} - Returns the message details
251+
*/
252+
getTicketMessage({ $, ticketId, messageId }) {
253+
return this._makeRequest({
254+
$,
255+
path: `/api/tickets/${ticketId}/messages/${messageId}`,
256+
method: 'get',
257+
});
258+
},
259+
229260
_defaultConfig({
230261
path, method = "get", params = {}, data,
231262
}) {

0 commit comments

Comments
 (0)