API Docs for: 1.5.0
Show:

CAPI Class

Defined in: src/CAPI.js:12

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]
)

Defined in src/CAPI.js:12

Parameters:

  • endPointUrl String

    url pointing to REST root

  • authenticationAgent Object

    Instance of one of the AuthAgents (e.g. SessionAuthAgent, HttpBasicAuthAgent)

  • [options] Object optional

    Object containing different options for the CAPI

    • [rootPath='/api/ezp/v2/'] String optional

      the API root path

    • [logRequests=false] Boolean optional

      whether to log requests

    • [siteAccess=null] String | Null optional

      siteaccess 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}
          ]
      });

Methods

getConnectionManager

() ConnectionManager

Defined in src/CAPI.js:191

Gets the connection manager

Returns:

Example:

 var connectionManager = jsCAPI.getConnectionManager();
 connectionManager.request(
     "GET",
     "/endpoint",
     "",
     {"Accept": "application/json"},
     callback
 );

getContentService

() ContentService

Defined in src/CAPI.js:108

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

Defined in src/CAPI.js:130

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

Defined in src/CAPI.js:174

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

Defined in src/CAPI.js:152

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
)

Defined in src/CAPI.js:70

Checks that the CAPI instance is logged in

Parameters:

  • callback Function

logIn

(
  • [credentials]
  • callback
)

Defined in src/CAPI.js:80

Logs in the user

Parameters:

  • [credentials] Object optional
    • login String
    • password String
  • callback Function

logOut

(
  • callback
)

Defined in src/CAPI.js:98

Logs out the current user.

Parameters:

  • callback Function