Commit 739522ee authored by Patricio Bruna's avatar Patricio Bruna

Rename domain.admins() to domain.getAdmins()

parent 71897e8e
...@@ -323,6 +323,6 @@ Return an Array of the Domain Admins `Accounts`. ...@@ -323,6 +323,6 @@ Return an Array of the Domain Admins `Accounts`.
```javascript ```javascript
// domain is a Domain, you got it from zimbraApi.getDomain.... // domain is a Domain, you got it from zimbraApi.getDomain....
domain.admins(callback); domain.getAdmins(callback);
// [Account, Account] // [Account, Account]
``` ```
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
## Accounts ## Accounts
* [ ] Que Dominios administra una cuenta * [ ] Que Dominios administra una cuenta
* [ ] Espacio usado
## DistributionList ## DistributionList
...@@ -18,7 +19,7 @@ ...@@ -18,7 +19,7 @@
* [ ] Devolver Tipo de renovación * [ ] Devolver Tipo de renovación
* [ ] Devolver Fecha de la proxima renovación * [ ] Devolver Fecha de la proxima renovación
* [ ] Devolver Empresa (esto entiendo necesitamos otro API) * [ ] Devolver Empresa (esto entiendo necesitamos otro API)
* [ ] Devolver Admins del dominio * [X] Devolver Admins del dominio
* [ ] Devolver Listas de distribución del dominio * [ ] Devolver Listas de distribución del dominio
## parseResponse Class? ## parseResponse Class?
......
This diff is collapsed.
This diff is collapsed.
...@@ -468,6 +468,22 @@ export default class ZimbraAdminApi { ...@@ -468,6 +468,22 @@ export default class ZimbraAdminApi {
this.performRequest(request_data); this.performRequest(request_data);
} }
setPassword(zimbra_id, password, callback) {
const request_data = { };
request_data.params = this.buildRequest();
request_data.request_name = "SetPassword";
request_data.params.name = `${request_data.request_name}Request`;
request_data.params.params = {
id: zimbra_id,
newPassword: password
};
request_data.callback = callback;
const that = this;
request_data.parse_response = function(data, _, callback){
return callback(null, data.response[0].SetPasswordResponse);
};
this.performRequest(request_data);
}
} }
......
...@@ -19,4 +19,8 @@ export default class Account extends Zimbra { ...@@ -19,4 +19,8 @@ export default class Account extends Zimbra {
} }
} }
// setPassword(password, callback) {
// this.api.setPassword(this.id, password, callback);
// }
} }
...@@ -10,11 +10,11 @@ export default class Domain extends Zimbra { ...@@ -10,11 +10,11 @@ export default class Domain extends Zimbra {
} }
// TODO: Fix this fucking ugly code // TODO: Fix this fucking ugly code
admins(callback) { getAdmins(callback) {
const that = this; const that = this;
this.getAdminsIdsFromGrants(function(e,d){ this.getAdminsIdsFromGrants(function(e,d){
if (e) return callback(e); if (e) return callback(e);
if (d.length < 1) return []; if (d.length < 1) return callback(null, []);
let query = "(|"; let query = "(|";
d.forEach((id) => { d.forEach((id) => {
const zimbra_id = `(zimbraId=${id})`; const zimbra_id = `(zimbraId=${id})`;
...@@ -24,7 +24,7 @@ export default class Domain extends Zimbra { ...@@ -24,7 +24,7 @@ export default class Domain extends Zimbra {
that.api.getAllAccounts(function(e,d){ that.api.getAllAccounts(function(e,d){
if (e) return callback(e); if (e) return callback(e);
if (d.total > 0) return callback(null, d.account); if (d.total > 0) return callback(null, d.account);
callback(null, []); return callback(null, []);
}, {query: query}); }, {query: query});
}); });
} }
......
...@@ -236,6 +236,19 @@ ...@@ -236,6 +236,19 @@
}); });
}); });
it('should set password', function(done){
let api = new ZimbraAdminApi(auth_data);
api.getAccount('pbruna@itlinux.cl', function(err, data){
let account = data;
account.setPassword('12345678910', function(err, data){
if (err) return console.log(err);
console.log(data);
done();
});
});
});
}); });
describe('Domain tests', function() { describe('Domain tests', function() {
...@@ -345,7 +358,7 @@ ...@@ -345,7 +358,7 @@
api.getDomain('customer.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.admins(function(e, d){ domain.getAdmins(function(e, d){
expect(d.length).to.be.above(1); expect(d.length).to.be.above(1);
expect(d[0].constructor.name).to.be.equal('Account'); expect(d[0].constructor.name).to.be.equal('Account');
done(); done();
...@@ -358,7 +371,8 @@ ...@@ -358,7 +371,8 @@
api.getDomain('zboxapp.dev', function(err, data){ api.getDomain('zboxapp.dev', function(err, data){
if (err) console.error(err); if (err) console.error(err);
let domain = data; let domain = data;
domain.admins(function(e, d){ domain.getAdmins(function(e, d){
if (e) return console.log(e);
expect(d.length).to.be.empty; expect(d.length).to.be.empty;
done(); done();
}); });
......
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