Agility CMS & Management API TypeScript SDK
To start using the Agility CMS & .NET 5 Starter, sign up for a FREE account and create a new Instance using the Blog Template.
About the Management API SDK
- Provides a facility to developers to use the new Agility Management API more effectively.
- Provides methods to perform operations on Assets, Batches, Containers, Content, Models, Pages, and Users.
- Supports the creation of Pages and Content in batches.
- Ability to generate Content in bulk for a Website.
Getting Started
Prerequisites
- Clone the repository agility-cms-management-sdk-typescript.
- Import the index file to make use of the Options class.
- Create an object of the Options class to provide values of -
- token -> Bearer token to authenticate a Rest Request to perform an operation.
- locale -> The locale under which your application is hosted. Example en-us.
- guid -> The guid under which your application is hosted.
- Create an object of Method class(es), which can be used to create and perform operations. Following is the description of Classes and their respective methods -
Making a Request
import * as index from "./index";
let options = new index.Options();
options.token = "<<Provide Auth Token>>";
options.guid = "<<Provide the Guid of the Website>>";
options.locale = "<<Provide the locale of the Website>>";
let contentMethods = new index.ContentMethods(options);
var contentItem = await contentMethods.getContentItem(22);
console.log(JSON.stringify(contentItem));
Class AssetMethods
This class is used to perform operations related to Assets. The following are the methods: -
upload
formData | FormData | This is an object of type FormData where files can be posted eg : const file = fs.readFileSync(<<Local File>>, null);const form = new FormData(); form.append('files',file,'<<File Name>>'); |
agilityFolderPath | string | Path of the folder in Agility where the file(s) needs to be uploaded. |
groupingID | number | Path of the folder in Agility where the file(s) needs to be uploaded. |
Returns: A collection of Media
class Object.
deleteFile
mediaID | number | The mediaID of the asset which needs to be deleted. |
Returns | | |
A string response if a file has been deleted. | | |
moveFile
mediaID | number | The mediaID of the file that needs to be moved. |
newFolder | string | The new location (in Agility) where the file needs to be moved. |
Returns: An object of Media
class with the new location of the file.
getMediaList
pageSize | number | The page size on which the assets needs to selected. |
recordOffset | number | The record offset value to skip search results. |
Returns: An object of AssetMediaList
class.
getAssetByID
mediaID | number | The mediaID of the requested asset. |
Returns: An object of Media
class with the information of the asset.
getAssetByUrl
url | string | The url of the requested asset. |
Returns: An object of Media
class with the information of the asset.
Class BatchMethods
This class is used to perform operations related to Batches. The following are the methods: -
getBatch
id | number | The batchID of the requested batch. |
Returns: A object of Batch
class.
Class ContainerMethods
This class is used to perform operations related to Containers. The following are the methods: -
getContainerByID
id | number | The container id of the requested container. |
Returns: A object of Container
class.
getContainerByReferenceName
referenceName | string | The container reference name of the requested container. |
Returns: A object of Container
class.
getContainerSecurity
id | number | The container id of the requested container. |
Returns: A object of Container
class.
getContainerList
Returns: A collection object of Container
class.
getNotificationList
id | number | The container id of the requested container. |
Returns: A collection object of Notification
class.
saveContainer
container | Container | A Container type object to create or update a container. |
Returns: An object of Container
class.
deleteContainer
id | number | The container id of the requested container. |
Returns: A string
response if a container has been deleted.
Class ContentMethods
This class is used to perform operations related to Content. The following are the methods: -
getContentItem
contentID | number | The contentid of the requested content. |
Returns: An object of ContentItem
class.
publishContent
contentID | number | The contentid of the requested content. |
comments | string | Additional comments for a batch request. |
Returns: An array of contentID
of the requested content.
unPublishContent
contentID | number | The contentid of the requested content. |
comments | string | Additional comments for a batch request. |
Returns: An array of contentID
of the requested content.
contentRequestApproval
contentID | number | The contentid of the requested content. |
comments | string | Additional comments for a batch request. |
Returns: An array of contentID
of the requested content.
approveContent
contentID | number | The contentid of the requested content. |
comments | string | Additional comments for a batch request. |
Returns: An array of contentID
of the requested content.
declineContent
contentID | number | The contentid of the requested content. |
comments | string | Additional comments for a batch request. |
Returns: An array of contentID
of the requested content.
saveContentItem
contentItem | ContentItem | A contentItem object to create or update a content. |
Returns: An array of contentID
of the requested content.
saveContentItems
contentItems | ContentItem[] | A collection of contentItems object to create or update multiple contents. |
Returns: An array of contentID
of the requested content.
deleteContent
contentID | number | The contentid of the requested content. |
comments | string | Additional comments for a batch request. |
Returns: An array of contentID
of the requested content.
getContentItems
referenceName | string | The reference name of the container for the requested content. |
filter | string | The filter condition for the requested content. |
fields | string | The fields mapped to the container. |
sortDirection | string | The direction to sort the result. |
sortField | string | The field on which the sort needs to be performed. |
take | number | The page size for the result. |
skip | number | The record offset for the result. |
Returns: An object of ContentList
class of the requested content.
Class InstanceUserMethods
This class is used to perform operations related to User. The following are the methods: -
getUsers
Returns: A collection of WebsiteUser
class of the requested content.
saveUser
emailAddress | string | The email address of the requested user. |
roles | InstanceRole[] | Collection object of InstanceRole class for the requested user. |
firstName | string | The first name of the requested user. |
lastName | string | The last name of the requested user. |
Returns: An object of the InstanceUser
class.
deleteUser
userID | number | The userID of the requested user. |
Returns: A string
response if a user has been deleted.
Class ModelMethods
This class is used to perform operations related to Models. The following are the methods: -
getContentModel
id | number | The id of the requested model. |
Returns: An object of Model
class.
getContentModules
includeDefaults | bool | Boolean value to include defaults. |
includeModules | bool | Boolean value to include modules. |
Returns: A collection object of Model
class.
getPageModules
includeDefault | bool | Boolean value to include defaults. |
Returns: A collection object of Model
class.
saveModel
model | Model | The object of Model to for the requested model. |
Returns: An object of Model
class.
deleteModel
id | number | The id for the requested model. |
Returns: A string
response if a model is deleted.
Class PageMethods
This class is used to perform operations related to Pages. The following are the methods: -
getSitemap
Returns: A collection object of Sitemap
class.
getPage
pageID | number | The id of the requested page. |
Returns: An object of PageItem
class.
publishPage
pageID | number | The pageID of the requested page. |
comments | string | Additional comments for a batch request. |
Returns: An array of pageID
of the requested page.
unPublishPage
pageID | number | The pageID of the requested page. |
comments | string | Additional comments for a batch request. |
Returns: An array of pageID
of the requested page.
deletePage
pageID | number | The pageID of the requested page. |
comments | string | Additional comments for a batch request. |
Returns: An array of pageID
of the requested page.
approvePage
pageID | number | The pageID of the requested page. |
comments | string | Additional comments for a batch request. |
Returns: An array of pageID
of the requested page.
declinePage
pageID | number | The pageID of the requested page. |
comments | string | Additional comments for a batch request. |
Returns: An array of pageID
of the requested page.
pageID | number | The pageID of the requested page. |
comments | string | Additional comments for a batch request. |
Returns: An array of pageID
of the requested page.
savePage
pageItem | PageItem | The object of PageItem class for the requested Page. |
parentPageID | number | The id of the parent page. |
placeBeforePageItemID | number | The id of the page before the page. |
Returns: An array of pageID
of the requested page.
Running the SDK Locally
npm run clean
npm run prepare
npm run build
How It Works
Resources
Agility CMS
Feedback and Questions
If you have feedback or questions about this starter, please use the Github Issues on this repo, join our Community Slack Channel or create a post on the Agility Developer Community.