Skip to content

Commit

Permalink
feat: Refactor paginated endpoints
Browse files Browse the repository at this point in the history
Methods that request paginated endpoints will now request every page
automatically. As an example: after switching to v2, getCustomers()
did not return all customers anymore. It only returned all customers
from the first page. With this change, the following methods will
automatically request all pages:

- getCustomers()
- getProjects()
- getEntries()
- getEntriesTexts()

In order to get each page indiviually, please use:

- getCustomersPage()
- getProjectsPage()
- getEntriesPage()
- getEntriesTextsPage()

BREAKING CHANGE: getCustomers(), getProjects(), getEntries(),
getEntriesTexts() won't return a paging property anymore since pages
are now requested automatically.

BREAKING CHANGE: We've also improved some typings for these endpoints
which might break your TypeScript build.
  • Loading branch information
jhnns committed Aug 4, 2022
1 parent a5ce5f5 commit 3e29d27
Show file tree
Hide file tree
Showing 8 changed files with 543 additions and 63 deletions.
74 changes: 68 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,29 @@ await clockodo.getCustomer({ id: 777 });

### getCustomers()

Get list of customers
Get all customers from all pages.

#### Example:

```js
await clockodo.getCustomers();
// or
await clockodo.getCustomers({
// Filter by active flag
filterActive: true,
});
```

---

### getCustomersPage()

Get all customers from a specific page.

#### Example:

```js
await clockodo.getCustomersPage({ page: 2 });
```

---
Expand All @@ -176,22 +193,40 @@ await clockodo.getEntry({ id: 4 });

### getEntries()

Gets list of Clockodo activity entries.
Get all entries from all pages.

#### Example:

```js
import { Billability } from "clockodo";

await clockodo.getEntries({
// timeSince and timeUntil are required
timeSince: "2017-08-18T00:00:00Z",
timeUntil: "2018-02-09T00:00:00Z",
// You can also add additional filters here
filterBillable: Billability.Billed,
});
```

---

### getEntriesPage()

Get all entries from a specific page

#### Example:

```js
await clockodo.getEntriesPage({
timeSince: "2017-08-18T00:00:00Z",
timeUntil: "2018-02-09T00:00:00Z",
page: 2,
});
```

---

### getEntryGroups()

Get a group of entries defined by your criteria.
Expand All @@ -211,7 +246,7 @@ await clockodo.getEntryGroups({

### getEntriesTexts()

Retreive descriptions (and no additional info) entered for time and lump sum entries. Seems to be a tight but case insensitive match.
Retreive all descriptions (and no additional info) entered for time and lump sum entries from all pages.

#### Example:

Expand All @@ -221,9 +256,21 @@ await clockodo.getEntriesTexts({ text: "meeting with client" });

---

### getEntriesTextsPage()

Retreive all descriptions from a specific page.

#### Example:

```js
await clockodo.getEntriesTextsPage({ text: "meeting with client", page: 2 });
```

---

### getProject()

Get a project by its ID. For a list of projects, use getCustomers().
Get a project by its ID.

#### Example:

Expand All @@ -235,20 +282,35 @@ await clockodo.getProject({ id: 1985 });

### getProjects()

Returns all projects.
Get all projects from all pages.

#### Example:

```js
await clockodo.getProjects();
// or filter by a specific customer id
// or
await clockodo.getProjects({
// Filter by a specific customer id
filterCustomersId: 123,
// Filter by active flag
filterActive: true,
});
```

---

### getProjectsPage()

Get all projects from a specific page.

#### Example:

```js
await clockodo.getProjectsPage({ page: 2 });
```

---

### getService()

Get a service by its ID.
Expand Down
63 changes: 52 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"@faker-js/faker": "^7.2.0",
"axios": "^0.21.4",
"map-obj": "^5.0.1",
"p-limit": "^4.0.0",
"qs": "^6.10.5"
},
"devDependencies": {
Expand Down
Loading

0 comments on commit 3e29d27

Please sign in to comment.