diff --git a/README.md b/README.md index 866755d..468669e 100644 --- a/README.md +++ b/README.md @@ -404,6 +404,29 @@ try { } ``` +**Get all link items:** + +Retrieves all link items (link type internal for links to other items within the Zesty.io instance, or external for links to third party web pages). + +```javascript +try { + const res = await zesty.getLinks() +} catch (err) { + console.log(err) +} +``` + +**Get specific link item by ZUID:** + +```javascript +try { + const linkZUID = '17-...' // Link ZUIDs begin with 17 + const res = await zeesty.getLink(linkZUID) +} catch (err) { + console.log(err) +} +``` + ### Views The wrapper allows CRUD on Zesty.io view files. See documentation [here](https://instances-api.zesty.org/#efc2e79a-e392-4114-a722-c3b512e23833): diff --git a/zestyio-api-wrapper.js b/zestyio-api-wrapper.js index cb440c9..68527e4 100644 --- a/zestyio-api-wrapper.js +++ b/zestyio-api-wrapper.js @@ -18,6 +18,8 @@ class ZestyioAPIWrapper { itemsGETVersions: '/content/models/MODEL_ZUID/items/ITEM_ZUID/versions', itemsGETVersion: '/content/models/MODEL_ZUID/items/ITEM_ZUID/versions/VERSION_NUMBER', itemsPUT: '/content/models/MODEL_ZUID/items/ITEM_ZUID', + linksGETAll: '/content/links', + linksGET: '/content/links/LINK_ZUID', viewsGETAll: '/web/views', viewsGET: '/web/views/VIEW_ZUID', viewsGETVersions: '/web/views/VIEW_ZUID/versions', @@ -415,6 +417,29 @@ class ZestyioAPIWrapper { }) } + async getLinks() { + const uri = this.buildAPIURL(this.instancesAPIEndpoints.linksGETAll) + + return await this.getRequest({ + uri + }) + } + + async getLink(linkZUID) { + const uri = this.buildAPIURL( + this.replaceInURL( + this.instancesAPIEndpoints.linksGET, + { + LINK_ZUID: linkZUID + } + ) + ) + + return await this.getRequest({ + uri + }) + } + async getViews() { const uri = this.buildAPIURL(this.instancesAPIEndpoints.viewsGETAll)