Skip to content

Commit 25f34c5

Browse files
thakurganeshsinghfwkaustavdm
authored andcommitted
Adding Pagination and header changes to Freshservice Tickets endpoint
Adding Pagination and header changes to Freshservice Tickets endpoint
1 parent 2f11b5c commit 25f34c5

File tree

3 files changed

+112
-57
lines changed

3 files changed

+112
-57
lines changed

docs/freshservice/tickets.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ A ticket can be an incident or a service request. An incident is a disruption to
1212
1313
## Ticket
1414

15-
These APIs help to list, retrive, create, update, delete, restore and other operations associated with FreshService tickets
15+
These APIs help to list, retrive, create, update, delete, restore and other operations associated with FreshService tickets. All the methods return response into Response object. The response object has 3 supported elements and 1 method as depicted below
16+
17+
- Use object.json() to access the object elements
18+
- Use object.statusCode to access object HTTP status code returned by the endpoint
19+
- Use object.header to access returned headers.
1620

1721
### List tickets
1822

@@ -21,6 +25,9 @@ Fetch the list of all Tickets in Freshservice
2125
```js
2226
// Using with query parameters included
2327
const tickets = await fs.tickets.list();
28+
// use tickets.json() to access object elements
29+
// use tickets.header access returned headers
30+
// use tickets.statusCode access returned HTTP status code
2431
```
2532

2633
```js
@@ -32,6 +39,9 @@ const query = {
3239
order_type: "asc"
3340
};
3441
const tickets = await fs.tickets.list(query);
42+
// use tickets.json() to access object elements
43+
// use tickets.header access returned headers
44+
// use tickets.statusCode access returned HTTP status code
3545
```
3646

3747
- Returns a `Promise` that resolves to an [`Freshservice.models.Tickets`](../api/classes/freshservice_models.Tickets.html) object
@@ -45,13 +55,19 @@ Get the details of a Freshservice Ticket
4555
// Using without query parameters included
4656
const ticket_id = 99999;
4757
const ticket = await fs.tickets.get(ticket_id);
58+
// use ticket.json() to access object elements
59+
// use ticket.header access returned headers
60+
// use ticket.statusCode access returned HTTP status code
4861
```
4962

5063
```js
5164
// Using with query parameters included
5265
const ticket_id = 99999;
5366
const include = "stats";
5467
const ticket = await fs.tickets.get(ticket_id, { include });
68+
// use ticket.json() to access object elements
69+
// use ticket.header access returned headers
70+
// use ticket.statusCode access returned HTTP status code
5571
```
5672

5773
- The first argument is the ticket ID - identifier of the ticket to be updated
@@ -91,6 +107,9 @@ const ticket = {
91107
]
92108
}
93109
const newTicket = await fs.tickets.create(ticket);
110+
// use newTicket.json() to access object elements
111+
// use newTicket.header access returned headers
112+
// use newTicket.statusCode access returned HTTP status code
94113
```
95114

96115
- Returns a `Promise` that resolves to a [`Freshservice.models.Ticket`](../api/classes/freshservice_models.Ticket.html) object
@@ -101,6 +120,7 @@ Edit an existing Freshservice Ticket
101120

102121
```js
103122
const updatedTicket = await fs.tickets.update(id, ticket);
123+
// use updatedTicket.json() to access object elements
104124
```
105125

106126
- The first argument is the ticket ID - identifier of the ticket to be updated
@@ -128,6 +148,7 @@ Restore a deleted Freshservice Ticket
128148
// Restore ticket with given ticket ID
129149
const ticket_id = 14000239432;
130150
const restoredTicket = await fs.tickets.restoreTicket(ticket_id);
151+
// use restoredTicket.json() to access object elements
131152
```
132153

133154
- The first argument is the ticket ID - identifier of the ticket to be restored
@@ -165,6 +186,7 @@ const childTicket = {
165186
]
166187
}
167188
const newChildTicket = await fs.tickets.createChildTicket(childTicket, ticket_id);
189+
// use newChildTicket.json() to access object elements
168190

169191
```
170192

@@ -184,6 +206,7 @@ View all time entries on a ticket with the given ID from Freshservice
184206
// List all time entries for given ticket ID with default pagination option i.e., page = 1 and per_page = 30
185207
const ticket_id = 14000239432;
186208
const timeEntries = await fs.tickets.timeEntries(ticket_id);
209+
// use timeEntries.json() to access object elements
187210
```
188211

189212
```js
@@ -194,6 +217,7 @@ const opts = {
194217
per_page: 10
195218
};
196219
const timeEntries = await fs.tickets.timeEntries(ticket_id, opts);
220+
// use timeEntries.json() to access object elements
197221
```
198222

199223
- The First argument is an ID of ticket
@@ -209,6 +233,7 @@ View all time entries on ticket with the given ticket ID from Freshservice
209233
const ticket_id = 14000239432;
210234
const time_entry_id = 14702899;
211235
const timeEntry = await fs.tickets.timeEntry(ticket_id, time_entry_id);
236+
// use timeEntry.json() to access object elements
212237
```
213238

214239
- The First argument is an ID of ticket
@@ -221,6 +246,7 @@ Create a new time entry on a freshservice ticket
221246

222247
```js
223248
const newTimeEntry = await fs.tickets.createTimeEntry(time_entry, ticket_id);
249+
// use newTimeEntry.json() to access object elements
224250
```
225251

226252
- 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
@@ -233,6 +259,7 @@ Update time entry for ticket with given ticket ID and time entry ID
233259

234260
```js
235261
const updatedTimeEntry = await fs.tickets.updateTimeEntry(time_entry, ticket_id, time_entry_id);
262+
// use updatedTimeEntry.json() to access object elements
236263
```
237264

238265
- 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
@@ -246,6 +273,7 @@ Remove a time entry on a freshservice ticket
246273

247274
```js
248275
const deleteTimeEntry = await fs.tickets.deleteTimeEntry(ticket_id, time_entry_id);
276+
// use deleteTimeEntry.json() to access object elements
249277
```
250278

251279
- The first argument is the ticket ID - identifier of the ticket for which time entry is to be deleted
@@ -262,6 +290,7 @@ const source = {
262290
position: 1
263291
};
264292
const fieldSource = await fs.tickets.source(source);
293+
// use fieldSource.json() to access object elements
265294
```
266295

267296
- The source argument is an object of type [`Freshservice.models.TicketSource`](../api/classes/freshservice_models.TicketSource.html) containing the details of custom ticket source to be created
@@ -286,6 +315,7 @@ const task = {
286315
start_date: "2021-11-22T16:58:45Z"
287316
};
288317
const newTask = await fs.tickets.createTask(task, ticket_id);
318+
// use newTask.json() to access object elements
289319
```
290320

291321
- The first argument is an object of type [`Freshservice.models.Task`](../api/classes/freshservice_models.Task.html) containing details of task to be created
@@ -300,6 +330,7 @@ Retrieve a task on a ticket request with the given ID from Freshservice
300330
const ticket_id = 14000239432;
301331
const task_id = 48;
302332
const taskDetail = await fs.tickets.getTask(ticket_id, task_id);
333+
// use taskDetail.json() to access object elements
303334
```
304335

305336
- The first argument is a Ticket identifier for which task is to be retrieved
@@ -318,12 +349,14 @@ const opts = {
318349
per_page: 10
319350
};
320351
const taskList = await fs.tickets.getTasks(ticket_id, opts);
352+
// use taskList.json() to access object elements
321353
```
322354

323355
```js
324356
// Retrieve all the tasks for ticket with given ticket ID without optional parameter
325357
const ticket_id = 14000239432;
326358
const taskList = await fs.tickets.getTasks(ticket_id);
359+
// use taskList.json() to access object elements
327360
```
328361

329362
- The first argument is a Ticket identifier for which task is to be retrieved
@@ -346,6 +379,7 @@ const task = {
346379
start_date: "2021-11-22T16:58:45Z"
347380
};
348381
const updateTask = await fs.tickets.updateTask(task, ticket_id, task_id);
382+
// use updateTask.json() to access object elements
349383
```
350384

351385
- The first argument is an object of type [`Freshservice.models.Task`](../api/classes/freshservice_models.Task.html) containing details of task to be updated
@@ -361,6 +395,7 @@ Delete the task on a ticket request with the given ID from Freshservice
361395
const ticket_id = 14000239432;
362396
const task_id = 48;
363397
const deleteTask = await fs.tickets.deleteTask(ticket_id, task_id);
398+
// use deleteTask.json() to access object elements
364399
```
365400

366401
- The first argument is the ticket ID - identifier of the ticket for which task is to be deleted

0 commit comments

Comments
 (0)