diff --git a/components/zoho_desk/actions/add-ticket-attachment/add-ticket-attachment.mjs b/components/zoho_desk/actions/add-ticket-attachment/add-ticket-attachment.mjs index 044dd73d14359..5596dc8a2790a 100644 --- a/components/zoho_desk/actions/add-ticket-attachment/add-ticket-attachment.mjs +++ b/components/zoho_desk/actions/add-ticket-attachment/add-ticket-attachment.mjs @@ -7,7 +7,7 @@ export default { name: "Add Ticket Attachment", description: "Attaches a file to a ticket. [See the docs here](https://desk.zoho.com/DeskAPIDocument#TicketAttachments#TicketAttachments_CreateTicketattachment)", type: "action", - version: "0.1.5", + version: "0.1.6", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/zoho_desk/actions/add-ticket-comment/add-ticket-comment.mjs b/components/zoho_desk/actions/add-ticket-comment/add-ticket-comment.mjs index 1a4d35a60183d..bca5d1fe5508b 100644 --- a/components/zoho_desk/actions/add-ticket-comment/add-ticket-comment.mjs +++ b/components/zoho_desk/actions/add-ticket-comment/add-ticket-comment.mjs @@ -5,7 +5,7 @@ export default { name: "Add Ticket Comment", description: "Adds a comment to a ticket. [See the docs here](https://desk.zoho.com/DeskAPIDocument#TicketsComments#TicketsComments_Createticketcomment)", type: "action", - version: "0.0.6", + version: "0.0.7", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/zoho_desk/actions/create-account/create-account.mjs b/components/zoho_desk/actions/create-account/create-account.mjs index 0fb5e80c052bd..11b2e75ebed1d 100644 --- a/components/zoho_desk/actions/create-account/create-account.mjs +++ b/components/zoho_desk/actions/create-account/create-account.mjs @@ -5,7 +5,7 @@ export default { name: "Create Account", description: "Creates an account in your help desk portal. [See the docs here](https://desk.zoho.com/DeskAPIDocument#Accounts#Accounts_CreateAccount)", type: "action", - version: "0.0.6", + version: "0.0.7", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/zoho_desk/actions/create-contact/create-contact.mjs b/components/zoho_desk/actions/create-contact/create-contact.mjs index 06d5a641e04de..ed18e39291adf 100644 --- a/components/zoho_desk/actions/create-contact/create-contact.mjs +++ b/components/zoho_desk/actions/create-contact/create-contact.mjs @@ -5,7 +5,7 @@ export default { name: "Create Contact", description: "Creates a contact in your help desk portal. [See the docs here](https://desk.zoho.com/DeskAPIDocument#Contacts#Contacts_CreateContact)", type: "action", - version: "0.0.6", + version: "0.0.7", annotations: { destructiveHint: false, openWorldHint: true, @@ -48,6 +48,27 @@ export default { description: "Mobile number of the contact", optional: true, }, + accountId: { + propDefinition: [ + zohoDesk, + "accountId", + ({ orgId }) => ({ + orgId, + }), + ], + }, + title: { + type: "string", + label: "Title", + description: "Job title of the contact", + optional: true, + }, + description: { + type: "string", + label: "Description", + description: "Description about the contact", + optional: true, + }, }, async run({ $ }) { const { @@ -57,19 +78,29 @@ export default { email, phone, mobile, + accountId, + title, + description, } = this; + const data = { + lastName, + }; + + // Add optional fields + if (firstName) data.firstName = firstName; + if (email) data.email = email; + if (phone) data.phone = phone; + if (mobile) data.mobile = mobile; + if (accountId) data.accountId = accountId; + if (title) data.title = title; + if (description) data.description = description; + const response = await this.zohoDesk.createContact({ headers: { orgId, }, - data: { - lastName, - firstName, - email, - phone, - mobile, - }, + data, }); $.export("$summary", `Successfully created a new contact with ID ${response.id}`); diff --git a/components/zoho_desk/actions/create-ticket/create-ticket.mjs b/components/zoho_desk/actions/create-ticket/create-ticket.mjs index f0fbe7f952931..f52e36066ec47 100644 --- a/components/zoho_desk/actions/create-ticket/create-ticket.mjs +++ b/components/zoho_desk/actions/create-ticket/create-ticket.mjs @@ -5,7 +5,7 @@ export default { name: "Create Ticket", description: "Creates a ticket in your helpdesk. [See the docs here](https://desk.zoho.com/DeskAPIDocument#Tickets#Tickets_Createaticket)", type: "action", - version: "0.0.6", + version: "0.0.7", annotations: { destructiveHint: false, openWorldHint: true, @@ -48,6 +48,75 @@ export default { description: "Description in the ticket", optional: true, }, + status: { + propDefinition: [ + zohoDesk, + "ticketStatus", + ], + }, + priority: { + propDefinition: [ + zohoDesk, + "ticketPriority", + ], + }, + assigneeId: { + propDefinition: [ + zohoDesk, + "assigneeId", + ({ orgId }) => ({ + orgId, + }), + ], + }, + channel: { + propDefinition: [ + zohoDesk, + "channel", + ], + }, + classification: { + propDefinition: [ + zohoDesk, + "classification", + ], + }, + category: { + propDefinition: [ + zohoDesk, + "category", + ], + }, + subCategory: { + propDefinition: [ + zohoDesk, + "subCategory", + ], + }, + dueDate: { + propDefinition: [ + zohoDesk, + "dueDate", + ], + }, + email: { + type: "string", + label: "Email", + description: "Email address for the ticket", + optional: true, + }, + phone: { + type: "string", + label: "Phone", + description: "Phone number for the ticket", + optional: true, + }, + productId: { + propDefinition: [ + zohoDesk, + "productId", + ], + }, }, async run({ $ }) { const { @@ -56,18 +125,44 @@ export default { contactId, subject, description, + status, + priority, + assigneeId, + channel, + classification, + category, + subCategory, + dueDate, + email, + phone, + productId, } = this; + const data = { + departmentId, + contactId, + subject, + }; + + // Add optional fields + if (description) data.description = description; + if (status) data.status = status; + if (priority) data.priority = priority; + if (assigneeId) data.assigneeId = assigneeId; + if (channel) data.channel = channel; + if (classification) data.classification = classification; + if (category) data.category = category; + if (subCategory) data.subCategory = subCategory; + if (dueDate) data.dueDate = dueDate; + if (email) data.email = email; + if (phone) data.phone = phone; + if (productId) data.productId = productId; + const response = await this.zohoDesk.createTicket({ headers: { orgId, }, - data: { - departmentId, - contactId, - subject, - description, - }, + data, }); $.export("$summary", `Successfully created a new ticket with ID ${response.id}`); diff --git a/components/zoho_desk/actions/find-contact/find-contact.mjs b/components/zoho_desk/actions/find-contact/find-contact.mjs index 0d243213c02a7..5b141302b2eb1 100644 --- a/components/zoho_desk/actions/find-contact/find-contact.mjs +++ b/components/zoho_desk/actions/find-contact/find-contact.mjs @@ -5,7 +5,7 @@ export default { name: "Find Contact", description: "Searches for contacts in your help desk portal. [See the docs here](https://desk.zoho.com/DeskAPIDocument#Search#Search_SearchContacts)", type: "action", - version: "0.0.6", + version: "0.0.7", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/zoho_desk/actions/find-or-create-contact/find-or-create-contact.mjs b/components/zoho_desk/actions/find-or-create-contact/find-or-create-contact.mjs index c32d8d331e9f2..3b1828e867822 100644 --- a/components/zoho_desk/actions/find-or-create-contact/find-or-create-contact.mjs +++ b/components/zoho_desk/actions/find-or-create-contact/find-or-create-contact.mjs @@ -5,7 +5,7 @@ export default { name: "Find or Create Contact", description: "Finds or create a contact. [See the docs here](https://desk.zoho.com/DeskAPIDocument#Contacts#Contacts_CreateContact)", type: "action", - version: "0.0.6", + version: "0.0.7", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/zoho_desk/actions/get-article/get-article.mjs b/components/zoho_desk/actions/get-article/get-article.mjs index c746b86cb5dad..25776fea755a7 100644 --- a/components/zoho_desk/actions/get-article/get-article.mjs +++ b/components/zoho_desk/actions/get-article/get-article.mjs @@ -5,7 +5,7 @@ export default { name: "Get Article", description: "Retrieves the details of a knowledge base article. [See the documentation](https://desk.zoho.com/portal/APIDocument.do#KnowledgeBase_Getarticle)", type: "action", - version: "0.0.2", + version: "0.0.3", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/zoho_desk/actions/list-articles/list-articles.mjs b/components/zoho_desk/actions/list-articles/list-articles.mjs index 148f1a6a3f441..5fedfe01f2c6d 100644 --- a/components/zoho_desk/actions/list-articles/list-articles.mjs +++ b/components/zoho_desk/actions/list-articles/list-articles.mjs @@ -4,7 +4,7 @@ export default { name: "List Articles", description: "Lists knowledge base articles for a help center. [See the documentation](https://desk.zoho.com/portal/APIDocument.do#KnowledgeBase#KnowledgeBase_Listarticles)", type: "action", - version: "0.0.2", + version: "0.0.3", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/zoho_desk/actions/list-help-centers/list-help-centers.mjs b/components/zoho_desk/actions/list-help-centers/list-help-centers.mjs index 738157764562c..9685b94706d8d 100644 --- a/components/zoho_desk/actions/list-help-centers/list-help-centers.mjs +++ b/components/zoho_desk/actions/list-help-centers/list-help-centers.mjs @@ -5,7 +5,7 @@ export default { name: "List Help Centers", description: "Lists the help centers configured in an organization. [See the documentation](https://desk.zoho.com/portal/APIDocument.do#HelpCenters_Listhelpcenters)", type: "action", - version: "0.0.2", + version: "0.0.3", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/zoho_desk/actions/list-root-categories/list-root-categories.mjs b/components/zoho_desk/actions/list-root-categories/list-root-categories.mjs index 4740b8c409406..8364b485dbc44 100644 --- a/components/zoho_desk/actions/list-root-categories/list-root-categories.mjs +++ b/components/zoho_desk/actions/list-root-categories/list-root-categories.mjs @@ -4,7 +4,7 @@ export default { name: "List Root Categories", description: "Lists root knowledge base categories for a help center. [See the documentation](https://desk.zoho.com/portal/APIDocument.do#KnowledgeBase_Listallrootcategoriesofthehelpcenter)", type: "action", - version: "0.0.2", + version: "0.0.3", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/zoho_desk/actions/list-tickets/list-tickets.mjs b/components/zoho_desk/actions/list-tickets/list-tickets.mjs new file mode 100644 index 0000000000000..7f0d620cf054f --- /dev/null +++ b/components/zoho_desk/actions/list-tickets/list-tickets.mjs @@ -0,0 +1,148 @@ +import zohoDesk from "../../zoho_desk.app.mjs"; + +export default { + key: "zoho_desk-list-tickets", + name: "List Tickets", + description: "Lists all tickets in your help desk with optional filtering. [See the docs here](https://desk.zoho.com/DeskAPIDocument#Tickets#Tickets_Listalltickets)", + type: "action", + version: "0.0.1", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + props: { + zohoDesk, + orgId: { + propDefinition: [ + zohoDesk, + "orgId", + ], + }, + departmentId: { + propDefinition: [ + zohoDesk, + "departmentId", + ({ orgId }) => ({ + orgId, + }), + ], + }, + status: { + propDefinition: [ + zohoDesk, + "ticketStatus", + ], + optional: true, + }, + priority: { + propDefinition: [ + zohoDesk, + "ticketPriority", + ], + }, + assigneeId: { + propDefinition: [ + zohoDesk, + "assigneeId", + ({ orgId }) => ({ + orgId, + }), + ], + }, + channel: { + propDefinition: [ + zohoDesk, + "channel", + ], + }, + contactId: { + propDefinition: [ + zohoDesk, + "contactId", + ({ orgId }) => ({ + orgId, + }), + ], + optional: true, + }, + sortBy: { + propDefinition: [ + zohoDesk, + "ticketSortBy", + ], + }, + from: { + propDefinition: [ + zohoDesk, + "from", + ], + }, + limit: { + propDefinition: [ + zohoDesk, + "limit", + ], + }, + maxResults: { + propDefinition: [ + zohoDesk, + "maxResults", + ], + }, + include: { + type: "string", + label: "Include", + description: "Additional resources to include in the response (comma-separated). For example: `contacts,products,assignee`", + optional: true, + }, + }, + async run({ $ }) { + const { + orgId, + departmentId, + status, + priority, + assigneeId, + channel, + contactId, + sortBy, + from, + limit, + maxResults, + include, + } = this; + + const params = {}; + + // Add optional filter parameters + if (departmentId) params.departmentId = departmentId; + if (status) params.status = status; + if (priority) params.priority = priority; + if (assigneeId) params.assignee = assigneeId; + if (channel) params.channel = channel; + if (sortBy) params.sortBy = sortBy; + if (from) params.from = from; + if (limit) params.limit = limit; + if (include) params.include = include; + + const tickets = []; + const stream = this.zohoDesk.getTicketsStream({ + headers: { + orgId, + }, + params, + max: maxResults, + }); + + for await (const ticket of stream) { + if (!contactId || ticket.contactId === contactId) { + tickets.push(ticket); + } + } + + $.export("$summary", `Successfully retrieved ${tickets.length} ticket(s)`); + + return tickets; + }, +}; diff --git a/components/zoho_desk/actions/search-articles/search-articles.mjs b/components/zoho_desk/actions/search-articles/search-articles.mjs index f41c50950c010..08709832d8b4a 100644 --- a/components/zoho_desk/actions/search-articles/search-articles.mjs +++ b/components/zoho_desk/actions/search-articles/search-articles.mjs @@ -4,7 +4,7 @@ export default { name: "Search Articles", description: "Searches for knowledge base articles. [See the documentation](https://desk.zoho.com/portal/APIDocument.do#KnowledgeBase_Searcharticles)", type: "action", - version: "0.0.2", + version: "0.0.3", annotations: { destructiveHint: false, openWorldHint: true, diff --git a/components/zoho_desk/actions/search-ticket/search-ticket.mjs b/components/zoho_desk/actions/search-ticket/search-ticket.mjs index b0c7a1b728a5b..d07e2af9e1100 100644 --- a/components/zoho_desk/actions/search-ticket/search-ticket.mjs +++ b/components/zoho_desk/actions/search-ticket/search-ticket.mjs @@ -5,7 +5,7 @@ export default { name: "Search Ticket", description: "Searches for tickets in your help desk. [See the docs here](https://desk.zoho.com/DeskAPIDocument#Search_TicketsSearchAPI)", type: "action", - version: "0.0.6", + version: "0.0.7", annotations: { destructiveHint: false, openWorldHint: true, @@ -23,24 +23,112 @@ export default { type: "string", label: "Search", description: "Search throughout the ticket with `wildcard search` strategy", + optional: true, + }, + departmentId: { + propDefinition: [ + zohoDesk, + "departmentId", + ({ orgId }) => ({ + orgId, + }), + ], + optional: true, + }, + status: { + propDefinition: [ + zohoDesk, + "ticketStatus", + ], + optional: true, + }, + priority: { + propDefinition: [ + zohoDesk, + "ticketPriority", + ], + }, + assigneeId: { + propDefinition: [ + zohoDesk, + "assigneeId", + ({ orgId }) => ({ + orgId, + }), + ], + }, + channel: { + propDefinition: [ + zohoDesk, + "channel", + ], + }, + sortBy: { + propDefinition: [ + zohoDesk, + "ticketSortBy", + ], + }, + from: { + propDefinition: [ + zohoDesk, + "from", + ], + }, + limit: { + propDefinition: [ + zohoDesk, + "limit", + ], + }, + maxResults: { + propDefinition: [ + zohoDesk, + "maxResults", + ], }, }, async run({ $ }) { const { orgId, search, + departmentId, + status, + priority, + assigneeId, + channel, + sortBy, + from, + limit, + maxResults, } = this; - const { data: tickets = [] } = - await this.zohoDesk.searchTickets({ - headers: { - orgId, - }, - params: { - _all: search, - sortBy: "relevance", - }, - }); + const params = { + _all: search, + sortBy: sortBy || "relevance", + }; + + // Add optional filter parameters + if (departmentId) params.departmentId = departmentId; + if (status) params.status = status; + if (priority) params.priority = priority; + if (assigneeId) params.assignee = assigneeId; + if (channel) params.channel = channel; + if (from) params.from = from; + if (limit) params.limit = limit; + + const tickets = []; + const stream = this.zohoDesk.searchTicketsStream({ + headers: { + orgId, + }, + params, + max: maxResults, + }); + + for await (const ticket of stream) { + tickets.push(ticket); + } $.export("$summary", `Successfully found ${tickets.length} ticket(s)`); diff --git a/components/zoho_desk/actions/send-email-reply/send-email-reply.mjs b/components/zoho_desk/actions/send-email-reply/send-email-reply.mjs index 9dc0aaf58c28c..c1763fe1fe2f3 100644 --- a/components/zoho_desk/actions/send-email-reply/send-email-reply.mjs +++ b/components/zoho_desk/actions/send-email-reply/send-email-reply.mjs @@ -5,7 +5,7 @@ export default { name: "Send E-Mail Reply", description: "Sends an email reply. [See the docs here](https://desk.zoho.com/DeskAPIDocument#Threads#Threads_SendEmailReply)", type: "action", - version: "0.0.6", + version: "0.0.7", annotations: { destructiveHint: false, openWorldHint: true, @@ -73,16 +73,13 @@ export default { description: "Content of the thread", optional: true, }, - ticketStatus: { - type: "string", - label: "Ticket Status", - description: "Type of ticket resolution status. The values supported are `OPEN` and `ON HOLD` and `CLOSED`.", - optional: true, - options: [ - "OPEN", - "ON HOLD", - "CLOSED", + status: { + propDefinition: [ + zohoDesk, + "ticketStatus", ], + description: "Type of ticket resolution status to set after sending the email reply", + optional: true, }, }, async run({ $ }) { @@ -93,23 +90,27 @@ export default { to, content, contentType, - ticketStatus, + status, } = this; + const data = { + fromEmailAddress, + to, + channel: "EMAIL", + isForward: "true", + }; + + // Add optional fields + if (content) data.content = content; + if (contentType) data.contentType = contentType; + if (status) data.ticketStatus = status; + const response = await this.zohoDesk.sendReply({ ticketId, headers: { orgId, }, - data: { - fromEmailAddress, - to, - content, - contentType, - ticketStatus, - channel: "EMAIL", - isForward: "true", - }, + data, }); $.export("$summary", `Successfully sent email reply with ID ${response.id}`); diff --git a/components/zoho_desk/actions/update-contact/update-contact.mjs b/components/zoho_desk/actions/update-contact/update-contact.mjs index 5f914cb1602a7..68bb673c2037d 100644 --- a/components/zoho_desk/actions/update-contact/update-contact.mjs +++ b/components/zoho_desk/actions/update-contact/update-contact.mjs @@ -5,7 +5,7 @@ export default { name: "Update Contact", description: "Updates details of an existing contact. [See the docs here](https://desk.zoho.com/DeskAPIDocument#Contacts#Contacts_Updateacontact)", type: "action", - version: "0.0.6", + version: "0.0.7", annotations: { destructiveHint: true, openWorldHint: true, @@ -32,6 +32,7 @@ export default { type: "string", label: "Last Name", description: "Last name of the contact", + optional: true, }, firstName: { type: "string", @@ -57,6 +58,27 @@ export default { description: "Mobile number of the contact", optional: true, }, + accountId: { + propDefinition: [ + zohoDesk, + "accountId", + ({ orgId }) => ({ + orgId, + }), + ], + }, + title: { + type: "string", + label: "Title", + description: "Job title of the contact", + optional: true, + }, + description: { + type: "string", + label: "Description", + description: "Description about the contact", + optional: true, + }, }, async run({ $ }) { const { @@ -67,20 +89,29 @@ export default { email, phone, mobile, + accountId, + title, + description, } = this; + const data = {}; + + // Add optional fields + if (lastName) data.lastName = lastName; + if (firstName) data.firstName = firstName; + if (email) data.email = email; + if (phone) data.phone = phone; + if (mobile) data.mobile = mobile; + if (accountId) data.accountId = accountId; + if (title) data.title = title; + if (description) data.description = description; + const response = await this.zohoDesk.updateContact({ contactId, headers: { orgId, }, - data: { - lastName, - firstName, - email, - phone, - mobile, - }, + data, }); $.export("$summary", `Successfully updated contact with ID ${response.id}`); diff --git a/components/zoho_desk/actions/update-ticket/update-ticket.mjs b/components/zoho_desk/actions/update-ticket/update-ticket.mjs index 3b6c40b36c91e..8239f4cba55ad 100644 --- a/components/zoho_desk/actions/update-ticket/update-ticket.mjs +++ b/components/zoho_desk/actions/update-ticket/update-ticket.mjs @@ -5,7 +5,7 @@ export default { name: "Update Ticket", description: "Updates an existing ticket. [See the docs here](https://desk.zoho.com/DeskAPIDocument#Tickets#Tickets_Updateaticket)", type: "action", - version: "0.0.6", + version: "0.0.7", annotations: { destructiveHint: true, openWorldHint: true, @@ -32,6 +32,7 @@ export default { type: "string", label: "Subject", description: "Subject of the ticket", + optional: true, }, description: { type: "string", @@ -39,6 +40,81 @@ export default { description: "Description in the ticket", optional: true, }, + status: { + propDefinition: [ + zohoDesk, + "ticketStatus", + ], + }, + priority: { + propDefinition: [ + zohoDesk, + "ticketPriority", + ], + }, + assigneeId: { + propDefinition: [ + zohoDesk, + "assigneeId", + ({ orgId }) => ({ + orgId, + }), + ], + }, + departmentId: { + propDefinition: [ + zohoDesk, + "departmentId", + ({ orgId }) => ({ + orgId, + }), + ], + }, + contactId: { + propDefinition: [ + zohoDesk, + "contactId", + ({ orgId }) => ({ + orgId, + }), + ], + }, + channel: { + propDefinition: [ + zohoDesk, + "channel", + ], + }, + classification: { + propDefinition: [ + zohoDesk, + "classification", + ], + }, + category: { + propDefinition: [ + zohoDesk, + "category", + ], + }, + subCategory: { + propDefinition: [ + zohoDesk, + "subCategory", + ], + }, + dueDate: { + propDefinition: [ + zohoDesk, + "dueDate", + ], + }, + productId: { + propDefinition: [ + zohoDesk, + "productId", + ], + }, }, async run({ $ }) { const { @@ -46,17 +122,42 @@ export default { ticketId, subject, description, + status, + priority, + assigneeId, + departmentId, + contactId, + channel, + classification, + category, + subCategory, + dueDate, + productId, } = this; + const data = {}; + + // Add optional fields + if (subject) data.subject = subject; + if (description) data.description = description; + if (status) data.status = status; + if (priority) data.priority = priority; + if (assigneeId) data.assigneeId = assigneeId; + if (departmentId) data.departmentId = departmentId; + if (contactId) data.contactId = contactId; + if (channel) data.channel = channel; + if (classification) data.classification = classification; + if (category) data.category = category; + if (subCategory) data.subCategory = subCategory; + if (dueDate) data.dueDate = dueDate; + if (productId) data.productId = productId; + const response = await this.zohoDesk.updateTicket({ ticketId, headers: { orgId, }, - data: { - subject, - description, - }, + data, }); $.export("$summary", `Successfully updated ticket with ID ${response.id}`); diff --git a/components/zoho_desk/package.json b/components/zoho_desk/package.json index 41febc4888613..dedb85eb0c8fb 100644 --- a/components/zoho_desk/package.json +++ b/components/zoho_desk/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/zoho_desk", - "version": "0.3.0", + "version": "0.3.1", "description": "Pipedream Zoho_desk Components", "main": "zoho_desk.app.mjs", "keywords": [ diff --git a/components/zoho_desk/sources/changed-ticket-status/changed-ticket-status.mjs b/components/zoho_desk/sources/changed-ticket-status/changed-ticket-status.mjs index a14e3ca0f1503..f17757fcb870b 100644 --- a/components/zoho_desk/sources/changed-ticket-status/changed-ticket-status.mjs +++ b/components/zoho_desk/sources/changed-ticket-status/changed-ticket-status.mjs @@ -6,7 +6,7 @@ export default { name: "New Ticket Status Change", description: "Emit new event when a status ticket is changed. [See the docs here](https://desk.zoho.com/DeskAPIDocument#Tickets#Tickets_Listalltickets)", type: "source", - version: "0.0.7", + version: "0.0.8", dedupe: "unique", props: { ...common.props, diff --git a/components/zoho_desk/sources/deleted-article-instant/deleted-article-instant.mjs b/components/zoho_desk/sources/deleted-article-instant/deleted-article-instant.mjs index 32d8505579744..b3d0655649c6c 100644 --- a/components/zoho_desk/sources/deleted-article-instant/deleted-article-instant.mjs +++ b/components/zoho_desk/sources/deleted-article-instant/deleted-article-instant.mjs @@ -7,7 +7,7 @@ export default { name: "Deleted Article (Instant)", description: "Emit new event when an article is deleted from the recycle bin", type: "source", - version: "0.0.3", + version: "0.0.4", dedupe: "unique", methods: { ...common.methods, diff --git a/components/zoho_desk/sources/new-account/new-account.mjs b/components/zoho_desk/sources/new-account/new-account.mjs index 8cb7e689de7a3..4e834fb57bc3a 100644 --- a/components/zoho_desk/sources/new-account/new-account.mjs +++ b/components/zoho_desk/sources/new-account/new-account.mjs @@ -6,7 +6,7 @@ export default { name: "New Account", description: "Emit new event when a new account is created. [See the docs here](https://desk.zoho.com/DeskAPIDocument#Accounts#Accounts_Listaccounts)", type: "source", - version: "0.0.7", + version: "0.0.8", dedupe: "unique", props: { ...common.props, diff --git a/components/zoho_desk/sources/new-agent/new-agent.mjs b/components/zoho_desk/sources/new-agent/new-agent.mjs index 5a9cc0656a87f..ec17f416355c7 100644 --- a/components/zoho_desk/sources/new-agent/new-agent.mjs +++ b/components/zoho_desk/sources/new-agent/new-agent.mjs @@ -6,7 +6,7 @@ export default { name: "New Agent", description: "Emit new event when a new agent is created. [See the docs here](https://desk.zoho.com/DeskAPIDocument#Agents#Agents_Listagents)", type: "source", - version: "0.0.7", + version: "0.0.8", dedupe: "unique", props: { ...common.props, diff --git a/components/zoho_desk/sources/new-article-instant/new-article-instant.mjs b/components/zoho_desk/sources/new-article-instant/new-article-instant.mjs index 1c89b8dbed71d..da3f6f1c34856 100644 --- a/components/zoho_desk/sources/new-article-instant/new-article-instant.mjs +++ b/components/zoho_desk/sources/new-article-instant/new-article-instant.mjs @@ -7,7 +7,7 @@ export default { name: "New Article (Instant)", description: "Emit new event when a new article is created", type: "source", - version: "0.0.3", + version: "0.0.4", dedupe: "unique", methods: { ...common.methods, diff --git a/components/zoho_desk/sources/new-contact/new-contact.mjs b/components/zoho_desk/sources/new-contact/new-contact.mjs index 46dc6a7933e0f..f048ba9669cd3 100644 --- a/components/zoho_desk/sources/new-contact/new-contact.mjs +++ b/components/zoho_desk/sources/new-contact/new-contact.mjs @@ -6,7 +6,7 @@ export default { name: "New Contact", description: "Emit new event when a new contact is created. [See the docs here](https://desk.zoho.com/DeskAPIDocument#Contacts#Contacts_Listcontacts)", type: "source", - version: "0.0.7", + version: "0.0.8", dedupe: "unique", props: { ...common.props, diff --git a/components/zoho_desk/sources/new-ticket-attachment/new-ticket-attachment.mjs b/components/zoho_desk/sources/new-ticket-attachment/new-ticket-attachment.mjs index 290e43ad5dc75..89ac004779c95 100644 --- a/components/zoho_desk/sources/new-ticket-attachment/new-ticket-attachment.mjs +++ b/components/zoho_desk/sources/new-ticket-attachment/new-ticket-attachment.mjs @@ -8,7 +8,7 @@ export default { name: "New Ticket Attachment", description: "Emit new event when a new ticket attachment is created. [See the docs here](https://desk.zoho.com/DeskAPIDocument#TicketAttachments#TicketAttachments_Listticketattachments)", type: "source", - version: "0.1.2", + version: "0.1.3", dedupe: "unique", props: { ...common.props, diff --git a/components/zoho_desk/sources/new-ticket-comment/new-ticket-comment.mjs b/components/zoho_desk/sources/new-ticket-comment/new-ticket-comment.mjs index 9ed785162b331..930d2bb30cb52 100644 --- a/components/zoho_desk/sources/new-ticket-comment/new-ticket-comment.mjs +++ b/components/zoho_desk/sources/new-ticket-comment/new-ticket-comment.mjs @@ -6,7 +6,7 @@ export default { name: "New Ticket Comment", description: "Emit new event when a new ticket comment is created. [See the docs here](https://desk.zoho.com/DeskAPIDocument#TicketsComments#TicketsComments_Listallticketcomments)", type: "source", - version: "0.0.7", + version: "0.0.8", dedupe: "unique", props: { ...common.props, diff --git a/components/zoho_desk/sources/new-ticket-message/new-ticket-message.mjs b/components/zoho_desk/sources/new-ticket-message/new-ticket-message.mjs index 97411f5b1ad78..0dd6836c43344 100644 --- a/components/zoho_desk/sources/new-ticket-message/new-ticket-message.mjs +++ b/components/zoho_desk/sources/new-ticket-message/new-ticket-message.mjs @@ -6,7 +6,7 @@ export default { name: "New Ticket Message", description: "Emit new event when a message ticket is created. [See the docs here](https://desk.zoho.com/DeskAPIDocument#Threads#Threads_Listallthreads)", type: "source", - version: "0.0.7", + version: "0.0.8", dedupe: "unique", props: { ...common.props, diff --git a/components/zoho_desk/sources/new-ticket/new-ticket.mjs b/components/zoho_desk/sources/new-ticket/new-ticket.mjs index c8bbca714afeb..fb155a713e9a4 100644 --- a/components/zoho_desk/sources/new-ticket/new-ticket.mjs +++ b/components/zoho_desk/sources/new-ticket/new-ticket.mjs @@ -6,7 +6,7 @@ export default { name: "New Ticket", description: "Emit new event when a new ticket is created. [See the docs here](https://desk.zoho.com/DeskAPIDocument#Tickets#Tickets_Listalltickets)", type: "source", - version: "0.0.7", + version: "0.0.8", dedupe: "unique", props: { ...common.props, diff --git a/components/zoho_desk/sources/updated-article-instant/updated-article-instant.mjs b/components/zoho_desk/sources/updated-article-instant/updated-article-instant.mjs index ea8bff05c0b29..2846ab6962ebe 100644 --- a/components/zoho_desk/sources/updated-article-instant/updated-article-instant.mjs +++ b/components/zoho_desk/sources/updated-article-instant/updated-article-instant.mjs @@ -7,7 +7,7 @@ export default { name: "Updated Article (Instant)", description: "Emit new event when an article is updated", type: "source", - version: "0.0.3", + version: "0.0.4", dedupe: "unique", methods: { ...common.methods, diff --git a/components/zoho_desk/sources/updated-ticket/updated-ticket.mjs b/components/zoho_desk/sources/updated-ticket/updated-ticket.mjs index 1837f643cce77..cae164908451b 100644 --- a/components/zoho_desk/sources/updated-ticket/updated-ticket.mjs +++ b/components/zoho_desk/sources/updated-ticket/updated-ticket.mjs @@ -6,7 +6,7 @@ export default { name: "New Updated Ticket", description: "Emit new event when a ticket is updated. [See the docs here](https://desk.zoho.com/DeskAPIDocument#Tickets#Tickets_Listalltickets)", type: "source", - version: "0.0.7", + version: "0.0.8", dedupe: "unique", props: { ...common.props, diff --git a/components/zoho_desk/zoho_desk.app.mjs b/components/zoho_desk/zoho_desk.app.mjs index a99e88d2b9312..dd99ac00ebe7a 100644 --- a/components/zoho_desk/zoho_desk.app.mjs +++ b/components/zoho_desk/zoho_desk.app.mjs @@ -1,4 +1,6 @@ -import { axios } from "@pipedream/platform"; +import { + axios, ConfigurationError, +} from "@pipedream/platform"; import constants from "./common/constants.mjs"; import utils from "./common/utils.mjs"; @@ -189,6 +191,168 @@ export default { optional: true, default: constants.MAX_RESOURCES, }, + ticketPriority: { + type: "string", + label: "Priority", + description: "Priority level of the ticket", + optional: true, + async options() { + const { data: fields = [] } = + await this.getOrganizationFields({ + params: { + module: "tickets", + apiNames: "priority", + }, + }); + const { allowedValues = [] } = fields[0] || {}; + return allowedValues.map(({ value }) => value); + }, + }, + assigneeId: { + type: "string", + label: "Assignee", + description: "The agent assigned to the ticket", + optional: true, + async options(args) { + return this.getResourcesOptions({ + ...args, + resourceFn: this.getAgents, + resourceMapper: ({ + id: value, name: label, + }) => ({ + value, + label, + }), + }); + }, + }, + channel: { + type: "string", + label: "Channel", + description: "The channel through which the ticket was created", + optional: true, + async options() { + const { data: fields = [] } = + await this.getOrganizationFields({ + params: { + module: "tickets", + apiNames: "channel", + }, + }); + const { allowedValues = [] } = fields[0] || {}; + return allowedValues.map(({ value }) => value); + }, + }, + ticketSortBy: { + type: "string", + label: "Sort By", + description: "Field to sort tickets by", + optional: true, + options: [ + { + label: "Created Time (Ascending)", + value: "createdTime", + }, + { + label: "Created Time (Descending)", + value: "-createdTime", + }, + { + label: "Modified Time (Ascending)", + value: "modifiedTime", + }, + { + label: "Modified Time (Descending)", + value: "-modifiedTime", + }, + { + label: "Due Date (Ascending)", + value: "dueDate", + }, + { + label: "Due Date (Descending)", + value: "-dueDate", + }, + { + label: "Relevance", + value: "relevance", + }, + ], + }, + from: { + type: "integer", + label: "From", + description: "Starting offset for pagination. Use this to retrieve results starting from a specific position.", + optional: true, + min: 1, + }, + limit: { + type: "integer", + label: "Limit", + description: "Number of records to retrieve per request (max 50)", + optional: true, + min: 1, + max: 50, + }, + accountId: { + type: "string", + label: "Account ID", + description: "The ID of the account", + optional: true, + async options(args) { + return this.getResourcesOptions({ + ...args, + resourceFn: this.getAccounts, + resourceMapper: ({ + id: value, accountName: label, + }) => ({ + value, + label, + }), + }); + }, + }, + productId: { + type: "string", + label: "Product ID", + description: "The ID of the product", + optional: true, + }, + category: { + type: "string", + label: "Category", + description: "Category of the ticket", + optional: true, + }, + subCategory: { + type: "string", + label: "Sub Category", + description: "Sub-category of the ticket", + optional: true, + }, + classification: { + type: "string", + label: "Classification", + description: "Classification of the ticket", + optional: true, + async options() { + const { data: fields = [] } = + await this.getOrganizationFields({ + params: { + module: "tickets", + apiNames: "classification", + }, + }); + const { allowedValues = [] } = fields[0] || {}; + return allowedValues.map(({ value }) => value); + }, + }, + dueDate: { + type: "string", + label: "Due Date", + description: "Due date for the ticket in ISO 8601 format (e.g., 2024-12-31T23:59:59Z)", + optional: true, + }, }, methods: { getUrl(url, path, apiPrefix) { @@ -231,7 +395,8 @@ export default { : await axios($, config); } catch (error) { console.log("Request error", error.response?.data); - throw error.response?.data; + throw new ConfigurationError(error.response?.data?.errors[0]?.errorMessage + || error.response?.data?.message); } }, createWebhook(args = {}) { @@ -328,6 +493,73 @@ export default { ...args, }); }, + async *streamResources({ + resourceFn, + params, + headers, + max = constants.MAX_RESOURCES, + } = {}) { + let from = params?.from || 0; + let resourcesCount = 0; + let nextResources; + + while (true) { + try { + ({ data: nextResources = [] } = + await resourceFn({ + withRetries: false, + headers, + params: { + ...params, + from, + limit: params?.limit || constants.DEFAULT_LIMIT, + }, + })); + } catch (error) { + console.log("Stream error", error); + return; + } + + if (nextResources?.length < 1) { + return; + } + + from += nextResources?.length; + + for (const resource of nextResources) { + resourcesCount += 1; + yield resource; + } + + if (max && resourcesCount >= max) { + return; + } + } + }, + async *getTicketsStream({ + params, + headers, + max = constants.MAX_RESOURCES, + } = {}) { + yield* this.streamResources({ + resourceFn: this.getTickets, + params, + headers, + max, + }); + }, + async *searchTicketsStream({ + params, + headers, + max = constants.MAX_RESOURCES, + } = {}) { + yield* this.streamResources({ + resourceFn: this.searchTickets, + params, + headers, + max, + }); + }, createTicketAttachment({ ticketId, ...args } = {}) {