-
Notifications
You must be signed in to change notification settings - Fork 1
Transactions
Jóhannes Erlingsson edited this page May 15, 2017
·
1 revision
One of the simplest thing to do with the Meniga SDK is getting a transaction. This can be achived by calling Meniga.transaction().getById(context, id).
MenigaTransaction.fetch(3782).getTask().continueWith(new Continuation<MenigaTransaction, Object>() {
@Override
public Object then(Task<MenigaTransaction> task) throws Exception {
Log.d("Transaction amount", task.getResult().getAmount().floatValue() + "");
}
});
##Accounts
###Getting accounts Accounts is one of the most important things in Meniga and can be fetched with the Meniga.accounts().get(context, callback) method
MenigaAccount.fetch().getTask().continueWith(new Continuation<List<MenigaAccount>, Object>() {
@Override
public Object then(Task<List<MenigaAccount>> task) throws Exception {
if(!task.isFaulted()) {
for(MenigaAccount account : task.getResult()) {
Log.d("Account name", account.getName());
}
}
return null;
}
});
To keep your Meniga data up-to-date and fresh you have to initiate a synchronisation session in the Meniga system. This is done by using the Meniga.sync().start(context, callback) method
MenigaSync.start(6000, 100).getTask().continueWith(new Continuation<MenigaSync, Object>() {
@Override
public Object then(Task<MenigaSync> task) throws Exception {
if(!task.isFaulted()) {
if(task.getResult().getNumNewTransactions() > 0) {
// Refresh e.g. feed
}
}
return null;
}
})
It is also possible to call start and not be bothered with the callback and check the sync status at a later time by using the method Meniga.sync().check(context, callback);