Skip to content

Commit b4aa584

Browse files
author
Kaustav Das Modak
authored
Release v0.3.0 (#84)
* 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>
1 parent 25f34c5 commit b4aa584

File tree

12 files changed

+2847
-12124
lines changed

12 files changed

+2847
-12124
lines changed

.github/workflows/build-test.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ on:
1111

1212
jobs:
1313
build:
14-
runs-on: [self-hosted, linux]
14+
runs-on: ubuntu-latest
1515

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

2121
steps:
22-
- uses: actions/checkout@v2
22+
- uses: actions/checkout@v3
2323
- name: Use Node.js ${{ matrix.node-version }}
24-
uses: actions/setup-node@v2
24+
uses: actions/setup-node@v3
2525
with:
26-
node-version: ${{ matrix.node-version }}
26+
node-version: 18
2727
cache: "npm"
2828
- name: Install dependencies
2929
run: npm ci

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ const ft = new Freshteam(domain, apiKey);
3434
Call a method, e.g., list all employees (who match a search criteria):
3535

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

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

50-
Call a method, e.g., remove a Freshservice Ticket
52+
Call a method, e.g., fetch a Freshservice Ticket
5153

5254
```js
53-
// Delete ticket with given ticket ID
54-
const ticket_id = 14000239432;
55-
const delTicket = await fs.tickets.delete(ticket_id);
55+
// Get a tick with given ticket ID
56+
const res = await fs.tickets.get(14000239432);
57+
// Access the response body as a `Ticket` object
58+
const ticket = res.json();
5659
```
5760

58-
- The first argument is the ticket ID - identifier of the ticket to be deleted
59-
- Returns a `Promise`
60-
6161
## Documentation
6262

6363
- [**Freshworks API SDK documentation**](https://developers.freshworks.com/api-sdk/)

docs/.vuepress/config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const { searchPlugin } = require('@vuepress/plugin-search')
2-
const { defaultTheme } = require('@vuepress/theme-default')
1+
import { searchPlugin } from '@vuepress/plugin-search'
2+
import { defaultTheme } from '@vuepress/theme-default'
33

44
module.exports = {
55
lang: "en-US",
@@ -178,4 +178,4 @@ module.exports = {
178178
hotKeys: ["s","/","f"]
179179
}),
180180
],
181-
};
181+
};

docs/freshservice/tickets.md

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,18 @@ Get the details of a Freshservice Ticket
5353

5454
```js
5555
// Using without query parameters included
56-
const ticket_id = 99999;
57-
const ticket = await fs.tickets.get(ticket_id);
56+
const ticketId = 99999;
57+
const ticket = await fs.tickets.get(ticketId);
5858
// use ticket.json() to access object elements
5959
// use ticket.header access returned headers
6060
// use ticket.statusCode access returned HTTP status code
6161
```
6262

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

134134
```js
135135
// Delete ticket with given ticket ID
136-
const ticket_id = 14000239432;
137-
const delTicket = await fs.tickets.delete(ticket_id);
136+
const ticketId = 14000239432;
137+
const delTicket = await fs.tickets.delete(ticketId);
138138
```
139139

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

147147
```js
148148
// Restore ticket with given ticket ID
149-
const ticket_id = 14000239432;
150-
const restoredTicket = await fs.tickets.restoreTicket(ticket_id);
149+
const ticketId = 14000239432;
150+
const restoredTicket = await fs.tickets.restoreTicket(ticketId);
151151
// use restoredTicket.json() to access object elements
152152
```
153153

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

161161
```js
162162
// Create a child ticket for a given parent ticket ID
163-
const ticket_id = 14000239432;
163+
const ticketId = 14000239432;
164164
const childTicket = {
165165
"cc_emails": [
166166
"test@freshservice.com"
@@ -185,13 +185,13 @@ const childTicket = {
185185
}
186186
]
187187
}
188-
const newChildTicket = await fs.tickets.createChildTicket(childTicket, ticket_id);
188+
const newChildTicket = await fs.tickets.createChildTicket(ticketId, childTicket);
189189
// use newChildTicket.json() to access object elements
190190

191191
```
192192

193-
- 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
194-
- The second argument is the ticket ID - identifier of the parent ticket for which child ticket is to be created
193+
- The first argument is the ticket ID - identifier of the parent ticket for which child ticket is to be created
194+
- 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
195195
- Returns a `Promise` that resolves to a [`Freshservice.models.Ticket`](../api/classes/freshservice_models.Ticket.html) object
196196

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

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

212212
```js
213213
// List all time entries for given ticket ID with pagination option
214-
const ticket_id = 14000239432;
214+
const ticketId = 14000239432;
215215
const opts = {
216216
page: 1,
217217
per_page: 10
218218
};
219-
const timeEntries = await fs.tickets.timeEntries(ticket_id, opts);
219+
const timeEntries = await fs.tickets.timeEntries(ticketId, opts);
220220
// use timeEntries.json() to access object elements
221221
```
222222

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

231231
```js
232232
// Get time entry for ticket with ticket ID and time entry ID
233-
const ticket_id = 14000239432;
234-
const time_entry_id = 14702899;
235-
const timeEntry = await fs.tickets.timeEntry(ticket_id, time_entry_id);
233+
const ticketId = 14000239432;
234+
const timeEntryId = 14702899;
235+
const timeEntry = await fs.tickets.timeEntry(ticketId, timeEntryId);
236236
// use timeEntry.json() to access object elements
237237
```
238238

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

247247
```js
248-
const newTimeEntry = await fs.tickets.createTimeEntry(time_entry, ticket_id);
248+
const newTimeEntry = await fs.tickets.createTimeEntry(ticketId, timeEntry);
249249
// use newTimeEntry.json() to access object elements
250250
```
251251

252-
- 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
253-
- The second argument is ID of the ticket for which time entries are to be added
252+
- The first argument is ID of the ticket for which time entries are to be added
253+
- 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
254254
- Returns a `Promise` that resolves to a [`Freshservice.models.TimeEntry`](.../api/classes/freshservice_models.TimeEntry.html) object
255255

256256
### Update a time entry
257257

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

260260
```js
261-
const updatedTimeEntry = await fs.tickets.updateTimeEntry(time_entry, ticket_id, time_entry_id);
261+
const updatedTimeEntry = await fs.tickets.updateTimeEntry(ticketId, timeEntryId, timeEntry);
262262
// use updatedTimeEntry.json() to access object elements
263263
```
264264

265-
- 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
266-
- The second argument is ID for the ticket for which time entries are to be updated
267-
- The third argument is ID of the time entry which is to be updated
265+
- The first argument is ID for the ticket for which time entries are to be updated
266+
- The second argument is ID of the time entry which is to be updated
267+
- 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
268268
- Returns a `Promise` that resolves to a [`Freshservice.models.TimeEntry`](.../api/classes/freshservice_models.TimeEntry.html) object
269269

270270
### Delete a Time Entry
271271

272272
Remove a time entry on a freshservice ticket
273273

274274
```js
275-
const deleteTimeEntry = await fs.tickets.deleteTimeEntry(ticket_id, time_entry_id);
275+
const deleteTimeEntry = await fs.tickets.deleteTimeEntry(ticketId, timeEntryId);
276276
// use deleteTimeEntry.json() to access object elements
277277
```
278278

@@ -289,7 +289,7 @@ const source = {
289289
name: "Email",
290290
position: 1
291291
};
292-
const fieldSource = await fs.tickets.source(source);
292+
const fieldSource = await fs.tickets.createSource(source);
293293
// use fieldSource.json() to access object elements
294294
```
295295

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

307307
```js
308-
const ticket_id = 14000239432;
308+
const ticketId = 14000239432;
309309
const task = {
310310
parent_type: "Ticket",
311311
due_date: "2021-11-24T11:30:00Z",
@@ -314,22 +314,22 @@ const task = {
314314
description: "Renew Software license",
315315
start_date: "2021-11-22T16:58:45Z"
316316
};
317-
const newTask = await fs.tickets.createTask(task, ticket_id);
317+
const newTask = await fs.tickets.createTask(ticketId, task);
318318
// use newTask.json() to access object elements
319319
```
320320

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

325325
### View task on a ticket
326326

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

329329
```js
330-
const ticket_id = 14000239432;
331-
const task_id = 48;
332-
const taskDetail = await fs.tickets.getTask(ticket_id, task_id);
330+
const ticketId = 14000239432;
331+
const taskId = 48;
332+
const taskDetail = await fs.tickets.getTask(ticketId, taskId);
333333
// use taskDetail.json() to access object elements
334334
```
335335

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

344344
```js
345345
// Retrieve all the tasks for ticket with given ticket ID with optional parameter
346-
const ticket_id = 14000239432;
346+
const ticketId = 14000239432;
347347
const opts = {
348348
page: 1,
349349
per_page: 10
350350
};
351-
const taskList = await fs.tickets.getTasks(ticket_id, opts);
351+
const taskList = await fs.tickets.getTasks(ticketId, opts);
352352
// use taskList.json() to access object elements
353353
```
354354

355355
```js
356356
// Retrieve all the tasks for ticket with given ticket ID without optional parameter
357-
const ticket_id = 14000239432;
358-
const taskList = await fs.tickets.getTasks(ticket_id);
357+
const ticketId = 14000239432;
358+
const taskList = await fs.tickets.getTasks(ticketId);
359359
// use taskList.json() to access object elements
360360
```
361361

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

370370
```js
371-
const ticket_id = 14000239432;
372-
const task_id = 48;
371+
const ticketId = 14000239432;
372+
const taskId = 48;
373373
const task = {
374374
parent_type: "Ticket",
375375
due_date: "2021-11-24T11:30:00Z",
@@ -378,23 +378,23 @@ const task = {
378378
description: "Renew Software license",
379379
start_date: "2021-11-22T16:58:45Z"
380380
};
381-
const updateTask = await fs.tickets.updateTask(task, ticket_id, task_id);
381+
const updateTask = await fs.tickets.updateTask(ticketId, taskId, task);
382382
// use updateTask.json() to access object elements
383383
```
384384

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

390390
### Delete task on a ticket
391391

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

394394
```js
395-
const ticket_id = 14000239432;
396-
const task_id = 48;
397-
const deleteTask = await fs.tickets.deleteTask(ticket_id, task_id);
395+
const ticketId = 14000239432;
396+
const taskId = 48;
397+
const deleteTask = await fs.tickets.deleteTask(ticketId, taskId);
398398
// use deleteTask.json() to access object elements
399399
```
400400

docs/freshteam/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ const ft = new Freshteam(domain, apiKey);
1717
Call a method, e.g., list all employees (who match a search criteria):
1818

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

2325
## Models

docs/get-started.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ To use this library in a Freshworks app, add the following to the `"dependencies
2929
{
3030
// ...
3131
"dependencies": {
32-
"@freshworks/api-sdk": "0.2.1"
32+
"@freshworks/api-sdk": "0.3.0"
3333
}
3434
}
3535
```
3636

37-
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`:
37+
#### Apps on platform-version 2.2
38+
39+
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`:
3840

3941
```js
4042
{
@@ -43,6 +45,8 @@ Then, allow the app to communicate with the domain for the product's REST API th
4345
}
4446
```
4547

48+
#### Running
49+
4650
The Freshworks CLI (`fdk`) will fetch the dependency next time you run `fdk run`.
4751

4852
## Sample code

0 commit comments

Comments
 (0)