
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
freshdesk-api
Advanced tools
npm install --save freshdesk-api
Also, you could use version 1 of API, provided by Kumar Harsh @kumarharsh, but this version is obsolete, and marked as deprecated:
npm install freshdesk-api@APIv1
var Freshdesk = require("freshdesk-api");
var freshdesk = new Freshdesk("https://yourdomain.freshdesk.com", "yourApiKey");
Or, with promises:
var Freshdesk = require("freshdesk-api");
var Promise = require("bluebird");
var asyncFreshdesk = Promise.promisifyAll(
new Freshdesk("https://yourdomain.freshdesk.com", "yourApiKey")
);
// see usage examples
bluebird
is not a dependency of this package, install it separately: npm install bluebird
freshdesk.createTicket(
{
name: "test ticket",
email: "test@test.com",
subject: "test sub",
description: "test description",
status: 2,
priority: 1,
},
function (err, data) {
console.log(err || data);
}
);
freshdesk.updateTicket(
21,
{
description: "updated description",
status: 2,
priority: 1,
},
function (err, data, extra) {
console.log(err || data);
}
);
freshdesk.getTicket(21, function (err, data, extra) {
console.log(err || data);
});
freshdesk.deleteTicket(21, function (err, data, extra) {
console.log(err || data);
});
freshdesk.createTicket(
{
description: "test description",
attachments: [
fs.createReadStream("/path/to/file1.ext"),
fs.createReadStream("/path/to/file2.ext"),
],
},
function (err, data) {
console.log(err || data);
}
);
* for promisified version only
asyncFreshdesk.getTicketAsync(21)
.then((data, extra) => {
console.log(data, extra)
})
.catch(Freshdesk.FreshdeskError, err => {
// typed `catch` exists only in bluebird
console.log('ERROR OCCURED', err)
})
})
Note that node-freshdesk-api
is using Undici as an HTTP client, which is not based on Node.js net
module. As a result, it is not compatible with popular nock
mocking library. When mocking node-freshdesk-api
interactions, make sure to use built-in Undici mocking functionality.
Alternatively, you can use tests of node-freshdesk-api
itself as an example.
The only exception are forms with attachments (field attachments
is set and is an array) - these requests are handled using form-data
library, use net
module and need to be mocked with nock
.
You can also use a mock server (such as Pactum) for completely client-agnostic server mocking.
Here is a part of webpack.config
:
webpackConfig.node = {
// ...
console: true,
fs: "empty",
net: "empty",
tls: "empty",
// ...
};
A little bit more about webpack here
Every SDK method receives a callback
parameter. It is a function, which will be called on Freshdesk response received.
Callback called with following arguments:
err
- Error
instance (if occured) or null
data
- object
. Freshdesk response, an object, parsed from JSONextra
- additional data, gathered from response. For example, information about pagingextra
is an object with following fields:
pageIsLast
- indicates, that the response is generated from the last page, and there is no sense to play with page
and per_page
parameters. This parameter is useful for listXXX
methods, called with paginationrequestId
- value of x-request-id
header from API responseTo enable debug info, run your program with environment flags
$ DEBUG=freshdesk-api nodejs NAME-OF-YOUR-SCRIPT.js
Not implemented: http://developers.freshdesk.com/api/#groups
Not implemented: http://developers.freshdesk.com/api/#discussions
Not implemented: http://developers.freshdesk.com/api/#surveys
Not implemented: http://developers.freshdesk.com/api/#satisfaction-ratings
Not implemented: http://developers.freshdesk.com/api/#email-configs
Not implemented: http://developers.freshdesk.com/api/#products
Not implemented: http://developers.freshdesk.com/api/#business-hours
SLA = service level agreement
Not implemented: http://developers.freshdesk.com/api/#sla-policies
See the LICENSE file for license rights and limitations (MIT).
Thanks goes to these wonderful people (emoji key):
Arjun Komath 💻 📖 ⚠️ | Maksim Koryukov 💻 📖 ⚠️ | DMehaffy 💻 📖 ⚠️ | John Williamson 💻 📖 | Wouter van der Neut 💻 📖 ⚠️ | Julián Duque 💻 | Michael Lambert 💻 📖 ⚠️ |
Pongstr 💻 | Igor Savin 💻 | jae kaplan 💻 | Kumar Harsh 💻 | roniger 💻 📖 ⚠️ | Mohamed Ahmed 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!
FAQs
Node wrapper for Freshdesk v2 API
We found that freshdesk-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.