-
Notifications
You must be signed in to change notification settings - Fork 3
API Documentation
Methods are part of the grout object you create in the getting started guide:
var grout = new Grout();
Grout extends Matter, which means that is has all of the same methods for Authentication, Basic Utils, and Token/Storage handling.
Here is an example of the login method (from Matter) that is used from grout:
Log user in provided username/email and password.
Example:
grout.login({username: 'test', password: 'test'})
.then(function(userData){
console.log('User logged in. Account:', userData.account);
});
Get a list of applications.
Example:
//Get applications
grout.apps.get().then(function(appsList){
console.log('Applications:', appsList);
});
Add an application.
Example:
//Add an application
var appData = {name: 'exampleApp', template: 'default'};
grout.apps.add(appData).then(function(newApp){
console.log('New application:', newApp);
});
Get an application's data.
Example:
//Get application's metadata
grout.app('exampleApp').get().then(function(appInfo){
console.log('Info for exampleApp:', appInfo);
});
Update an application.
Example:
//Update application's name
var appData = {name: 'exampleApp2'};
grout.app('exampleApp').update(appData).then(function(appInfo){
console.log('Info for exampleApp:', appInfo);
});
Delete an application.
Example:
//Get application's metadata
grout.app('exampleApp').del().then(function(appInfo){
console.log('Info for exampleApp:', appInfo);
});
Get an application's files in array format.
Example:
//Get array of application's files
grout.app('exampleApp').files.get().then(function(appFiles){
console.log('Files for exampleApp:', appFiles);
});
Add file to application's files and upload/publish.
Example:
//Publish all of application's files
var fileData = {content: '<h2>Some html content</h2>', path: '/templates/random.html'};
grout.app('exampleApp').files.add(fileData).then(function(addedFile){
console.log('File added successfully:', addedFile);
});
Get an application's file contents and metadata.
Example:
//Get array of application's files
var fileData = {content: '<h2>Some html content</h2>', path: '/templates/random.html'};
grout.app('exampleApp').files.get().then(function(addedFile){
console.log('File added successfully:', addedFile);
});
WARNING: METHOD STILL UNDER CONSTRUCTION
Publish all of application's files at one time.
Example:
//Publish all of application's files
grout.app('exampleApp').files.publish().then(function(structureFormat){
console.log('Example app files in structure format:', structureFormat);
});
Useful for displaying folder/file structure and children contents
Example:
//Get application's file in structure format
grout.app('exampleApp').structure.then(function(structureFormat){
console.log('Example app files in structure format:', structureFormat);
});
An application's groups work the same way that Groups works (documentation in Groups section below), just attached to app('appName')
.
Examples:
//Add a group
var newGroup = {name: 'admin', accounts:[]};
grout.app('exampleApp').groups().add().then(function(groupData){
console.log('Admin group of example app loaded:', groupData);
});
//Load a specific group
grout.app('exampleApp').group('admin').then(function(groupData){
console.log('Admin group of example app loaded:', groupData);
});
An application's groups work the same way that Groups works (documentation in Groups section below), just attached to app('appName')
.
Examples:
//Add a group
var newDirectory = {name: 'admin', accounts:[13411234523,32412234523], groups:[1241234]};
grout.app('exampleApp').directories().add().then(function(addedDirectory){
console.log('Admin group of example app loaded:', addedDirectory);
});
//Load a specific group
grout.app('exampleApp').directory('exampleApp-testers').then(function(directoryData){
console.log('exampleApp-tests directory of example app loaded:', directoryData);
});
Groups are equivalent to "roles". A group is a set of users accounts that can be assigned a capability all at once. For example, if you create a group called "admin" and accounts to that group, those "admins" can then be given capabilities to do things that a "users" group can not.
Get users.
Examples:
//Get users
grout.users.get().then(function(groupData){
console.log('Admin group of example app loaded:', groupData);
});
Add a group.
Examples:
//Add a group
var newUser = {username: 'test', password: 'testtest', name: 'Test user'};
grout.users().add(newUser).then(function(userData){
console.log('New user added: ', userData);
});
Get a specific user's data.
Examples:
//Get user with username "test"
grout.user('test').get().then(function(userData){
console.log('User with username test: ', userData);
});
Update a user.
Examples:
//Get users
grout.user('test').update().then(function(groupData){
console.log('Admin group of example app loaded:', groupData);
});
Groups are equivalent to "roles". A group is a set of users accounts that can be assigned a capability all at once. For example, if you create a group called "admin" and accounts to that group, those "admins" can then be given capabilities to do things that a "users" group can not.
Get groups.
Examples:
//Get groups
grout.groups.get().then(function(groupData){
console.log('Admin group of example app loaded:', groupData);
});
Add a group.
Examples:
//Add a group
var newGroup = {name: 'admin', accounts:[], application: 123};
grout.groups().add(newGroup).then(function(groupData){
console.log('Admin group of example app loaded:', groupData);
});
WARNING: CURRENTLY GETS FROM ALL GROUPS WHICH WILL BE CHANGED
Get a specific group's data.
Examples:
//Get groups
grout.group('admin').get().then(function(groupData){
console.log('Admin group of example app loaded:', groupData);
});
WARNING: CURRENTLY UPDATES FROM ALL GROUPS WHICH WILL BE CHANGED
Get a specific group's data.
Examples:
//Get groups
grout.group('admin').update().then(function(groupData){
console.log('Admin group of example app loaded:', groupData);
});
Directories include Groups and Accounts
List of directories.
Example:
//Get directory named exampleApp-testers
grout.directories.add().then(function(groupData){
console.log('Admin group of example app loaded:', groupData);
});
Add a directory.
Example:
//Get directory named exampleApp-testers
grout.directories.add().then(function(groupData){
console.log('Admin group of example app loaded:', groupData);
});
WARNING: CURRENTLY UPDATES FROM ALL GROUPS WHICH WILL BE CHANGED
Get a specific directory's data.
Example:
//Update directories accounts by id
var updateData = {accounts:[1u98qu9wer, 2a87987, 323482398]}
grout.directory('exampleApp-testers').update().then(function(directoryData){
console.log('exampleApp-testers directory loaded:', directoryData);
});
WARNING: CURRENTLY UPDATES FROM ALL GROUPS WHICH WILL BE CHANGED
Get a specific directory's data.
Example:
//Get directory named exampleApp-testers
grout.directory('exampleApp-testers').update().then(function(groupData){
console.log('Admin group of example app loaded:', groupData);
});