Skip to content

Commit c168f70

Browse files
authored
New Components - gorgias_oauth (#12453)
* gorgias_oauth init * [Action] Gorgias - Update Ticket #12414 Actions - Update Ticket * pnpm update * remove node_modules
1 parent 80f84e1 commit c168f70

File tree

13 files changed

+249
-20
lines changed

13 files changed

+249
-20
lines changed

components/gorgias_oauth/actions/create-customer/create-customer.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import gorgias_oauth from "../../gorgias_oauth.app.mjs";
21
import channels from "../../common/customer-channels.mjs";
2+
import gorgias_oauth from "../../gorgias_oauth.app.mjs";
33

44
export default {
55
key: "gorgias_oauth-create-customer",
66
name: "Create Customer",
77
description: "Create a new customer. [See the docs](https://developers.gorgias.com/reference/post_api-customers)",
8-
version: "0.0.3",
8+
version: "0.0.4",
99
type: "action",
1010
props: {
1111
gorgias_oauth,

components/gorgias_oauth/actions/create-ticket/create-ticket.mjs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "gorgias_oauth-create-ticket",
55
name: "Create Ticket",
66
description: "Create a new ticket. [See the docs](https://developers.gorgias.com/reference/post_api-tickets)",
7-
version: "0.0.4",
7+
version: "0.0.5",
88
type: "action",
99
props: {
1010
gorgias_oauth,
@@ -16,9 +16,10 @@ export default {
1616
label: "From Address",
1717
},
1818
subject: {
19-
type: "string",
20-
label: "Subject",
21-
description: "The subject of the message",
19+
propDefinition: [
20+
gorgias_oauth,
21+
"subject",
22+
],
2223
},
2324
message: {
2425
type: "string",

components/gorgias_oauth/actions/list-tickets/list-tickets.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "gorgias_oauth-list-tickets",
55
name: "List Tickets",
66
description: "List all tickets. [See the docs](https://developers.gorgias.com/reference/get_api-tickets)",
7-
version: "0.0.4",
7+
version: "0.0.5",
88
type: "action",
99
props: {
1010
gorgias_oauth,

components/gorgias_oauth/actions/retrieve-customer/retrieve-customer.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "gorgias_oauth-retrieve-customer",
55
name: "Retrieve a Customer",
66
description: "Retrieve a customer. [See the docs](https://developers.gorgias.com/reference/get_api-customers-id-)",
7-
version: "0.0.3",
7+
version: "0.0.4",
88
type: "action",
99
props: {
1010
gorgias_oauth,

components/gorgias_oauth/actions/update-customer/update-customer.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import gorgias_oauth from "../../gorgias_oauth.app.mjs";
2-
import channels from "../../common/customer-channels.mjs";
31
import { ConfigurationError } from "@pipedream/platform";
42
import {
53
pick,
64
pickBy,
75
} from "lodash-es";
6+
import channels from "../../common/customer-channels.mjs";
7+
import gorgias_oauth from "../../gorgias_oauth.app.mjs";
88

99
export default {
1010
key: "gorgias_oauth-update-customer",
1111
name: "Update Customer",
1212
description: "Update a customer. [See the docs](https://developers.gorgias.com/reference/put_api-customers-id-)",
13-
version: "0.0.3",
13+
version: "0.0.4",
1414
type: "action",
1515
props: {
1616
gorgias_oauth,
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
import { parseObject } from "../../common/utils.mjs";
2+
import gorgiasOauth from "../../gorgias_oauth.app.mjs";
3+
4+
export default {
5+
key: "gorgias_oauth-update-ticket",
6+
name: "Update Ticket",
7+
description: "Updates a predefined ticket in the Gorgias system. [See the documentation](https://developers.gorgias.com/reference/update-ticket)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
gorgiasOauth,
12+
ticketId: {
13+
propDefinition: [
14+
gorgiasOauth,
15+
"ticketId",
16+
],
17+
},
18+
assigneeTeamId: {
19+
propDefinition: [
20+
gorgiasOauth,
21+
"assigneeTeamId",
22+
],
23+
optional: true,
24+
},
25+
assigneeUserId: {
26+
propDefinition: [
27+
gorgiasOauth,
28+
"userId",
29+
],
30+
optional: true,
31+
},
32+
channel: {
33+
propDefinition: [
34+
gorgiasOauth,
35+
"channel",
36+
],
37+
},
38+
closedDatetime: {
39+
type: "string",
40+
label: "Closed Datetime",
41+
description: "When the ticket was closed (ISO 8601 format)",
42+
optional: true,
43+
},
44+
customerId: {
45+
propDefinition: [
46+
gorgiasOauth,
47+
"customerId",
48+
],
49+
optional: true,
50+
},
51+
customerEmail: {
52+
type: "string",
53+
label: "Customer Email",
54+
description: "The email of the customer linked to the ticket",
55+
optional: true,
56+
},
57+
externalId: {
58+
propDefinition: [
59+
gorgiasOauth,
60+
"externalId",
61+
],
62+
},
63+
fromAgent: {
64+
type: "boolean",
65+
label: "From Agent",
66+
description: "Whether the first message of the ticket was sent by your company to a customer, or the opposite",
67+
optional: true,
68+
},
69+
isUnread: {
70+
type: "boolean",
71+
label: "Is Unread",
72+
description: "Whether the ticket is unread for you",
73+
optional: true,
74+
},
75+
language: {
76+
propDefinition: [
77+
gorgiasOauth,
78+
"language",
79+
],
80+
},
81+
spam: {
82+
type: "boolean",
83+
label: "Spam",
84+
description: "Whether the ticket is considered as spam or not",
85+
optional: true,
86+
},
87+
status: {
88+
type: "string",
89+
label: "Status",
90+
description: "The status of the ticket. Default: `open`",
91+
options: [
92+
"open",
93+
"closed",
94+
],
95+
optional: true,
96+
},
97+
subject: {
98+
propDefinition: [
99+
gorgiasOauth,
100+
"subject",
101+
],
102+
optional: true,
103+
},
104+
tags: {
105+
type: "string[]",
106+
label: "Tags",
107+
description: "Tags linked to the ticket",
108+
optional: true,
109+
},
110+
},
111+
async run({ $ }) {
112+
const response = await this.gorgiasOauth.updateTicket({
113+
$,
114+
ticketId: this.ticketId,
115+
data: {
116+
assignee_team: this.assigneeTeamId
117+
? {
118+
id: this.assigneeTeamId,
119+
}
120+
: undefined,
121+
assignee_user: this.assigneeUserId
122+
? {
123+
id: this.assigneeUserId,
124+
}
125+
: undefined,
126+
channel: this.channel,
127+
closed_datetime: this.closedDatetime,
128+
customer: this.customerId
129+
? {
130+
id: this.customerId,
131+
email: this.customerEmail,
132+
}
133+
: undefined,
134+
external_id: this.externalId,
135+
from_agent: this.fromAgent,
136+
is_unread: this.isUnread,
137+
language: this.language,
138+
spam: this.spam,
139+
status: this.status,
140+
subject: this.subject,
141+
tags: this.tags
142+
? parseObject(this.tags)?.map((tag) => ({
143+
name: tag,
144+
}))
145+
: undefined,
146+
},
147+
});
148+
149+
$.export("$summary", `Successfully updated ticket with ID ${this.ticketId}`);
150+
return response;
151+
},
152+
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export const parseObject = (obj) => {
2+
if (!obj) return undefined;
3+
4+
if (Array.isArray(obj)) {
5+
return obj.map((item) => {
6+
if (typeof item === "string") {
7+
try {
8+
return JSON.parse(item);
9+
} catch (e) {
10+
return item;
11+
}
12+
}
13+
return item;
14+
});
15+
}
16+
if (typeof obj === "string") {
17+
try {
18+
return JSON.parse(obj);
19+
} catch (e) {
20+
return obj;
21+
}
22+
}
23+
return obj;
24+
};

components/gorgias_oauth/gorgias_oauth.app.mjs

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ export default {
6060
type: "integer",
6161
label: "Ticket ID",
6262
description: "The ID of a ticket to watch for new messages",
63-
optional: true,
6463
async options({ prevContext }) {
6564
const {
6665
data: tickets,
@@ -134,6 +133,42 @@ export default {
134133
description: "Maximum number to return",
135134
optional: true,
136135
},
136+
assigneeTeamId: {
137+
type: "integer",
138+
label: "Assignee Team ID",
139+
description: "The ID of the team assigned to the ticket",
140+
async options({ prevContext }) {
141+
const {
142+
data: teams,
143+
meta,
144+
} = await this.listTeams({
145+
params: {
146+
cursor: prevContext.nextCursor,
147+
},
148+
});
149+
return {
150+
options: teams.map(({
151+
id: value, name: label,
152+
}) => ({
153+
label,
154+
value,
155+
})),
156+
context: {
157+
nextCursor: meta.next_cursor,
158+
},
159+
};
160+
},
161+
},
162+
assigneeUserId: {
163+
type: "integer",
164+
label: "Assignee User ID",
165+
description: "The ID of the user assigned to the ticket",
166+
},
167+
subject: {
168+
type: "string",
169+
label: "Subject",
170+
description: "The subject of the ticket",
171+
},
137172
},
138173
methods: {
139174
_defaultConfig({
@@ -299,11 +334,27 @@ export default {
299334
path: `tickets/${id}`,
300335
});
301336
},
337+
async updateTicket({
338+
ticketId,
339+
...opts
340+
}) {
341+
return this._makeRequest({
342+
method: "PUT",
343+
path: `/tickets/${ticketId}`,
344+
...opts,
345+
});
346+
},
302347
listUsers(opts = {}) {
303348
return this._makeRequest({
304349
path: "/users",
305350
...opts,
306351
});
307352
},
353+
listTeams(opts = {}) {
354+
return this._makeRequest({
355+
path: "/teams",
356+
...opts,
357+
});
358+
},
308359
},
309360
};

components/gorgias_oauth/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/gorgias_oauth",
3-
"version": "0.3.9",
3+
"version": "0.4.0",
44
"description": "Pipedream Gorgias OAuth Components",
55
"main": "gorgias_oauth.app.mjs",
66
"keywords": [
@@ -15,7 +15,7 @@
1515
"access": "public"
1616
},
1717
"dependencies": {
18-
"@pipedream/platform": "^1.4.1",
18+
"@pipedream/platform": "^2.0.0",
1919
"lodash-es": "^4.17.21"
2020
}
2121
}

components/gorgias_oauth/sources/ticket-created/ticket-created.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default {
77
key: "gorgias_oauth-ticket-created",
88
name: "New Ticket",
99
description: "Emit new event when a ticket is created. [See the documentation](https://developers.gorgias.com/reference/the-event-object)",
10-
version: "0.1.4",
10+
version: "0.1.5",
1111
type: "source",
1212
props: {
1313
...base.props,

0 commit comments

Comments
 (0)