API Docs for: 1.5.0
Show:

PromiseCAPI Class

Defined in: src/PromiseCAPI.js:5

Creates an instance of PromiseCAPI object based on existing CAPI object

Constructor

PromiseCAPI

(
  • originalCapi
)

Parameters:

  • originalCapi CAPI

    main REST client object

Methods

_createPromiseServiceFactory

(
  • serviceFactoryName
)
Function private

Convert any CAPI service factory into Promise-based service factory.

The factory will cache once created instances inside the _services object to not create new service wrappers each time they are requested

Parameters:

  • serviceFactoryName String

    name of the function which returns one of the CAPI services

Returns:

Function:

function which returns instance of the PromiseService - promise-based wrapper around any of the CAPI services

getContentService

() PromiseService

Dynamically generated method which returns promise-based version of the ContentService. Resulting service provides set of methods named the same as the regular ContentService methods. The only exception are structure constructors (new...Struct methods) which are not implemented in promise-based services. These promise-based methods should be used without the callback parameter and according to promises approach. Basic usage of a promise-based method is provided in the following example. Read more about promises at https://github.com/kriskowal/q

Returns:

Example:

var jsCAPI = new eZ.CAPI(
    'http://ez.git.local',
    new eZ.SessionAuthAgent({login: "admin", password: "ezpublish"}),
    {logRequests: true},
),
jsPromiseCAPI = new eZ.PromiseCAPI(jsCAPI),
promiseContentService = jsPromiseCAPI.getContentService(),
promise = promiseContentService.loadSection("/api/ezp/v2/content/sections/1");

promise.then(
    function (result) {
        console.log(result);
    }, function (error) {
        console.log(error);
    }
);

getContentTypeService

() PromiseService

Dynamically generated method which returns promise-based version of the ContentTypeService. Resulting service provides set of methods named the same as the regular ContentTypeService methods. The only exception are structure constructors (new...Struct methods) which are not implemented in promise-based services. These promise-based methods should be used without the callback parameter and according to promises approach. Basic usage of a promise-based method is provided in the following example. Read more about promises at https://github.com/kriskowal/q

Returns:

Example:

var jsCAPI = new eZ.CAPI(
    'http://ez.git.local',
    new eZ.SessionAuthAgent({login: "admin", password: "ezpublish"}),
    {logRequests: true},
),
jsPromiseCAPI = new eZ.PromiseCAPI(jsCAPI),
promiseContentTypeService = jsPromiseCAPI.getContentTypeService(),
promise = promiseContentTypeService.loadContentTypeGroup("/api/ezp/v2/content/typegroups/1");

promise.then(
    function (result) {
        console.log(result);
    }, function (error) {
        console.log(error);
    }
);

getUserService

() PromiseService

Dynamically generated method which returns promise-based version of the UserService. Resulting service provides set of methods named the same as the regular UserService methods. The only exception are structure constructors (new...Struct methods) which are not implemented in promise-based services. These promise-based methods should be used without the callback parameter and according to promises approach. Basic usage of a promise-based method is provided in the following example. Read more about promises at https://github.com/kriskowal/q

Returns:

Example:

var jsCAPI = new eZ.CAPI(
    'http://ez.git.local',
    new eZ.SessionAuthAgent({login: "admin", password: "ezpublish"}),
    {logRequests: true},
),
jsPromiseCAPI = new eZ.PromiseCAPI(jsCAPI),
promiseUserService = jsPromiseCAPI.getUserService(),
promise = promiseUserService.loadUserGroup("/api/ezp/v2/user/groups/1/5");

promise.then(
    function (result) {
        console.log(result);
    }, function (error) {
        console.log(error);
    }
);

Attributes

_services

Object protected

Array of promise-based services instances (needed to implement singletons approach)