Commit 01dcd68d authored by Patricio Bruna's avatar Patricio Bruna

getInfo() return info of the current logged user

parent 04f264bc
......@@ -14,7 +14,7 @@ var zimbraApi = new ZimbraAdminApi({
Here you see how to get basic information using a function like `getAllDomains`:
```javascript
zimbraApi.getAllDomains(function(data, err){
zimbraApi.getAllDomains(function(err, data){
if (err) return console.log(err);
data.forEach(function(v){
console.log(v.id + ' ' + v.name);
......@@ -25,7 +25,7 @@ zimbraApi.getAllDomains(function(data, err){
Here you see how to get basic information using a function like `getAllAccounts`:
```javascript
zimbraApi.getAllAccounts(function(data, err){
zimbraApi.getAllAccounts(function(err, data){
if (err) return console.log(err);
data.forEach(function(v){
console.log(v.id + ' ' + v.name);
......
This diff is collapsed.
This diff is collapsed.
......@@ -224,6 +224,24 @@ export default class ZimbraAdminApi {
this.getAll('DistributionList', callback);
}
// Get current logged account information
getInfo(callback) {
const req_params = { name: 'GetInfoRequest', namespace: 'zimbraAccount' };
const that = this;
this.client.getRequest({}, function(err, req) {
if (err) return callback(this.handleError(err));
req.addRequest(req_params, function(err){
if (err) return callback(that.handleError(err));
that.client.send(req, function(err, data){
if (err) return callback(that.handleError(err));
const result = data.response[0].GetInfoResponse
return callback(null, result);
});
});
});
}
}
if (typeof module === 'object' && typeof module.exports === 'object') {
......
......@@ -207,6 +207,19 @@
});
});
it('getInfo() should return the logged user info', function(done){
let api = new ZimbraAdminApi(auth_data);
let callback = function(err, data) {
if (err) return console.log(err);
api.getInfo(function(err, data){
if (err) return console.log(err);
expect(data.name).to.equal('admin@zboxapp.dev');
done();
});
};
api.login(callback);
});
});
})();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment