-
Notifications
You must be signed in to change notification settings - Fork 0
home
- Baasic App. Settings SDK Documentation
- Baasic Articles SDK Documentation
- Baasic Dynamic Resource SDK Documentation
- Baasic Key Value SDK Documentation
- Baasic Membership SDK Documentation
- Baasic Security SDK Documentation
- Baasic Value Set SDK Documentation
To get a better understanding of Baasic AngularJS services bellow are the details of the main architecture to which all the library services conform to.
-
baasicApp service is used to manage Baasic application instances. Multiple AngularJS application instances can be created and coexist at the same time (each will communicate with its corresponding Baasic application)
- create an application
module.controller("MyCtrl", ["baasicApp", function MyCtrl(baasicApp) { var app = baasicApp.create("my-app-identifier", { apiRootUrl: "api.baasic.com", apiVersion: "v1" }); }]);
- get the default application
module.controller("MyCtrl", ["baasicApp", function MyCtrl(baasicApp) { var app = baasicApp.get(); }]);
- application object has the following methods
var apiKey = app.get_apiKey(); var apiURI = app.get_apiUrl(); var accessToken = app.get_accessToken(); app.update_accessToken(accessToken); var currentUser = app.get_user(); app.set_user(userDetails, accessToken); var currentLanguage = app.get_currentLanguage(); var defaultLanguage = app.get_defaultLanguage();
-
baasicApiHttp
Baasic HTTP service is used to perform low level communication with the Baasic back-end.
This service handles:
- authentication tokens
- HAL parsing
-
baasicApiService
This service is used to perform low level model or option transformations before they are sent to the Baasic back-end.
The following transformations are supported:
- Resource collection fetch transformation
- Single resource fetch transformation
- Create resource transformation
- Update resource transformation
- Delete resource transformation
-
baasicConstants
Baasic constants contain values such as id property name and model property name parameters that can be used in case manual model or option transformation is needed.
- every service has a route service used to wrap REST service URL discovery
- route service parses the REST service URL and prepares the URL for expansion
- route services contain the following routes
-
find
- used to fetch a collection of resources that can be filtered, paged, sorted -
get
- used to fetch a single resource -
create
- used to create a new resources
-
- supported route parameters:
-
find
route supports the following parameters:-
searchQuery
- used to build simple filters or complex queries (read more about Baasic Query Language in Baasic User Manual) -
page
- used to define the current page -
rpp
- used to define the number of resources per page -
sort
- used to define sorting expression applied to the returned resources. Sorting expressions use the following format:fieldName|asc
,field1Name|asc,field2Name|desc
-
embed
- used to embed additional resources -
fields
- used to define the list of fields returned by the service
-
-
get
route supports the following parameters:-
embed
- used to embed additional resources -
fields
- used to define list of fields returned by the service
-
-
create
route in most cases has no parameters
-
-
parse
is an utility method used to parse custom URIs (Note: parse will not return a route)
- Baasic module services are built on top of AngularJS services
- module services depend upon route services as they are used for REST service URL discovery (Note: every service exposes route service through the routeService property)
- every service has the
find
,get
,create
,update
andremove
functions used to communicate with the Baasic back-end - all services accept data object as a function parameter
Resources returned from Baasic are by default in HAL format and they look similar to this:
{
"key": "your-key",
"value": "your-value",
"dateCreated": "2015-01-01T14:24:56.795849Z",
"dateUpdated": "2015-01-01T14:24:56.795849Z",
"id": "4f788120-7cf8-44e1-bf81-a33e012c94ee",
"_links": {
"self": {
"href": "http://api.baasic.local/v1/your-app-id/key-values/your-key",
"templated": false
},
"post": {
"href": "http://api.baasic.local/v1/your-app-id/key-values",
"templated": false
},
"put": {
"href": "http://api.baasic.local/v1/your-app-id/key-values/your-key",
"templated": false
},
"delete": {
"href": "http://api.baasic.local/v1/your-app-id/key-values/your-key",
"templated": false
}
},
"_embedded": { }
}
Note: The preferred way of accessing Bassic back-end is through use of AngularJS SDK services. For manual access to the back-end URL's you can use this (or similar) code:
data.links('put').href
data.links('delete').href
You can for example also create your own update
function by using Baasic core services:
update: function (data) {
var params = baasicApiService.updateParams(data);
var url = params[baasicConstants.modelPropertyName].links('put').href;
var model = params[baasicConstants.modelPropertyName];
return baasicApiHttp.put(url, model);
},
Baasic built-in models can be extended with custom properties by simply setting property values.
article.myProperty = 1;
article.myPropertyObject = {
firstProp: 1,
secondProp: 2
}
update: function (article) {
return articleService.update(article);
}
This powerful feature allows you to extend all built-in models with custom properties which allows modules like Article to fully suit your needs.