Code Monkey home page Code Monkey logo

node-freshdesk-api's People

Contributors

allcontributors[bot] avatar andrewlab-lokalise avatar arjunkomath avatar dependabot-preview[bot] avatar dependabot[bot] avatar derrickmehaffy avatar jeffreymele avatar jkap avatar julianduque avatar kibertoad avatar mae776569 avatar maxkoryukov avatar nibynool avatar pongstr avatar velua avatar wvdneut avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

node-freshdesk-api's Issues

Is the repo alive?

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?

Issue about createReply

##npm version
freshdesk-api V2

Current behavior

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!

How to get x-request-id.

  • freshdesk-api V1 (obsolete)

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.

what is difference between freshdesk-api and node-freshdesk-api

what is the difference?

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.

Can you add feature?

If migration is the only way to fix that issue,Can you expose that x-request-id response header as a feature.

Implement pagination for listAllConversations

Feature Request

Current behavior

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

Expected behavior

should be similar to listAllTickets

More details

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

Build failed for NodeJS 4x on Travis

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

Add requestId even if the requset fail.

  • [ ] freshdesk-api V2

Current behavior

The extra arg only returns requestId iff the request is successful.

Expected behavior

Can you please add that requsetId even if the request fails since we need requestId only to trace the error.

The below screenshot is response header with requestId set by freshdesk in failed request.

Screenshot (7)
#68 #67

cb is not a function

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

Update ticket attachments

Good morning,

I have an issue with updating attachments of a ticket in the freshdesk-api V2.

Current behavior

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' } ]

Expected behavior

The attachments field is supposed to be an array of objects so I provided that. My code is in the attached file below.

Code

update.pdf

Details

{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.

Validation error on getTicket

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.

Expose pagination from headers

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'
}

utilize JSDoc

This will make README.md shorter and will help us to keep docs updated.

  • Generate documentation
  • autopublish docs
  • add namespaces for documentation (there is a mess)
  • add CompanyResponse, TimeEntryResponse to the html, currently they are excluded (it is a bug)

[Question] how to get all tickets using listAllTickets

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

createXXX methods fail

Every API creatng-method response with 201 status code.

Library checks the status, and it expects only 200 status..

promisifyAll example is broken

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)

Bring back all tickets

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...

Create reply with attachment failing: "(TypeError): form.getHeaders is not a function"

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?

npm WARN deprecated [email protected]: request has been deprecated

  • freshdesk-api V2
  • freshdesk-api V1 (obsolete)

Current behavior

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?

Expected behavior

Having a new http request package that is not deprecated

More details

provide the output of npm version in the root of your package

{ 'freshdesk-api': '2.12.0',
  npm: '6.14.11',
}

getAll* calls are misleading

  • freshdesk-api V2
  • freshdesk-api V1 (obsolete)

Current behavior

When calling an endpoint that will paginate it does not return ALL records - it returns only the records in the initial API response.

Expected behavior

Return ALL records via pagination.

More details

It seems this is already sort of considered:

// TODO: reconsider this property

Cant attach files to Create Ticket ***

Current behavior

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.

Expected behavior

It should include de file as attachment as per documentation.

More details

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)

PROPOSAL: publish on NPM from TRAVIS CI

It is not a difficult task, to set up an autopublish:

  1. Build package on Travis CI
  • build
  • lint
  • test
  1. If it is a tag - deploy package to NPM (only if there are no errors on test- and lint- steps). Version for the new NPM package will be taken from name of the tag

Using with Webpack

Just a quick question, has anyone had any trouble using this package with webpack in use as well?

Typescript build error

Current behavior

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'.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.