Agility Management API JS SDK for retrieving content from the Agility CMS
- Source:
Methods
(static) approveContent(requestParams) → {Promise.<number>}
Approve a given content item.
- Source:
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
requestParams |
Object
|
The paramaters for the API request.
|
Returns:
- Type:
-
Promise.<number>
- Returns the contentID.
Example
import agilityMgmt from '@agility/content-management'
#Create a new instance API client
const api = agilityMgmt.getApi({
location: 'MyLocation',
websiteName: 'MyWebsiteName',
securityKey: 'MySecurityKey'
});
#Set the contentID and language code of content you want to approve
let contentID = contentIDToWorkOn;
let languageCode = "en-us";
api.approveContent({
contentID,
languageCode
})
.then(function(contentID) {
#check contentID is greater > 0 for success
})
.catch(function(error) {
#handle error
});
(static) declineContent(requestParams) → {Promise.<number>}
Decline a given content item.
- Source:
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
requestParams |
Object
|
The paramaters for the API request.
|
Returns:
- Type:
-
Promise.<number>
- Returns the contentID.
Example
import agilityMgmt from '@agility/content-management'
#Create a new instance API client
const api = agilityMgmt.getApi({
location: 'MyLocation',
websiteName: 'MyWebsiteName',
securityKey: 'MySecurityKey'
});
#Set the contentID and language code of content you want to decline
let contentID = contentIDToWorkOn;
let languageCode = "en-us";
api.declineContent({
contentID,
languageCode
})
.then(function(contentID) {
#check contentID is greater > 0 for success
})
.catch(function(error) {
#handle error
});
(static) deleteContent(requestParams) → {Promise.<number>}
Delete a given content item.
- Source:
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
requestParams |
Object
|
The paramaters for the API request.
|
Returns:
- Type:
-
Promise.<number>
- Returns the contentID.
Example
import agilityMgmt from '@agility/content-management'
#Create a new instance API client
const api = agilityMgmt.getApi({
location: 'MyLocation',
websiteName: 'MyWebsiteName',
securityKey: 'MySecurityKey'
});
#Set the contentID and language code of content you want to delete
let contentID = contentIDToWorkOn;
let languageCode = "en-us";
api.deleteContent({
contentID,
languageCode
})
.then(function(contentID) {
#check contentID is greater > 0 for success
})
.catch(function(error) {
#handle error
});
(static) publishContent(requestParams) → {Promise.<number>}
Publish a given content item.
- Source:
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
requestParams |
Object
|
The paramaters for the API request.
|
Returns:
- Type:
-
Promise.<number>
- Returns the contentID.
Example
import agilityMgmt from '@agility/content-management'
#Create a new instance API client
const api = agilityMgmt.getApi({
location: 'MyLocation',
websiteName: 'MyWebsiteName',
securityKey: 'MySecurityKey'
});
#Set the contentID and language code of content you want to publish
let contentID = contentIDToWorkOn;
let languageCode = "en-us";
api.publishContent({
contentID,
languageCode
})
.then(function(contentID) {
#check contentID is greater > 0 for success
})
.catch(function(error) {
#handle error
});
(static) requestApproval(requestParams) → {Promise.<number>}
Request approval for a given content item.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
requestParams |
Object
|
The paramaters for the API request.
|
Returns:
- Type:
-
Promise.<number>
- Returns the contentID.
Example
import agilityMgmt from '@agility/content-management'
#Create a new instance API client
const api = agilityMgmt.getApi({
location: 'MyLocation',
websiteName: 'MyWebsiteName',
securityKey: 'MySecurityKey'
});
#Set the contentID and language code of content you want to request for approval
let contentID = contentIDToWorkOn;
let languageCode = "en-us";
api.requestApproval({
contentID,
languageCode
})
.then(function(contentID) {
#check contentID is greater > 0 for success
})
.catch(function(error) {
#handle error
});
(static) saveContentItem(requestParams) → {Promise.<number>}
Saves a content item.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
requestParams |
Object
|
The paramaters for the API request.
|
Returns:
- Type:
-
Promise.<number>
- Returns the contentID.
Example
import agilityMgmt from '@agility/content-management'
#Create a new instance API client
const api = agilityMgmt.getApi({
location: 'MyLocation',
websiteName: 'MyWebsiteName',
securityKey: 'MySecurityKey'
});
#Set the contentItem structure
#Important: The fields are not camel case - make sure the field names match EXACTLY with your content definition in Agility instance
#The example below shows how to structure your fields with simple types and nested objects
let contentItem = {
contentID: -1,
fields: {
"Title": "Test Title",
"Image": {
"mediaID": 123,
"label": "Test Image"
}
}
}
#Set language code and reference name of content you want to save
let languageCode = "en-us";
let referenceName = "MyReferenceName";
api.saveContentItem({
contentItem,
languageCode,
referenceName
})
.then(function(contentID) {
#check contentID is greater > 0 for success
#update contentID of saved item
contentIDToWorkOn = contentID;
})
.catch(function(error) {
#handle error
});
(static) unpublishContent(requestParams) → {Promise.<number>}
Unpublish a given content item.
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
requestParams |
Object
|
The paramaters for the API request.
|
Returns:
- Type:
-
Promise.<number>
- Returns the contentID.
Example
import agilityMgmt from '@agility/content-management'
#Create a new instance API client
const api = agilityMgmt.getApi({
location: 'MyLocation',
websiteName: 'MyWebsiteName',
securityKey: 'MySecurityKey'
});
#Set the contentID and language code of content you want to unpublish
let contentID = contentIDToWorkOn;
let languageCode = "en-us";
api.unpublishContent({
contentID,
languageCode
})
.then(function(contentID) {
#check contentID is greater > 0 for success
})
.catch(function(error) {
#handle error
});