Skip to content

services templatingService

mzilic edited this page Oct 14, 2016 · 1 revision

baasicTemplatingService

Baasic Templating Service provides an easy way to consume Baasic Templating REST API end-points. In order to obtain a needed routes baasicTemplatingService uses baasicTemplatingRouteService.


baasicTemplatingService.find()

Returns a promise that is resolved once the find action has been performed. Success response returns a list of template resources matching the given criteria.

Example:

baasicTemplatingService.find({
 pageNumber : 1,
 pageSize : 10,
 orderBy : '<field>',
 orderDirection : '<asc|desc>',
 search : '<search-phrase>'
})
.success(function (collection) {
 // perform success action here
})
.error(function (response, status, headers, config) {
 // perform error handling here
});    

baasicTemplatingService.get()

Returns a promise that is resolved once the get action has been performed. Success response returns the specified template resource.

Example:

baasicTemplatingService.get('<template-id>')
.success(function (data) {
 // perform success action here
})
.error(function (response, status, headers, config) {
 // perform error handling here
});

baasicTemplatingService.create()

Returns a promise that is resolved once the create template action has been performed; this action creates a new template resource.

Example:

baasicTemplatingService.create({
 content : '<content>',
 templateId : '<template-id>'
})
.success(function (data) {
 // perform success action here
})
.error(function (response, status, headers, config) {
 // perform error handling here
});

baasicTemplatingService.update()

Returns a promise that is resolved once the update template action has been performed; this action updates a template resource. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply baasicTemplatingRouteService route template. Here is an example of how a route can be obtained from HAL enabled objects:

var params = baasicApiService.removeParams(template);
var uri = params['model'].links('put').href;

Example:

// template is a resource previously fetched using get action.
template.content = '<new-content>';
baasicTemplatingService.update(template)
.success(function (data) {
 // perform success action here
})
.error(function (response, status, headers, config) {
 // perform error handling here
});

baasicTemplatingService.remove()

Returns a promise that is resolved once the remove action has been performed. This action will remove a template resource from the system if successfully completed. This route uses HAL enabled objects to obtain routes and therefore it doesn't apply baasicTemplatingRouteService route template. Here is an example of how a route can be obtained from HAL enabled objects:

var params = baasicApiService.removeParams(template);
var uri = params['model'].links('delete').href;

Example:

// template is a resource previously fetched using get action.				 
baasicTemplatingService.remove(template)
.success(function (data) {
 // perform success action here
})
.error(function (response, status, headers, config) {
 // perform error handling here
});		

baasicTemplatingService.routeService()

Provides direct access to baasicKeyValueRouteService.

Example:

baasicTemplatingService.routeService.get.expand(expandObject);

baasicTemplatingService.batch.create()

Returns a promise that is resolved once the create action has been performed; this action creates new template resources.

Example:

baasicTemplatingService.batch.create([{
      content : '<content>',
      templateId : '<template-id>'
    }])
    .success(function (data) {
      // perform success action here
    })
    .error(function (response, status, headers, config) {
      // perform error handling here
    });

baasicTemplatingService.batch.update()

Returns a promise that is resolved once the update action has been performed; this action updates specified template resources.

Example:

baasicTemplatingService.batch.update(templates)
    .success(function (data) {
      // perform success action here
    })
    .error(function (response, status, headers, config) {
      // perform error handling here
    });

baasicTemplatingService.batch.remove()

Returns a promise that is resolved once the remove action has been performed. This action will remove template resources from the system if successfully completed.

Example:

baasicTemplatingService.batch.remove(companyIds)
    .success(function (data) {
      // perform success action here
    })
    .error(function (response, status, headers, config) {
      // perform error handling here
    });		

Notes:

  • Refer to the REST API documentation for detailed information about available Baasic REST API end-points.
  • All end-point objects are transformed by the associated route service.