node-freshdesk-api
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -30,2 +30,6 @@ /** | ||
return cb(data); | ||
} else if (!error && response.statusCode == 204) { | ||
return cb(null, { | ||
message: 'The server has successfully fulfilled the request and that there is no additional content to send in the response payload body' | ||
}); | ||
} else return cb(error); | ||
@@ -35,3 +39,3 @@ } | ||
Freshdesk.prototype.req = function (method, url, data, cb) { | ||
Freshdesk.prototype.req = function (method, url, qs, data, cb) { | ||
authKey = new Buffer(this.apikey + ":X").toString('base64'); | ||
@@ -44,3 +48,4 @@ var options = { | ||
}, | ||
url: url | ||
url: url, | ||
qs: qs | ||
} | ||
@@ -52,26 +57,30 @@ if(data) | ||
Freshdesk.prototype.listAllTickets = function (cb) { | ||
this.req('GET', '{domain}/api/v2/tickets'.replace('{domain}', this.domain), null, cb) | ||
Freshdesk.prototype.listAllTickets = function (params, cb) { | ||
this.req('GET', '{domain}/api/v2/tickets'.replace('{domain}', this.domain), params, null, cb) | ||
} | ||
Freshdesk.prototype.listAllTicketFields = function (cb) { | ||
this.req('GET', '{domain}/api/v2/ticket_fields'.replace('{domain}', this.domain), null, cb) | ||
this.req('GET', '{domain}/api/v2/ticket_fields'.replace('{domain}', this.domain), null, null, cb) | ||
} | ||
Freshdesk.prototype.createTicket = function (data, cb) { | ||
this.req('POST', '{domain}/api/v2/tickets'.replace('{domain}', this.domain), data, cb) | ||
this.req('POST', '{domain}/api/v2/tickets'.replace('{domain}', this.domain), null, data, cb) | ||
} | ||
Freshdesk.prototype.getTicket = function (id, cb) { | ||
this.req('GET', '{domain}/api/v2/tickets/{id}'.replace('{domain}', this.domain).replace('{id}', id), null, cb) | ||
this.req('GET', '{domain}/api/v2/tickets/{id}'.replace('{domain}', this.domain).replace('{id}', id), null, null, cb) | ||
} | ||
Freshdesk.prototype.updateTicket = function (id, data, cb) { | ||
this.req('PUT', '{domain}/api/v2/tickets/{id}'.replace('{domain}', this.domain).replace('{id}', id), data, cb) | ||
this.req('PUT', '{domain}/api/v2/tickets/{id}'.replace('{domain}', this.domain).replace('{id}', id), null, data, cb) | ||
} | ||
Freshdesk.prototype.deleteTicket = function (id, cb) { | ||
this.req('DELETE', '{domain}/api/v2/tickets/{id}'.replace('{domain}', this.domain).replace('{id}', id), null, cb) | ||
this.req('DELETE', '{domain}/api/v2/tickets/{id}'.replace('{domain}', this.domain).replace('{id}', id), null, null, cb) | ||
} | ||
Freshdesk.prototype.restoreTicket = function (id, cb) { | ||
this.req('PUT', '{domain}/api/v2/tickets/{id}/restore'.replace('{domain}', this.domain).replace('{id}', id), null, null, cb) | ||
} | ||
Freshdesk.prototype.listAllConversations = function (id, cb) { | ||
@@ -82,5 +91,5 @@ this.req('GET', '{domain}/api/v2/tickets/{id}/conversations'.replace('{domain}', this.domain).replace('{id}', id), null, cb) | ||
Freshdesk.prototype.listAllTimeEntries = function (id, cb) { | ||
this.req('GET', '{domain}/api/v2/tickets/{id}/time_entries'.replace('{domain}', this.domain).replace('{id}', id), null, cb) | ||
this.req('GET', '{domain}/api/v2/tickets/{id}/time_entries'.replace('{domain}', this.domain).replace('{id}', id), null, null, cb) | ||
} | ||
module.exports = Freshdesk; |
{ | ||
"name": "node-freshdesk-api", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Node wrapper for Freshdesh v2 API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# node-freshdesk-api | ||
Node wrapper for Freshdesh v2 API | ||
Node wrapper for [Freshdesk v2 API](http://developer.freshdesk.com/api/#introduction) | ||
:construction_worker: Work In Progress | ||
## Install | ||
``` | ||
npm i node-freshdesk-api | ||
``` | ||
## Usage | ||
``` | ||
var fd = require('node-freshdesk-api'); | ||
var freshdesk = new fd('https://domain.freshdesk.com', 'yourApiKey'); | ||
``` | ||
## Functions and Responses | ||
- **createTicket(ticket, callback)** - Create a new ticket, list of [parameters](http://developer.freshdesk.com/api/#create_ticket) | ||
- **getTicket(id, callback)** - Get a ticket by its id | ||
- **updateTicket(id, ticket, callback)** - Update a ticket by its id, list of [parameters](http://developer.freshdesk.com/api/#update_ticket) | ||
- **deleteTicket(id, callback)** - Delete a ticket by its id | ||
- **restoreTicket(id, callback)** - Restore a ticket by its id | ||
- **listAllTickets(filter, callback)** - List All Tickets, check list of [filters](http://developer.freshdesk.com/api/#list_all_tickets) | ||
- **listAllTicketFields(callback)** - List All Ticket Fields | ||
- **listAllConversations(id, callback)** - List All Conversations of a Ticket by its id | ||
- **listAllTimeEntries(id, callback)** - List All Time Entries of a Ticket by its id | ||
## Examples | ||
### Create a new ticket | ||
``` | ||
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); | ||
}) | ||
``` | ||
### Update a ticket | ||
``` | ||
freshdesk.updateTicket(21, { | ||
description: 'updated description', | ||
status: 2, | ||
priority: 1 | ||
}, function (err, data) { | ||
console.log(err || data); | ||
}) | ||
``` | ||
### Get a ticket | ||
``` | ||
freshdesk.getTicket(21, function (err, data) { | ||
console.log(err || data); | ||
}) | ||
``` | ||
### Delete a ticket | ||
``` | ||
freshdesk.deleteTicket(21, function (err, data) { | ||
console.log(err || data); | ||
}) | ||
``` | ||
## Contribute | ||
Feature Request, Bugs and Ideas can be added [here.](https://github.com/arjunkomath/node-freshdesk-api/issues) | ||
## About Author | ||
Built with <3 by Arjun Komath, [arjunkomath@gmail.com](mailto:arjunkomath@gmail.com) | ||
## License | ||
See the [LICENSE](https://github.com/arjunkomath/node-freshdesk-api/blob/master/LICENSE) file for license rights and limitations (MIT). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7497
6
75
75