Skip to content

Commit

Permalink
Merge pull request #330 from skedify/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarrku authored Aug 25, 2021
2 parents ba6adc8 + 4b39a04 commit 2b82ed0
Show file tree
Hide file tree
Showing 14 changed files with 6,519 additions and 6,394 deletions.
1 change: 0 additions & 1 deletion .husky/.gitignore

This file was deleted.

2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14
16.6.2
42 changes: 16 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,40 +233,30 @@ SDK.subjects().sort(item => {
})
```

## ~~Paging~~
## Paging

> **NOTE:** Pagination is currently not supported by the API itself. However some endpoints (customers, offices and recently used subjects) have a `limit` query parameter.
The user can limit the amount of responses by using the `.limit` method. To achieve paging, the user can either use the `.offset` method to manually skip a number of entities. For convenience, the user can also use the `.page` method which will deduce the offset based on the limit (=page size)
The user can limit the amount of responses by using the `.limit` & `.page` method.

```js
SDK.subjects()
.limit(10)
.offset(10)
.then(response => {
.page(1)
.then((response) => {
// in addition to the regular properties on response, it will also additionally have
// a new `paging` property with the following props:
response.paging.size; // the amount of entities per page (=limit)
response.paging.current; // the current page you're on
response.paging.total; // the total amount of entities
response.paging.pages; // the amount of pages
response.paging.hasNext(); // check if there is a next page
response.paging.hasPrevious(); // check if there is a previous page
response.paging.next(); // start loading the next page. This will return a new Promise wich will resolve in a new response
response.paging.previous(); // start loading the previous page. This will return a new Promise wich will resolve in a new response
});

// and also
SDK.subjects()
.limit(10)
.page(3);

// is equivalent to
SDK.subjects()
.limit(10)
.offset(10 * (3 - 1));
response.paging.size // the amount of entities per page (=limit)
response.paging.currentPage // the current page you're on
response.paging.totalResults // the total amount of entities
response.paging.totalPages // the amount of pages
response.paging.hasNext // check if there is a next page
response.paging.hasPrevious // check if there is a previous page

// Not implemented yet:
response.paging.next() // start loading the next page. This will return a new Promise wich will resolve in a new response
response.paging.previous() // start loading the previous page. This will return a new Promise wich will resolve in a new response
})

// NOTE: the page() function requires the limit to be defined.
// NOTE: the page() and limit() methods needs to be called together•
```

## Filters
Expand Down
Loading

0 comments on commit 2b82ed0

Please sign in to comment.