New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

node-zendesk

Package Overview
Dependencies
Maintainers
3
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-zendesk - npm Package Compare versions

Comparing version 4.0.4 to 4.0.5

5

package.json
{
"name": "node-zendesk",
"version": "4.0.4",
"version": "4.0.5",
"type": "commonjs",

@@ -67,3 +67,4 @@ "description": "zendesk API client wrapper",

"Heriberto Madrigal <magic-madrigal@noreply.users.github.com>",
"Fred Souza <fmsouza@noreply.users.github.com>"
"Fred Souza <fmsouza@noreply.users.github.com>",
"Marcelo Luiz Onhate <onhate@noreply.users.github.com>"
],

@@ -70,0 +71,0 @@ "license": "MIT",

4

src/client/client.js

@@ -85,2 +85,6 @@ // Client.js - main client file that does most of the processing

async patch(resource, body) {
return this.request('PATCH', resource, body);
}
async put(resource, body) {

@@ -87,0 +91,0 @@ return this.request('PUT', resource, body);

@@ -147,8 +147,5 @@ // Automations.js: Client for the zendesk API.

async reorder(automationIDs) {
return this.requestAll(
// TODO: putAll
'PUT',
['automations', 'reorder'],
{automation_ids: automationIDs},
);
return this.requestAll('PUT', ['automations', 'reorder'], {
automation_ids: automationIDs,
});
}

@@ -155,0 +152,0 @@ }

@@ -1,5 +0,12 @@

// SatisfactionRatings.js: Client for the zendesk API.
const {Client} = require('../client');
/**
* Client for the Satisfaction Ratings section of the Zendesk API.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/ticket-management/satisfaction_ratings/}
*/
class SatisfactionRatings extends Client {
/**
* Creates a new SatisfactionRatings instance.
* @param {Object} options - Options for initializing the client.
*/
constructor(options) {

@@ -10,3 +17,9 @@ super(options);

// Listing SatisfactionRatings
/**
* Lists all satisfaction ratings.
* @async
* @return {Array} A list of satisfaction ratings.
* @example const ratings = await client.satisfactionratings.list();
* @see {@link https://developer.zendesk.com/api-reference/ticketing/ticket-management/satisfaction_ratings/#list-satisfaction-ratings}
*/
async list() {

@@ -16,2 +29,8 @@ return this.getAll(['satisfaction_ratings']);

/**
* Lists all received satisfaction ratings.
* @async
* @return {Array} A list of received satisfaction ratings.
* @example const ratingsReceived = await client.satisfactionratings.received();
*/
async received() {

@@ -21,2 +40,10 @@ return this.getAll(['satisfaction_ratings', 'received']);

/**
* Retrieves details of a specific satisfaction rating.
* @async
* @param {number} satisfactionRatingID - The ID of the satisfaction rating to retrieve.
* @return {Object} Details of the satisfaction rating.
* @example const ratingDetails = await client.satisfactionratings.show(12345);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/ticket-management/satisfaction_ratings/#show-satisfaction-rating}
*/
async show(satisfactionRatingID) {

@@ -26,3 +53,16 @@ return this.get(['satisfaction_ratings', satisfactionRatingID]);

// Posting SatisfactionRatings
/**
* Creates a satisfaction rating for a ticket.
* @async
* @param {number} ticketID - The ID of the ticket.
* @param {Object} satisfactionRating - The details of the satisfaction rating to create.
* @return {Object} The created satisfaction rating.
* @throws Will throw an error if the requester is not an end user of the ticket or if the ticket is not solved.
* @example
* const rating = {
* satisfaction_rating: { score: "good", comment: "Awesome support." }
* };
* const newRating = await client.satisfactionratings.create(12345, rating);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/ticket-management/satisfaction_ratings/#create-a-satisfaction-rating}
*/
async create(ticketID, satisfactionRating) {

@@ -35,3 +75,10 @@ return this.post(

// New Incremental Export
/**
* Incrementally exports satisfaction ratings based on a start time.
* @async
* @param {number} startTime - The start time for the incremental export (Unix epoch time).
* @return {Array} A list of satisfaction ratings from the specified start time.
* @example const ratingsExported = await client.satisfactionratings.incremental(1498151194);
* @see {@link https://developer.zendesk.com/api-reference/live-chat/chat-api/incremental_export/#start-time}
*/
async incremental(startTime) {

@@ -38,0 +85,0 @@ this.get(['satisfaction_ratings', {start_time: startTime}]);

// Search.js: Client for the zendesk API.
const {Client} = require('../client');
/**
* Client for the Zendesk Search API.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/ticket-management/search/}
*/
class Search extends Client {

@@ -10,3 +14,11 @@ constructor(options) {

// Listing Search
/**
* Search for the given term and retrieve results.
* @async
* @param {string} searchTerm - The term to search for.
* @returns {Promise<Object>} A JSON object with the search results.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/ticket-management/search/#list-search-results}
* @example
* const results = await client.search.query('open tickets');
*/
async query(searchTerm) {

@@ -16,2 +28,10 @@ return this.get(['search', {query: searchTerm}]);

/**
* Search for the given term and retrieve all results.
* @async
* @param {string} searchTerm - The term to search for.
* @returns {Promise<Array>} An array of search results.
* @example
* const allResults = await client.search.queryAll('open tickets');
*/
async queryAll(searchTerm) {

@@ -21,2 +41,10 @@ return this.getAll(['search', {query: searchTerm}]);

/**
* Anonymous search for the given term and retrieve results.
* @async
* @param {string} searchTerm - The term to search for.
* @returns {Promise<Object>} A JSON object with the search results.
* @example
* const anonResults = await client.search.queryAnonymous('open tickets');
*/
async queryAnonymous(searchTerm) {

@@ -26,7 +54,47 @@ return this.get(['portal', 'search', {query: searchTerm}]);

/**
* Anonymous search for the given term and retrieve all results.
* @async
* @param {string} searchTerm - The term to search for.
* @returns {Promise<Array>} An array of search results.
* @example
* const allAnonResults = await client.search.queryAnonymousAll('open tickets');
*/
async queryAnonymousAll(searchTerm) {
return this.getAll(['portal', 'search', {query: searchTerm}]);
}
/**
* Retrieve the count of search results for the given term.
* @async
* @param {string} searchTerm - The term to search for.
* @returns {Promise<Object>} An Object with the number of items matching the query.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/ticket-management/search/#show-results-count}
* @example
* const { count } = await client.search.showResultsCount('open tickets');
*/
async showResultsCount(searchTerm) {
return this.get(['search', 'count', {query: searchTerm}]);
}
/**
* Export the search results for the given term.
* @async
* @param {string} searchTerm - The term to search for.
* @param {string} objectType - The type of object to return (ticket, organization, user, or group).
* @param {number} [pageSize=100] - The number of results per page.
* @returns {Promise<Array>} An array of search results.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/ticket-management/search/#export-search-results}
* @example
* const { results } = await client.search.exportResults('open tickets', 'ticket');
*/
async exportResults(searchTerm, objectType, pageSize = 100) {
return this.getAll([
'search',
'export',
{query: searchTerm, 'filter[type]': objectType, 'page[size]': pageSize},
]);
}
}
exports.Search = Search;

@@ -1,4 +0,8 @@

// Sessions.js: Client for the zendesk API.
// File: sessions.js
const {Client} = require('../client');
/**
* Client class for interacting with Zendesk's Sessions API.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/account-configuration/sessions/}
*/
class Sessions extends Client {

@@ -10,3 +14,10 @@ constructor(options) {

// List Sessions
/**
* List all sessions.
* @async
* @returns {Promise<Object[]>} Array of sessions.
* @example
* const sessions = await client.sessions.get();
* @see {@link https://developer.zendesk.com/api-reference/ticketing/account-configuration/sessions/#list-sessions}
*/
async get() {

@@ -16,2 +27,11 @@ return this.getAll(['sessions']);

/**
* List sessions by user ID.
* @async
* @param {number} userId - The ID of the user.
* @returns {Promise<Object[]>} Array of sessions.
* @example
* const sessions = await client.sessions.getByUserId(12345);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/account-configuration/sessions/#list-sessions}
*/
async getByUserId(userId) {

@@ -21,2 +41,12 @@ return this.getAll(['users', userId, 'sessions']);

/**
* Retrieve a specific session by user ID and session ID.
* @async
* @param {number} userId - The ID of the user.
* @param {number} sessionId - The ID of the session.
* @returns {Promise<Object>} Session details.
* @example
* const session = await client.sessions.getByUserIdBySessionId(12345, 67890);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/account-configuration/sessions/#show-session}
*/
async getByUserIdBySessionId(userId, sessionId) {

@@ -26,2 +56,10 @@ return this.get(['users', userId, 'sessions', sessionId]);

/**
* Retrieve details of the currently authenticated session.
* @async
* @returns {Promise<Object>} Session details.
* @example
* const session = await client.sessions.getMyAuthenticatedSession();
* @see {@link https://developer.zendesk.com/api-reference/ticketing/account-configuration/sessions/#show-the-currently-authenticated-session}
*/
async getMyAuthenticatedSession() {

@@ -31,2 +69,13 @@ return this.get(['users', 'me', 'session']);

/**
* Delete a specific session by user ID and session ID.
* @async
* @param {number} userId - The ID of the user.
* @param {number} sessionId - The ID of the session.
* @returns {Promise<void>}
* @throws Will throw an error if the request fails.
* @example
* await client.sessions.deleteByUserIdBySessionId(12345, 67890);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/account-configuration/sessions/#delete-session}
*/
async deleteByUserIdBySessionId(userId, sessionId) {

@@ -36,2 +85,12 @@ return super.delete(['users', userId, 'sessions', sessionId]);

/**
* Delete all sessions for a specific user by user ID.
* @async
* @param {number} userId - The ID of the user.
* @returns {Promise<void>}
* @throws Will throw an error if the request fails.
* @example
* await client.sessions.bulkDeleteByUserId(12345);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/account-configuration/sessions/#bulk-delete-sessions}
*/
async bulkDeleteByUserId(userId) {

@@ -41,2 +100,11 @@ return super.delete(['users', userId, 'sessions']);

/**
* Logs out the current authenticated user.
* @async
* @returns {Promise<void>}
* @throws Will throw an error if the request fails.
* @example
* await client.sessions.logMeOut();
* @see {@link https://developer.zendesk.com/api-reference/ticketing/account-configuration/sessions/#delete-the-authenticated-session}
*/
async logMeOut() {

@@ -43,0 +111,0 @@ return super.delete(['users', 'me', 'sessions']);

@@ -5,2 +5,6 @@ // SharingAgreement.js: Client for the zendesk API.

/**
* Class representing the SharingAgreement API methods.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/sharing_agreements/}
*/
class SharingAgreement extends Client {

@@ -12,8 +16,79 @@ constructor(options) {

// Listing SharingAgreement
/**
* List all Sharing Agreements.
* @async
* @returns {Promise<Array>} An array of Sharing Agreement objects.
* @throws {Error} Throws an error if the request fails.
* @example
* const sharingAgreements = await client.sharingagreement.show();
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/sharing_agreements/#list-sharing-agreements}
*/
async show() {
return this.get(['sharing_agreements']);
}
/**
* Show a specific Sharing Agreement by its ID.
* @async
* @param {number} id The ID of the Sharing Agreement.
* @returns {Promise<Object>} The Sharing Agreement object.
* @throws {Error} Throws an error if the request fails.
* @example
* const sharingAgreement = await client.sharingagreement.showById(12345);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/sharing_agreements/#show-a-sharing-agreement}
*/
async showById(id) {
return this.get(['sharing_agreements', id]);
}
/**
* Create a new Sharing Agreement.
* @async
* @param {Object} data The data for the new Sharing Agreement.
* @returns {Promise<Object>} The created Sharing Agreement object.
* @throws {Error} Throws an error if the request fails.
* @example
* const newSharingAgreement = {
* remote_subdomain: "Foo"
* };
* const createdAgreement = await client.sharingagreement.create(newSharingAgreement);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/sharing_agreements/#create-sharing-agreement}
*/
async create(data) {
return this.post(['sharing_agreements'], {sharing_agreement: data});
}
/**
* Update an existing Sharing Agreement.
* @async
* @param {number} id The ID of the Sharing Agreement to update.
* @param {Object} data The data to update the Sharing Agreement with. Only 'status' is allowed.
* @returns {Promise<Object>} The updated Sharing Agreement object.
* @throws {Error} Throws an error if the request fails.
* @example
* const updatedData = {
* status: "accepted"
* };
* const updatedAgreement = await client.sharingagreement.update(12345, updatedData);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/sharing_agreements/#update-a-sharing-agreement}
*/
async update(id, data) {
return this.put(['sharing_agreements', id], {sharing_agreement: data});
}
/**
* Delete a specific Sharing Agreement by its ID.
* @async
* @param {number} id The ID of the Sharing Agreement.
* @returns {Promise<void>}
* @throws {Error} Throws an error if the request fails.
* @example
* await client.sharingagreement.delete(12345);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/sharing_agreements/#delete-a-sharing-agreement}
*/
async delete(id) {
return super.delete(['sharing_agreements', id]);
}
}
exports.SharingAgreement = SharingAgreement;
// SuspendedTickets.js: Client for the zendesk API.
const {Client} = require('../client');
/**
* @class SuspendedTickets
* @extends Client
* @description A thin wrapper around the Zendesk Suspended Tickets API
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/suspended_tickets/}
*/
class SuspendedTickets extends Client {

@@ -10,3 +16,9 @@ constructor(options) {

// Listing SuspendedTickets
/**
* List all suspended tickets
* @async
* @returns {Promise} Returns a promise that resolves to a list of suspended tickets
* @example const tickets = await client.suspendedtickets.list();
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/suspended_tickets/#list-suspended-tickets}
*/
async list() {

@@ -16,3 +28,10 @@ return this.getAll(['suspended_tickets']);

// Viewing SuspendedTickets
/**
* Get details of a specific suspended ticket by ID
* @async
* @param {number} suspendedTicketID - ID of the suspended ticket
* @returns {Promise} Returns a promise that resolves to the details of the suspended ticket
* @example const ticket = await client.suspendedtickets.show(12345);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/suspended_tickets/#show-suspended-ticket}
*/
async show(suspendedTicketID) {

@@ -22,3 +41,10 @@ return this.get(['suspended_tickets', suspendedTicketID]);

// Recover SuspendedTickets
/**
* Recover a specific suspended ticket by ID
* @async
* @param {number} suspendedTicketID - ID of the suspended ticket to recover
* @returns {Promise} Returns a promise that resolves once the ticket has been recovered
* @example await client.suspendedtickets.recover(12345);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/suspended_tickets/#recover-suspended-ticket}
*/
async recover(suspendedTicketID) {

@@ -28,2 +54,10 @@ return this.put(['suspended_tickets', suspendedTicketID, 'recover']);

/**
* Recover multiple suspended tickets by their IDs
* @async
* @param {Array<number>} suspendedTicketIDs - An array of suspended ticket IDs to recover
* @returns {Promise} Returns a promise that resolves once the tickets have been recovered
* @example await client.suspendedtickets.recoverMany([12345, 67890]);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/suspended_tickets/#recover-multiple-suspended-tickets}
*/
async recoverMany(suspendedTicketIDs) {

@@ -37,7 +71,24 @@ return this.put([

// Deleting SuspendedTickets
/**
* Delete a specific suspended ticket by ID
* @async
* @param {number} suspendedTicketID - ID of the suspended ticket to delete
* @returns {Promise} Returns a promise that resolves once the ticket has been deleted
* @example await client.suspendedtickets.delete(12345);
* @throws Will throw an error if the request fails
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/suspended_tickets/#delete-suspended-ticket}
*/
async delete(suspendedTicketID) {
return this.request('DELETE', ['suspended_tickets', suspendedTicketID]);
return super.delete(['suspended_tickets', suspendedTicketID]);
}
/**
* Deletes multiple suspended tickets by their IDs
* @async
* @param {Array<number>} suspendedTicketIDs - An array of suspended ticket IDs to delete
* @returns {Promise} Returns a promise that resolves once the tickets have been deleted
* @example await client.suspendedtickets.destroyMany([12345, 67890]);
* @throws Will throw an error if the request fails
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/suspended_tickets/#delete-multiple-suspended-tickets}
*/
async destroyMany(suspendedTicketIDs) {

@@ -47,15 +98,45 @@ return super.delete([

'destroy_many',
{ids: suspendedTicketIDs},
{
ids: suspendedTicketIDs,
},
]);
}
/**
* @deprecated Use `destroyMany` method instead.
* Deletes multiple suspended tickets by their IDs. This method is deprecated.
* @async
* @param {Array<number>} suspendedTicketIDs - An array of suspended ticket IDs to delete
* @returns {Promise} Returns a promise that resolves once the tickets have been deleted
* @example await client.suspendedtickets.deleteMany([12345, 67890]);
* @throws Will throw an error if the request fails
*/
async deleteMany(suspendedTicketIDs) {
return super.delete([
'suspended_tickets',
'destroy_many',
{ids: suspendedTicketIDs},
]);
return this.destroyMany(suspendedTicketIDs);
}
/**
* Get attachments for a specific suspended ticket by ID
* @async
* @param {number} suspendedTicketID - ID of the suspended ticket to get attachments from
* @returns {Promise} Returns a promise that resolves to the attachments of the suspended ticket
* @example const attachments = await client.suspendedtickets.attachments(12345);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/suspended_tickets/#suspended-ticket-attachments}
*/
async attachments(suspendedTicketID) {
return this.post(['suspended_tickets', suspendedTicketID, 'attachments']);
}
/**
* Export suspended tickets for the Zendesk Support instance
* @async
* @returns {Promise} Returns a promise that resolves once the export request has been initiated
* @example await client.suspendedtickets.exportTickets();
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/suspended_tickets/#export-suspended-tickets}
*/
async exportTickets() {
return this.post(['suspended_tickets', 'export']);
}
}
exports.SuspendedTickets = SuspendedTickets;

@@ -1,5 +0,7 @@

// Tags.js: Client for the zendesk API.
const {Client} = require('../client');
/**
* Client for the Zendesk Tags API.
* @see {@link https://developer.zendesk.com/api-reference/sales-crm/resources/tags/}
*/
class Tags extends Client {

@@ -11,8 +13,79 @@ constructor(options) {

// Listing Tags
/**
* Retrieves all tags available to the user.
* @async
* @returns {Promise<Object[]>} A promise that resolves with the list of tags.
* @see {@link https://developer.zendesk.com/api-reference/sales-crm/resources/tags/#retrieve-all-tags}
* @example
* const client = createClient({...});
* const tags = await client.tags.list();
*/
async list() {
return this.getAll(['tags']);
}
/**
* Creates a new tag.
* @async
* @param {Object} tagData - Data for the new tag.
* @param {string} tagData.name - Name of the tag.
* @param {string} tagData.resource_type - Type of resource the tag is attached to (lead, contact, deal).
* @returns {Promise<Object>} A promise that resolves with the created tag.
* @throws Will throw an error if the API call fails.
* @see {@link https://developer.zendesk.com/api-reference/sales-crm/resources/tags/#create-a-tag}
* @example
* const client = createClient({...});
* const newTag = await client.tags.create({ name: 'important', resource_type: 'contact' });
*/
async create(tagData) {
return this.post(['tags'], tagData);
}
/**
* Retrieves a single tag by its ID.
* @async
* @param {number} id - Unique identifier of the tag.
* @returns {Promise<Object>} A promise that resolves with the retrieved tag.
* @throws Will throw an error if the API call fails.
* @see {@link https://developer.zendesk.com/api-reference/sales-crm/resources/tags/#retrieve-a-single-tag}
* @example
* const client = createClient({...});
* const tag = await client.tags.show(5);
*/
async show(id) {
return this.get(['tags', id]);
}
/**
* Updates a tag's information.
* @async
* @param {number} id - Unique identifier of the tag.
* @param {Object} updatedData - Data to update.
* @returns {Promise<Object>} A promise that resolves with the updated tag.
* @throws Will throw an error if the API call fails.
* @see {@link https://developer.zendesk.com/api-reference/sales-crm/resources/tags/#update-a-tag}
* @example
* const client = createClient({...});
* const updatedTag = await client.tags.update(5, { name: 'super important' });
*/
async update(id, updatedData) {
return this.put(['tags', id], updatedData);
}
/**
* Deletes a tag by its ID.
* @async
* @param {number} id - Unique identifier of the tag.
* @returns {Promise<void>} A promise that resolves when the tag has been deleted.
* @throws Will throw an error if the API call fails.
* @see {@link https://developer.zendesk.com/api-reference/sales-crm/resources/tags/#delete-a-tag}
* @example
* const client = createClient({...});
* await client.tags.delete(1);
*/
async delete(id) {
return super.delete(['tags', id]);
}
}
exports.Tags = Tags;
// Targetfailures.js: Client for the zendesk API.
const {Client} = require('../client');
/**
* A class for interacting with the Zendesk Target Failures API.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/targets/target_failures/}
*/
class TargetFailures extends Client {

@@ -10,10 +14,29 @@ constructor(options) {

// Listing Target Failures
/**
* Lists the 25 most recent target failures, per target.
* @async
* @return {Array} An array of target failures.
* @example
* const client = createClient({...});
* const failures = await client.targetfailures.list();
* @see {@link https://developer.zendesk.com/api-reference/ticketing/targets/target_failures/#list-target-failures}
* @throws {Error} Throws an error if the request fails.
*/
async list() {
this.getAll(['target_failures']);
return this.getAll(['target_failures']);
}
// Viewing Target Failure
/**
* Retrieves the details of a specific target failure by its ID.
* @async
* @param {number} targetFailureID - The ID of the target failure.
* @return {Object} The target failure details.
* @example
* const client = createClient({...});
* const failureDetails = await client.targetfailures.show(6001326);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/targets/target_failures/#show-target-failure}
* @throws {Error} Throws an error if the request fails or if the target failure ID is not found.
*/
async show(targetFailureID) {
this.get(['target_failures', targetFailureID]);
return this.get(['target_failures', targetFailureID]);
}

@@ -20,0 +43,0 @@ }

@@ -1,4 +0,7 @@

// Targets.js: Client for the zendesk API.
const {Client} = require('../client');
/**
* Represents a client for the Zendesk Targets API.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/targets/targets/}
*/
class Targets extends Client {

@@ -10,3 +13,10 @@ constructor(options) {

// Listing Targets
/**
* Lists all targets.
* @async
* @returns {Promise<Object>} A promise that resolves to the list of targets.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/targets/targets/#list-targets}
* @example
* const targets = await client.targets.list();
*/
async list() {

@@ -16,8 +26,30 @@ return this.getAll(['targets']);

// Viewing Targets
async show(triggerID) {
return this.get(['targets', triggerID]);
/**
* Retrieves details of a specific target.
* @async
* @param {number} targetId - The ID of the target to retrieve.
* @returns {Promise<Object>} A promise that resolves to the target details.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/targets/targets/#show-target}
* @example
* const target = await client.targets.show(12345);
*/
async show(targetId) {
return this.get(['targets', targetId]);
}
// Creating Targets
/**
* Creates a new target.
* @async
* @param {Object} target - The target data.
* @returns {Promise<Object>} A promise that resolves to the created target's details.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/targets/targets/#create-target}
* @example
* const target = {
* type: 'email_target',
* title: 'Test Email Target',
* email: 'hello@example.com',
* subject: 'Test Target'
* };
* const response = await client.targets.create(target);
*/
async create(target) {

@@ -27,10 +59,29 @@ return this.post(['targets'], target);

// Updating Targets
async update(targetID, target) {
return this.put(['targets', targetID], target);
/**
* Updates a specific target.
* @async
* @param {number} targetId - The ID of the target to update.
* @param {Object} target - The updated target data.
* @returns {Promise<Object>} A promise that resolves to the updated target's details.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/targets/targets/#update-target}
* @example
* const updatedData = { email: 'updated@example.com' };
* const response = await client.targets.update(12345, updatedData);
*/
async update(targetId, target) {
return this.put(['targets', targetId], target);
}
// Deleting Targets
async delete(targetID) {
return super.delete(['targets', targetID]);
/**
* Deletes a specific target.
* @async
* @param {number} targetId - The ID of the target to delete.
* @returns {Promise<void>} A promise that resolves once the target has been deleted.
* @throws {Error} Throws an error if deletion fails.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/targets/targets/#delete-target}
* @example
* await client.targets.delete(12345);
*/
async delete(targetId) {
return super.delete(['targets', targetId]);
}

@@ -37,0 +88,0 @@ }

@@ -1,4 +0,7 @@

// TicketAudits.js: Client for the zendesk API.
const {Client} = require('../client');
/**
* Client for the Zendesk Ticket Audits API.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_audits/}
*/
class TicketAudits extends Client {

@@ -14,8 +17,79 @@ constructor(options) {

// Listing TicketAudits
/**
* List all ticket audits. Note: Archived tickets are not included.
* @async
* @returns {Promise<Array<Object>>} Returns an array of ticket audit objects.
* @throws {Error} Throws an error if request fails.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_audits/#list-all-ticket-audits}
* @example
* const client = createClient({...});
* const allAudits = await client.ticketaudits.listAll();
*/
async listAll() {
return this.get('ticket_audits');
}
/**
* List all audits for a specified ticket.
* @async
* @param {number} ticketID - The ID of the ticket.
* @returns {Promise<Array<Object>>} Returns an array of ticket audit objects.
* @throws {Error} Throws an error if request fails.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_audits/#list-audits-for-a-ticket}
* @example
* const client = createClient({...});
* const audits = await client.ticketaudits.list(12345);
*/
async list(ticketID) {
return this.getAll(['tickets', ticketID, 'audits']);
}
/**
* Get an approximate count of audits for a specified ticket.
* @async
* @param {number} ticketID - The ID of the ticket.
* @returns {Promise<number>} Returns an approximate count of audits.
* @throws {Error} Throws an error if request fails.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_audits/#count-audits-for-a-ticket}
* @example
* const client = createClient({...});
* const auditCount = await client.ticketaudits.count(12345);
*/
async count(ticketID) {
return this.get(['tickets', ticketID, 'audits', 'count']);
}
/**
* Show details of a specific ticket audit.
* @async
* @param {number} ticketID - The ID of the ticket.
* @param {number} auditID - The ID of the ticket audit.
* @returns {Promise<Object>} Returns details of the ticket audit.
* @throws {Error} Throws an error if request fails.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_audits/#show-audit}
* @example
* const client = createClient({...});
* const auditDetails = await client.ticketaudits.show(12345, 67890);
*/
async show(ticketID, auditID) {
return this.get(['tickets', ticketID, 'audits', auditID]);
}
/**
* Change a comment from public to private for a specific ticket audit.
* @async
* @param {number} ticketID - The ID of the ticket.
* @param {number} auditID - The ID of the ticket audit.
* @returns {Promise<Object>} Returns the updated ticket audit details.
* @throws {Error} Throws an error if request fails.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_audits/#change-a-comment-from-public-to-private}
* @example
* const client = createClient({...});
* await client.ticketaudits.makePrivate(12345, 67890);
*/
async makePrivate(ticketID, auditID) {
return this.put(['tickets', ticketID, 'audits', auditID, 'make_private']);
}
}
exports.TicketAudits = TicketAudits;
// TicketEvents.js: Client for the zendesk API.
const {Client} = require('../client');
/**
* TicketEvents class to handle operations related to the Zendesk Ticket Events API.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/ticket-management/incremental_exports/}
*/
class TicketEvents extends Client {

@@ -10,3 +14,12 @@ constructor(options) {

// New Incremental TicketEvents Export with include
/**
* Fetches incremental ticket events with optional inclusion.
* @async
* @param {number} startTime - The time to start the incremental export from.
* @param {string} include - Additional entities to include in the response.
* @returns {Promise<Object>} Returns the result of the API call.
* @throws {Error} Throws an error if the API call fails.
* @example const result = await client.ticketevents.incrementalInclude(1632505559, 'comment_events');
* @see {@link https://developer.zendesk.com/api-reference/ticketing/ticket-management/incremental_exports/#incremental-ticket-event-export}
*/
async incrementalInclude(startTime, include) {

@@ -20,3 +33,11 @@ return this.getAll([

// New Incremental Ticket Export
/**
* Fetches incremental ticket events.
* @async
* @param {number} startTime - The time to start the incremental export from.
* @returns {Promise<Object>} Returns the result of the API call.
* @throws {Error} Throws an error if the API call fails.
* @example const result = await client.ticketevents.incremental(1632505559);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/ticket-management/incremental_exports/#incremental-ticket-event-export}
*/
async incremental(startTime) {

@@ -30,3 +51,11 @@ return this.getAll([

// New Incremental Ticket Export Sample
/**
* Fetches a sample of ticket events for testing purposes.
* @async
* @param {number} startTime - The time to start the incremental export from.
* @returns {Promise<Object>} Returns the result of the API call.
* @throws {Error} Throws an error if the API call fails.
* @example const result = await client.ticketevents.incrementalSample(1632505559);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/ticket-management/incremental_exports/#incremental-sample-export}
*/
async incrementalSample(startTime) {

@@ -33,0 +62,0 @@ return this.get([

@@ -1,4 +0,7 @@

// Tickets.js: Client for the zendesk API.
const {Client} = require('../client');
/**
* TicketExport class for interacting with the Zendesk Ticket Export API.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/ticket-management/incremental_exports/}
*/
class TicketExport extends Client {

@@ -10,3 +13,11 @@ constructor(options) {

// Creating Tickets
/**
* Export tickets that changed since the provided start time using the time-based approach.
* @async
* @param {number} start_time - The time to start the incremental export from.
* @returns {Promise<Object>} Returns the response from the Zendesk API.
* @throws Will throw an error if the request fails.
* @example const tickets = await client.ticketexport.export(1332034771);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/ticket-management/incremental_exports/#incremental-ticket-export-time-based}
*/
async export(start_time) {

@@ -16,2 +27,10 @@ return this.get(['incremental', 'tickets', '?start_time=' + start_time]);

/**
* Export tickets with associated users and groups since the provided start time.
* @async
* @param {number} start_time - The time to start the incremental export from.
* @returns {Promise<Object>} Returns the response from the Zendesk API with users and groups included.
* @throws Will throw an error if the request fails.
* @example const ticketsWithUsers = await client.ticketexport.exportWithUser(1332034771);
*/
async exportWithUser(start_time) {

@@ -25,10 +44,78 @@ return this.get([

// Ticket Audits
/**
*
* Export incremental tickets based on a specified start time and optional include parameters.
*
* @async
* @param {string} startTime - The start time for exporting incremental tickets.
* @param {string} include - Optional parameters to include in the export.
* @returns {Promise<Array>} A promise that resolves with an array of exported incremental tickets.
*
* @throws {Error} If `startTime` is not a valid string.
*
* @example
* // Export incremental tickets based on a start time with optional include parameters
* const startTime = '2023-01-01T00:00:00Z';
* const include = 'users,groups';
* const incrementalTickets = await client.tickets.ticketexport(startTime, include);
*
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#ticket-export-incremental-include}
*/
async exportWithInclude(startTime, include) {
return this.getAll([
'incremental',
'tickets',
{start_time: startTime, include},
]);
}
// Listing Audits
/**
* Export tickets using the cursor-based approach.
* @async
* @param {number} start_time - The time to start the incremental export from.
* @param {string} [cursor] - The cursor pointer for subsequent requests.
* @returns {Promise<Object>} Returns the response from the Zendesk API.
* @throws Will throw an error if the request fails.
* @example const cursorTickets = await client.ticketexport.exportCursor(1332034771, 'MTU3NjYxMzUzOS4wfHw0NTF8');
* @see {@link https://developer.zendesk.com/api-reference/ticketing/ticket-management/incremental_exports/#incremental-ticket-export-cursor-based}
*/
async exportCursor(start_time, cursor) {
return this.get(['incremental', 'tickets', 'cursor', {start_time, cursor}]);
}
/**
* @deprecated Use the `list` method from the `TicketAudits` class instead.
* Retrieve all audits for a specific ticket.
* @async
* @param {number} ticketID - The ID of the ticket.
* @returns {Promise<Object>} Returns the list of audits for the ticket.
* @throws Will throw an error if the request fails.
* @example const ticketAudits = await client.ticketexport.exportAudit(12345);
*/
async exportAudit(ticketID) {
return this.getAll(['tickets', ticketID, 'audits']);
}
/**
* Export a sample of tickets based on a specified start time.
*
* @async
* @param {string} startTime - The start time for exporting the sample of tickets.
* @returns {Promise<Object>} A promise that resolves with the exported sample of tickets.
*
* @throws {Error} If `startTime` is not a valid string.
*
* @example
* // Export a sample of tickets based on a start time
* const startTime = '2023-01-01T00:00:00Z';
* const exportedSample = await client.ticketexport.sample(startTime);
*
* @see {@link https://developer.zendesk.com/api-reference/ticketing/ticket-management/incremental_exports/#incremental-sample-export}
*/
async sample(startTime) {
return this.get(['exports', 'tickets', 'sample', {start_time: startTime}]);
}
}
exports.TicketExport = TicketExport;
// Ticketfields.js: Client for the zendesk API.
const {Client} = require('../client');
/**
* Client for the Zendesk Ticket Fields API.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/}
*/
class TicketFields extends Client {

@@ -10,3 +14,12 @@ constructor(options) {

// Listing Tickets Fields
/**
* Lists all ticket fields.
* @async
* @return {Promise<Array>} Returns an array of ticket fields.
* @example
* const client = createClient({...});
* const fields = await client.ticketfields.list();
* @throws {Error} Throws an error if the request fails.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#list-ticket-fields}
*/
async list() {

@@ -16,8 +29,45 @@ return this.getAll(['ticket_fields']);

// Viewing Tickets Fields
async show(ticketFieldID) {
return this.get(['ticket_fields', ticketFieldID]);
/**
* Retrieves a specific ticket field by ID.
* @async
* @param {number} ticketFieldId - The ID of the ticket field to retrieve.
* @return {Promise<Object>} Returns the details of the ticket field.
* @example
* const client = createClient({...});
* const field = await client.ticketfields.show(12345);
* @throws {Error} Throws an error if the request fails.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#show-ticket-field}
*/
async show(ticketFieldId) {
return this.get(['ticket_fields', ticketFieldId]);
}
// Creating Tickets Fields
/**
* Retrieves the count of ticket fields.
* @async
* @return {Promise<number>} Returns the count of ticket fields.
* @example
* const client = createClient({...});
* const count = await client.ticketfields.count();
* @throws {Error} Throws an error if the request fails.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#count-ticket-fields}
*/
async count() {
return this.get(['ticket_fields', 'count']);
}
/**
* Creates a new ticket field.
* @async
* @param {Object} ticketField - The properties of the ticket field to create.
* @return {Promise<Object>} Returns the created ticket field.
* @example
* const client = createClient({...});
* const newField = await client.ticketfields.create({
* type: 'text',
* title: 'New Field'
* });
* @throws {Error} Throws an error if the request fails.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#create-ticket-field}
*/
async create(ticketField) {

@@ -27,13 +77,102 @@ return this.post(['ticket_fields'], ticketField);

// Updating Tickets Fields
async update(ticketFieldID, ticketField) {
return this.put(['ticket_fields', ticketFieldID], ticketField);
/**
* Updates a specific ticket field by ID.
* @async
* @param {number} ticketFieldId - The ID of the ticket field to update.
* @param {Object} ticketField - The updated properties of the ticket field.
* @return {Promise<Object>} Returns the updated ticket field.
* @example
* const client = createClient({...});
* const updatedField = await client.ticketfields.update(12345, {
* title: 'Updated Field'
* });
* @throws {Error} Throws an error if the request fails.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#update-ticket-field}
*/
async update(ticketFieldId, ticketField) {
return this.put(['ticket_fields', ticketFieldId], ticketField);
}
// Deleting Tickets Fields
async delete(ticketFieldID) {
return super.delete(['ticket_fields', ticketFieldID]);
/**
* Deletes a specific ticket field by ID.
* @async
* @param {number} ticketFieldId - The ID of the ticket field to delete.
* @return {Promise<void>}
* @example
* const client = createClient({...});
* await client.ticketfields.delete(12345);
* @throws {Error} Throws an error if the request fails.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#delete-ticket-field}
*/
async delete(ticketFieldId) {
return super.delete(['ticket_fields', ticketFieldId]);
}
/**
* Lists all options of a ticket field.
* @async
* @param {number} ticketFieldId - The ID of the ticket field to retrieve options from.
* @return {Promise<Array>} Returns an array of options for the ticket field.
* @example
* const client = createClient({...});
* const options = await client.ticketfields.listOptions(12345);
* @throws {Error} Throws an error if the request fails.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#list-ticket-field-options}
*/
async listOptions(ticketFieldId) {
return this.get(['ticket_fields', ticketFieldId, 'options']);
}
/**
* Retrieves a specific option of a ticket field by ID.
* @async
* @param {number} ticketFieldId - The ID of the ticket field.
* @param {number} optionID - The ID of the option to retrieve.
* @return {Promise<Object>} Returns the option details.
* @example
* const client = createClient({...});
* const option = await client.ticketfields.showOption(12345, 67890);
* @throws {Error} Throws an error if the request fails.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#show-ticket-field-option}
*/
async showOption(ticketFieldId, optionID) {
return this.get(['ticket_fields', ticketFieldId, 'options', optionID]);
}
/**
* Creates or updates an option of a ticket field.
* @async
* @param {number} ticketFieldId - The ID of the ticket field.
* @param {Object} option - The properties of the option to create or update.
* @return {Promise<Object>} Returns the created or updated option.
* @example
* const client = createClient({...});
* const newOption = await client.ticketfields.createOrUpdateOption(12345, {
* name: 'Option Name',
* value: 'Option Value'
* });
* @throws {Error} Throws an error if the request fails.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#create-or-update-ticket-field-option}
*/
async createOrUpdateOption(ticketFieldId, option) {
return this.put(['ticket_fields', ticketFieldId, 'options'], option);
}
/**
* Deletes a specific option of a ticket field by ID.
* @async
* @param {number} ticketFieldId - The ID of the ticket field.
* @param {number} optionID - The ID of the option to delete.
* @return {Promise<void>}
* @example
* const client = createClient({...});
* await client.ticketfields.deleteOption(12345, 67890);
* @throws {Error} Throws an error if the request fails.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_fields/#delete-ticket-field-option}
*/
async deleteOption(ticketFieldId, optionID) {
return super.delete(['ticket_fields', ticketFieldId, 'options', optionID]);
}
}
exports.TicketFields = TicketFields;
// Ticketforms.js: Client for the zendesk API.
const {Client} = require('../client');
/**
* @class
* @classdesc Client for interacting with the Zendesk TicketForms API.
* @see {@link https://developer.zendesk.com/rest_api/docs/support#ticket-forms}
*/
class TicketForms extends Client {

@@ -10,9 +15,38 @@ constructor(options) {

// Listing Tickets Forms
async list() {
return this.getAll(['ticket_forms']);
/**
* List ticket forms based on the provided query parameters.
*
* @async
* @param {Object} [options] - Optional query parameters.
* @param {boolean} [options.active] - true returns active ticket forms; false returns inactive ticket forms. If not present, returns both.
* @param {boolean} [options.associated_to_brand] - true returns the ticket forms of the brand specified by the url's subdomain.
* @param {boolean} [options.end_user_visible] - true returns ticket forms where end_user_visible; false returns ticket forms that are not end-user visible. If not present, returns both.
* @param {boolean} [options.fallback_to_default] - true returns the default ticket form when the criteria defined by the parameters results in a set without active and end-user visible ticket forms.
*
* @returns {Promise<Array>} An array of ticket forms.
* @throws {Error} Throws an error if there is an issue with the API call.
*
* @example
* const client = createClient({...});
* const activeTicketForms = await client.ticketforms.list({ active: true });
* const allTicketForms = await client.ticketforms.list();
*
* @see {@link https://developer.zendesk.com/rest_api/docs/support#list-ticket-forms}
*/
async list(options = {}) {
return this.getAll(['ticket_forms', options]);
}
//
// Viewing TicketForm
/**
* Retrieve a specific ticket form by its ID.
*
* @async
* @param {number} ticketFormID - The ID of the ticket form to retrieve.
* @returns {Promise<Object>} The requested ticket form.
* @throws {Error} Throws an error if there is an issue with the API call.
* @example
* const client = createClient({...});
* const ticketForm = await client.ticketforms.show(12345);
* @see {@link https://developer.zendesk.com/rest_api/docs/support#show-ticket-form}
*/
async show(ticketFormID) {

@@ -22,8 +56,104 @@ return this.get(['ticket_forms', ticketFormID]);

// Updating TicketForm
/**
* Creates a new Ticket Form.
*
* @async
* @param {Object} ticketForm - The ticket form object to be created.
* @returns {Promise<Object>} - A promise that resolves to the created ticket form.
* @throws {Error} - Throws an error if the API call fails.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_forms/#create-ticket-form}
*
* @example
* const ticketFormData = {
* name: "Snowboard Problem",
* end_user_visible: true,
* // ... other properties ...
* };
* const newTicketForm = await client.ticketforms.create(ticketFormData);
*/
async create(ticketForm) {
return this.post(['ticket_forms'], ticketForm);
}
/**
* Update a specific ticket form by its ID.
*
* @async
* @param {number} ticketFormID - The ID of the ticket form to update.
* @param {Object} ticketForm - The updated ticket form object.
* @returns {Promise<Object>} The updated ticket form.
* @throws {Error} Throws an error if there is an issue with the API call.
* @example
* const client = createClient({...});
* const updatedForm = await client.ticketforms.update(12345, {name: 'Updated Form'});
* @see {@link https://developer.zendesk.com/rest_api/docs/support#update-ticket-form}
*/
async update(ticketFormID, ticketForm) {
return this.put(['ticket_forms', ticketFormID], ticketForm);
}
/**
* Deletes a Ticket Form by its ID.
*
* @async
* @param {number} ticketFormID - The ID of the ticket form to be deleted.
*
* @returns {Promise<void>} - A promise that resolves when the ticket form is deleted.
*
* @throws {Error} - Throws an error if the API call fails.
*
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_forms/#delete-ticket-form}
*
* @example
* await client.ticketforms.delete(12345); // Replace 12345 with the actual ticket form ID.
*/
async delete(ticketFormID) {
return super.delete(['ticket_forms', ticketFormID]);
}
/**
* Clones an already existing Ticket Form by its ID.
*
* @async
* @param {number} ticketFormID - The ID of the ticket form to be cloned.
* @param {boolean} [prependCloneTitle=false] - Whether to prepend the title with "Clone of" or not.
*
* @returns {Promise<Object>} - A promise that resolves to the cloned ticket form details.
*
* @throws {Error} - Throws an error if the API call fails.
*
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_forms/#clone-an-already-existing-ticket-form}
*
* @example
* const clonedForm = await client.ticketforms.clone(12345, true); // Replace 12345 with the actual ticket form ID.
*/
async clone(ticketFormID, prependCloneTitle = false) {
const payload = {
prepend_clone_title: prependCloneTitle,
};
return this.post(['ticket_forms', ticketFormID, 'clone'], payload);
}
/**
* Reorders the specified Ticket Forms based on the provided array of IDs.
*
* @async
* @param {number[]} ticketFormIDs - An array of ticket form IDs in the desired order.
*
* @returns {Promise<Object>} - A promise that resolves to the reordered ticket forms' details.
*
* @throws {Error} - Throws an error if the API call fails.
*
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_forms/#reorder-ticket-forms}
*
* @example
* const reorderedForms = await client.ticketforms.reorder([2, 23, 46, 50]);
*/
async reorder(ticketFormIDs) {
return this.put(['ticket_forms', 'reorder'], {
ticket_form_ids: ticketFormIDs,
});
}
}
exports.TicketForms = TicketForms;
// Tickets.js: Client for the zendesk API.
const {Client} = require('../client');
/**
* TicketImport: A class that provides methods to interact with Zendesk's Ticket Import API.
* This is a thin wrapper around the Zendesk REST API for ticket imports.
*
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_import/}
*/
class TicketImport extends Client {

@@ -10,3 +17,28 @@ constructor(options) {

// Creating Tickets
/**
* Imports a ticket into Zendesk.
*
* @async
* @param {Object} ticket - The ticket data to be imported.
* @param {number} ticket.assignee_id - The ID of the user to assign this ticket to.
* @param {Array} ticket.comments - Array of comments associated with the ticket.
* @param {string} ticket.description - The description of the ticket.
* @param {number} ticket.requester_id - The ID of the user requesting the ticket.
* @param {string} ticket.subject - The subject of the ticket.
* @param {Array} ticket.tags - Array of tags associated with the ticket.
* @returns {Promise<Object>} The response from the Zendesk API.
* @throws {Error} Throws an error if the request to the Zendesk API fails.
* @example
* const ticketData = {
* assignee_id: 19,
* comments: [{ author_id: 19, value: "This is a comment" }],
* description: "A description",
* requester_id: 827,
* subject: "Help",
* tags: ["foo", "bar"]
* };
* const response = await client.ticketimport.import(ticketData);
*
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_import/#ticket-import}
*/
async import(ticket) {

@@ -16,10 +48,60 @@ return this.post(['imports/tickets'], ticket);

// Ticket Audits
// Listing Audits
/**
* @deprecated Use the `list` method from the `TicketAudits` class instead.
* Exports the audits of a specific ticket.
*
* @async
* @param {number} ticketID - The ID of the ticket to fetch the audits for.
* @returns {Promise<Array>} An array of ticket audits from the Zendesk API.
* @throws {Error} Throws an error if the request to the Zendesk API fails.
* @example
* const ticketID = 12345;
* const audits = await client.ticketimport.exportAudit(ticketID);
*
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_import/}
*/
async exportAudit(ticketID) {
return this.getAll(['tickets', ticketID, 'audits']);
}
/**
* Bulk imports multiple tickets into Zendesk.
*
* @async
* @param {Array} tickets - An array containing ticket data to be imported. Accepts up to 100 ticket objects.
* @param {Object} tickets[n] - The nth ticket object in the array.
* @param {number} tickets[n].assignee_id - The ID of the user to assign this ticket to.
* @param {Array} tickets[n].comments - Array of comments associated with the ticket.
* @param {string} tickets[n].description - The description of the ticket.
* @param {number} tickets[n].requester_id - The ID of the user requesting the ticket.
* @param {string} tickets[n].subject - The subject of the ticket.
* @param {Array} tickets[n].tags - Array of tags associated with the ticket.
* @returns {Promise<Object>} The response from the Zendesk API, including a job status object.
* @throws {Error} Throws an error if the request to the Zendesk API fails.
* @example
* const ticketDataArray = [{
* assignee_id: 19,
* comments: [{ author_id: 19, value: "This is a comment" }],
* description: "A description",
* requester_id: 827,
* subject: "Help",
* tags: ["foo", "bar"]
* },
* {
* assignee_id: 20,
* comments: [{ author_id: 20, value: "Another comment" }],
* description: "Another description",
* requester_id: 828,
* subject: "Help Again",
* tags: ["foo2", "bar2"]
* }];
* const response = await client.ticketimport.bulkImport(ticketDataArray);
*
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_import/#ticket-bulk-import}
*/
async bulkImport(tickets) {
return this.post(['imports', 'tickets', 'create_many'], {tickets});
}
}
exports.TicketImport = TicketImport;

@@ -1,4 +0,7 @@

// Ticketmetrics.js: Client for the zendesk API.
const {Client} = require('../client');
/**
* TicketMetrics client for the Zendesk API.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_metrics/}
*/
class TicketMetrics extends Client {

@@ -10,3 +13,13 @@ constructor(options) {

// Listing TicketMetrics for ticket
/**
* Lists the Ticket Metrics for a specific ticket.
* @async
* @param {number} ticketID - The ID of the ticket.
* @returns {Promise<Object>} The ticket metrics data.
* @throws {Error} Throws an error if the request fails.
* @example
* const client = createClient({...});
* const metrics = await client.ticketmetrics.list(12345);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_metrics/#show-ticket-metrics}
*/
async list(ticketID) {

@@ -16,3 +29,12 @@ return this.get(['tickets', ticketID, 'metrics']);

// Listing ALL TicketMetrics
/**
* Lists all Ticket Metrics.
* @async
* @returns {Promise<Object[]>} An array of all ticket metrics data.
* @throws {Error} Throws an error if the request fails.
* @example
* const client = createClient({...});
* const allMetrics = await client.ticketmetrics.listAll();
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_metrics/#list-ticket-metrics}
*/
async listAll() {

@@ -22,3 +44,13 @@ return this.getAll(['ticket_metrics']);

// Viewing A Single TicketMetric
/**
* Shows a specific Ticket Metric by its ID.
* @async
* @param {number} ticketMetricId - The ID of the ticket metric to retrieve.
* @returns {Promise<Object>} The ticket metric data.
* @throws {Error} Throws an error if the request fails.
* @example
* const client = createClient({...});
* const metric = await client.ticketmetrics.show(12345);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_metrics/#show-ticket-metrics}
*/
async show(ticketMetricId) {

@@ -25,0 +57,0 @@ return this.get(['ticket_metrics', ticketMetricId]);

@@ -1,4 +0,8 @@

// Tickets.js: Client for the zendesk API.
// File: tickets.js
const {Client} = require('../client');
/**
* Client for the Zendesk API - Tickets.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/}
*/
class Tickets extends Client {

@@ -21,3 +25,10 @@ constructor(options) {

// Listing Tickets
/**
* List all the tickets.
* @async
* @returns {Promise<Array>} An array of tickets.
* @example
* const tickets = await client.tickets.list();
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets}
*/
async list() {

@@ -27,2 +38,11 @@ return this.getAll(['tickets']);

/**
* List all tickets assigned to a specific user.
* @async
* @param {number} userID - The ID of the user.
* @returns {Promise<Array>} An array of tickets assigned to the user.
* @example
* const assignedTickets = await client.tickets.listAssigned(12345);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets}
*/
async listAssigned(userID) {

@@ -32,2 +52,11 @@ return this.getAll(['users', userID, 'tickets', 'assigned']);

/**
* List all tickets associated with a specific organization.
* @async
* @param {number} orgID - The ID of the organization.
* @returns {Promise<Array>} An array of tickets under the organization.
* @example
* const orgTickets = await client.tickets.listByOrganization(6789);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets}
*/
async listByOrganization(orgID) {

@@ -37,2 +66,11 @@ return this.getAll(['organizations', orgID, 'tickets']);

/**
* List all tickets requested by a specific user.
* @async
* @param {number} userID - The ID of the user.
* @returns {Promise<Array>} An array of tickets requested by the user.
* @example
* const requestedTickets = await client.tickets.listByUserRequested(12345);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets}
*/
async listByUserRequested(userID) {

@@ -42,2 +80,11 @@ return this.getAll(['users', userID, 'tickets', 'requested']);

/**
* List all tickets where a specific user is CC'd.
* @async
* @param {number} userID - The ID of the user.
* @returns {Promise<Array>} An array of tickets where the user is CC'd.
* @example
* const ccdTickets = await client.tickets.listByUserCCD(12345);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets}
*/
async listByUserCCD(userID) {

@@ -47,2 +94,12 @@ return this.getAll(['users', userID, 'tickets', 'ccd']);

/**
* List tickets based on a specific filter.
* @async
* @param {string} type - Type of filter.
* @param {string|number} value - Value for the filter.
* @returns {Promise<Array>} An array of tickets matching the filter.
* @example
* const filteredTickets = await client.tickets.listWithFilter('status', 'open');
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets}
*/
async listWithFilter(type, value) {

@@ -52,2 +109,10 @@ return this.getAll(['tickets', {[type]: value}]);

/**
* List recently viewed tickets by the requesting agent.
* @async
* @returns {Promise<Array>} An array of recently viewed tickets.
* @example
* const recentTickets = await client.tickets.listRecent();
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets}
*/
async listRecent() {

@@ -57,24 +122,80 @@ return this.getAll(['tickets', 'recent']);

async listCollaborators(ticketID) {
return this.getAll(['tickets', ticketID, 'collaborators']);
/**
* List collaborators of a specific ticket.
* @async
* @param {number} ticketId - The ID of the ticket.
* @returns {Promise<Array>} An array of collaborators for the ticket.
* @example
* const collaborators = await client.tickets.listCollaborators(7890);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets}
*/
async listCollaborators(ticketId) {
return this.getAll(['tickets', ticketId, 'collaborators']);
}
async listIncidents(ticketID) {
return this.getAll(['tickets', ticketID, 'incidents']);
/**
* List incidents related to a specific ticket.
* @async
* @param {number} ticketId - The ID of the ticket.
* @returns {Promise<Array>} An array of incidents related to the ticket.
* @example
* const incidents = await client.tickets.listIncidents(7890);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets}
*/
async listIncidents(ticketId) {
return this.getAll(['tickets', ticketId, 'incidents']);
}
async listMetrics(ticketID) {
return this.get(['tickets', ticketID, 'metrics']);
/**
* Retrieve metrics for a specific ticket.
* @async
* @param {number} ticketId - The ID of the ticket.
* @returns {Promise<Object>} Metrics details for the ticket.
* @example
* const metrics = await client.tickets.listMetrics(7890);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#list-tickets}
*/
async listMetrics(ticketId) {
return this.get(['tickets', ticketId, 'metrics']);
}
// Viewing Tickets
async show(ticketID) {
return this.get(['tickets', ticketID]);
/**
* Retrieve a specific ticket by its ID.
* @async
* @param {number} ticketId - The ID of the ticket.
* @returns {Promise<Object>} Details of the ticket.
* @throws {Error} If the ticket ID is not provided or invalid.
* @example
* const ticket = await client.tickets.show(12345);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#show-ticket}
*/
async show(ticketId) {
return this.get(['tickets', ticketId]);
}
async showMany(ticket_ids) {
return this.get(['tickets', 'show_many', '?ids=' + ticket_ids.toString()]);
/**
* Retrieve details for multiple tickets based on their IDs.
*
* @async
* @param {Array<number>} ticketIds - An array of ticket IDs to fetch.
* @returns {Promise<Array>} An array of ticket details.
* @example
* const ticketsDetails = await client.tickets.showMany([123, 456, 789]);
*
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#show-multiple-tickets}
*/
async showMany(ticketIds) {
return this.get(['tickets', 'show_many', {ids: ticketIds}]);
}
// Creating Tickets
/**
* Create a new ticket.
* @async
* @param {Object} ticket - Details of the ticket to be created.
* @returns {Promise<Object>} The created ticket details.
* @throws {Error} If the ticket details are not provided or invalid.
* @example
* const newTicket = await client.tickets.create({ subject: 'New ticket', description: 'Ticket description' });
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#create-ticket}
*/
async create(ticket) {

@@ -84,2 +205,21 @@ return this.post(['tickets'], ticket);

/**
* Create multiple new tickets.
*
* @async
* @param {Array<Object>} tickets - An array of ticket objects to create.
* @returns {Promise<Array<Object>>} A promise that resolves to an array of created ticket objects.
*
* @throws {Error} If the provided `tickets` is not an array or is empty.
*
* @example
* // Create multiple new tickets
* const newTickets = [
* { subject: 'Ticket 1', description: 'Description 1' },
* { subject: 'Ticket 2', description: 'Description 2' },
* ];
* const createdTickets = await client.tickets.createMany(newTickets);
*
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#create-multiple-tickets}
*/
async createMany(tickets) {

@@ -89,34 +229,137 @@ return this.post(['tickets', 'create_many'], tickets);

// Updating Tickets
async update(ticketID, ticket) {
return this.put(['tickets', ticketID], ticket);
/**
* Update an existing ticket by its ID.
*
* @async
* @param {number} ticketId - The ID of the ticket to update.
* @param {Object} ticket - The updated ticket data as an object.
* @returns {Promise<Object>} A promise that resolves to the updated ticket object.
*
* @throws {Error} If `ticketId` is not a number or if `ticket` is not an object.
*
* @example
* // Update an existing ticket
* const updatedTicketData = {
* subject: 'Updated Ticket Subject',
* description: 'Updated Ticket Description',
* };
* const updatedTicket = await client.tickets.update(123, updatedTicketData);
*
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#update-ticket}
*/
async update(ticketId, ticket) {
return this.put(['tickets', ticketId], ticket);
}
async updateMany(ticket_ids, ticket) {
return this.put(
['tickets', 'update_many', '?ids=' + ticket_ids.toString()],
ticket,
);
/**
* Update multiple tickets by their IDs.
*
* @async
* @param {Array<number>} ticketIds - An array of ticket IDs to update.
* @param {Object} ticket - The updated ticket data as an object.
* @returns {Promise<Object>} A promise that resolves to the updated ticket object.
*
* @throws {Error} If `ticketIds` is not an array of numbers or if `ticket` is not an object.
*
* @example
* // Update multiple tickets by their IDs
* const ticketIdsToUpdate = [123, 456, 789];
* const updatedTicketData = {
* status: 'solved',
* priority: 'high',
* };
* const updatedTickets = await client.tickets.updateMany(ticketIdsToUpdate, updatedTicketData);
*
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#update-many-tickets}
*/
async updateMany(ticketIds, ticket) {
return this.put(['tickets', 'update_many', {ids: ticketIds}], ticket);
}
// Deleting Tickets
async delete(ticketID) {
return super.delete(['tickets', ticketID]);
/**
* Delete a ticket by its ID.
*
* @async
* @param {number} ticketId - The ID of the ticket to delete.
* @returns {Promise<void>} A promise that resolves when the ticket is successfully deleted.
*
* @throws {Error} If `ticketId` is not a number or is not provided.
*
* @example
* // Delete a ticket by its ID
* const ticketIdToDelete = 123;
* await client.tickets.delete(ticketIdToDelete);
*
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#delete-ticket}
*/
async delete(ticketId) {
return super.delete(['tickets', ticketId]);
}
async deleteMany(ticket_ids) {
return super.delete([
'tickets',
'destroy_many',
'?ids=' + ticket_ids.toString(),
]);
/**
* Delete multiple tickets by their IDs.
*
* @async
* @param {Array<number>} ticketIds - An array of ticket IDs to delete.
* @returns {Promise<void>} A promise that resolves when the tickets are successfully deleted.
*
* @throws {Error} If `ticketIds` is not an array of valid ticket IDs.
*
* @example
* // Delete multiple tickets by their IDs
* const ticketIdsToDelete = [123, 456, 789];
* await client.tickets.deleteMany(ticketIdsToDelete);
*
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#bulk-delete-tickets}
*/
async deleteMany(ticketIds) {
return super.delete(['tickets', 'destroy_many', {ids: ticketIds}]);
}
// Merging tickets
async merge(ticketID, mergedTicket) {
return this.post(['tickets', ticketID, 'merge'], mergedTicket);
/**
* Merge a ticket with another ticket.
*
* @async
* @param {number} ticketId - The ID of the ticket to be merged.
* @param {Object} mergedTicket - The ticket object representing the ticket to merge with.
* @returns {Promise<Object>} A promise that resolves with the merged ticket object.
*
* @throws {Error} If `ticketId` is not a valid ticket ID or `mergedTicket` is not a valid ticket object.
*
* @example
* // Merge a ticket with another ticket
* const sourceTicketId = 123;
* const targetTicket = {
* subject: 'Merged Ticket',
* description: 'This is the merged ticket description.',
* // ...other ticket properties
* };
* const mergedTicket = await client.tickets.merge(sourceTicketId, targetTicket);
*
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#merge-tickets}
*/
async merge(ticketId, mergedTicket) {
return this.post(['tickets', ticketId, 'merge'], mergedTicket);
}
// *** Ticket export (max 1000 tickets per request in 5 min intrvals)
// Ticket Export
/**
* **DEPRECATED**: Use the `TicketExport` class method `export` instead.
*
* Export tickets based on a specified start time.
*
* @deprecated Use `TicketExport.export(startTime)` method instead.
*
* @async
* @param {string} startTime - The start time for exporting tickets.
* @returns {Promise<Object>} A promise that resolves with the exported tickets.
*
* @throws {Error} If `startTime` is not a valid string.
*
* @example
* // Export tickets based on a start time
* const startTime = '2023-01-01T00:00:00Z';
* const exportedTickets = await client.tickets.export(startTime);
*
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#ticket-export}
*/
async export(startTime) {

@@ -126,3 +369,22 @@ return this.get(['exports', 'tickets', {start_time: startTime}]);

// Ticket Export Sample (max 50 tickets per request)
/**
* **DEPRECATED**: Use the `TicketExport` class method `sample` instead.
*
* Export a sample of tickets based on a specified start time.
*
* @deprecated Use `TicketExport.sample(startTime)` method instead.
*
* @async
* @param {string} startTime - The start time for exporting the sample of tickets.
* @returns {Promise<Object>} A promise that resolves with the exported sample of tickets.
*
* @throws {Error} If `startTime` is not a valid string.
*
* @example
* // Export a sample of tickets based on a start time
* const startTime = '2023-01-01T00:00:00Z';
* const exportedSample = await client.tickets.exportSample(startTime);
*
* @see {@link https://developer.zendesk.com/api-reference/ticketing/ticket-management/incremental_exports/#incremental-sample-export}
*/
async exportSample(startTime) {

@@ -132,3 +394,22 @@ return this.get(['exports', 'tickets', 'sample', {start_time: startTime}]);

// New Incremental Ticket Export
/**
* **DEPRECATED**: Use the `TicketExport` class method `export` instead.
*
* Export incremental tickets based on a specified start time.
*
* @deprecated Use `TicketExport.export(startTime)` method instead.
*
* @async
* @param {string} startTime - The start time for exporting incremental tickets.
* @returns {Promise<Array>} A promise that resolves with an array of exported incremental tickets.
*
* @throws {Error} If `startTime` is not a valid string.
*
* @example
* // Export incremental tickets based on a start time
* const startTime = '2023-01-01T00:00:00Z';
* const incrementalTickets = await client.tickets.incremental(startTime);
*
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#ticket-export-incremental}
*/
async incremental(startTime) {

@@ -138,3 +419,24 @@ return this.getAll(['incremental', 'tickets', {start_time: startTime}]);

// New Incremental Ticket Export with include
/**
* **DEPRECATED**: Use the `TicketExport` class method `exportWithInclude` instead.
*
* Export incremental tickets based on a specified start time and optional include parameters.
*
* @deprecated Use `TicketExport.exportWithInclude(startTime, include)` method instead.
*
* @async
* @param {string} startTime - The start time for exporting incremental tickets.
* @param {string} include - Optional parameters to include in the export.
* @returns {Promise<Array>} A promise that resolves with an array of exported incremental tickets.
*
* @throws {Error} If `startTime` is not a valid string.
*
* @example
* // Export incremental tickets based on a start time with optional include parameters
* const startTime = '2023-01-01T00:00:00Z';
* const include = 'users,groups';
* const incrementalTickets = await client.tickets.incrementalInclude(startTime, include);
*
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#ticket-export-incremental-include}
*/
async incrementalInclude(startTime, include) {

@@ -148,3 +450,22 @@ return this.getAll([

// New Incremental Ticket Export Sample
/**
* **DEPRECATED**: Use the `TicketExport` class method `sample` instead.
*
* Export a sample of incremental tickets based on a specified start time.
*
* @deprecated Use `TicketExport.sample(startTime)` method instead.
*
* @async
* @param {string} startTime - The start time for exporting the sample of incremental tickets.
* @returns {Promise<Array>} A promise that resolves with an array of exported incremental tickets.
*
* @throws {Error} If `startTime` is not a valid string.
*
* @example
* // Export a sample of incremental tickets based on a start time
* const startTime = '2023-01-01T00:00:00Z';
* const incrementalSampleTickets = await client.tickets.incrementalSample(startTime);
*
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#ticket-export-incremental-sample}
*/
async incrementalSample(startTime) {

@@ -159,24 +480,85 @@ return this.get([

// Listing Ticket Comments
async getComments(ticketID) {
return this.getAll(['tickets', ticketID, 'comments']);
/**
* Retrieve comments associated with a specific ticket.
*
* @async
* @param {number} ticketId - The ID of the ticket to retrieve comments for.
* @returns {Promise<Array>} A promise that resolves with an array of comments associated with the ticket.
*
* @throws {Error} If `ticketId` is not a valid number.
*
* @example
* // Retrieve comments for a specific ticket
* const ticketId = 12345;
* const comments = await client.tickets.getComments(ticketId);
*
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/ticket_comments/}
*/
async getComments(ticketId) {
return this.getAll(['tickets', ticketId, 'comments']);
}
// *** Ticket Audits
// Listing Audits
async exportAudit(ticketID) {
return this.getAll(['tickets', ticketID, 'audits']);
/**
* Retrieve audits associated with a specific ticket. (Deprecated: Use TicketAudits class list method instead)
*
* @deprecated Use the `TicketAudits` class `list` method instead.
* @async
* @param {number} ticketId - The ID of the ticket to retrieve audits for.
* @returns {Promise<Array>} A promise that resolves with an array of audits associated with the ticket.
*
* @throws {Error} If `ticketId` is not a valid number.
*
* @example
* // Retrieve audits for a specific ticket (deprecated)
* const ticketId = 12345;
* const audits = await client.tickets.exportAudit(ticketId);
*
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#listing-ticket-audits}
*/
async exportAudit(ticketId) {
return this.getAll(['tickets', ticketId, 'audits']);
}
// *** Ticket Tags
// Add Tags to Ticket
async addTags(ticketID, tags) {
return this.requestAll('PUT', ['tickets', ticketID, 'tags'], tags); // TODO: putAll
/**
* Add tags to a specific ticket.
*
* @async
* @param {number} ticketId - The ID of the ticket to add tags to.
* @param {Array<string>} tags - An array of tags to add to the ticket.
* @returns {Promise<void>} A promise that resolves when the tags are successfully added to the ticket.
*
* @throws {Error} If `ticketId` is not a valid number or `tags` is not an array of strings.
*
* @example
* // Add tags to a specific ticket
* const ticketId = 12345;
* const tags = ['tag1', 'tag2'];
* await client.tickets.addTags(ticketId, tags);
*
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#updating-tag-lists}
*/
async addTags(ticketId, tags) {
return this.requestAll('PUT', ['tickets', ticketId, 'tags'], tags);
}
// Replace Tags to Ticket
async updateTags(ticketID, tags) {
return this.requestAll('POST', ['tickets', ticketID, 'tags'], tags); // TODO: postAll
/**
* Replace tags on a specific ticket with new tags.
*
* @async
* @param {number} ticketId - The ID of the ticket to replace tags on.
* @param {Array<string>} tags - An array of new tags to replace the existing tags on the ticket.
* @returns {Promise<void>} A promise that resolves when the tags are successfully replaced on the ticket.
*
* @throws {Error} If `ticketId` is not a valid number or `tags` is not an array of strings.
*
* @example
* // Replace tags on a specific ticket
* const ticketId = 12345;
* const newTags = ['newTag1', 'newTag2'];
* await client.tickets.updateTags(ticketId, newTags);
*
* @see {@link https://developer.zendesk.com/api-reference/ticketing/tickets/tickets/#updating-tag-lists}
*/
async updateTags(ticketId, tags) {
return this.requestAll('POST', ['tickets', ticketId, 'tags'], tags);
}

@@ -183,0 +565,0 @@ }

// Triggers.js: Client for the zendesk API.
const {Client} = require('../client');
/**
* Client for interacting with the Zendesk Triggers API.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/}
*/
class Triggers extends Client {

@@ -10,8 +14,23 @@ constructor(options) {

// Searching Triggers
/**
* Searches for triggers based on the provided search term.
* @async
* @param {string} searchTerm - The term to search for.
* @returns {Promise<Object>} The search results.
* @throws {Error} Throws an error if the request fails.
* @example const results = await client.triggers.search('exampleTerm');
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/#search-triggers}
*/
async search(searchTerm) {
return this.request('GET', ['triggers', 'search', {query: searchTerm}]);
return this.get(['triggers', 'search', {query: searchTerm}]);
}
// Trigger Definitions
/**
* Retrieves trigger definitions.
* @async
* @returns {Promise<Object>} The trigger definitions.
* @throws {Error} Throws an error if the request fails.
* @example const definitions = await client.triggers.definitions();
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/#list-trigger-action-and-condition-definitions}
*/
async definitions() {

@@ -21,7 +40,29 @@ return this.getAll(['triggers', 'definitions']);

// Listing Triggers
async list() {
return this.getAll(['triggers']);
/**
* Lists all triggers, with optional filtering and sorting.
* @async
* @param {Object} [options] - Optional parameters for listing triggers.
* @param {boolean} [options.active] - Filter by active triggers if true or inactive triggers if false.
* @param {string} [options.category_id] - Filter triggers by category ID.
* @param {string} [options.sort_by] - Possible values are "alphabetical", "created_at", "updated_at", "usage_1h", "usage_24h", or "usage_7d". Defaults to "position".
* @param {string} [options.sort_order] - One of "asc" or "desc". Defaults to "asc" for alphabetical and position sort, "desc" for all others.
* @returns {Promise<Object>} A list of all triggers.
* @throws {Error} Throws an error if the request fails.
* @example
* const triggers = await client.triggers.list();
* const activeTriggers = await client.triggers.list({ active: true });
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/#list-triggers}
*/
async list(options = {}) {
return this.getAll(['triggers', options]);
}
/**
* Lists all active triggers.
* @async
* @returns {Promise<Object>} A list of all active triggers.
* @throws {Error} Throws an error if the request fails.
* @example const activeTriggers = await client.triggers.listActive();
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/#list-active-triggers}
*/
async listActive() {

@@ -31,3 +72,11 @@ return this.getAll(['triggers', 'active']);

// Viewing Triggers
/**
* Retrieves details of a specific trigger.
* @async
* @param {number} triggerID - The ID of the trigger.
* @returns {Promise<Object>} Details of the specified trigger.
* @throws {Error} Throws an error if the request fails.
* @example const triggerDetails = await client.triggers.show(12345);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/#show-trigger}
*/
async show(triggerID) {

@@ -37,3 +86,17 @@ return this.get(['triggers', triggerID]);

// Creating Triggers
/**
* Creates a new trigger.
* @async
* @param {Object} trigger - The trigger object to be created.
* @returns {Promise<Object>} The created trigger.
* @throws {Error} Throws an error if the request fails.
* @example
* const newTrigger = {
* title: "Example Trigger",
* conditions: {...},
* actions: [...]
* };
* const response = await client.triggers.create(newTrigger);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/#create-trigger}
*/
async create(trigger) {

@@ -43,3 +106,18 @@ return this.post(['triggers'], trigger);

// Updating Triggers
/**
* Updates an existing trigger.
* @async
* @param {number} triggerID - The ID of the trigger to be updated.
* @param {Object} trigger - The updated trigger object.
* @returns {Promise<Object>} The updated trigger.
* @throws {Error} Throws an error if the request fails.
* @example
* const updatedTrigger = {
* title: "Updated Trigger",
* conditions: {...},
* actions: [...]
* };
* const response = await client.triggers.update(12345, updatedTrigger);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/#update-trigger}
*/
async update(triggerID, trigger) {

@@ -49,3 +127,29 @@ return this.put(['triggers', triggerID], trigger);

// Deleting Triggers
/**
* Updates multiple triggers.
* @async
* @param {Array<Object>} triggers - An array of trigger objects to be updated.
* @returns {Promise<Object>} The response from the update request.
* @throws {Error} Throws an error if the request fails.
* @example
* const triggersToUpdate = [
* {id: 12345, position: 3},
* {id: 67890, position: 5}
* ];
* const response = await client.triggers.updateMany(triggersToUpdate);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/#update-many-triggers}
*/
async updateMany(triggers) {
return this.put(['triggers', 'update_many'], {triggers});
}
/**
* Deletes a specified trigger.
* @async
* @param {number} triggerID - The ID of the trigger to be deleted.
* @returns {Promise<Object>} The response from the deletion request.
* @throws {Error} Throws an error if the request fails.
* @example const response = await client.triggers.delete(12345);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/#delete-trigger}
*/
async delete(triggerID) {

@@ -55,13 +159,64 @@ return super.delete(['triggers', triggerID]);

// Reorder Audits
/**
* Deletes multiple triggers based on their IDs.
* @async
* @param {Array<number>} triggerIDs - An array of trigger IDs to be deleted.
* @returns {Promise<Object>} The response from the deletion request.
* @throws {Error} Throws an error if the request fails.
* @example const response = await client.triggers.bulkDelete([12345, 67890]);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/#bulk-delete-triggers}
*/
async bulkDelete(triggerIDs) {
return this.delete([
'triggers',
'destroy_many',
{
ids: triggerIDs,
},
]);
}
/**
* Reorders the triggers based on the provided trigger IDs.
* @async
* @param {Array<number>} triggerIDs - An array of trigger IDs in the desired order.
* @returns {Promise<Object>} The response from the reorder request.
* @throws {Error} Throws an error if the request fails.
* @example const response = await client.triggers.reorder([12345, 67890, 11223]);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/#reorder-triggers}
*/
async reorder(triggerIDs) {
return this.requestAll(
// TODO: putAll
'PUT',
['triggers', 'reorder'],
{trigger_ids: triggerIDs},
);
return this.requestAll('PUT', ['triggers', 'reorder'], {
trigger_ids: triggerIDs,
});
}
/**
* Lists the revisions associated with a trigger.
* @async
* @param {number} triggerID - The ID of the trigger.
* @returns {Promise<Object>} A list of revisions for the specified trigger.
* @throws {Error} Throws an error if the request fails.
* @example const revisions = await client.triggers.listRevisions(12345);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/#list-trigger-revisions}
*/
async listRevisions(triggerID) {
return this.getAll(['triggers', triggerID, 'revisions']);
}
/**
* Fetches a specific revision associated with a trigger.
* @async
* @param {number} triggerID - The ID of the trigger.
* @param {number} revisionID - The ID of the revision.
* @returns {Promise<Object>} Details of the specified trigger revision.
* @throws {Error} Throws an error if the request fails.
* @example const revisionDetails = await client.triggers.showRevision(12345, 67890);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/triggers/#show-trigger-revision}
*/
async showRevision(triggerID, revisionID) {
return this.get(['triggers', triggerID, 'revisions', revisionID]);
}
}
exports.Triggers = Triggers;

@@ -1,4 +0,7 @@

// Userfields.js: Client for the zendesk API.
const {Client} = require('../client');
/**
* Represents the UserFields client for the Zendesk API.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/user_fields/}
*/
class UserFields extends Client {

@@ -10,3 +13,9 @@ constructor(options) {

// Listing UserFields
/**
* Lists all custom user fields in the account.
* @async
* @returns {Promise<Object>} The list of user fields.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/user_fields/#list-user-fields}
* @example const userFields = await client.userfields.list();
*/
async list() {

@@ -16,3 +25,10 @@ return this.getAll(['user_fields']);

// Viewing UserFields
/**
* Retrieves details of a specific user field.
* @async
* @param {number} userFieldID - The ID of the user field.
* @returns {Promise<Object>} Details of the user field.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/user_fields/#show-user-field}
* @example const userField = await client.userfields.show(12345);
*/
async show(userFieldID) {

@@ -22,3 +38,10 @@ return this.get(['user_fields', userFieldID]);

// Creating UserFields
/**
* Creates a new user field.
* @async
* @param {Object} userField - The user field data.
* @returns {Promise<Object>} The created user field.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/user_fields/#create-user-field}
* @example const newUserField = await client.userfields.create({ type: 'text', title: 'Support description' });
*/
async create(userField) {

@@ -28,3 +51,11 @@ return this.post(['user_fields'], userField);

// Updating UserFields
/**
* Updates an existing user field.
* @async
* @param {number} userFieldID - The ID of the user field.
* @param {Object} userField - The updated user field data.
* @returns {Promise<Object>} The updated user field.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/user_fields/#update-user-field}
* @example await client.userfields.update(12345, { title: 'Updated Support description' });
*/
async update(userFieldID, userField) {

@@ -34,8 +65,86 @@ return this.put(['user_fields', userFieldID], userField);

// Deleting UserFields
/**
* Deletes a user field.
* @async
* @param {number} userFieldID - The ID of the user field.
* @returns {Promise<Object>} The response from the delete operation.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/user_fields/#delete-user-field}
* @example await client.userfields.delete(12345);
*/
async delete(userFieldID) {
return super.delete(['user_fields', userFieldID]);
}
/**
* Reorders the user fields based on the provided IDs.
* @async
* @param {Array<number>} userFieldIDs - An array of user field IDs in the desired order.
* @returns {Promise<Object>} The reordered user fields.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/user_fields/#reorder-user-field}
* @example await client.userfields.reorder([3, 4]);
*/
async reorder(userFieldIDs) {
return this.put(['user_fields', 'reorder'], {user_field_ids: userFieldIDs});
}
/**
* Lists options for a specific dropdown user field.
* @async
* @param {number} userFieldID - The ID of the user field.
* @returns {Promise<Object>} The list of user field options.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/user_fields/#list-user-field-options}
* @example const options = await client.userfields.listOptions(12345);
*/
async listOptions(userFieldID) {
return this.get(['user_fields', userFieldID, 'options']);
}
/**
* Retrieves details of a specific user field option.
* @async
* @param {number} userFieldID - The ID of the user field.
* @param {number} userFieldOptionID - The ID of the user field option.
* @returns {Promise<Object>} Details of the user field option.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/user_fields/#show-a-user-field-option}
* @example const option = await client.userfields.showOption(12345, 67890);
*/
async showOption(userFieldID, userFieldOptionID) {
return this.get(['user_fields', userFieldID, 'options', userFieldOptionID]);
}
/**
* Creates or updates a user field option.
* @async
* @param {number} userFieldID - The ID of the user field.
* @param {Object} customFieldOption - The user field option data.
* @returns {Promise<Object>} The created or updated user field option.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/user_fields/#create-or-update-a-user-field-option}
* @example await client.userfields.createOrUpdateOption(12345, { name: 'Grapes', position: 2, value: 'grape' });
*/
async createOrUpdateOption(userFieldID, customFieldOption) {
return this.post(
['user_fields', userFieldID, 'options'],
customFieldOption,
);
}
/**
* Deletes a user field option.
* @async
* @param {number} userFieldID - The ID of the user field.
* @param {number} userFieldOptionID - The ID of the user field option.
* @returns {Promise<Object>} The response from the delete operation.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/user_fields/#delete-user-field-option}
* @example await client.userfields.deleteOption(12345, 67890);
*/
async deleteOption(userFieldID, userFieldOptionID) {
return super.delete([
'user_fields',
userFieldID,
'options',
userFieldOptionID,
]);
}
}
exports.UserFields = UserFields;

@@ -1,4 +0,7 @@

// UserIdentities.js: Client for the zendesk API.
const {Client} = require('../client');
/**
* Client for interacting with the Zendesk User Identities API.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/user_identities/}
*/
class UserIdentities extends Client {

@@ -10,37 +13,83 @@ constructor(options) {

// Listing UserIdentities
async list(userID) {
return this.getAll(['users', userID, 'identities']);
/**
* List all identities for a given user.
* @async
* @param {number} userId - The ID of the user.
* @returns {Promise<Object[]>} A list of user identities.
* @throws {Error} Throws an error if the request fails.
* @example const identities = await client.useridentities.list(12345);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/user_identities/#list-identities}
*/
async list(userId) {
return this.getAll(['users', userId, 'identities']);
}
// Viewing UserIdentities
async show(userID, userIdentityID) {
return this.get(['users', userID, 'identities', userIdentityID]);
/**
* Show a specific identity for a given user.
* @async
* @param {number} userId - The ID of the user.
* @param {number} userIdentityId - The ID of the user identity to show.
* @returns {Promise<Object>} The user identity details.
* @throws {Error} Throws an error if the request fails.
* @example const identity = await client.useridentities.show(12345, 67890);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/user_identities/#show-identity}
*/
async show(userId, userIdentityId) {
return this.get(['users', userId, 'identities', userIdentityId]);
}
// Creating UserIdentities
async create(userID, userIDentity) {
/**
* Create a new identity for a given user.
* @async
* @param {number} userId - The ID of the user.
* @param {Object} userIdentity - The user identity details to create.
* @returns {Promise<Object>} The created user identity.
* @throws {Error} Throws an error if the request fails.
* @example const newIdentity = await client.useridentities.create(12345, {type: 'email', value: 'test@example.com'});
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/user_identities/#create-identity}
*/
async create(userId, userIdentity) {
if (
userIDentity &&
typeof userIDentity === 'object' &&
!Array.isArray(userIDentity) &&
!Object.hasOwn(userIDentity, 'identity')
userIdentity &&
typeof userIdentity === 'object' &&
!Array.isArray(userIdentity) &&
!Object.hasOwn(userIdentity, 'identity')
) {
userIDentity = {identity: userIDentity};
userIdentity = {identity: userIdentity};
}
return this.post(['users', userID, 'identities'], userIDentity);
return this.post(['users', userId, 'identities'], userIdentity);
}
// Updating UserIdentities
async update(userID, userIdentityID, identity) {
return this.put(['users', userID, 'identities', userIdentityID], identity);
/**
* Update a specific identity for a given user.
* @async
* @param {number} userId - The ID of the user.
* @param {number} userIdentityId - The ID of the user identity to update.
* @param {Object} identity - The updated identity details.
* @returns {Promise<Object>} The updated user identity.
* @throws {Error} Throws an error if the request fails.
* @example const updatedIdentity = await client.useridentities.update(12345, 67890, {verified: true});
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/user_identities/#update-identity}
*/
async update(userId, userIdentityId, identity) {
return this.put(['users', userId, 'identities', userIdentityId], identity);
}
async makePrimary(userID, userIdentityID) {
/**
* Make a specific identity the primary identity for a given user.
* @async
* @param {number} userId - The ID of the user.
* @param {number} userIdentityId - The ID of the user identity to make primary.
* @returns {Promise<Object>} The updated user identity.
* @throws {Error} Throws an error if the request fails.
* @example await client.useridentities.makePrimary(12345, 67890);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/user_identities/#make-identity-primary}
*/
async makePrimary(userId, userIdentityId) {
return this.put([
'users',
userID,
userId,
'identities',
userIdentityID,
userIdentityId,
'make_primary',

@@ -50,12 +99,32 @@ ]);

async verify(userID, userIdentityID) {
return this.put(['users', userID, 'identities', userIdentityID, 'verify']);
/**
* Verify a specific identity for a given user.
* @async
* @param {number} userId - The ID of the user.
* @param {number} userIdentityId - The ID of the user identity to verify.
* @returns {Promise<Object>} The verified user identity.
* @throws {Error} Throws an error if the request fails.
* @example await client.useridentities.verify(12345, 67890);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/user_identities/#verify-identity}
*/
async verify(userId, userIdentityId) {
return this.put(['users', userId, 'identities', userIdentityId, 'verify']);
}
async requestVerification(userID, userIdentityID) {
/**
* Request verification for a specific identity for a given user.
* @async
* @param {number} userId - The ID of the user.
* @param {number} userIdentityId - The ID of the user identity to request verification for.
* @returns {Promise<Object>} The user identity verification request details.
* @throws {Error} Throws an error if the request fails.
* @example await client.useridentities.requestVerification(12345, 67890);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/user_identities/#request-user-verification}
*/
async requestVerification(userId, userIdentityId) {
return this.put([
'users',
userID,
userId,
'identities',
userIdentityID,
userIdentityId,
'request_verification',

@@ -65,5 +134,14 @@ ]);

// Deleting UserIdentities
async delete(userID, userIdentityID) {
return super.delete(['users', userID, 'identities', userIdentityID]);
/**
* Delete a specific identity for a given user.
* @async
* @param {number} userId - The ID of the user.
* @param {number} userIdentityId - The ID of the user identity to delete.
* @returns {Promise<void>}
* @throws {Error} Throws an error if the request fails.
* @example await client.useridentities.delete(12345, 67890);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/user_identities/#delete-identity}
*/
async delete(userId, userIdentityId) {
return super.delete(['users', userId, 'identities', userIdentityId]);
}

@@ -70,0 +148,0 @@ }

@@ -1,5 +0,8 @@

// Users.js: Client for the zendesk API.
// File: users.js
const {Client} = require('../client');
/**
* Client for the Zendesk Users API.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/users/}
*/
class Users extends Client {

@@ -28,4 +31,10 @@ constructor(options) {

// Users
/**
* Authenticates the current user.
* @async
* @returns {Promise<Object>} The authenticated user's details.
* @example
* const user = await client.users.auth();
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/users/#show-the-currently-authenticated-user}
*/
async auth() {

@@ -35,2 +44,10 @@ return this.get(['users', 'me']);

/**
* Lists all users.
* @async
* @returns {Promise<Array<Object>>} An array of user objects.
* @example
* const users = await client.users.list();
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/users/#list-users}
*/
async list() {

@@ -40,2 +57,12 @@ return this.getAll(['users']);

/**
* Lists users with a specific filter.
* @async
* @param {string} type - The type of filter.
* @param {string|number} value - The value for the filter.
* @returns {Promise<Array<Object>>} An array of user objects.
* @example
* const users = await client.users.listWithFilter('type', 'value');
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/users/#list-users}
*/
async listWithFilter(type, value) {

@@ -45,2 +72,11 @@ return this.getAll(['users', {[type]: value}]);

/**
* Lists users by group ID.
* @async
* @param {number} id - The ID of the group.
* @returns {Promise<Array<Object>>} An array of user objects.
* @example
* const users = await client.users.listByGroup(12345);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/users/#list-users}
*/
async listByGroup(id) {

@@ -50,2 +86,11 @@ return this.getAll(['groups', id, 'users']);

/**
* Lists users by organization ID.
* @async
* @param {number} id - The ID of the organization.
* @returns {Promise<Array<Object>>} An array of user objects.
* @example
* const users = await client.users.listByOrganization(12345);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/users/#list-users}
*/
async listByOrganization(id) {

@@ -55,2 +100,11 @@ return this.getAll(['organizations', id, 'users']);

/**
* Shows details of a user by ID.
* @async
* @param {number} id - The ID of the user.
* @returns {Promise<Object>} The user's details.
* @example
* const user = await client.users.show(12345);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/users/#show-user}
*/
async show(id) {

@@ -60,6 +114,24 @@ return this.get(['users', id]);

/**
* Shows details of multiple users by their IDs.
* @async
* @param {Array<number>} userIds - An array of user IDs.
* @returns {Promise<Array<Object>>} An array of user details.
* @example
* const users = await client.users.showMany([12345, 67890]);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/users/#show-many-users}
*/
async showMany(userIds) {
return this.get(['users', 'show_many', '?ids=' + userIds.toString()]);
return this.get(['users', 'show_many', {ids: userIds}]);
}
/**
* Creates a new user.
* @async
* @param {Object} user - The user details.
* @returns {Promise<Object>} The created user's details.
* @example
* const newUser = await client.users.create({name: 'John Doe', email: 'john@example.com'});
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/users/#create-user}
*/
async create(user) {

@@ -69,2 +141,11 @@ return this.post(['users'], user);

/**
* Creates multiple users.
* @async
* @param {Array<Object>} users - An array of user details.
* @returns {Promise<Array<Object>>} An array of created user details.
* @example
* const newUsers = await client.users.createMany([{name: 'John Doe', email: 'john@example.com'}, {name: 'Jane Smith', email: 'jane@example.com'}]);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/users/#create-many-users}
*/
async createMany(users) {

@@ -74,2 +155,11 @@ return this.post(['users', 'create_many'], users);

/**
* Creates or updates a user.
* @async
* @param {Object} user - The user details.
* @returns {Promise<Object>} The created or updated user's details.
* @example
* const user = await client.users.createOrUpdate({name: 'John Doe', email: 'john@example.com'});
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/users/#create-or-update-user}
*/
async createOrUpdate(user) {

@@ -79,2 +169,11 @@ return this.post(['users', 'create_or_update'], user);

/**
* Creates or updates multiple users.
* @async
* @param {Array<Object>} users - An array of user details.
* @returns {Promise<Array<Object>>} An array of created or updated user details.
* @example
* const users = await client.users.createOrUpdateMany([{name: 'John Doe', email: 'john@example.com'}, {name: 'Jane Smith', email: 'jane@example.com'}]);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/users/#create-or-update-many-users}
*/
async createOrUpdateMany(users) {

@@ -84,2 +183,12 @@ return this.post(['users', 'create_or_update_many'], users);

/**
* Updates a user by ID.
* @async
* @param {number} id - The ID of the user.
* @param {Object} user - The updated user details.
* @returns {Promise<Object>} The updated user's details.
* @example
* const updatedUser = await client.users.update(12345, {name: 'Johnathan Doe'});
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/users/#update-user}
*/
async update(id, user) {

@@ -89,2 +198,12 @@ return this.put(['users', id], user);

/**
* Updates multiple users.
* @async
* @param {...*} args - Arguments including optional IDs and user details.
* @returns {Promise<Array<Object>>} An array of updated user details.
* @throws {Error} Throws an error if not enough arguments are provided.
* @example
* const updatedUsers = await client.users.updateMany([12345, 67890], [{name: 'John Doe'}, {name: 'Jane Smith'}]);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/users/#update-many-users}
*/
async updateMany(...args /* Optional ids, users, cb */) {

@@ -141,2 +260,11 @@ if (args.length < 2) {

/**
* Suspends a user by ID.
* @async
* @param {number} id - The ID of the user to suspend.
* @returns {Promise<Object>} The suspended user's details.
* @example
* await client.users.suspend(12345);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/users/#suspend-user}
*/
async suspend(id) {

@@ -146,2 +274,11 @@ return this.put(['users', id], {user: {suspended: true}});

/**
* Unsuspends a user by ID.
* @async
* @param {number} id - The ID of the user to unsuspend.
* @returns {Promise<Object>} The unsuspended user's details.
* @example
* await client.users.unsuspend(12345);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/users/#unsuspend-user}
*/
async unsuspend(id) {

@@ -151,2 +288,12 @@ return this.put(['users', id], {user: {suspended: false}});

/**
* Deletes a user by ID.
* @async
* @param {number} id - The ID of the user to delete.
* @returns {Promise<void>}
* @throws {Error} Throws an error if the user cannot be deleted.
* @example
* await client.users.delete(12345);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/users/#delete-user}
*/
async delete(id) {

@@ -156,2 +303,12 @@ return super.delete(['users', id]);

/**
* Deletes multiple users.
* @async
* @param {...*} args - Arguments including optional IDs and user details.
* @returns {Promise<void>}
* @throws {Error} Throws an error if not enough arguments are provided.
* @example
* await client.users.destroyMany([12345, 67890]);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/users/#delete-many-users}
*/
async destroyMany(...args) {

@@ -208,2 +365,11 @@ if (args.length < 2) {

/**
* Searches for users based on specific parameters.
* @async
* @param {Object} parameters - The search parameters.
* @returns {Promise<Array<Object>>} An array of user objects that match the search criteria.
* @example
* const users = await client.users.search({query: 'john@example.com'});
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/users/#search-users}
*/
async search(parameters) {

@@ -213,2 +379,10 @@ return this.getAll(['users', 'search', parameters]);

/**
* Retrieves details of the currently authenticated user.
* @async
* @returns {Promise<Object>} The authenticated user's details.
* @example
* const user = await client.users.me();
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/users/#show-the-currently-authenticated-user}
*/
async me() {

@@ -218,2 +392,12 @@ return this.get(['users', 'me']);

/**
* Merges a user into another user.
* @async
* @param {number} id - The ID of the user to be merged.
* @param {number} targetId - The ID of the user into which the first user will be merged.
* @returns {Promise<Object>} The details of the merged user.
* @example
* await client.users.merge(12345, 67890);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/users/#merge-user-into-another-user}
*/
async merge(id, targetId) {

@@ -223,2 +407,13 @@ return this.put(['users', id, 'merge'], {user: {id: targetId}});

/**
* Changes the password of a user.
* @async
* @param {number} userId - The ID of the user whose password is to be changed.
* @param {string} oldPassword - The current password of the user.
* @param {string} newPassword - The new password for the user.
* @returns {Promise<Object>} The user's details after the password change.
* @example
* await client.users.password(12345, 'oldPassword123', 'newPassword456');
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/users/#change-password}
*/
async password(userId, oldPassword, newPassword) {

@@ -231,2 +426,12 @@ return this.put(['users', userId, 'password'], {

/**
* Retrieves users incrementally with included related data.
* @async
* @param {number} startTime - The start time for the incremental export.
* @param {string} include - The related data to include.
* @returns {Promise<Array<Object>>} An array of user objects with included data.
* @example
* const users = await client.users.incrementalInclude(1632614395, 'relatedData');
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/users/#incremental-export-users}
*/
async incrementalInclude(startTime, include) {

@@ -240,2 +445,11 @@ return this.getAll([

/**
* Retrieves users incrementally.
* @async
* @param {number} startTime - The start time for the incremental export.
* @returns {Promise<Array<Object>>} An array of user objects.
* @example
* const users = await client.users.incremental(1632614395);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/users/#incremental-export-users}
*/
async incremental(startTime) {

@@ -245,2 +459,11 @@ return this.getAll(['incremental', 'users', {start_time: startTime}]);

/**
* Retrieves a sample of users incrementally.
* @async
* @param {number} startTime - The start time for the incremental export.
* @returns {Promise<Array<Object>>} A sample array of user objects.
* @example
* const usersSample = await client.users.incrementalSample(1632614395);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/users/#incremental-sample-export-users}
*/
async incrementalSample(startTime) {

@@ -255,4 +478,11 @@ return this.get([

// User Tags
/**
* Lists tags associated with a user.
* @async
* @param {number} userId - The ID of the user.
* @returns {Promise<Array<string>>} An array of tags associated with the user.
* @example
* const tags = await client.users.listTags(12345);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/user-tags/#list-tags}
*/
async listTags(userId) {

@@ -262,2 +492,12 @@ return this.getAll(['users', userId, 'tags']);

/**
* Sets tags for a user.
* @async
* @param {number} userId - The ID of the user.
* @param {Array<string>} tags - An array of tags to set for the user.
* @returns {Promise<Object>} The user's details with the updated tags.
* @example
* await client.users.setTags(12345, ['tag1', 'tag2']);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/user-tags/#set-tags}
*/
async setTags(userId, tags) {

@@ -267,2 +507,12 @@ return this.post(['users', userId, 'tags'], tags);

/**
* Adds tags to a user.
* @async
* @param {number} userId - The ID of the user.
* @param {Array<string>} tags - An array of tags to add to the user.
* @returns {Promise<Object>} The user's details with the added tags.
* @example
* await client.users.addTags(12345, ['tag3', 'tag4']);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/user-tags/#add-tags}
*/
async addTags(userId, tags) {

@@ -272,2 +522,12 @@ return this.put(['users', userId, 'tags'], tags);

/**
* Removes tags from a user.
* @async
* @param {number} userId - The ID of the user.
* @param {Array<string>} tags - An array of tags to remove from the user.
* @returns {Promise<void>}
* @example
* await client.users.removeTags(12345, ['tag3', 'tag4']);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/users/user-tags/#remove-tags}
*/
async removeTags(userId, tags) {

@@ -274,0 +534,0 @@ return super.delete(['users', userId, 'tags'], tags);

@@ -1,4 +0,8 @@

// Views.js: Client for the zendesk API.
// File: views.js
const {Client} = require('../client');
/**
* Represents the Views API methods.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/views/}
*/
class Views extends Client {

@@ -10,3 +14,10 @@ constructor(options) {

// Listing Views
/**
* Lists shared and personal views available to the current user.
* @async
* @returns {Promise<Object>} A promise that resolves to the list of views.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#list-views}
* @example
* const views = await client.views.list();
*/
async list() {

@@ -16,3 +27,10 @@ return this.getAll(['views']);

// Listing Active Views
/**
* Lists active shared and personal views available to the current user.
* @async
* @returns {Promise<Object>} A promise that resolves to the list of active views.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#list-active-views}
* @example
* const activeViews = await client.views.listActive();
*/
async listActive() {

@@ -22,4 +40,10 @@ return this.getAll(['views', 'active']);

// GET /api/v2/views/compact.json
// A compacted list of shared and personal views available to the current user
/**
* A compacted list of shared and personal views available to the current user.
* @async
* @returns {Promise<Object>} A promise that resolves to the compact list of views.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#list-views-compact}
* @example
* const compactViews = await client.views.listCompact();
*/
async listCompact() {

@@ -29,3 +53,11 @@ return this.getAll(['views', 'compact']);

// Viewing Views
/**
* Shows details of a specific view.
* @async
* @param {number} viewID - The ID of the view to retrieve.
* @returns {Promise<Object>} A promise that resolves to the details of the view.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#show-view}
* @example
* const viewDetails = await client.views.show(12345);
*/
async show(viewID) {

@@ -35,4 +67,15 @@ return this.get(['views', viewID]);

// Create View
// POST /api/v2/views.json
/**
* Creates a new view.
* @async
* @param {Object} view - The view data to create.
* @returns {Promise<Object>} A promise that resolves to the created view details.
* @example
* const newView = {
* title: "My New View",
* conditions: {...}
* };
* const createdView = await client.views.create(newView);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#create-view}
*/
async create(view) {

@@ -42,4 +85,15 @@ return this.post(['views'], view);

// Update View
// PUT /api/v2/views/{id}.json
/**
* Updates an existing view by its ID.
* @async
* @param {number} viewID - The ID of the view to update.
* @param {Object} viewData - The updated view data.
* @returns {Promise<Object>} A promise that resolves to the updated view details.
* @example
* const updatedData = {
* title: "Updated View Title"
* };
* const updatedView = await client.views.update(12345, updatedData);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#update-view}
*/
async update(viewID, viewData) {

@@ -49,5 +103,11 @@ return this.put(['views', viewID], viewData);

// Executing Views
// GET /api/v2/views/{id}/execute.json
// :params can be http://developer.zendesk.com/documentation/rest_api/views.html#previewing-views
/**
* Executes a specific view by its ID.
* @async
* @param {number} viewID - The ID of the view to execute.
* @param {Object} parameters - Additional parameters for execution.
* @returns {Promise<Object>} A promise that resolves to the executed view results.
* @example const executedView = await client.views.execute(12345, {sort_by: 'status'});
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#execute-view}
*/
async execute(viewID, parameters) {

@@ -57,4 +117,10 @@ return this.getAll(['views', viewID, 'execute', parameters]);

// Getting Tickets from a view
// GET /api/v2/views/{id}/tickets.json
/**
* Retrieves tickets from a specific view by its ID.
* @async
* @param {number} viewID - The ID of the view.
* @returns {Promise<Object>} A promise that resolves to the list of tickets from the view.
* @example const ticketsFromView = await client.views.tickets(12345);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#list-tickets-from-a-view}
*/
async tickets(viewID) {

@@ -64,9 +130,27 @@ return this.getAll(['views', viewID, 'tickets']);

// Previewing Views
// POST /api/v2/views/preview.json
// :params can be http://developer.zendesk.com/documentation/rest_api/views.html#previewing-views
/**
* Previews a new view without saving it.
* @async
* @param {Object} view - The view data to preview.
* @returns {Promise<Object>} A promise that resolves to the previewed view results.
* @example
* const viewData = {
* title: "Preview View",
* conditions: {...}
* };
* const previewResults = await client.views.preview(viewData);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#preview-view}
*/
async preview(parameters) {
return this.requestAll('POST', ['views', 'preview'], parameters); // TODO: postAll
return this.requestAll('POST', ['views', 'preview'], parameters);
}
/**
* Retrieves the count of tickets for a specific view.
* @async
* @param {number} viewID - The ID of the view to count tickets for.
* @returns {Promise<Object>} A promise that resolves to the ticket count for the view.
* @example const ticketCount = await client.views.showCount(12345);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#show-view-count}
*/
async showCount(viewID) {

@@ -76,2 +160,10 @@ return this.get(['views', viewID, 'count']);

/**
* Retrieves the ticket counts for multiple views.
* @async
* @param {Array<number>} viewIDs - An array of view IDs to count tickets for.
* @returns {Promise<Object>} A promise that resolves to the ticket counts for the specified views.
* @example const ticketCounts = await client.views.showCounts([12345, 67890]);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#show-multiple-view-counts}
*/
async showCounts(viewIDs) {

@@ -81,9 +173,69 @@ return this.get(['views', 'count_many', {ids: viewIDs}]);

// Exporting Views
// GET /api/v2/views/{id}/export.json
/**
* Exports views to a JSON file.
* @async
* @param {Array<number>} viewIDs - An array of view IDs to export.
* @returns {Promise<Object>} A promise that resolves to the exported views in JSON format.
* @example const exportedViews = await client.views.export([12345, 67890]);
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#export-views}
*/
async export(viewID) {
return this.get(['views', viewID, 'export']);
}
/**
* Retrieves all active shared views.
* @async
* @returns {Promise<Object>} A promise that resolves to the list of all active shared views.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#list-active-shared-views}
*/
async listActiveShared() {
return this.get(['views', 'shared']);
}
/**
* Retrieves the view's execution status.
* @async
* @param {number} viewID - The ID of the view to check the execution status for.
* @returns {Promise<Object>} A promise that resolves to the execution status of the view.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#show-view-execution-status}
*/
async showExecutionStatus(viewID) {
return this.get(['views', viewID, 'execution_status']);
}
/**
* Retrieves the view's recent ticket IDs.
* @async
* @param {number} viewID - The ID of the view to retrieve recent ticket IDs for.
* @returns {Promise<Object>} A promise that resolves to the recent ticket IDs of the view.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#show-view-recent-ticket-ids}
*/
async showRecentTicketIDs(viewID) {
return this.get(['views', viewID, 'recent_ticket_ids']);
}
/**
* Deletes a specific view by its ID.
* @async
* @param {number} viewID - The ID of the view to delete.
* @returns {Promise<Object>} A promise that resolves when the view is deleted.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#delete-view}
*/
async delete(viewID) {
return this.delete(['views', viewID]);
}
/**
* Reorders views based on the provided order.
* @async
* @param {Array<number>} viewOrder - An array of view IDs in the desired order.
* @returns {Promise<Object>} A promise that resolves when the views are reordered.
* @see {@link https://developer.zendesk.com/api-reference/ticketing/business-rules/views/#reorder-views}
*/
async reorder(viewOrder) {
return this.put(['views', 'reorder'], {view_order: viewOrder});
}
}
exports.Views = Views;
// Webhooks.js: Client for the zendesk API.
const {Client} = require('../client');
/**
* Webhooks client for interacting with the Zendesk Webhooks API.
* @see {@link https://developer.zendesk.com/api-reference/webhooks/webhooks-api/webhooks/}
*/
class Webhooks extends Client {

@@ -10,28 +14,165 @@ constructor(options) {

// Listing Webhooks
/**
* List all webhooks.
* @async
* @returns {Promise<Object>} A promise that resolves to the list of webhooks.
* @see {@link https://developer.zendesk.com/api-reference/webhooks/webhooks-api/webhooks/#list-webhooks}
* @example const webhooks = await client.webhooks.list();
*/
async list() {
return this.getAll('/webhooks');
return this.getAll(['webhooks']);
}
// Viewing Webhooks
/**
* Retrieve a specific webhook by ID.
* @async
* @param {string} webhookID - The ID of the webhook to retrieve.
* @returns {Promise<Object>} A promise that resolves to the specified webhook.
* @see {@link https://developer.zendesk.com/api-reference/webhooks/webhooks-api/webhooks/#show-webhook}
* @example const webhook = await client.webhooks.show('webhookID123');
*/
async show(webhookID) {
return this.get(`/webhooks/${webhookID}`);
return this.get(['webhooks', webhookID]);
}
// Creating Webhooks
/**
* Create a new webhook.
* @async
* @param {Object} webhook - The webhook data to create.
* @returns {Promise<Object>} A promise that resolves to the created webhook.
* @see {@link https://developer.zendesk.com/api-reference/webhooks/webhooks-api/webhooks/#create-or-clone-webhook}
* @example
* const newWebhook = {
* // ... webhook data ...
* };
* const createdWebhook = await client.webhooks.create(newWebhook);
*/
async create(webhook) {
return this.post('/webhooks', webhook);
return this.post(['webhooks'], webhook);
}
// Updating Webhooks
/**
* Update a specific webhook by ID.
* @async
* @param {string} webhookID - The ID of the webhook to update.
* @param {Object} webhook - The updated webhook data.
* @returns {Promise<Object>} A promise that resolves to the updated webhook.
* @see {@link https://developer.zendesk.com/api-reference/webhooks/webhooks-api/webhooks/#update-webhook}
* @example
* const updatedData = {
* // ... updated data ...
* };
* const updatedWebhook = await client.webhooks.update('webhookID123', updatedData);
*/
async update(webhookID, webhook) {
return this.put(`/webhooks/${webhookID}`, webhook);
return this.put(['webhooks', webhookID], webhook);
}
// Deleting Webhooks
/**
* Delete a specific webhook by ID.
* @async
* @param {string} webhookID - The ID of the webhook to delete.
* @returns {Promise<Object>} A promise that resolves when the webhook is deleted.
* @see {@link https://developer.zendesk.com/api-reference/webhooks/webhooks-api/webhooks/#delete-webhook}
* @example await client.webhooks.delete('webhookID123');
*/
async delete(webhookID) {
return super.delete(`/webhooks/${webhookID}`);
return super.delete(['webhooks', webhookID]);
}
// ... Previous code ...
/**
* Test a new or existing webhook.
* @async
* @param {Object} request - The request data for testing the webhook.
* @param {string} [webhookID] - The ID of the webhook to be tested (for existing webhooks).
* @returns {Promise<Object>} A promise that resolves to the test result.
* @see {@link https://developer.zendesk.com/api-reference/webhooks/webhooks-api/webhooks/#test-webhook}
* @example
* const requestData = {
* // ... request data ...
* };
* const testResult = await client.webhooks.test(requestData, 'webhookID123');
*/
async test(request, webhookID) {
const endpoint = webhookID
? `/webhooks/test?webhook_id=${webhookID}`
: '/webhooks/test';
return this.post(endpoint, request);
}
/**
* List invocations for a specific webhook.
* @async
* @param {string} webhookID - The ID of the webhook.
* @returns {Promise<Object>} A promise that resolves to the list of invocations.
* @see {@link https://developer.zendesk.com/api-reference/webhooks/webhooks-api/webhooks/#list-webhook-invocations}
* @example const invocations = await client.webhooks.listInvocations('webhookID123');
*/
async listInvocations(webhookID) {
return this.get(['webhooks', webhookID, 'invocations']);
}
/**
* List invocation attempts for a specific webhook.
* @async
* @param {string} webhookID - The ID of the webhook.
* @param {string} invocationID - The ID of the webhook invocation.
* @returns {Promise<Object>} A promise that resolves to the list of invocation attempts.
* @see {@link https://developer.zendesk.com/api-reference/webhooks/webhooks-api/webhooks/#list-webhook-invocation-attempts}
* @example const attempts = await client.webhooks.listInvocationAttempts('webhookID123', 'invocationID123');
*/
async listInvocationAttempts(webhookID, invocationID) {
return this.get([
'webhooks',
webhookID,
'invocations',
invocationID,
'attempts',
]);
}
/**
* Retrieve the signing secret of a specific webhook.
* @async
* @param {string} webhookID - The ID of the webhook.
* @returns {Promise<Object>} A promise that resolves to the signing secret.
* @see {@link https://developer.zendesk.com/api-reference/webhooks/webhooks-api/webhooks/#show-webhook-signing-secret}
* @example const secret = await client.webhooks.getSigningSecret('webhookID123');
*/
async getSigningSecret(webhookID) {
return this.get(['webhooks', webhookID, 'signing_secret']);
}
/**
* Reset the signing secret for a specific webhook.
* @async
* @param {string} webhookID - The ID of the webhook.
* @returns {Promise<Object>} A promise that resolves to the new signing secret.
* @see {@link https://developer.zendesk.com/api-reference/webhooks/webhooks-api/webhooks/#reset-webhook-signing-secret}
* @example const newSecret = await client.webhooks.resetSigningSecret('webhookID123');
*/
async resetSigningSecret(webhookID) {
return this.post(['webhooks', webhookID, 'signing_secret']);
}
/**
* Patch a specific webhook by ID.
* @async
* @param {string} webhookID - The ID of the webhook to patch.
* @param {Object} webhook - The data to patch.
* @returns {Promise<Object>} A promise that resolves to the patched webhook.
* @see {@link https://developer.zendesk.com/api-reference/webhooks/webhooks-api/webhooks/#patch-webhook}
* @example
* const patchData = {
* // ... patch data ...
* };
* const patchedWebhook = await client.webhooks.patch('webhookID123', patchData);
*/
async patch(webhookID, webhook) {
return super.patch(['webhooks', webhookID], webhook);
}
}
exports.Webhooks = Webhooks;

@@ -89,3 +89,3 @@ const failCodes = {

*
* @param {string} method - The HTTP method. Can be "GET", "POST", "PUT", or "DELETE".
* @param {string} method - The HTTP method. Can be "GET", "PATCH", "POST", "PUT", or "DELETE".
* @param {Array<string|Object>} [uri] - An array representing the URL segments. The last element can be an object of query parameters or a query string.

@@ -228,3 +228,6 @@ * @returns {string} The assembled URL.

// The following occurs on delete requests
if (response.status === 204 && (response.statusText == null || response.statusText === 'No Content')) {
if (
response.status === 204 &&
(response.statusText ?? 'No Content') === 'No Content'
) {
return createError('No Content', response.status);

@@ -231,0 +234,0 @@ }

const MODULES = {
core: [
'AccountSettings',
'ActivityStream',
'Attachments',
'Automations',
'Brand',
'CustomAgentRoles',
'DynamicContent',
'DynamicContentVariants',
'GroupMemberships',
'Groups',
'Imports',
'Installations',
'JobStatuses',
'Locales',
'Macros',
'OauthTokens',
'OrganizationFields',
'OrganizationMemberships',
'Organizations',
'PermissionGroups',
'Policies',
'Requests',
'SatisfactionRatings',
'Search',
'Sessions',
'SharingAgreement',
'SuspendedTickets',
'Tags',
'Targets',
'TicketAudits',
'TicketEvents',
'TicketExport',
'TicketFields',
'TicketForms',
'TicketImport',
'TicketMetrics',
'Tickets',
'TopicComments',
'Topics',
'TopicSubscriptions',
'TopicVotes',
'Triggers',
'UserFields',
'UserIdentities',
'Users',
'Views',
'Webhooks',
],
helpcenter: [
'AccessPolicies',
'ArticleAttachments',
'ArticleComments',
'ArticleLabels',
'Articles',
'Categories',
'Search',
'Sections',
'Subscriptions',
'Translations',
'UserSegments',
'Votes',
],
nps: ['Invitations', 'Surveys'],
services: ['Links'],
voice: [
'AgentActivity',
'Availabilities',
'CurrentQueueActivity',
'GreetingCategories',
'Greetings',
'HistoricalQueueActivity',
'PhoneNumbers',
],
core: {
AccountSettings: require('./client/core/accountsettings'),
ActivityStream: require('./client/core/activitystream'),
Attachments: require('./client/core/attachments'),
Automations: require('./client/core/automations'),
Brand: require('./client/core/brand'),
CustomAgentRoles: require('./client/core/customagentroles'),
DynamicContent: require('./client/core/dynamiccontent'),
DynamicContentVariants: require('./client/core/dynamiccontentvariants'),
GroupMemberships: require('./client/core/groupmemberships'),
Groups: require('./client/core/groups'),
Imports: require('./client/core/imports'),
Installations: require('./client/core/installations'),
JobStatuses: require('./client/core/jobstatuses'),
Locales: require('./client/core/locales'),
Macros: require('./client/core/macros'),
OauthTokens: require('./client/core/oauthtokens'),
OrganizationFields: require('./client/core/organizationfields'),
OrganizationMemberships: require('./client/core/organizationmemberships'),
Organizations: require('./client/core/organizations'),
PermissionGroups: require('./client/core/permissiongroups'),
Policies: require('./client/core/policies'),
Requests: require('./client/core/requests'),
SatisfactionRatings: require('./client/core/satisfactionratings'),
Search: require('./client/core/search'),
Sessions: require('./client/core/sessions'),
SharingAgreement: require('./client/core/sharingagreement'),
SuspendedTickets: require('./client/core/suspendedtickets'),
Tags: require('./client/core/tags'),
Targets: require('./client/core/targets'),
TicketAudits: require('./client/core/ticketaudits'),
TicketEvents: require('./client/core/ticketevents'),
TicketExport: require('./client/core/ticketexport'),
TicketFields: require('./client/core/ticketfields'),
TicketForms: require('./client/core/ticketforms'),
TicketImport: require('./client/core/ticketimport'),
TicketMetrics: require('./client/core/ticketmetrics'),
Tickets: require('./client/core/tickets'),
Triggers: require('./client/core/triggers'),
UserFields: require('./client/core/userfields'),
UserIdentities: require('./client/core/useridentities'),
Users: require('./client/core/users'),
Views: require('./client/core/views'),
Webhooks: require('./client/core/webhooks'),
},
helpcenter: {
AccessPolicies: require('./client/helpcenter/accesspolicies'),
ArticleAttachments: require('./client/helpcenter/articleattachments'),
ArticleComments: require('./client/helpcenter/articlecomments'),
ArticleLabels: require('./client/helpcenter/articlelabels'),
Articles: require('./client/helpcenter/articles'),
Categories: require('./client/helpcenter/categories'),
Search: require('./client/helpcenter/search'),
Sections: require('./client/helpcenter/sections'),
Subscriptions: require('./client/helpcenter/subscriptions'),
Translations: require('./client/helpcenter/translations'),
UserSegments: require('./client/helpcenter/usersegments'),
Votes: require('./client/helpcenter/votes'),
},
nps: {
Invitations: require('./client/nps/invitations'),
Surveys: require('./client/nps/surveys'),
},
services: {
Links: require('./client/services/links'),
},
voice: {
AgentActivity: require('./client/voice/agentactivity'),
Availabilities: require('./client/voice/availabilities'),
CurrentQueueActivity: require('./client/voice/currentqueueactivity'),
GreetingCategories: require('./client/voice/greetingcategories'),
Greetings: require('./client/voice/greetings'),
HistoricalQueueActivity: require('./client/voice/historicalqueueactivity'),
PhoneNumbers: require('./client/voice/phonenumbers'),
},
};

@@ -93,17 +94,2 @@

const MODULE_MAP = {};
for (const apiType in MODULES) {
if (Object.prototype.hasOwnProperty.call(MODULES, apiType)) {
MODULE_MAP[apiType] = {};
for (const moduleName of MODULES[apiType]) {
const modulePath = `${
MODULE_BASE_PATHS[apiType]
}${moduleName.toLowerCase()}`;
MODULE_MAP[apiType][moduleName.toLowerCase()] = require(modulePath);
}
}
}
module.exports = {MODULES, MODULE_BASE_PATHS, MODULE_MAP, ENDPOINTS};
module.exports = {MODULES, MODULE_BASE_PATHS, ENDPOINTS};
// Index.js - node-zendesk client initialization
'use strict';
const {MODULES, MODULE_MAP, ENDPOINTS} = require('./constants');
const {MODULES, ENDPOINTS} = require('./constants');

@@ -74,5 +74,5 @@ /**

for (const module of clientModules) {
for (const module in clientModules) {
const moduleName = module.toLowerCase();
const ModuleClass = MODULE_MAP[type][moduleName][module];
const ModuleClass = MODULES[type][module][module];
this.client[moduleName] = new ModuleClass({

@@ -79,0 +79,0 @@ ...this.config,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc