Skip to content

Commit

Permalink
Release v0.3.0 (#84)
Browse files Browse the repository at this point in the history
* Update README.md

Signed-off-by: Kaustav Das Modak <kaustav.dasmodak@freshworks.com>

* DX pass: Freshservice tickets endpoints

Signed-off-by: Kaustav Das Modak <kaustav.dasmodak@freshworks.com>

* prettier format

Signed-off-by: Kaustav Das Modak <kaustav.dasmodak@freshworks.com>

* Upgrade dependencies and remove unnecessary ones

Signed-off-by: Kaustav Das Modak <kaustav.dasmodak@freshworks.com>

* Bump version to v0.3.0

Signed-off-by: Kaustav Das Modak <kaustav.dasmodak@freshworks.com>

* GH Actions: Use ubuntu-latest and Node 18 for tests

Signed-off-by: Kaustav Das Modak <kaustav.dasmodak@freshworks.com>

Signed-off-by: Kaustav Das Modak <kaustav.dasmodak@freshworks.com>
  • Loading branch information
Kaustav Das Modak authored Dec 20, 2022
1 parent 25f34c5 commit b4aa584
Show file tree
Hide file tree
Showing 12 changed files with 2,847 additions and 12,124 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ on:

jobs:
build:
runs-on: [self-hosted, linux]
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
node-version: [12.x, 14.x, 16.x, 18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
node-version: 18
cache: "npm"
- name: Install dependencies
run: npm ci
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ const ft = new Freshteam(domain, apiKey);
Call a method, e.g., list all employees (who match a search criteria):

```js
const employees = await ft.employees.list({ first_name: "Arthur", last_name: "Dent" });
const res = await ft.employees.list({ first_name: "Arthur", last_name: "Dent" });
// Access the response body as an Array of `Employee` objects
const employees = res.json();
```

### Freshservice
Expand All @@ -47,17 +49,15 @@ const { Freshservice } = require("@freshworks/api-sdk");
const fs = new Freshservice(domain, apiKey);
```

Call a method, e.g., remove a Freshservice Ticket
Call a method, e.g., fetch a Freshservice Ticket

```js
// Delete ticket with given ticket ID
const ticket_id = 14000239432;
const delTicket = await fs.tickets.delete(ticket_id);
// Get a tick with given ticket ID
const res = await fs.tickets.get(14000239432);
// Access the response body as a `Ticket` object
const ticket = res.json();
```

- The first argument is the ticket ID - identifier of the ticket to be deleted
- Returns a `Promise`

## Documentation

- [**Freshworks API SDK documentation**](https://developers.freshworks.com/api-sdk/)
Expand Down
6 changes: 3 additions & 3 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { searchPlugin } = require('@vuepress/plugin-search')
const { defaultTheme } = require('@vuepress/theme-default')
import { searchPlugin } from '@vuepress/plugin-search'
import { defaultTheme } from '@vuepress/theme-default'

module.exports = {
lang: "en-US",
Expand Down Expand Up @@ -178,4 +178,4 @@ module.exports = {
hotKeys: ["s","/","f"]
}),
],
};
};
94 changes: 47 additions & 47 deletions docs/freshservice/tickets.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,18 @@ Get the details of a Freshservice Ticket

```js
// Using without query parameters included
const ticket_id = 99999;
const ticket = await fs.tickets.get(ticket_id);
const ticketId = 99999;
const ticket = await fs.tickets.get(ticketId);
// use ticket.json() to access object elements
// use ticket.header access returned headers
// use ticket.statusCode access returned HTTP status code
```

```js
// Using with query parameters included
const ticket_id = 99999;
const ticketId = 99999;
const include = "stats";
const ticket = await fs.tickets.get(ticket_id, { include });
const ticket = await fs.tickets.get(ticketId, { include });
// use ticket.json() to access object elements
// use ticket.header access returned headers
// use ticket.statusCode access returned HTTP status code
Expand Down Expand Up @@ -133,8 +133,8 @@ Remove a Freshservice Ticket

```js
// Delete ticket with given ticket ID
const ticket_id = 14000239432;
const delTicket = await fs.tickets.delete(ticket_id);
const ticketId = 14000239432;
const delTicket = await fs.tickets.delete(ticketId);
```

- The first argument is the ticket ID - identifier of the ticket to be deleted
Expand All @@ -146,8 +146,8 @@ Restore a deleted Freshservice Ticket

```js
// Restore ticket with given ticket ID
const ticket_id = 14000239432;
const restoredTicket = await fs.tickets.restoreTicket(ticket_id);
const ticketId = 14000239432;
const restoredTicket = await fs.tickets.restoreTicket(ticketId);
// use restoredTicket.json() to access object elements
```

Expand All @@ -160,7 +160,7 @@ Create a new child Ticket on an existing Freshservice Ticket

```js
// Create a child ticket for a given parent ticket ID
const ticket_id = 14000239432;
const ticketId = 14000239432;
const childTicket = {
"cc_emails": [
"test@freshservice.com"
Expand All @@ -185,13 +185,13 @@ const childTicket = {
}
]
}
const newChildTicket = await fs.tickets.createChildTicket(childTicket, ticket_id);
const newChildTicket = await fs.tickets.createChildTicket(ticketId, childTicket);
// use newChildTicket.json() to access object elements

```

- The First argument is an object of type [`Freshservice.models.Ticket`](../api/classes/freshservice_models.Ticket.html) consisting details of the child ticket to be created
- The second argument is the ticket ID - identifier of the parent ticket for which child ticket is to be created
- The first argument is the ticket ID - identifier of the parent ticket for which child ticket is to be created
- The second argument is an object of type [`Freshservice.models.Ticket`](../api/classes/freshservice_models.Ticket.html) consisting details of the child ticket to be created
- Returns a `Promise` that resolves to a [`Freshservice.models.Ticket`](../api/classes/freshservice_models.Ticket.html) object

## Time Entries
Expand All @@ -204,19 +204,19 @@ View all time entries on a ticket with the given ID from Freshservice

```js
// List all time entries for given ticket ID with default pagination option i.e., page = 1 and per_page = 30
const ticket_id = 14000239432;
const timeEntries = await fs.tickets.timeEntries(ticket_id);
const ticketId = 14000239432;
const timeEntries = await fs.tickets.timeEntries(ticketId);
// use timeEntries.json() to access object elements
```

```js
// List all time entries for given ticket ID with pagination option
const ticket_id = 14000239432;
const ticketId = 14000239432;
const opts = {
page: 1,
per_page: 10
};
const timeEntries = await fs.tickets.timeEntries(ticket_id, opts);
const timeEntries = await fs.tickets.timeEntries(ticketId, opts);
// use timeEntries.json() to access object elements
```

Expand All @@ -230,9 +230,9 @@ View all time entries on ticket with the given ticket ID from Freshservice

```js
// Get time entry for ticket with ticket ID and time entry ID
const ticket_id = 14000239432;
const time_entry_id = 14702899;
const timeEntry = await fs.tickets.timeEntry(ticket_id, time_entry_id);
const ticketId = 14000239432;
const timeEntryId = 14702899;
const timeEntry = await fs.tickets.timeEntry(ticketId, timeEntryId);
// use timeEntry.json() to access object elements
```

Expand All @@ -245,34 +245,34 @@ const timeEntry = await fs.tickets.timeEntry(ticket_id, time_entry_id);
Create a new time entry on a freshservice ticket

```js
const newTimeEntry = await fs.tickets.createTimeEntry(time_entry, ticket_id);
const newTimeEntry = await fs.tickets.createTimeEntry(ticketId, timeEntry);
// use newTimeEntry.json() to access object elements
```

- The first argument is an object of type [`Freshservice.models.TimeEntry`](.../api/classes/freshservice_models.TimeEntry.html) containing the details of time entry to be created
- The second argument is ID of the ticket for which time entries are to be added
- The first argument is ID of the ticket for which time entries are to be added
- The second argument is an object of type [`Freshservice.models.TimeEntry`](.../api/classes/freshservice_models.TimeEntry.html) containing the details of time entry to be created
- Returns a `Promise` that resolves to a [`Freshservice.models.TimeEntry`](.../api/classes/freshservice_models.TimeEntry.html) object

### Update a time entry

Update time entry for ticket with given ticket ID and time entry ID

```js
const updatedTimeEntry = await fs.tickets.updateTimeEntry(time_entry, ticket_id, time_entry_id);
const updatedTimeEntry = await fs.tickets.updateTimeEntry(ticketId, timeEntryId, timeEntry);
// use updatedTimeEntry.json() to access object elements
```

- The first argument is an object of type [`Freshservice.models.TimeEntry`](.../api/classes/freshservice_models.TimeEntry.html) containing the details of time entry to be updated
- The second argument is ID for the ticket for which time entries are to be updated
- The third argument is ID of the time entry which is to be updated
- The first argument is ID for the ticket for which time entries are to be updated
- The second argument is ID of the time entry which is to be updated
- The third argument is an object of type [`Freshservice.models.TimeEntry`](.../api/classes/freshservice_models.TimeEntry.html) containing the details of time entry to be updated
- Returns a `Promise` that resolves to a [`Freshservice.models.TimeEntry`](.../api/classes/freshservice_models.TimeEntry.html) object

### Delete a Time Entry

Remove a time entry on a freshservice ticket

```js
const deleteTimeEntry = await fs.tickets.deleteTimeEntry(ticket_id, time_entry_id);
const deleteTimeEntry = await fs.tickets.deleteTimeEntry(ticketId, timeEntryId);
// use deleteTimeEntry.json() to access object elements
```

Expand All @@ -289,7 +289,7 @@ const source = {
name: "Email",
position: 1
};
const fieldSource = await fs.tickets.source(source);
const fieldSource = await fs.tickets.createSource(source);
// use fieldSource.json() to access object elements
```

Expand All @@ -305,7 +305,7 @@ This section lists all API that can be used to create, edit or otherwise manipul
Create a new task against a ticket in Freshservice

```js
const ticket_id = 14000239432;
const ticketId = 14000239432;
const task = {
parent_type: "Ticket",
due_date: "2021-11-24T11:30:00Z",
Expand All @@ -314,22 +314,22 @@ const task = {
description: "Renew Software license",
start_date: "2021-11-22T16:58:45Z"
};
const newTask = await fs.tickets.createTask(task, ticket_id);
const newTask = await fs.tickets.createTask(ticketId, task);
// use newTask.json() to access object elements
```

- The first argument is an object of type [`Freshservice.models.Task`](../api/classes/freshservice_models.Task.html) containing details of task to be created
- The second argument is the ticket ID - identifier of the ticket for which task is to be created
- The first argument is the ticket ID - identifier of the ticket for which task is to be created
- The second argument is an object of type [`Freshservice.models.Task`](../api/classes/freshservice_models.Task.html) containing details of task to be created
- Returns a `Promise` that resolves to a [`Freshservice.models.Task`](../api/classes/freshservice_models.Task.html) object

### View task on a ticket

Retrieve a task on a ticket request with the given ID from Freshservice

```js
const ticket_id = 14000239432;
const task_id = 48;
const taskDetail = await fs.tickets.getTask(ticket_id, task_id);
const ticketId = 14000239432;
const taskId = 48;
const taskDetail = await fs.tickets.getTask(ticketId, taskId);
// use taskDetail.json() to access object elements
```

Expand All @@ -343,19 +343,19 @@ Retrieve a task on a ticket request with the given ID from Freshservice

```js
// Retrieve all the tasks for ticket with given ticket ID with optional parameter
const ticket_id = 14000239432;
const ticketId = 14000239432;
const opts = {
page: 1,
per_page: 10
};
const taskList = await fs.tickets.getTasks(ticket_id, opts);
const taskList = await fs.tickets.getTasks(ticketId, opts);
// use taskList.json() to access object elements
```

```js
// Retrieve all the tasks for ticket with given ticket ID without optional parameter
const ticket_id = 14000239432;
const taskList = await fs.tickets.getTasks(ticket_id);
const ticketId = 14000239432;
const taskList = await fs.tickets.getTasks(ticketId);
// use taskList.json() to access object elements
```

Expand All @@ -368,8 +368,8 @@ const taskList = await fs.tickets.getTasks(ticket_id);
Update an existing task on an existing ticket request in Freshservice

```js
const ticket_id = 14000239432;
const task_id = 48;
const ticketId = 14000239432;
const taskId = 48;
const task = {
parent_type: "Ticket",
due_date: "2021-11-24T11:30:00Z",
Expand All @@ -378,23 +378,23 @@ const task = {
description: "Renew Software license",
start_date: "2021-11-22T16:58:45Z"
};
const updateTask = await fs.tickets.updateTask(task, ticket_id, task_id);
const updateTask = await fs.tickets.updateTask(ticketId, taskId, task);
// use updateTask.json() to access object elements
```

- The first argument is an object of type [`Freshservice.models.Task`](../api/classes/freshservice_models.Task.html) containing details of task to be updated
- The second argument is the ticket ID - identifier of the ticket for which task is to be updated
- The first argument is the ticket ID - identifier of the ticket for which task is to be updated
- The second argument is identifier of the task which is to be updated
- The third argument is an object of type [`Freshservice.models.Task`](../api/classes/freshservice_models.Task.html) containing details of task to be updated
- Returns a `Promise` that resolves to a [`Freshservice.models.Task`](../api/classes/freshservice_models.Task.html) object

### Delete task on a ticket

Delete the task on a ticket request with the given ID from Freshservice

```js
const ticket_id = 14000239432;
const task_id = 48;
const deleteTask = await fs.tickets.deleteTask(ticket_id, task_id);
const ticketId = 14000239432;
const taskId = 48;
const deleteTask = await fs.tickets.deleteTask(ticketId, taskId);
// use deleteTask.json() to access object elements
```

Expand Down
4 changes: 3 additions & 1 deletion docs/freshteam/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ const ft = new Freshteam(domain, apiKey);
Call a method, e.g., list all employees (who match a search criteria):

```js
const employees = await ft.employees.list({ first_name: "Arthur", last_name: "Dent" });
const res = await ft.employees.list({ first_name: "Arthur", last_name: "Dent" });
// Access the response body as an Array of `Employee` objects
const employees = res.json();
```

## Models
Expand Down
8 changes: 6 additions & 2 deletions docs/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ To use this library in a Freshworks app, add the following to the `"dependencies
{
// ...
"dependencies": {
"@freshworks/api-sdk": "0.2.1"
"@freshworks/api-sdk": "0.3.0"
}
}
```

Then, allow the app to communicate with the domain for the product's REST API that you would be using (currently, only Freshteam and Freshservice). To do this, update the `"whitelisted-domains"` array in `manifest.json`:
#### Apps on platform-version 2.2

For apps on platform-version up to `2.2`, allow the app to communicate with the domain for the product's REST API that you would be using (currently, only Freshteam and Freshservice). To do this, update the `"whitelisted-domains"` array in `manifest.json`:

```js
{
Expand All @@ -43,6 +45,8 @@ Then, allow the app to communicate with the domain for the product's REST API th
}
```

#### Running

The Freshworks CLI (`fdk`) will fetch the dependency next time you run `fdk run`.

## Sample code
Expand Down
Loading

0 comments on commit b4aa584

Please sign in to comment.