ListResource
Extends:
Direct Subclass:
API abstract list resource class.
Constructor Summary
Public Constructor | ||
public |
constructor(url: string, auth: Object) Constructor |
Member Summary
Public Members | ||
public |
collection: * |
|
public get |
Get the list of item data objects (REST API descriptors). |
|
public get |
Return true if the list resource object has a next list page in the paginated REST API. |
|
public get |
Return true if the list resource object has a previous list page in the paginated REST API. |
|
public |
|
|
public |
|
|
public |
|
|
public get |
Get the total count of items of the entire collection across pages in the paginated REST API. |
Method Summary
Public Methods | ||
public |
Fetch this list resource from the REST API based on search parameters. |
|
public |
Get an item resource object given its id from the list of items in this list resource object. |
|
public |
Get an array of item resource objects corresponding to the items in this list resource object. |
|
public |
getPOSTParameters(): string[] Get an array of parameter names that can be used as properties of the data object in POST requests. |
|
public |
Get an array of search parameter names that can be used as properties of the
|
Private Methods | ||
private |
_getResource(linkRelation: string, ResourceClass: Object, searchParams: Object, timeout: number): Promise<ResourceClass> Internal method to fetch a related resource from the REST API that is referenced by a link relation within this list resource's collection object. |
|
private |
Internal helper method to make a POST request to this list resource through the REST API. |
Inherited Summary
From class Resource | ||
public static |
Helper method to make a deep copy clone of the passed object resource. |
|
public get |
Return true if the resource object contains any data. |
|
public |
|
|
public |
|
|
public |
|
|
public |
|
|
public |
Make a deep copy clone of this object resource. |
Public Constructors
Public Members
public get hasNextPage: boolean source
Return true if the list resource object has a next list page in the paginated REST API.
Public Methods
public get(searchParams: Object, timeout: number): Promise<this> source
Fetch this list resource from the REST API based on search parameters. If no search parameters then get the default first page.
Params:
Name | Type | Attribute | Description |
searchParams | Object |
|
search parameters object which is
resource-specific, the |
searchParams.limit | number |
|
page limit |
searchParams.offset | number |
|
page offset |
timeout | number |
|
request timeout |
public getItem(id: number): Object source
Get an item resource object given its id from the list of items in this list resource object.
Params:
Name | Type | Attribute | Description |
id | number | item id |
public getItems(): Object[] source
Get an array of item resource objects corresponding to the items in this list resource object.
public getPOSTParameters(): string[] source
Get an array of parameter names that can be used as properties of the data object in POST requests.
Return:
string[] (nullable: true) | array of POST data properties or null if this list resource's data has not been fetched from the API yet or it doesn't support POST requests. |
public getSearchParameters(): string[] source
Get an array of search parameter names that can be used as properties of the
searchParams
argument to the get
method.
Return:
string[] (nullable: true) | array of search parameter names or null if this list resource's data has not been fetched from the API yet. |
Private Methods
private _getResource(linkRelation: string, ResourceClass: Object, searchParams: Object, timeout: number): Promise<ResourceClass> source
Internal method to fetch a related resource from the REST API that is referenced by a link relation within this list resource's collection object.
Params:
Name | Type | Attribute | Description |
linkRelation | string | ||
ResourceClass | Object | ||
searchParams | Object |
|
search parameters object which is resource-specific |
searchParams.limit | number |
|
page limit |
searchParams.offset | number |
|
page offset |
timeout | number |
|
request timeout |
Throw:
throw error if this list resource has not yet been fetched from the REST API |
|
throw error when the link relation is not found |