Skip to content

Commit 6703b0e

Browse files
committed
updates
1 parent f4135c8 commit 6703b0e

File tree

5 files changed

+114
-19
lines changed

5 files changed

+114
-19
lines changed

components/gorgias_oauth/actions/get-ticket-message/get-ticket-message.mjs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
import { defineAction } from "@pipedream/types";
21
import gorgiasOAuth from "../../gorgias_oauth.app.mjs";
32

4-
export default defineAction({
3+
export default {
54
name: "Get Ticket Message",
6-
description: "Get a specific message from a ticket [See docs here](https://developers.gorgias.com/reference/get-ticket-message)",
5+
description: "Get a specific message from a ticket. [See the documentation](https://developers.gorgias.com/reference/get-ticket-message)",
76
key: "gorgias_oauth-get-ticket-message",
87
version: "0.0.1",
98
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
1014
props: {
1115
gorgiasOAuth,
1216
ticketId: {
@@ -19,6 +23,23 @@ export default defineAction({
1923
type: "integer",
2024
label: "Message ID",
2125
description: "The ID of the message to retrieve",
26+
async options({ prevContext }) {
27+
const {
28+
data: messages,
29+
meta,
30+
} = await this.listTicketMessages({
31+
ticketId: this.ticketId,
32+
params: {
33+
cursor: prevContext.nextCursor,
34+
},
35+
});
36+
return {
37+
options: messages.map(({ id }) => id),
38+
context: {
39+
nextCursor: meta.next_cursor,
40+
},
41+
};
42+
},
2243
},
2344
},
2445
async run({ $ }) {
@@ -28,9 +49,8 @@ export default defineAction({
2849
messageId: this.messageId,
2950
});
3051

31-
// Add summary for user feedback
3252
$.export("$summary", `Successfully retrieved message ${this.messageId} from ticket ${this.ticketId}`);
3353

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

components/gorgias_oauth/actions/list-ticket-messages/list-ticket-messages.mjs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
import { defineAction } from "@pipedream/types";
21
import gorgiasOAuth from "../../gorgias_oauth.app.mjs";
32

4-
export default defineAction({
3+
export default {
54
name: "List Ticket Messages",
6-
description: "List all messages for a specific ticket [See docs here](https://developers.gorgias.com/reference/list-ticket-messages)",
5+
description: "List all messages for a specific ticket. [See the documentation](https://developers.gorgias.com/reference/list-ticket-messages)",
76
key: "gorgias_oauth-list-ticket-messages",
87
version: "0.0.1",
98
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: true,
13+
},
1014
props: {
1115
gorgiasOAuth,
1216
ticketId: {
@@ -34,7 +38,7 @@ export default defineAction({
3438
const params = {
3539
limit: this.limit,
3640
};
37-
41+
3842
if (this.cursor) {
3943
params.cursor = this.cursor;
4044
}
@@ -45,13 +49,14 @@ export default defineAction({
4549
params,
4650
});
4751

48-
// Add summary for user feedback
49-
$.export("$summary", `Successfully retrieved ${response.data.length} message${response.data.length === 1 ? '' : 's'}`);
52+
$.export("$summary", `Successfully retrieved ${response.data.length} message${response.data.length === 1
53+
? ""
54+
: "s"}`);
5055

5156
// Return the data and pagination info
5257
return {
5358
data: response.data,
5459
meta: response.meta,
5560
};
5661
},
57-
});
62+
};

components/gorgias_oauth/gorgias_oauth.app.mjs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,30 +233,45 @@ export default {
233233
* @param {Object} params.params - Optional query parameters (cursor, limit, etc.)
234234
* @returns {Promise<Object>} - Returns the list of messages and pagination info
235235
*/
236-
listTicketMessages({ $, ticketId, params = {} }) {
236+
listTicketMessages({
237+
$, ticketId, params = {},
238+
}) {
237239
return this._makeRequest({
238240
$,
239241
path: `/tickets/${ticketId}/messages`,
240-
method: 'get',
241242
params,
242243
});
243244
},
244-
245245
/**
246246
* Get a specific message by ID
247247
* @param {Object} params - Parameters for the request
248248
* @param {number} params.ticketId - The ID of the ticket
249249
* @param {number} params.messageId - The ID of the message to retrieve
250250
* @returns {Promise<Object>} - Returns the message details
251251
*/
252-
getTicketMessage({ $, ticketId, messageId }) {
252+
getTicketMessage({
253+
$, ticketId, messageId,
254+
}) {
253255
return this._makeRequest({
254256
$,
255257
path: `/tickets/${ticketId}/messages/${messageId}`,
256-
method: 'get',
257258
});
258259
},
259-
260+
/**
261+
* List all messages
262+
* @param {Object} params - Parameters for the request
263+
* @param {Object} params.params - Optional query parameters (cursor, limit, etc.)
264+
* @returns {Promise<Object>} - Returns the list of messages and pagination info
265+
*/
266+
listMessages({
267+
$, params = {},
268+
}) {
269+
return this._makeRequest({
270+
$,
271+
path: "/messages",
272+
params,
273+
});
274+
},
260275
_defaultConfig({
261276
path, method = "get", params = {}, data,
262277
}) {

components/gorgias_oauth/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/gorgias_oauth",
3-
"version": "0.6.2",
3+
"version": "0.7.0",
44
"description": "Pipedream Gorgias OAuth Components",
55
"main": "gorgias_oauth.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)