Commit bd42b71e authored by Patricio Bruna's avatar Patricio Bruna

Added getAccountMembership

parent 8e8355ea
...@@ -318,6 +318,18 @@ account.disableArchiving(callback); ...@@ -318,6 +318,18 @@ account.disableArchiving(callback);
// account.archiveEnabled === false; // account.archiveEnabled === false;
``` ```
### Get Account Membership
Get distribution lists an account is a member of.
```javascript
api.getAccountMembership(account, callback);
// [DistributionList, DistributionList, ...]
// Or as a method of the account
account.getAccountMembership(callback);
// [DistributionList, DistributionList, ...]
```
### Get Mailbox ### Get Mailbox
```javascript ```javascript
account.getMailbox(callback); account.getMailbox(callback);
......
...@@ -548,11 +548,23 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -548,11 +548,23 @@ return /******/ (function(modules) { // webpackBootstrap
request_data.params.params.target = target; request_data.params.params.target = target;
return this.performRequest(request_data); return this.performRequest(request_data);
} }
}, {
// Get current logged account information key: 'getAccountMembership',
value: function getAccountMembership(account, callback) {
var request_data = this.buildRequestData('GetAccountMembership', callback);
request_data.resource = 'dl';
request_data.parse_response = ResponseParser.allResponse;
request_data.params.params.account = {
'by': this.dictionary.byIdOrName(account),
'_content': account
};
return this.performRequest(request_data);
}
}, { }, {
key: 'getInfo', key: 'getInfo',
// Get current logged account information
value: function getInfo(callback) { value: function getInfo(callback) {
var request_data = this.buildRequestData('GetInfo', callback); var request_data = this.buildRequestData('GetInfo', callback);
request_data.params.namespace = 'zimbraAccount'; request_data.params.namespace = 'zimbraAccount';
...@@ -30808,7 +30820,7 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -30808,7 +30820,7 @@ return /******/ (function(modules) { // webpackBootstrap
module.exports = { module.exports = {
"name": "zimbra-admin-api-js", "name": "zimbra-admin-api-js",
"version": "0.2.12", "version": "0.2.13",
"main": "src/index.js", "main": "src/index.js",
"dependencies": { "dependencies": {
"crypto-browserify": "^3.11.0", "crypto-browserify": "^3.11.0",
...@@ -32440,6 +32452,11 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -32440,6 +32452,11 @@ return /******/ (function(modules) { // webpackBootstrap
return callback(null, size); return callback(null, size);
}); });
} }
}, {
key: 'getAccountMembership',
value: function getAccountMembership(callback) {
return this.api.getAccountMembership(this.id, callback);
}
}, { }, {
key: 'removeAccountAlias', key: 'removeAccountAlias',
value: function removeAccountAlias(alias, callback) { value: function removeAccountAlias(alias, callback) {
......
{ {
"name": "zimbra-admin-api-js", "name": "zimbra-admin-api-js",
"version": "0.2.12", "version": "0.2.13",
"main": "src/index.js", "main": "src/index.js",
"dependencies": { "dependencies": {
"crypto-browserify": "^3.11.0", "crypto-browserify": "^3.11.0",
......
...@@ -423,6 +423,17 @@ class ZimbraAdminApi { ...@@ -423,6 +423,17 @@ class ZimbraAdminApi {
return this.performRequest(request_data); return this.performRequest(request_data);
} }
getAccountMembership(account, callback) {
const request_data = this.buildRequestData('GetAccountMembership', callback);
request_data.resource = 'dl';
request_data.parse_response = ResponseParser.allResponse;
request_data.params.params.account = {
'by': this.dictionary.byIdOrName(account),
'_content': account
};
return this.performRequest(request_data);
};
// Get current logged account information // Get current logged account information
getInfo(callback) { getInfo(callback) {
const request_data = this.buildRequestData('GetInfo', callback); const request_data = this.buildRequestData('GetInfo', callback);
......
...@@ -69,6 +69,10 @@ class Account extends Zimbra { ...@@ -69,6 +69,10 @@ class Account extends Zimbra {
}); });
} }
getAccountMembership(callback) {
return this.api.getAccountMembership(this.id, callback);
}
removeAccountAlias(alias, callback) { removeAccountAlias(alias, callback) {
this.api.removeAccountAlias(this.id, alias, callback); this.api.removeAccountAlias(this.id, alias, callback);
} }
......
...@@ -199,6 +199,40 @@ ...@@ -199,6 +199,40 @@
describe('Account tests', function() { describe('Account tests', function() {
this.timeout(10000); this.timeout(10000);
it('should return the account membership', function(done){
const account = 'admin@zboxapp.dev';
let api = new ZimbraAdminApi(auth_data);
api.getAccountMembership(account, function(err, data){
if (err) return console.log(err);
expect(data[0].constructor.name).to.be.equal('DistributionList');
done();
});
});
it('should return the account membership when used as account method', function(done){
const account = 'admin@zboxapp.dev';
let api = new ZimbraAdminApi(auth_data);
api.getAccount(account, function(err, account){
if (err) return console.log(err);
account.getAccountMembership(function(err, data){
if (err) return console.log(err);
expect(data[0].constructor.name).to.be.equal('DistributionList');
done();
});
})
});
it('should return OK if the account membership is empty', function(done){
const account = 'pbruna@itlinux.cl';
let api = new ZimbraAdminApi(auth_data);
api.getAccountMembership(account, function(err, data){
if (err) return console.log(err);
console.log(data);
expect(data.length).to.be.equal(0);
done();
});
});
it('should create and return an account', function(done){ it('should create and return an account', function(done){
let account_name = Date.now() + '@big.com'; let account_name = Date.now() + '@big.com';
let account_password = Date.now(); let account_password = Date.now();
......
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