0.1.18 • Published 12 months ago

@agility/management-sdk v0.1.18

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

Agility CMS & Management API TypeScript SDK

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

  1. Clone the repository agility-cms-management-sdk-typescript.
  2. Import the index file to make use of the Options class.
  3. Create an object of the Options class to provide values of -
    • token -> Bearer token to authenticate a Rest Request to perform an operation.
  4. 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 mgmtApi from "./index";

//initialize the Options Class
let options = new mgmtApi.Options();

options.token = "<<Provide Auth Token>>"
//Initialize the APIClient Class
let apiClient = new mgmtApi.ApiClient(options);

let guid = "<<Provide the Guid of the Website>>";
let locale = "<<Provide the locale of the Website>>"; //Example: en-us



//make the request: get a content item with the ID '22'
var contentItem = await apiClient.contentMethods.getContentItem(22,guid, locale);

//To log the response of the contentItem object in console.
console.log(JSON.stringify(contentItem));

Class AssetMethods

This class is used to perform operations related to Assets. The following are the methods: -

upload

ParameterTypeDescription
formDataFormDataThis 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>>');
agilityFolderPathstringPath of the folder in Agility where the file(s) needs to be uploaded.
guidstringCurrent website guid.
groupingIDnumberPath of the folder in Agility where the file(s) needs to be uploaded.

Returns: A collection of Media class Object.

createFolder

ParameterTypeDescription
originKeystringThe origin key of the requested folder.
guidstringCurrent website guid.

Returns: A collection of Media class Object.

deleteFolder

ParameterTypeDescription
originKeystringThe origin key of the requested folder.
guidstringCurrent website guid.
mediaIDnumberThe mediaID of the folder that needs to be deleted.

renameFolder

ParameterTypeDescription
folderNamestringThe original folder name.
newFolderNamestringThe new folder name.
guidstringCurrent website guid.
mediaIDnumberThe mediaID of the folder that needs to be renamed.

deleteFile

ParameterTypeDescription
mediaIDnumberThe mediaID of the asset which needs to be deleted.
guidstringCurrent website guid.

Returns A string response if a file has been deleted.

moveFile

ParameterTypeDescription
mediaIDnumberThe mediaID of the file that needs to be moved.
newFolderstringThe new location (in Agility) where the file needs to be moved.
guidstringCurrent website guid.

Returns: An object of Media class with the new location of the file.

getMediaList

ParameterTypeDescription
pageSizenumberThe page size on which the assets needs to selected.
recordOffsetnumberThe record offset value to skip search results.
guidstringCurrent website guid.

Returns: An object of AssetMediaList class.

getGalleryById

ParameterTypeDescription
guidstringCurrent website guid.
idnumberThe ID of the requested gallery.

Returns: An object of assetMediaGrouping class.

getGalleryByName

ParameterTypeDescription
guidstringCurrent website guid.
galleryNamestringThe name of the requested gallery.

Returns: An object of assetMediaGrouping class.

getDefaultContainer

ParameterTypeDescription
guidstringCurrent website guid.

Returns: An object of assetContainer class.

getGalleries

ParameterTypeDescription
guidstringCurrent website guid.
searchstringString to search a specific gallery item.
pageSizenumberThe pageSize on which the galleries needs to be selected.
rowIndexnumberThe rowIndex value for the resultant record set.

Returns: An object of assetGalleries class.

saveGallery

ParameterTypeDescription
guidstringCurrent website guid.
galleryassetMediaGroupingObject of AssetMediaGrouping class.

Returns: An object of assetMediaGrouping class.

deleteGallery

ParameterTypeDescription
guidstringCurrent website guid.
idnumberThe id of the gallery to be deleted.

A string response if the gallery has been deleted.

getAssetByID

ParameterTypeDescription
mediaIDnumberThe mediaID of the requested asset.
guidstringCurrent website guid.

Returns: An object of Media class with the information of the asset.

getAssetByUrl

ParameterTypeDescription
urlstringThe url of the requested asset.
guidstringCurrent website guid.

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

ParameterTypeDescription
idnumberThe batchID of the requested batch.
guidstringCurrent website guid.

Returns: A object of Batch class.

Class ContainerMethods

This class is used to perform operations related to Containers. The following are the methods: -

getContainerByID

ParameterTypeDescription
idnumberThe container id of the requested container.
guidstringCurrent website guid.

Returns: A object of Container class.

getContainersByModel

ParameterTypeDescription
modelIdnumberThe model id of the requested container.
guidstringCurrent website guid.

Returns: A object of Container class.

getContainerByReferenceName

ParameterTypeDescription
referenceNamestringThe container reference name of the requested container.
guidstringCurrent website guid.

Returns: A object of Container class.

getContainerSecurity

ParameterTypeDescription
idnumberThe container id of the requested container.
guidstringCurrent website guid.

Returns: A object of Container class.

getContainerList

ParameterTypeDescription
guidstringCurrent website guid.

Returns: A collection object of Container class.

getNotificationList

ParameterTypeDescription
idnumberThe container id of the requested container.
guidstringCurrent website guid.

Returns: A collection object of Notification class.

saveContainer

ParameterTypeDescription
containerContainerA Container type object to create or update a container.
guidstringCurrent website guid.

Returns: An object of Container class.

deleteContainer

ParameterTypeDescription
idnumberThe container id of the requested container.
guidstringCurrent website guid.

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

ParameterTypeDescription
contentIDnumberThe contentid of the requested content.
guidstringCurrent website guid.
localestringCurrent website locale.

Returns: An object of ContentItem class.

publishContent

ParameterTypeDescription
contentIDnumberThe contentid of the requested content.
guidstringCurrent website guid.
localestringCurrent website locale.
commentsstringAdditional comments for a batch request.

Returns: An array of contentID of the requested content.

unPublishContent

ParameterTypeDescription
contentIDnumberThe contentid of the requested content.
guidstringCurrent website guid.
localestringCurrent website locale.
commentsstringAdditional comments for a batch request.

Returns: An array of contentID of the requested content.

contentRequestApproval

ParameterTypeDescription
contentIDnumberThe contentid of the requested content.
guidstringCurrent website guid.
localestringCurrent website locale.
commentsstringAdditional comments for a batch request.

Returns: An array of contentID of the requested content.

approveContent

ParameterTypeDescription
contentIDnumberThe contentid of the requested content.
guidstringCurrent website guid.
localestringCurrent website locale.
commentsstringAdditional comments for a batch request.

Returns: An array of contentID of the requested content.

declineContent

ParameterTypeDescription
contentIDnumberThe contentid of the requested content.
guidstringCurrent website guid.
localestringCurrent website locale.
commentsstringAdditional comments for a batch request.

Returns: An array of contentID of the requested content.

saveContentItem

ParameterTypeDescription
contentItemContentItemA contentItem object to create or update a content.
guidstringCurrent website guid.
localestringCurrent website locale.

Returns: An array of contentID of the requested content.

saveContentItems

ParameterTypeDescription
contentItemsContentItem[]A collection of contentItems object to create or update multiple contents.
guidstringCurrent website guid.
localestringCurrent website locale.

Returns: An array of contentID of the requested content.

deleteContent

ParameterTypeDescription
contentIDnumberThe contentid of the requested content.
guidstringCurrent website guid.
localestringCurrent website locale.
commentsstringAdditional comments for a batch request.

Returns: An array of contentID of the requested content.

getContentItems

ParameterTypeDescription
referenceNamestringThe reference name of the container for the requested content.
guidstringCurrent website guid.
localestringCurrent website locale.
listParamsListParamsThe parameters list to apply filter on the content list.

Returns: An object of ContentList class of the requested content.

getContentList

ParameterTypeDescription
referenceNamestringThe reference name of the container for the requested content.
guidstringCurrent website guid.
localestringCurrent website locale.
listParamsListParamsThe parameters list to apply filter on the content list.
filterObjectContentListFilterModelTo apply filter at the field level.

Returns: An object of ContentList class of the requested content.

getContentHistory

ParameterTypeDescription
localestringCurrent website locale.
guidstringCurrent website guid.
contentIDnumberThe contentID of the requested content.
takenumberThe number of items per record set default value 50.
skipnumberThe skip level on the record set default value 0.

Returns: An object of ContentItemHistory class of the requested content history.

getContentComments

ParameterTypeDescription
localestringCurrent website locale.
guidstringCurrent website guid.
contentIDnumberThe contentID of the requested content.
takenumberThe number of items per record set default value 50.
skipnumberThe skip level on the record set default value 0.

Returns: An object of ItemComments class of the requested content comments.

Class InstanceUserMethods

This class is used to perform operations related to User. The following are the methods: -

getUsers

ParameterTypeDescription
guidstringCurrent website guid.

Returns: A collection of WebsiteUser class of the requested content.

saveUser

ParameterTypeDescription
emailAddressstringThe email address of the requested user.
rolesInstanceRole[]Collection object of InstanceRole class for the requested user.
guidstringCurrent website guid.
firstNamestringThe first name of the requested user.
lastNamestringThe last name of the requested user.

Returns: An object of the InstanceUser class.

deleteUser

ParameterTypeDescription
userIDnumberThe userID of the requested user.
guidstringCurrent website guid.

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

ParameterTypeDescription
idnumberThe id of the requested model.
guidstringCurrent website guid.

Returns: An object of Model class.

GetModelByReferenceName

ParameterTypeDescription
referenceNamestringThe referenceName of the requested model.
guidstringThe guid of the requested model.

getContentModules

ParameterTypeDescription
includeDefaultsboolBoolean value to include defaults.
guidstringCurrent website guid.
includeModulesboolBoolean value to include modules.

Returns: A collection object of Model class.

getPageModules

ParameterTypeDescription
includeDefaultboolBoolean value to include defaults.
guidstringCurrent website guid.

Returns: A collection object of Model class.

saveModel

ParameterTypeDescription
modelModelThe object of Model to for the requested model.
guidstringCurrent website guid.

Returns: An object of Model class.

deleteModel

ParameterTypeDescription
idnumberThe id for the requested model.
guidstringCurrent website guid.

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

ParameterTypeDescription
guidstringCurrent website guid.
localestringCurrent website locale.

Returns: A collection object of Sitemap class.

getPageTemplates

ParameterTypeDescription
guidstringCurrent website guid.
localestringCurrent website locale.
includeModuleZonesbooleanTo include zones in the result set.
searchFilterstringTo apply search criteria on the requested page template.

Returns: A collection object of PageModel class.

getPageTemplate

ParameterTypeDescription
guidstringCurrent website guid.
localestringCurrent website locale.
pageTemplateIdnumberThe pageTemplateId of the requested page template.

Returns: An object of PageModel class.

getPageTemplateName

ParameterTypeDescription
guidstringCurrent website guid.
localestringCurrent website locale.
templateNamestringThe templateName of the requested page template.

Returns: An object of PageModel class.

deletePageTemplate

ParameterTypeDescription
guidstringCurrent website guid.
localestringCurrent website locale.
pageTemplateIdstringThe pageTemplateId of the requested page template.

getPageItemTemplates

ParameterTypeDescription
guidstringCurrent website guid.
localestringCurrent website locale.
idnumberThe id of the requested page template.

Returns: A collection of ContentSectionDefinition class.

savePageTemplate

ParameterTypeDescription
guidstringCurrent website guid.
localestringCurrent website locale.
pageModelPageModelThe pageModel object of the requested page template.

Returns: An object of PageModel class.

getPage

ParameterTypeDescription
pageIDnumberThe id of the requested page.
guidstringCurrent website guid.
localestringCurrent website locale.

Returns: An object of PageItem class.

publishPage

ParameterTypeDescription
pageIDnumberThe pageID of the requested page.
guidstringCurrent website guid.
localestringCurrent website locale.
commentsstringAdditional comments for a batch request.

Returns: An array of pageID of the requested page.

unPublishPage

ParameterTypeDescription
pageIDnumberThe pageID of the requested page.
guidstringCurrent website guid.
localestringCurrent website locale.
commentsstringAdditional comments for a batch request.

Returns: An array of pageID of the requested page.

deletePage

ParameterTypeDescription
pageIDnumberThe pageID of the requested page.
guidstringCurrent website guid.
localestringCurrent website locale.
commentsstringAdditional comments for a batch request.

Returns: An array of pageID of the requested page.

approvePage

ParameterTypeDescription
pageIDnumberThe pageID of the requested page.
guidstringCurrent website guid.
localestringCurrent website locale.
commentsstringAdditional comments for a batch request.

Returns: An array of pageID of the requested page.

declinePage

ParameterTypeDescription
pageIDnumberThe pageID of the requested page.
guidstringCurrent website guid.
localestringCurrent website locale.
commentsstringAdditional comments for a batch request.

Returns: An array of pageID of the requested page.

pageRequestApproval

ParameterTypeDescription
pageIDnumberThe pageID of the requested page.
guidstringCurrent website guid.
localestringCurrent website locale.
commentsstringAdditional comments for a batch request.

Returns: An array of pageID of the requested page.

savePage

ParameterTypeDescription
pageItemPageItemThe object of PageItem class for the requested Page.
guidstringCurrent website guid.
localestringCurrent website locale.
parentPageIDnumberThe id of the parent page.
placeBeforePageItemIDnumberThe id of the page before the page.

Returns: An array of pageID of the requested page.

getPageHistory

ParameterTypeDescription
localestringCurrent website locale.
guidstringCurrent website guid.
pageIDnumberThe pageID of the requested page.
takenumberThe number of items per record set default value 50.
skipnumberThe skip level on the record set default value 0.

Returns: An object of PageHistory class of the requested page history.

getPageComments

ParameterTypeDescription
localestringCurrent website locale.
guidstringCurrent website guid.
pageIDnumberThe pageID of the requested page.
takenumberThe number of items per record set default value 50.
skipnumberThe skip level on the record set default value 0.

Returns: An object of ItemComments class of the requested page comments.

Class ServerUserMethods

This class is used to perform operations related to Server User. The following are the methods: -

me

ParameterTypeDescription
guidstringCurrent website guid.

Returns: An object of ServerUser class of the requested user.

you

ParameterTypeDescription
guidstringCurrent website guid.
serverUserIDnumberCurrent website guid.

Returns: An object of ServerUser class of the requested user.

Class WebhookMethods

This class is used to perform operations related to Webhooks in the agility instance. The following are the methods: -

webhookList

ParameterTypeDescription
guidstringCurrent website guid.
takenumberThe number of items per record set default value 20.
skipnumberThe skip level on the record set default value 0.

Returns: A list of webhooks configured in the instance.

saveWebhook

ParameterTypeDescription
guidstringCurrent website guid.
webhookWebhookAn object of Webhook type with the webhook data.

Returns: An object with the created Webhook.

getWebhook

ParameterTypeDescription
guidstringCurrent website guid.
webhookIDstringThe webhookID of the requested webhook.

Returns: An object with the requested Webhook.

deleteWebhook

ParameterTypeDescription
guidstringCurrent website guid.
webhookIDstringThe webhookID of the requested webhook.

Running the SDK Locally

  • npm run clean
  • npm run prepare
  • npm run build

How It Works

Resources

Agility CMS

Community

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.

0.1.17

1 year ago

0.1.18

12 months ago

0.1.16

1 year ago

0.1.15

2 years ago

0.1.14

2 years ago

0.1.11

2 years ago

0.1.12

2 years ago

0.1.13

2 years ago

0.1.10

2 years ago

0.1.8

2 years ago

0.1.9

2 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago