User Provider
        
        
        
- Copyright:
 - Kiwigrid GmbH 2014-2015
 
- Source:
 
Classes
Methods
- <inner> $create() → {promise}
 - <inner> $delete() → {promise}
 - <inner> $reset() → {undefined}
 - <inner> $update() → {promise}
 - <inner> create(eventBus, properties) → {UserInstance}
 - <inner> getChannel(eventBus, channelId) → {String}
 - <inner> getCurrent(eventBus) → {UserInstance}
 
- 
    
<inner> $create() → {promise}
 - 
    
    
    
Creates a remote UserInstance from local one the method is called on.
- Source:
 
Returns:
promise promiseExample
angular.module('exampleApp', ['keta.services.User']) .controller('ExampleController', function(ketaUser) { var user = ketaUser.create({ userId: 'userId' }); user.$create() .then(function(reply) { // success handler // ... }, function(reply) { // error handler // ... }); }); - 
    
<inner> $delete() → {promise}
 - 
    
    
    
Deletes a remote UserInstance from local one the method is called on.
- Source:
 
Returns:
promise promiseExample
angular.module('exampleApp', ['keta.services.User']) .controller('ExampleController', function(ketaUser) { var user = ketaUser.create({ userId: 'userId' }); user.$delete() .then(function(reply) { // success handler // ... }, function(reply) { // error handler // ... }); }); - 
    
<inner> $reset() → {undefined}
 - 
    
    
    
Resets a UserInstance to it's $pristine state.
- Source:
 
Returns:
undefined nothingExample
angular.module('exampleApp', ['keta.services.User']) .controller('ExampleController', function(ketaUser) { var user = ketaUser.create({ userId: 'john.doe', channel: 'channel', givenName: 'John', familyName: 'Doe', email: 'john.doe@test.com', address: { street: 'Main Street', number: '100 E', city: 'Phoenix', country: 'USA', zip: '85123' }, properties: { position: 'left' } }); user.email = 'john.doe@kiwigrid.com'; delete user.properties.position; user.$update() .then(function(reply) { // success handler // ... }, function(reply) { // error handler user.$reset(); }); }); - 
    
<inner> $update() → {promise}
 - 
    
    
    
Updates a remote UserInstance from local one the method is called on.
- Source:
 
Returns:
promise promiseExample
angular.module('exampleApp', ['keta.services.User']) .controller('ExampleController', function(ketaUser) { var user = ketaUser.create({ userId: 'john.doe', channel: 'channel', givenName: 'John', familyName: 'Doe', email: 'john.doe@test.com', address: { street: 'Main Street', number: '100 E', city: 'Phoenix', country: 'USA', zip: '85123' }, properties: { position: 'left' } }); user.email = 'john.doe@kiwigrid.com'; delete user.properties.position; user.$update() .then(function(reply) { // success handler // ... }, function(reply) { // error handler // ... }); }); - 
    
<inner> create(eventBus, properties) → {UserInstance}
 - 
    
    
    
Creates a UserInstance with given EventBus instance and properties.
Parameters:
Name Type Description eventBusEventBus EventBus instance to use for communication propertiesObject Properties to set upon UserInstance creation - Source:
 
Returns:
UserInstance created UserInstanceExample
angular.module('exampleApp', ['keta.services.User']) .controller('ExampleController', function(ketaUser) { var user = ketaUser.create(eventBus, { userId: 'john.doe', channel: 'channel', givenName: 'John', familyName: 'Doe', email: 'john.doe@test.com', address: { street: 'Main Street', number: '100 E', city: 'Phoenix', country: 'USA', zip: '85123' } }); }); - 
    
<inner> getChannel(eventBus, channelId) → {String}
 - 
    
    
    
Returns the channel name for given channel id.
Parameters:
Name Type Description eventBusEventBus EventBus instance to use for communication channelIdString Channel id to retrieve. - Source:
 
Returns:
String channel nameExample
angular.module('exampleApp', ['keta.services.User']) .controller('ExampleController', function(ketaUser) { ketaUser.getChannel(eventBus, 'channel-1') .then(function(reply) { // reply is channel name }); }); - 
    
<inner> getCurrent(eventBus) → {UserInstance}
 - 
    
    
    
Returns the currently logged-in user.
Parameters:
Name Type Description eventBusEventBus EventBus instance to use for communication - Source:
 
Returns:
UserInstance current logged-in userExample
angular.module('exampleApp', ['keta.services.User']) .controller('ExampleController', function(ketaUser) { ketaUser.getCurrentUser(eventBus) .then(function(reply) { // reply is current UserInstance }); });