Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Gorgias: New Ticket source - Add Tags prop for filtering tags #14130

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "gorgias_oauth-create-customer",
name: "Create Customer",
description: "Create a new customer. [See the docs](https://developers.gorgias.com/reference/post_api-customers)",
version: "0.0.4",
version: "0.0.5",
type: "action",
props: {
gorgias_oauth,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "gorgias_oauth-create-ticket",
name: "Create Ticket",
description: "Create a new ticket. [See the docs](https://developers.gorgias.com/reference/post_api-tickets)",
version: "0.0.5",
version: "0.0.6",
type: "action",
props: {
gorgias_oauth,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "gorgias_oauth-list-tickets",
name: "List Tickets",
description: "List all tickets. [See the docs](https://developers.gorgias.com/reference/get_api-tickets)",
version: "0.0.5",
version: "0.0.6",
type: "action",
props: {
gorgias_oauth,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "gorgias_oauth-retrieve-customer",
name: "Retrieve a Customer",
description: "Retrieve a customer. [See the docs](https://developers.gorgias.com/reference/get_api-customers-id-)",
version: "0.0.4",
version: "0.0.5",
type: "action",
props: {
gorgias_oauth,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default {
key: "gorgias_oauth-update-customer",
name: "Update Customer",
description: "Update a customer. [See the docs](https://developers.gorgias.com/reference/put_api-customers-id-)",
version: "0.0.4",
version: "0.0.5",
type: "action",
props: {
gorgias_oauth,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "gorgias_oauth-update-ticket",
name: "Update Ticket",
description: "Updates a predefined ticket in the Gorgias system. [See the documentation](https://developers.gorgias.com/reference/update-ticket)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
gorgiasOauth,
Expand Down
37 changes: 37 additions & 0 deletions components/gorgias_oauth/gorgias_oauth.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,37 @@ export default {
label: "Subject",
description: "The subject of the ticket",
},
tagId: {
type: "string",
label: "Tag ID",
description: "The tag id.",
optional: true,
async options({ prevContext: { cursor } }) {
if (cursor === null) {
return [];
}
const {
meta: { next_cursor: nextCursor },
data: tags,
} = await this.listTags({
params: {
cursor,
},
});
const options = tags.map(({
id: value, name: label,
}) => ({
label,
value,
}));
return {
options,
context: {
cursor: nextCursor,
},
};
},
},
GTFalcao marked this conversation as resolved.
Show resolved Hide resolved
},
methods: {
_defaultConfig({
Expand Down Expand Up @@ -356,5 +387,11 @@ export default {
...opts,
});
},
listTags(opts = {}) {
return this._makeRequest({
path: "/tags",
...opts,
});
},
},
};
2 changes: 1 addition & 1 deletion components/gorgias_oauth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/gorgias_oauth",
"version": "0.4.0",
"version": "0.4.1",
"description": "Pipedream Gorgias OAuth Components",
"main": "gorgias_oauth.app.mjs",
"keywords": [
Expand Down
15 changes: 13 additions & 2 deletions components/gorgias_oauth/sources/ticket-created/ticket-created.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
key: "gorgias_oauth-ticket-created",
name: "New Ticket",
description: "Emit new event when a ticket is created. [See the documentation](https://developers.gorgias.com/reference/the-event-object)",
version: "0.1.5",
version: "0.1.6",
type: "source",
props: {
...base.props,
Expand All @@ -33,16 +33,27 @@ export default {
"userId",
],
},
tagIds: {
type: "string[]",
label: "Tag IDs",
description: "The tag ids to filter tickets by.",
propDefinition: [
base.props.gorgias_oauth,
"tagId",
],
},
},
methods: {
...base.methods,
getEventType() {
return eventTypes.TICKET_CREATED;
},
isRelevant(ticket) {
const tagIds = ticket.tags.map(({ id }) => id);
return (!this.channel || ticket.channel === this.channel)
&& (!this.via || ticket.via === this.via)
&& (!this.assigneeId || ticket?.assignee_user_id === this.assigneeId);
&& (!this.assigneeId || ticket?.assignee_user_id === this.assigneeId)
&& (!this.tagIds || this.tagIds.some((tagId) => tagIds.includes(tagId)));
},
async processHistoricalEvent(event) {
const ticket = await this.retrieveTicket(event.object_id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
key: "gorgias_oauth-ticket-message-created",
name: "New Ticket Message",
description: "Emit new event when a ticket message is created. [See the documentation](https://developers.gorgias.com/reference/the-event-object)",
version: "0.1.5",
version: "0.1.6",
type: "source",
props: {
...base.props,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
key: "gorgias_oauth-ticket-updated",
name: "New Updated Ticket",
description: "Emit new event when a ticket is updated. [See the documentation](https://developers.gorgias.com/reference/the-event-object)",
version: "0.1.5",
version: "0.1.6",
type: "source",
props: {
...base.props,
Expand Down
Loading