. . .

Basic Module

Standard module which is added to every app automatically. It contains the user class, which is a representation for a user of your app.

Configuration

Users can see each other

TRUE if all user of an application can see a list of other user (e.g. to send messages to them) or FALSE if not.

Usage

Every user of your app should be represented by a corresponding User object. Using this is not only a nice and easy way to store and view your user without creating a own class, but is also necessary for authorization. Most requests on the server (especially those which require the client to be the owner) need the credentials of a valid user to make authorization work. So the first initial step in your app will be the creation and authentication of your user:

Android
// Create your user
final User user = new User();
user.setUserName("johnDoe");
user.setPassword("123456");
 
// Configure the Datastore, a static class doing all the network stuff,
// before doing the first request
Datastore.configureWithCredentials(user);
 
// Now check if the user already exists and in case he doesn't: create the user
user.loadMeAsync(new AOMEmptyCallback() {
@Override
public void isDone(ApiomatRequestException exception) {
if (exception != null) {
// if the member is not found on the server just create it
user.saveAsync(new AOMEmptyCallback() {
@Override
public void isDone(ApiomatRequestException exception) {
// ...
}
});
}
}
});
iOS
// Create your user
AOMUser *u = [[AOMUser alloc] init];
[u setUserName:@"johnDoe" ];
[u setPassword:@"123456" ];
// Configure the Datastore,
// a static class doing all the network stuff,
// before doing the first request
[AOMDatastore configureWithUser:u];
 
// now you can try to load the users data from the server
[u loadMeAsyncWithFinishingBlock:^(NSError *error) {
// if the user exists, we should now have a valid href
if([u getHref] == NULL || error)
{
// if not, let us create the user initally
[u saveAsyncWithBlock:^(NSError *error) {
 
}];
}
}];
JavaScript
// Create a new member/user of your app
var myUser = new Apiomat.User();
myUser.setUserName("johnDoe");
myUser.setPassword("1,618");
 
// configure datastore with user credentials
Apiomat.Datastore.configureWithCredentials(myUser);
 
var saveCB = {
onOk : function() {
console.log("saved");
//Now you can create objects of your class with this new user..
},
onError : function(error) {
console.log("Some error occured: (" + error.statusCode + ")" + error.message);
}
};
 
// Try to load user or create new one if not exists
myUser.loadMe({
onOk : function() {
//Now you can do sth with loaded object
},
onError : function(error) {
// and save it
myUser.save(saveCB);
}
});

As you have seen, the Datastore plays an important role: All requests are done using it. But that’s only FYI, all calls are encapsulated in SDK generated methods. Usually you should operate only with your generated classes.

* link only available in Enterprise Documentation