Skip to content
This repository was archived by the owner on May 28, 2024. It is now read-only.

Commit 539763c

Browse files
committed
refactor: rename list and getAllEvents methods
1 parent 1b61654 commit 539763c

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ And every resource returns a [`Promise`](https://developer.mozilla.org/en/docs/W
2828

2929
```js
3030

31-
const workplaces = await deskbookers.workplaces.list(params)
31+
const workplaces = await deskbookers.workplaces.retrieve(params)
3232
for (let workplace of workplaces) {
3333
// Use workplace data
3434
}
@@ -47,6 +47,6 @@ for (let workplace of workplaces) {
4747
* [`urgency(id, params)`](docs/workplaces.md#urgencyid-params)
4848
* events
4949
* [`unread()`](docs/events.md#unread)
50-
* [`list(tabId, limit)`](docs/events.md##listtabid-limit)
51-
* [`getAllEvents(limit, offset, tags)`](docs/events.md##get-all-events)
50+
* [`retrieve(tabId, limit)`](docs/events.md##retrievetabid-limit)
51+
* [`list(limit, offset, tags)`](docs/events.md##list)
5252
* [`markAllAsRead(tags)`](docs/events.md##mark-all-as-read)

docs/events.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ const unread = await deskbookers.events.unread()
2020
}
2121
```
2222

23-
## `list(tabId, limit)`
23+
## `retrieve(tabId, limit)`
2424
Lists the events for a given tab `id`. Returns an [async generator](https://github.com/tc39/proposal-async-iteration), or throws and `Error` if no events are returned.
2525

2626
```js
2727
const tabId = 1
2828
const eventsLimit = 10
29-
const eventsIterator = deskbookers.events.list(tabId, eventsLimit)
29+
const eventsIterator = deskbookers.events.retrieve(tabId, eventsLimit)
3030

3131

3232
// Use async generator directly
@@ -45,7 +45,7 @@ Name | Type | Description | Required
4545
tabId | Number | Tab id | Yes
4646
eventsLimit | Number | Amount of events to return | Yes
4747

48-
## `getAllEvents(limit, offset, tags)`
48+
## `list(limit, offset, tags)`
4949
Gets all the events for a specific user, if only events of certain type where to be required you can specify them in the tags array.
5050

5151
```js

src/resources/Events.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default class Events extends Resource {
1212
})
1313
}
1414

15-
async list (tabId = null, limit = 10) {
15+
async retrieve (tabId = null, limit = 10) {
1616
if (!tabId) {
1717
throw new Error('No tab id')
1818
}
@@ -44,7 +44,7 @@ export default class Events extends Resource {
4444
}
4545
}
4646

47-
async getAllEvents (limit, offset, tags = []) {
47+
async list (limit, offset, tags = []) {
4848
return await this.request({
4949
method: 'GET',
5050
path: 'event',

test/events.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ test('Events', async t => {
2929
const unread = await deskbookers.events.unread()
3030
const tabId = unread.tabs[0].id
3131

32-
// List events
33-
const events = await deskbookers.events.list(tabId)
32+
// Retrieve events
33+
const events = await deskbookers.events.retrieve(tabId)
3434
const firstBatch = await events.next()
3535
t.truthy(firstBatch.value.length)
3636
})
3737

38-
test.only('Can retrieve first page containing all events', async t => {
38+
test('Can retrieve first page containing all events', async t => {
3939
await deskbookers.account.login(
4040
process.env.LOGIN_EMAIL,
4141
process.env.LOGIN_PASSWORD
4242
)
4343

44-
const res = await deskbookers.events.getAllEvents(30, 0)
44+
const res = await deskbookers.events.list(30, 0)
4545

4646
t.truthy(Array.isArray(res))
4747
})

0 commit comments

Comments
 (0)