Commit a84f8c1a authored by Patricio Bruna's avatar Patricio Bruna

Added domain.getAllDistributionLists()

parent 739522ee
...@@ -326,3 +326,12 @@ Return an Array of the Domain Admins `Accounts`. ...@@ -326,3 +326,12 @@ Return an Array of the Domain Admins `Accounts`.
domain.getAdmins(callback); domain.getAdmins(callback);
// [Account, Account] // [Account, Account]
``` ```
### Distribution Lists
Return an Array of the Domain `DistributionList`s.
```javascript
// domain is a Domain, you got it from zimbraApi.getDomain....
domain.getAllDistributionLists(callback);
// [DistributionList, DistributionList]
```
...@@ -13161,6 +13161,16 @@ return /******/ (function(modules) { // webpackBootstrap ...@@ -13161,6 +13161,16 @@ return /******/ (function(modules) { // webpackBootstrap
return callback(null, ids); return callback(null, ids);
}); });
} }
}, {
key: 'getAllDistributionLists',
value: function getAllDistributionLists(callback) {
var query_object = { domain: this.name };
this.api.getAllDistributionLists(function (e, d) {
if (e) return callback(e);
if (d.total === 0) return callback(null, []);
return callback(null, d.dl);
}, query_object);
}
}, { }, {
key: 'countAccounts', key: 'countAccounts',
value: function countAccounts(callback) { value: function countAccounts(callback) {
This diff is collapsed.
...@@ -43,6 +43,15 @@ export default class Domain extends Zimbra { ...@@ -43,6 +43,15 @@ export default class Domain extends Zimbra {
}); });
} }
getAllDistributionLists(callback) {
let query_object = { domain: this.name };
this.api.getAllDistributionLists(function(e,d){
if (e) return callback(e);
if (d.total === 0) return callback(null, []);
return callback(null, d.dl);
}, query_object);
}
countAccounts(callback) { countAccounts(callback) {
const maxAccountsByCos = this.maxAccountsByCos(); const maxAccountsByCos = this.maxAccountsByCos();
this.api.countAccounts(this.id, function(e,d){ this.api.countAccounts(this.id, function(e,d){
......
...@@ -353,7 +353,7 @@ ...@@ -353,7 +353,7 @@
}); });
}); });
it('domain.admins() should return the domain admins', function(done){ it('domain.getAdmins() should return the domain admins', function(done){
let api = new ZimbraAdminApi(auth_data); let api = new ZimbraAdminApi(auth_data);
api.getDomain('customer.dev', function(err, data){ api.getDomain('customer.dev', function(err, data){
if (err) console.error(err); if (err) console.error(err);
...@@ -366,19 +366,21 @@ ...@@ -366,19 +366,21 @@
}); });
}); });
it('domain.admins() should return empty array if no admins', function(done){ it('domain.getAllDistributionLists should return the DLs', function(done){
let api = new ZimbraAdminApi(auth_data); let api = new ZimbraAdminApi(auth_data);
api.getDomain('zboxapp.dev', function(err, data){ api.getDomain('customer.dev', function(err, data){
if (err) console.error(err); if (err) console.error(err);
let domain = data; let domain = data;
domain.getAdmins(function(e, d){ domain.getAllDistributionLists(function(e, d){
if (e) return console.log(e); if (e) return console.log(e);
expect(d.length).to.be.empty; expect(d[0].constructor.name).to.be.equal('DistributionList');
done(); done();
}); });
}); });
}); });
}); });
describe('DistributionList tests', function() { describe('DistributionList tests', function() {
......
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