0.1.16 • Published 26 days ago

@agility/management-sdk v0.1.16

Weekly downloads
-
License
MIT
Repository
github
Last release
26 days 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 index from "./index";

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

options.token = "<<Provide Auth Token>>"
//Initialize the APIClient Class
let apiClient = new index.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.

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.

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.
filterstringThe filter condition for the requested content.
fieldsstringThe fields mapped to the container.
sortDirectionstringThe direction to sort the result.
sortFieldstringThe field on which the sort needs to be performed.
takenumberThe page size for the result.
skipnumberThe 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

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.

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.

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.16

26 days ago

0.1.15

12 months ago

0.1.14

1 year ago

0.1.11

1 year ago

0.1.12

1 year ago

0.1.13

1 year ago

0.1.10

1 year ago

0.1.8

1 year ago

0.1.9

1 year ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago