CAPI Class
Creates an instance of CAPI - main object which handles the API initialization and gives ability to retrieve various services. Could be created only in one instance. Handles connections, authorization and REST paths discovery automatically.
Constructor
CAPI
-
endPointUrl
-
authenticationAgent
-
[options]
Parameters:
-
endPointUrl
Stringurl pointing to REST root
-
authenticationAgent
ObjectInstance of one of the AuthAgents (e.g. SessionAuthAgent, HttpBasicAuthAgent)
-
[options]
Object optionalObject containing different options for the CAPI
-
[rootPath='/api/ezp/v2/']
String optionalthe API root path
-
[logRequests=false]
Boolean optionalwhether to log requests
-
[siteAccess=null]
String | Null optionalsiteaccess in which requests should be executed
-
Example:
var authAgent = new SessionAuthAgent({
login: "admin",
password: "admin"
}),
jsCAPI = new CAPI(
'http://ez.git.local', authAgent, {
logRequests: true, // Whether we should log each request to the js console or not
rootPath: '/api/ezp/v2/', // Path to the REST root
connectionStack: [ // Array of connections, should be filled-in in preferred order
{connection: XmlHttpRequestConnection},
{connection: MicrosoftXmlHttpRequestConnection}
]
});
Item Index
Methods
getConnectionManager
()
ConnectionManager
Gets the connection manager
Returns:
Example:
var connectionManager = jsCAPI.getConnectionManager();
connectionManager.request(
"GET",
"/endpoint",
"",
{"Accept": "application/json"},
callback
);
getContentService
()
ContentService
Get instance of Content Service. Use ContentService to retrieve information and execute operations related to Content.
Returns:
Example:
var contentService = jsCAPI.getContentService();
contentService.loadRoot(
callback
);
getContentTypeService
()
ContentTypeService
Get instance of Content Type Service. Use ContentTypeService to retrieve information and execute operations related to ContentTypes.
Returns:
Example:
var contentTypeService = jsCAPI.getContentTypeService();
contentTypeService.loadContentType(
'/api/ezp/v2/content/types/18',
callback
);
getDiscoveryService
()
DiscoveryService
Get instance of Discovery Service. Use DiscoveryService to internally to discover resources URI and media type provided in the root resource.
Returns:
Example:
var discoveryService = jsCAPI.getDiscoveryService();
discoveryService.getInfoObject(
"Trash",
callback
);
getUserService
()
UserService
Get instance of User Service. Use UserService to retrieve information and execute operations related to Users.
Returns:
Example:
var userService = jsCAPI.getUserService();
userService.loadRootUserGroup(
callback
);
isLoggedIn
-
callback
Checks that the CAPI instance is logged in
Parameters:
-
callback
Function
logIn
-
[credentials]
-
callback
Logs in the user
Parameters:
-
[credentials]
Object optional-
login
String -
password
String
-
-
callback
Function
logOut
-
callback
Logs out the current user.
Parameters:
-
callback
Function