Skip to content
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 {
name: "Add Ticket Tags",
description: "Add tags to a ticket (appends to existing tags). [See the documentation](https://developer.zendesk.com/api-reference/ticketing/ticket-management/tags/#add-tags).",
type: "action",
version: "0.0.2",
version: "0.0.3",
props: {
app,
ticketId: {
Expand Down
2 changes: 1 addition & 1 deletion components/zendesk/actions/create-ticket/create-ticket.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
name: "Create Ticket",
description: "Creates a ticket. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#create-ticket).",
type: "action",
version: "0.1.6",
version: "0.1.7",
props: {
app,
ticketCommentBody: {
Expand Down
2 changes: 1 addition & 1 deletion components/zendesk/actions/delete-ticket/delete-ticket.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
name: "Delete Ticket",
description: "Deletes a ticket. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#delete-ticket).",
type: "action",
version: "0.1.6",
version: "0.1.7",
props: {
app,
ticketId: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
name: "Get Ticket Info",
description: "Retrieves information about a specific ticket. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#show-ticket).",
type: "action",
version: "0.0.4",
version: "0.0.5",
props: {
app,
ticketId: {
Expand Down
2 changes: 1 addition & 1 deletion components/zendesk/actions/get-user-info/get-user-info.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "zendesk-get-user-info",
name: "Get User Info",
description: "Retrieves information about a specific user. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/users/users/#show-user).",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
zendesk,
Expand Down
2 changes: 1 addition & 1 deletion components/zendesk/actions/list-locales/list-locales.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "zendesk-list-locales",
name: "List Locales",
description: "Retrieves all locales. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/account-configuration/locales/).",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
zendesk,
Expand Down
2 changes: 1 addition & 1 deletion components/zendesk/actions/list-macros/list-macros.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "zendesk-list-macros",
name: "List Macros",
description: "Retrieves all macros. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/business-rules/macros/#list-macros).",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
zendesk,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "zendesk-list-ticket-comments",
name: "List Ticket Comments",
description: "Retrieves all comments for a specific ticket. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_comments/#list-comments).",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
zendesk,
Expand Down
2 changes: 1 addition & 1 deletion components/zendesk/actions/list-tickets/list-tickets.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
name: "List Tickets",
description: "Retrieves a list of tickets. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets).",
type: "action",
version: "0.0.4",
version: "0.0.5",
props: {
app,
sortBy: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
name: "Remove Ticket Tags",
description: "Remove specific tags from a ticket. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/ticket-management/tags/#remove-tags).",
type: "action",
version: "0.0.2",
version: "0.0.3",
props: {
app,
ticketId: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
name: "Search Tickets",
description: "Searches for tickets using Zendesk's search API. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/ticket-management/search/#search-tickets).",
type: "action",
version: "0.0.5",
version: "0.0.6",
props: {
app,
query: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
name: "Set Ticket Tags",
description: "Set tags on a ticket (replaces all existing tags). [See the documentation](https://developer.zendesk.com/api-reference/ticketing/ticket-management/tags/#set-tags).",
type: "action",
version: "0.0.2",
version: "0.0.3",
props: {
app,
ticketId: {
Expand Down
36 changes: 34 additions & 2 deletions components/zendesk/actions/update-ticket/update-ticket.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import app from "../../zendesk.app.mjs";
export default {
key: "zendesk-update-ticket",
name: "Update Ticket",
description: "Updates a ticket and optionally manages tags. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#update-ticket).",
description: "Updates a ticket. [See the documentation](https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#update-ticket).",
type: "action",
version: "0.1.6",
version: "0.2.0",
props: {
app,
ticketId: {
Expand Down Expand Up @@ -56,6 +56,12 @@ export default {
"customSubdomain",
],
},
attachments: {
propDefinition: [
app,
"attachments",
],
},
ticketTags: {
propDefinition: [
app,
Expand Down Expand Up @@ -104,6 +110,7 @@ export default {
ticketStatus,
ticketCommentPublic,
customSubdomain,
attachments,
ticketTags,
tagAction,
} = this;
Expand All @@ -118,6 +125,24 @@ export default {

ticketComment.public = ticketCommentPublic;

// Upload attachments if provided
if (attachments && attachments.length > 0) {
try {
const uploadTokens = await this.app.uploadFiles({
attachments,
customSubdomain,
step,
});

if (uploadTokens.length > 0) {
ticketComment.uploads = uploadTokens;
}
} catch (error) {
step.export("$summary", `Failed to upload attachments: ${error.message}`);
throw error;
}
}

const response = await this.updateTicket({
step,
ticketId,
Expand All @@ -132,6 +157,13 @@ export default {
},
});

const attachmentCount = ticketComment.uploads?.length || 0;
const summary = attachmentCount > 0
? `Successfully updated ticket with ID ${response.ticket.id} with ${attachmentCount} attachment(s)`
: `Successfully updated ticket with ID ${response.ticket.id}`;

step.export("$summary", summary);

// Handle tag operations if tags are provided
if (ticketTags && ticketTags.length > 0) {
let tagResponse;
Expand Down
7 changes: 4 additions & 3 deletions components/zendesk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/zendesk",
"version": "0.8.1",
"version": "0.8.2",
"description": "Pipedream Zendesk Components",
"main": "zendesk.app.mjs",
"keywords": [
Expand All @@ -14,7 +14,8 @@
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3",
"crypto": "^1.0.1"
"@pipedream/platform": "^3.1.0",
"crypto": "^1.0.1",
"path": "^0.12.7"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
export default {
...common,
key: "zendesk-locale-updated",
name: "Locale Updated",

Check warning on line 6 in components/zendesk/sources/locale-updated/locale-updated.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
type: "source",
description: "Emit new event when a locale has been updated",
version: "0.0.1",
version: "0.0.2",
dedupe: "unique",
async run() {
const lastTs = this._getLastTs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
key: "zendesk-new-ticket-comment-added",
type: "source",
description: "Emit new event when a ticket comment has been added",
version: "0.0.1",
version: "0.0.2",
dedupe: "unique",
props: {
app,
Expand Down
2 changes: 1 addition & 1 deletion components/zendesk/sources/new-ticket/new-ticket.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default {
key: "zendesk-new-ticket",
type: "source",
description: "Emit new event when a ticket is created",
version: "0.2.6",
version: "0.2.7",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "zendesk-ticket-added-to-view",
name: "New Ticket Added to View (Instant)",
description: "Emit new event when a ticket is added to the specified view",
version: "0.0.6",
version: "0.0.7",
type: "source",
dedupe: "unique",
props: {
Expand Down
2 changes: 1 addition & 1 deletion components/zendesk/sources/ticket-closed/ticket-closed.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

export default {
...common,
name: "Ticket Closed (Instant)",

Check warning on line 5 in components/zendesk/sources/ticket-closed/ticket-closed.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
key: "zendesk-ticket-closed",
type: "source",
description: "Emit new event when a ticket has changed to closed status",
version: "0.2.6",
version: "0.2.7",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
2 changes: 1 addition & 1 deletion components/zendesk/sources/ticket-pended/ticket-pended.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

export default {
...common,
name: "Ticket Pending (Instant)",

Check warning on line 5 in components/zendesk/sources/ticket-pended/ticket-pended.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
key: "zendesk-ticket-pended",
type: "source",
description: "Emit new event when a ticket has changed to pending status",
version: "0.2.6",
version: "0.2.7",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
2 changes: 1 addition & 1 deletion components/zendesk/sources/ticket-solved/ticket-solved.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

export default {
...common,
name: "Ticket Solved (Instant)",

Check warning on line 5 in components/zendesk/sources/ticket-solved/ticket-solved.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
key: "zendesk-ticket-solved",
type: "source",
description: "Emit new event when a ticket has changed to solved status",
version: "0.2.6",
version: "0.2.7",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

export default {
...common,
name: "Ticket Updated (Instant)",

Check warning on line 5 in components/zendesk/sources/ticket-updated/ticket-updated.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Source names should start with "New". See https://pipedream.com/docs/components/guidelines/#source-name
key: "zendesk-ticket-updated",
type: "source",
description: "Emit new event when a ticket has been updated",
version: "0.2.6",
version: "0.2.7",
dedupe: "unique",
methods: {
...common.methods,
Expand Down
96 changes: 96 additions & 0 deletions components/zendesk/zendesk.app.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { axios } from "@pipedream/platform";
import constants from "./common/constants.mjs";
import { getFileStreamAndMetadata } from "@pipedream/platform";
import path from "path";

export default {
type: "app",
Expand Down Expand Up @@ -260,6 +262,12 @@ export default {
description: "For Enterprise Zendesk accounts: optionally specify the subdomain to use. This will override the subdomain that was provided when connecting your Zendesk account to Pipedream. For example, if you Zendesk URL is https://examplehelp.zendesk.com, your subdomain is `examplehelp`",
optional: true,
},
attachments: {
type: "string[]",
label: "Attachments",
description: "File paths or URLs to attach to the ticket. Multiple files can be attached.",
optional: true,
},
ticketTags: {
type: "string[]",
label: "Tags",
Expand Down Expand Up @@ -369,6 +377,94 @@ export default {
...args,
});
},
streamToBuffer(stream) {
return new Promise((resolve, reject) => {
const chunks = [];
stream.on("data", (chunk) => chunks.push(chunk));
stream.on("end", () => resolve(Buffer.concat(chunks)));
stream.on("error", reject);
});
},
/**
* Upload a single file (local path or http(s) URL) to Zendesk Uploads API.
* @param {Object} params
* @param {string} params.filePath - Local filesystem path or http(s) URL.
* @param {string} [params.filename] - Optional filename override for the upload.
* @param {string} [params.customSubdomain]
* @param {*} [params.step]
*/
async uploadFile({
filePath, filename, customSubdomain, step,
}) {
if (!filePath || typeof filePath !== "string") {
throw new Error("uploadFile: 'filePath' (string) is required");
}

const {
stream, metadata,
} = await getFileStreamAndMetadata(filePath);
const fileBinary = await this.streamToBuffer(stream);

if (!filename) {
filename = path.basename(filePath);
}

return this.makeRequest({
step,
method: "post",
path: `/uploads?filename=${encodeURIComponent(filename)}`,
customSubdomain,
headers: {
"Content-Type": metadata.contentType,
"Content-Length": metadata.size,
"Accept": "application/json",
},
data: Buffer.from(fileBinary, "binary"),
});
},
async uploadFiles({
attachments, customSubdomain, step,
} = {}) {
if (!attachments || !attachments.length) {
return [];
}
const files = attachments
.map((a) => (typeof a === "string"
? a.trim()
: a))
.filter(Boolean);

const settled = await Promise.allSettled(
files.map((attachment) =>
this.uploadFile({
filePath: attachment,
customSubdomain,
step,
})),
);

const tokens = [];
const errors = [];
settled.forEach((res, i) => {
const attachment = files[i];
if (res.status === "fulfilled") {
const token = res.value?.upload?.token;
if (!token) {
errors.push(`Upload API returned no token for ${attachment}`);
} else {
tokens.push(token);
}
} else {
const reason = res.reason?.message || String(res.reason || "Unknown error");
errors.push(`${attachment}: ${reason}`);
}
});

if (errors.length) {
throw new Error(`Failed to upload ${errors.length}/${files.length} attachment(s): ${errors.join("; ")}`);
}
return tokens;
},
listTicketComments({
ticketId, ...args
} = {}) {
Expand Down
Loading
Loading