# freshdesk

> A nodejs sdk for the Freshdesk API. Some major routes are implemented, but this SDK exposes the basic GET, POST, PUT, DELETE routes so that you can fill in the gaps in your apps for the unimplemented routes, and send a pull request to complete it!

Latest version **1.1.1** (published 2017-01-05) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install freshdesk
pnpm add freshdesk
yarn add freshdesk
bun add freshdesk
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2017-01-05 |
| First published | 2015-02-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Kumar Harsh |
| Maintainers | kumarharsh |

## Links

- npm: https://www.npmjs.com/package/freshdesk
- Repository: https://github.com/kumarharsh/node-freshdesk
- Homepage: http://github.com/kumarharsh/node-freshdesk
- Issues: https://github.com/kumarharsh/node-freshdesk/issues
- npm.io page: https://npm.io/package/freshdesk

## Dependencies (1)

- [request](https://npm.io/package/request.md) ^2.53.0

## Recent versions

- 1.1.1 (latest) — 2017-01-05
- 1.1.0 — 2016-11-15
- 1.0.0 — 2016-11-12
- 0.2.0 — 2016-04-14
- 0.1.1 — 2015-02-17
- 0.1.0 — 2015-02-17

## README

# node-freshdesk

**WARNING**

[![npm version](https://img.shields.io/badge/NPM-deprecated-red.svg)](https://github.com/maxkoryukov/node-freshdesk-api/issues/1)

This repository and corresponding NPM package are deprecated in favor of [**freshdesk-api**](https://www.npmjs.com/package/freshdesk-api).

Useful links:

1. [NPM package](https://www.npmjs.com/package/freshdesk-api):
    * v2: `npm install freshdesk-api`
    * v1: `npm install freshdesk-api@APIv1`
2. GitHub, `node-freshdesk-api`:
    * [v2 on master branch](https://github.com/arjunkomath/node-freshdesk-api)
    * [v1 branch](https://github.com/arjunkomath/node-freshdesk-api/tree/API-v1)

----

A NodeJS library for integrating your backend with Freshdesk.

[![npm version](https://badge.fury.io/js/freshdesk.svg)](https://badge.fury.io/js/freshdesk)

# Install

```
npm install freshdesk
```

# Usage

You'll need your API Key and the base url of your support portal handy for configuring the SDK. To get your API key, refer the [Freshdesk Docs](http://freshdesk.com/api#authentication).

```
var _fd = require('freshdesk')
var Freshdesk = new _fd('http://mydomain.freshdesk.com', 'MyR4nD0MAp1KeY');

Freshdesk.listTickets(function(err, res, body) {
  console.log("The tickets are: ", body);
});
```

# Supported Functions

Most of the functions pertaining **Tickets** and **Users** are implemented. For unimplemented routes, you can use the raw routes, such as `Freshdesk.get()` to make the requests directly.

Here are the currently supported functions. For a detailed explanation of the arguments you have to pass to each functions, refer to the [official docs](http://freshdesk.com/api).

* **createTicket** (data <object>, cb <function>)
  method: post
  url: `/helpdesk/tickets.json`,

* **listTickets** (cb <function>)
  method: get
  url: `/helpdesk/tickets.json`

* **allTickets** (cb <function>)
  method: get
  url: `/helpdesk/tickets/filter/all_tickets?format=json`

* **getTicket** (id <number>, cb <function>)
  method: get
  url: `/helpdesk/tickets/#{id}.json`

* **updateTicket** (id <number>, cb <function>)
  method: put
  url: `/helpdesk/tickets/#{id}.json`, data

* **pickTicket** (id <number>, cb <function>)
  method: put
  url: `/helpdesk/tickets/#{id}/pick_tickets.json`, {}

* **deleteTicket** (id <number>, cb <function>)
  method: delete
  url: `/helpdesk/tickets/#{id}.json`

* **restoreTicket** (id <number>, cb <function>)
  method: put
  url: `/helpdesk/tickets/#{id}/restore.json`

* **assignTicket** (id <number>, user_id <freshdesk_user_id>, cb <function>)
  method: put
  url: `/helpdesk/tickets/#{id}/assign.json?responder_id=#{user_id}`

* **ticketFields** (cb <function>)
  method: get
  url: `/ticket_fields.json`

* **addNoteToTicket** (id <number>, note <object>, cb <function>)
  method: post
  url: `/helpdesk/tickets/#{id}/conversations/note.json`

* **createUser** (cb <function>)
  method: post
  url: `/contacts.json`, contact

* **listUsers** (cb <function>)
  method: get
  url: `/contacts.json`state=all'

* **updateUser** (id <number>, cb <function>)
  method: put
  url: `/contacts/#{id}.json`, data

* **getUserByEmail** (email_id <string>, cb <function>)
  method: GET
  url: `/contacts.json?state=all&query=#{query}`

# Examples

### Get a Particular Ticket
```
Freshdesk.pickTicket(100, function(err, res) {
  console.log("My Ticket is", res.body);
});
```

### Create a New TIcket
```
var ticket = {
  'helpdesk_ticket': {
    'description': "Hello, I'm an ephemeral ticket created from the API. I will be deleted as soon as my creator wishes so...",
    'subject': "Efemeros",
    'email': 'efemeros@mailinator.com',
    'priority': '1',
    'status': '2',
    'custom_field': {
      // remove these comments, as they're not valid json
      // any custom fields you'd have configured in your app...
      // like:
      // 'location_XXXXX': 'Tristan da Cunha'
      // where XXXXX is a (possibly random) ID appended to your custom field
      // This would most probably be different for each portal.
    }
  }
};
Freshdesk.createTicket(100, function(err, res) {
  console.log("My Ticket is", res.body);
});
```

# Contributing

If you feel the need to add more functions, just fork this repo, add your functions and submit a PR. Wanna improve docs or the source, or even add tests? You're more than welcome :)
This is just a side project I created because I needed it, and the existing `node-freshdesk` [lacked some functions](https://github.com/capraconsulting/node-freshdesk/issues/2) which my project needed.

---
_Source: https://npm.io/package/freshdesk · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
