Breaking change
With v0.3.0
, all API SDK methods return results wrapped in a Response
object Promise<Response<T>>
. The Response
object has the following properties.
- Method:
.json()
: Call the.json()
method on the response to access the response body as model objects
- Properties:
.headers
: Use theheaders
property to access response headers as an object.statusCode
: Numeric response status code.body
: Access the raw response body
Usage example:
v0.2.0
:
// `employees` is an Array of `Freshteam.models.Employee`
const employees = await ft.employees.list();
// No further way to access response headers
v0.3.0
:
const res = await ft.employees.list();
const { headers, statusCode } = res;
const employees = res.json();
Introducing Freshservice Tickets endpoints
With this release, the API SDK supports the Tickets API endpoints for Freshservice, thanks to the efforts by @thakurganeshsinghfw.
Usage example:
// Setup
const { Freshservice } = require("@freshworks/api-sdk");
const fs = new Freshservice(domain, apiKey);
// Get list of tickets
const res = await fs.tickets.list();
const tickets = res.json();
New methods added
fs.tickets.list(query)
- List and search ticketsfs.tickets.get(id, opts)
- Get ticket by ID, with additional options to include detailsfs.tickets.create(ticket)
- Create a new ticketfs.tickets.update(id, ticket)
- Update an existing ticketfs.tickets.delete(id)
- Delete ticket by idfs.tickets.restore(id)
- Restore ticket by IDfs.tickets.createChildTicket(parentId, childTicket)
- Create a child ticket for a given parent ticketfs.tickets.timeEntry(ticketId, timeEntryId)
- Get a time entry by ID for a given ticketfs.tickets.timeEntries(ticketId, opts)
- Get all time entries for a ticketfs.tickets.createTimeEntry(ticketId, timeEntry)
- Create a time entry for a ticketfs.tickets.updateTimeEntry(ticketId, timeEntryId, timeEntry)
- Update an existing time entry for a ticketfs.tickets.deleteTimeEntry(ticketId, timeEntryId)
- Delete an existing time entry for a ticketfs.tickets.createSource(source)
- Create a new ticket sourcefs.tickets.getTask(ticketId, taskId)
- Get a specific task by idfs.tickets.getTasks(ticketId, opts)
- Get all tasks for a given ticketfs.tickets.createTask(ticketId, task)
- Create a new task for a given ticketfs.tickets.updateTask(ticketId, taskId, task)
- Update an existing taskfs.tickets.deleteTask(ticketId, taskId)
- Delete an existing task
See the docs for more details.