efesto-angular
v0.4.2
Published
Angular sdk for efesto
Readme
Efesto Angular
Angular sdk for Efesto that provides an angular module that handles authentication and requests to an Efesto API.
Installation
Install using npm:
npm install efesto-angularThen load the module:
angular.module('myapp', ['efesto.angular']);Usage
Set the domain where the api is located:
api.domain = 'http://youdomain.com';Set the credentials for an user:
api.addUser('myuser', 'password');Login with that user:
api.login('myuser', successCallback);Now you can make requests to collections:
/* Get list of users */
var users = api.collection('users');
users.get({rank: 1}, successCallback, failureCallback);
/* New user */
var myUser = {name: 'myself', rank: 1, email: 'mail', password: 'passwd'};
users.post(myUser, null, successCallback, failureCallback);To resources:
var user = api.resource('users');
/* Get user with id 7 */
user.get({id: 7}, successCallback, failureCallback);
/* Update user #7's name */
user.patch({id: 7, name: 'newname'}, successCallback, failureCallback);
/* Delete user #7 */
user.delete({id: 7}, successCallback, failureCallback);If you already know your token, such as when using a public user:
api.addToken('public', 'mytoken')
api.user.currentUser = 'public';