Serves functions for manipulating items and related documents
- Source:
Methods
(static) getResource(url, done)
Callback resource found at URL.
Parameters:
Name | Type | Description |
---|---|---|
url |
string | URL of resource with extension that corresponds to a supported media type. |
done |
module:controllers/item~resourceCallback |
- Source:
(static) hasSupportedMediaType(url) → {boolean|undefined}
Return whether URL with extension indicates media type supported by controller operations.
Parameters:
Name | Type | Description |
---|---|---|
url |
string | URL |
- Source:
Returns:
Whether media type supported by controller operations
- Type
- boolean | undefined
(static) itemDataObjectsFromPage(page, source, contentType) → {Array.<Object>}
Return array of item data objects from within page object from source for contentType
Parameters:
Name | Type | Description |
---|---|---|
page |
module:controllers/item~Page | |
source |
Source | |
contentType |
ContentType |
- Source:
Returns:
ItemDataObjects
- Type
- Array.<Object>
(static) itemsGetUrl(source, contentType, userSourceAuth, pagination) → {string}
Return URL for making a GET request for items from source.
Parameters:
Name | Type | Description |
---|---|---|
source |
Object | Source from which to retrieve items. |
contentType |
Object | ContentType of items. |
userSourceAuth |
Object | UserSourceAuth used to make request. |
pagination |
Object | Pagination used to make request. |
- Source:
Returns:
URL for making a GET request
- Type
- string
(static) itemsPageError(page) → {error}
Returns error from items page if error exists within.
Parameters:
Name | Type | Description |
---|---|---|
page |
Object | Items page. |
- Source:
Returns:
Error
- Type
- error
(static) itemsPageNextPagination(page, pagination, contentType) → {Object}
Returns pagination for next items page after current items page.
Parameters:
Name | Type | Description |
---|---|---|
page |
Object | Current items page. |
pagination |
Object | Pagination of current items page. |
contentType |
Object | ContentType of current items page. |
- Source:
Returns:
Pagination for next items page.
- Type
- Object
(static) persistItemDataObject(itemDataObject, relationships, done)
Persist an object representing Item data to the database and return corresponding Item.
Create new Item in database if none with corresponding IDs exists; otherwise retrieve existing Item.
Update Item with data provided by itemDataObject param before returning.
Parameters:
Name | Type | Description |
---|---|---|
itemDataObject |
Object | Basic itemDataObject containing Item data. |
relationships |
Object | Relationships to use for persistence of item with itemDataObject. |
done |
function | Error-first callback function expecting Item as second parameter. |
- Source:
(static) storagePath(item, data, done)
Callbacks file system path used to store item on storage.
Parameters:
Name | Type | Description |
---|---|---|
item |
Item | Item. |
data |
Object | Raw item data from source. |
done |
function | Error-first callback function expecting file system path as second parameter. |
- Source:
(static) storeAllForUserStorageSource(user, source, storage, done)
Store all items of all supported contentTypes found from source for user.
Persist new Items in database for any not previously stored.
Emit event on app for each Item once stored.
Parameters:
Name | Type | Description |
---|---|---|
user |
User | User for which to retrieve items from source and store them in storage. |
source |
Source | Source from which to retrieve items. |
storage |
Storage | Storage within which to store items. |
done |
callback |
- Source:
(static) storeAllForUserStorageSourceContentType(user, source, storage, contentType, done)
Store all items of contentType found from source for user.
Persist new Items in database for any not previously stored.
Emit event on app for each Item once stored.
Parameters:
Name | Type | Description |
---|---|---|
user |
User | User for which to retrieve items from source and store them in storage. |
source |
Source | Source from which to retrieve items. |
storage |
Storage | Storage within which to store items. |
contentType |
ContentType | ContentType of which to retrieve items. |
done |
callback |
- Source:
(static) storeFile(user, storage, path, data, done)
Store file to storage on behalf of user.
Parameters:
Name | Type | Description |
---|---|---|
user |
User | User object. |
storage |
Object | Storage object. |
path |
string | Path to store file on storage. |
data |
Object | Object that represents data for file. |
done |
function | Error-first callback function with object representing HTTP response body from storage request as second parameter. |
- Source:
(static) storeItemData(item, data, done)
Store data contained in property of Item in storage.
Update attemptedAt, failedAt and verifiedAt timestamps as appropriate during process.
Update storageError if storage fails.
Update storageBytes and storagePath if storage succeeds.
Parameters:
Name | Type | Description |
---|---|---|
item |
Item | Item object. |
data |
Object | Raw item data from source. |
done |
callback |
- Source:
(static) storeItemsPage(user, source, storage, contentType, pagination, done)
Store all items of contentType found from source for user.
Persist new Items in database for any not previously stored.
Emit event on app for each Item once stored.
Parameters:
Name | Type | Description |
---|---|---|
user |
User | User for which to retrieve items from source and store them in storage. |
source |
Source | Source from which to retrieve items. |
storage |
Storage | Storage within which to store items. |
contentType |
ContentType | ContentType of which to retrieve items. |
pagination |
Object | – Object containing pagination information. |
done |
callback |
- Source:
(static) totalItemsAvailableFromPage(page, source, contentType) → {number}
Returns total number of items available from page object returned by source.
Note: This is the total across all pages available from source, not just available within given page.
Parameters:
Name | Type | Description |
---|---|---|
page |
Object | Page of items. |
source |
source | Source of items page. |
contentType |
Object | ContentType of items. |
- Source:
Returns:
Total number of items available.
- Type
- number
Type Definitions
Page
Page of item data objects from source
Type:
- object
- Source:
resourceCallback(error, resource)
Error-first callback with data representing resource as second parameter.
Parameters:
Name | Type | Description |
---|---|---|
error |
Error | Error encountered during attempt to retrieve resource |
resource |
Object | Response body representing resource |
- Source: