arjunkomath / node-freshdesk-api Goto Github PK
View Code? Open in Web Editor NEWNode wrapper for Freshdesk v2 API
Home Page: http://arjunkomath.github.io/node-freshdesk-api/
License: MIT License
Node wrapper for Freshdesk v2 API
Home Page: http://arjunkomath.github.io/node-freshdesk-api/
License: MIT License
Hello! Thanks for this package;)
I would like to use it for my tiny project, but I need Companies stuff. I have already added all required functions to my local copy of your package, but I could send you a pull request (and we will have a better version of the package)
Are there a chance to update the package on the NPM?
##npm version
freshdesk-api V2
I try to create fresh desk reply with the api with this config:
freshdesk.createReply(123, {
body: `Testing at ${new Date()}`,
attachments: [
fs.createReadStream('xxx.xlsx'),
fs.createReadStream('sample.json')
],
cc_emails: ["[email protected]"],
// bcc_emails: ["xxxx@xxx"]
}, function (err, data) {
console.log(err || data)
})
However its returning error message:
Error: form-data: Arrays are not supported.
at FormData.append (/Users/yu/Desktop/test/node_modules/request/node_modules/form-data/lib/form_data.js:66:17)
at makeRequest (/Users/yu/Desktop/test/node_modules/freshdesk-api/lib/utils.js:200:9)
at Freshdesk.createReply (/Users/yu/Desktop/test/node_modules/freshdesk-api/lib/client.js:155:3)
at main (/Users/yu/Desktop/test/index.js:75:13)
at Object.<anonymous> (/Users/yu/Desktop/test/index.js:87:1)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
just check the problem on cc_emmails and bcc_emails
For the API Doc, bcc_emails and cc_emails allow to use
how can I change my api setting?
BTW, I find it is a working setting when I use unirest
// unirest.post(URL)
// .headers(headers)
// .field('body', `Testing at ${new Date()}`)
// .field('cc_emails[]', "[email protected]")
// .field('bcc_emails[]', "[email protected]")
// .attach('attachments[]', fs.createReadStream('xxx.xlsx'))
// .attach('attachments[]', fs.createReadStream('sample.json'))
// .end(function(response){ console.log(response.req.res.body) })
Thanks!
I want to console the x-request-id from the response header.Please help me on how to get that particular header using this api.
Not implemented: http://developers.freshdesk.com/api/#settings
An application which is in production for the past three year built using node-freshdesk-api,now we are facing some issue on freshdesk side so to fix that particular issue we need x-request-id (set by freshdesk server) .Is there any hack to console that x-request-id in that production app itself or we need to migrate to freshdesk-api by doing so what are the changes we have to make please explain.
If migration is the only way to fix that issue,Can you expose that x-request-id response header as a feature.
Right now, a user passes an id, and the API returns by default 30 conversations. However, there is no way to get more conversations in a paginated manner
should be similar to listAllTickets
tested we can add per_page and page fields as parameters for the conversation endpoint
GET request to https://domain.freshdesk.com/api/v2/tickets/{ticket_id}/conversations?per_page=1&page=1
returns a link parameter in header
Users have to promisify node-freshdesk-api
Promise-based API is available out-of-the-box
No additional libraries are needed for this, Node has native solution: https://nodejs.org/api/util.html#utilpromisifyoriginal
https://stackoverflow.com/questions/28229044/http-keep-alive-in-node-js
Let me know if you need help. I can send PR.
Not implemented: http://developers.freshdesk.com/api/#satisfaction-ratings
Not implemented: http://developers.freshdesk.com/api/#email-configs
Another one NPM-related bug.
Will be automatically solved 1 May - we will drop NodeJS 4x support (in accordance with NodeJS LTS schedule).
Just don't forget to rollback changes in .travis.yml
The extra arg only returns requestId iff the request is successful.
Can you please add that requsetId even if the request fails since we need requestId only to trace the error.
When using listAllConversations method of module. following error is returned.
TypeError: cb is not a function
at Request._callback (/Users/manish/Remitr/projects/remitr-common/freshdesk/node_modules/node-freshdesk-api/lib/utils.js:63:11)
at Request.self.callback (/Users/manish/Remitr/projects/remitr-common/freshdesk/node_modules/request/request.js:188:22)
at emitTwo (events.js:106:13)
```.
On further debugging i found that there is a small error in lib/client.js
```js
listAllConversations(id, cb) {
makeRequest('GET', this._auth, `${this.baseUrl}/api/v2/tickets/${id}/conversations`, null, cb)
},
callback cb is passed as 5th parameter instead of 6th.
listAllConversations(id, cb) {
makeRequest('GET', this._auth, `${this.baseUrl}/api/v2/tickets/${id}/conversations`, null, null, cb)
},
Please update the repo accordingly
Looks, like you forgot to mention request
in your package.json
in dependencies-section
axios is used as an http client
undici is used as an http client
undici is significantly faster than clients, based on node http
module, such as axios: https://github.com/nodejs/undici#benchmarks
If this is approved, I can work on PR.
Not implemented: http://developers.freshdesk.com/api/#business-hours
Good morning,
I have an issue with updating attachments of a ticket in the freshdesk-api V2.
When I try to update the attachment, I get this error
[ { field: 'attachments',
message: 'It should contain elements of type valid file format only',
code: 'datatype_mismatch' } ]
The attachments field is supposed to be an array of objects so I provided that. My code is in the attached file below.
{freshdesk-api: 2.5.0'
npm: '5.6.0',
ares: '1.14.0',
cldr: '33.0',
http_parser: '2.8.0',
icu: '61.1',
modules: '64',
napi: '3',
nghttp2: '1.29.0',
node: '10.1.0',
openssl: '1.1.0h',
tz: '2018c',
unicode: '10.0',
uv: '1.20.2',
v8: '6.6.346.27-node.6',
zlib: '1.2.11' }
Thank you.
SLA = service level agreement
Not implemented: http://developers.freshdesk.com/api/#sla-policies
Not implemented: http://developers.freshdesk.com/api/#products
i want to use all other api feather like create contact group etc... it is possible to use those feather using this module if yes then how ??
If do:
freshdesk.updateTicket(8, {description: "foo"}, cb);
all is fine, ticket gets updated and so on
but when I do:
freshdesk.getTicket(8, cb);
I get:
name: 'FreshdeskError',
message: 'Validation failed',
data.errors[0] {
"field": "ticket",
"message": "Unexpected/invalid field in request",
"code": "invalid_field"
}
I get similar if I try listAllTickets
I can make the calls through curl and HTTP.call without problems.
Strange.
Looks like we don't support
https://developer.freshdesk.com/api/#filter_tickets
Hey @arjunkomath, I was wondering if it's possible to also return/expose pagination details from
the headers and return an object
instead of array
like so:
{
data: [
{ ... },
{ ... },
{ ... }
],
per_page: 10,
pages: 2,
next_url: 'https://test.freshdesk.com/api/v2/tickets/?per_page=10&pages=2'
}
This will make README.md
shorter and will help us to keep docs updated.
CompanyResponse
, TimeEntryResponse
to the html, currently they are excluded (it is a bug)see npm/npm#17858
I tried to use docs to figure out how to get all tickets from API, but it's just giving me the first 30 tickets; I can see in the extra object there are more pages but don't know how to get those.
Could you please show me an example of that use case?
Thanks
Every API creatng-method response with 201 status code.
Library checks the status, and it expects only 200 status..
Not implemented: http://developers.freshdesk.com/api/#solutions
const freshdesk = promisifyAll(
new Freshdesk('https://aboutsnack.freshdesk.com', argv.freshdeskApiKey),
);
await freshdesk.createTicket({
description: 'test description',
email: '[email protected]',
name: 'test ticket',
priority: 1,
status: 2,
subject: 'test sub',
});
gives error:
/Users/gajus/Documents/dev/snack/snack-api/node_modules/freshdesk-api/lib/utils.js:112
return cb(null, data, extra)
^
TypeError: cb is not a function
at Request._callback (/Users/gajus/Documents/dev/snack/snack-api/node_modules/freshdesk-api/lib/utils.js:112:11)
at Request.self.callback (/Users/gajus/Documents/dev/snack/snack-api/node_modules/request/request.js:185:22)
Hi,
There isnt any documentation in regards to this node package as to how you bring back all tickets through the "extra" parameter e.g. freshdesk.listAllTickets((err,data,extra){ console.log(extra) } <
this brings back an object pageIsLast = true,
How can play around with extras because its only bringing back 20 tickets when there are over 100...
Hi,
I am trying to update a ticket with an attachment but it's failing with the below error:
Unhandled Rejection (TypeError): form.getHeaders is not a function
utils.js:159 Uncaught (in promise) TypeError: form.getHeaders is not a function
at makeRequest (utils.js:159)
at Freshdesk.createReply (client.js:226)
at uploadScreenshot (QuickTicket.jsx:211)
The payload is:
{
body: ReactDOMServer.renderToString(rDesc),
from_email: user.email,
attachments: [
sStream
],
};
I followed the instructions on https://www.npmjs.com/package/freshdesk-api to attach a file.
Am I missing something?
The package is working just fine, but I think it would be good to update some npm dependencies.
Could be possible to replace request package, which is deprecated, to another one like got, for example?
Having a new http request package that is not deprecated
provide the output of npm version
in the root of your package
{ 'freshdesk-api': '2.12.0',
npm: '6.14.11',
}
When calling an endpoint that will paginate it does not return ALL records - it returns only the records in the initial API response.
Return ALL records via pagination.
It seems this is already sort of considered:
node-freshdesk-api/lib/utils.js
Line 80 in d4f5aeb
Not implemented: http://developers.freshdesk.com/api/#surveys
@arjunkomath , plz, take a look at #17
End point of this module are based on api V1 of freshdesk, how to update it for api v2 please suggest.
I´m trying to attach file to a new ticket creation using the below sintax:
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);
}
);
And I´m getting the following error message:
(node:15224) UnhandledPromiseRejectionWarning: TypeError: source.on is not a function
at Function.DelayedStream.create (/path/to\node_modules\delayed-stream\lib\delayed_stream.js:33:10)
at FormData.CombinedStream.append (/path/to\node_modules\combined-stream\lib\combined_stream.js:45:37)
at FormData.append (/path/to\node_modules\form-data\lib\form_data.js:75:3)
at makeRequest (/path/to\node_modules\freshdesk-api\lib\utils.js:155:11)
at Freshdesk.createTicket (/path/to\node_modules\freshdesk-api\lib\client.js:147:3)
at createProviderTicket (/path/to\routes\provider.js:8701:13)
at Layer.handle [as handle_request] (/path/to\node_modules\express\lib\router\layer.js:95:5)
at next (/path/to\node_modules\express\lib\router\route.js:137:13)
at Immediate. (/path/to\node_modules\multer\lib\make-middleware.js:53:37)
at processImmediate (internal/timers.js:458:21)
(node:15224) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:15224) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
It should include de file as attachment as per documentation.
File is being uploaded.
This is how my code is: (ticket creation without attachment is workinh fine)
var TicketObj = {}
TicketObj.type = "Question";
TicketObj.name = name.replace(/[|&;$#%"<>()+,]/g, "");
TicketObj.email = email.replace(/[|&;$#%"<>()+,]/g, "");
TicketObj.subject = subject.replace(/[|&;$#%"<>()+,]/g, "");
TicketObj.description = description.replace(/[|&;$#%"<>()+,]/g, "");
TicketObj.status = 2; //(open)
TicketObj.source = 2; //(portal)
TicketObj.priority = parseInt(priority ? priority : 1); //(low)
TicketObj.custom_fields = {
cf_origin:"provider",
cf_instance:ProviderUserId
}
var src = req.files.attachedFile[0].destination+"/"+req.files.attachedFile[0].filename;
var attachment = fs.createReadStream(src);
TicketObj.attachments = [attachment]
// Create Ticket
freshdesk.createTicket(
TicketObj,
function (err, data) {
// if error
if (err) {
res.status(200);
return res.json({
error: err,
success:false,
failedCreation:true,
message: 'Ticket NOT created'
});
} // end if
// Store Requester ID and Id of the created ticket for late consult
// ...
res.status(200);
return res.json({
error: false,
data: data,
success:true,
message: 'Ticket created'
});
}
);
Anyone?
{ 'freshdesk-api': '2.4.0',
npm: '5.5.1',
http_parser: '2.7.0',
icu: '58.2',
modules: '48',
node: '6.12.0',
zlib: '1.2.11' }
provide stacktrace (if available)
It is not a difficult task, to set up an autopublish:
Just a quick question, has anyone had any trouble using this package with webpack in use as well?
@arjunkomath plz, fix the typo in the description of the repo
It's Hacktoberfest 2019. Feel free to send your pull requests. 👍
Not implemented: http://developers.freshdesk.com/api/#discussions
When you build a project with typescript 4, you get a long list of errors like this:
Error: node_modules/freshdesk-api/dist/client.d.ts(48,38): error TS2694: Namespace 'Freshdesk' has no exported member 'TicketsFilter'.
Error: node_modules/freshdesk-api/dist/client.d.ts(48,67): error TS2694: Namespace 'Freshdesk' has no exported member 'requestCallback'.
Error: node_modules/freshdesk-api/dist/client.d.ts(48,93): error TS2694: Namespace 'Freshdesk' has no exported member 'Tickets'.
Error: node_modules/freshdesk-api/dist/client.d.ts(92,49): error TS2694: Namespace 'Freshdesk' has no exported member 'requestCallback'.
Error: node_modules/freshdesk-api/dist/client.d.ts(92,75): error TS2694: Namespace 'Freshdesk' has no exported member 'ContactViewData'.
Error: node_modules/freshdesk-api/dist/client.d.ts(164,40): error TS2694: Namespace 'Freshdesk' has no exported member 'requestCallback'.
Error: node_modules/freshdesk-api/dist/client.d.ts(164,66): error TS2694: Namespace 'Freshdesk' has no exported member 'AgentResponse'.
Error: node_modules/freshdesk-api/dist/client.d.ts(176,37): error TS2694: Namespace 'Freshdesk' has no exported member 'AgentFilter'.
Error: node_modules/freshdesk-api/dist/client.d.ts(176,64): error TS2694: Namespace 'Freshdesk' has no exported member 'requestCallback'.
Error: node_modules/freshdesk-api/dist/client.d.ts(176,90): error TS2694: Namespace 'Freshdesk' has no exported member 'AgentResponse'.
Error: node_modules/freshdesk-api/dist/client.d.ts(189,45): error TS2694: Namespace 'Freshdesk' has no exported member 'AgentData'.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.