Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zimbra-admin-api-js
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Public
zimbra-admin-api-js
Commits
623f2f19
Commit
623f2f19
authored
Apr 29, 2016
by
Patricio Bruna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Array attributes working now
parent
00b65399
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
5 deletions
+51
-5
zimbra-admin-api.js
lib/zimbra-admin-api.js
+18
-1
zimbra-admin-api.js.map
lib/zimbra-admin-api.js.map
+1
-1
package.json
package.json
+1
-1
dictionary.js
src/utils/dictionary.js
+16
-2
test.js
test/js/spec/test.js
+15
-0
No files found.
lib/zimbra-admin-api.js
View file @
623f2f19
...
...
@@ -12611,11 +12611,19 @@ return /******/ (function(modules) { // webpackBootstrap
}, {
key: 'attributesToArray',
value: function attributesToArray(attributes) {
var _this = this;
if ($.isEmptyObject(attributes)) return [];
var result = [];
var map = new _map2.default((0, _entries2.default)(attributes));
map.forEach(function (key, value) {
result.push({ 'n': value, '_content': key });
if (_this.checkIfArray(key)) {
key.forEach(function (e) {
result.push({ 'n': value, '_content': e });
});
} else {
result.push({ 'n': value, '_content': key });
}
});
return result;
}
...
...
@@ -12654,6 +12662,15 @@ return /******/ (function(modules) { // webpackBootstrap
var class_name = this.resourceToClass(resource.toLowerCase());
return new class_name(object, client);
}
}, {
key: 'checkIfArray',
value: function checkIfArray(object) {
var result = false;
if (Object.prototype.toString.call(object) === '[object Array]') {
result = true;
}
return result;
}
// This return a string or array of objects
// useful for Zimbra functions that works with both
lib/zimbra-admin-api.js.map
View file @
623f2f19
This diff is collapsed.
Click to expand it.
package.json
View file @
623f2f19
{
"name"
:
"zimbra-admin-api-js"
,
"version"
:
"0.0.
19
"
,
"version"
:
"0.0.
20
"
,
"private"
:
true
,
"main"
:
"lib/zimbra-admin-api.js"
,
"dependencies"
:
{
...
...
src/utils/dictionary.js
View file @
623f2f19
...
...
@@ -32,7 +32,13 @@ export default class Dictionary {
const
result
=
[];
const
map
=
new
Map
(
Object
.
entries
(
attributes
));
map
.
forEach
((
key
,
value
)
=>
{
result
.
push
({
'n'
:
value
,
'_content'
:
key
});
if
(
this
.
checkIfArray
(
key
))
{
key
.
forEach
((
e
)
=>
{
result
.
push
({
'n'
:
value
,
'_content'
:
e
});
});
}
else
{
result
.
push
({
'n'
:
value
,
'_content'
:
key
});
}
});
return
result
;
}
...
...
@@ -43,7 +49,7 @@ export default class Dictionary {
'type'
:
target_data
.
type
,
'by'
:
this
.
byIdOrName
(
target_data
.
identifier
),
'_content'
:
target_data
.
identifier
}
}
;
if
(
grantee_data
)
grantee
=
{
'type'
:
grantee_data
.
type
,
...
...
@@ -69,6 +75,14 @@ export default class Dictionary {
return
new
class_name
(
object
,
client
);
}
checkIfArray
(
object
)
{
let
result
=
false
;
if
(
Object
.
prototype
.
toString
.
call
(
object
)
===
'[object Array]'
)
{
result
=
true
;
}
return
result
;
}
// This return a string or array of objects
// useful for Zimbra functions that works with both
convertToZimbraArray
(
object
)
{
...
...
test/js/spec/test.js
View file @
623f2f19
...
...
@@ -172,6 +172,21 @@
});
});
it
(
'Should create Account with an array attributes'
,
function
(
done
){
let
account_name
=
Date
.
now
()
+
'@big.com'
;
let
account_password
=
Date
.
now
();
let
account_attributes
=
{
'sn'
:
'Bruna'
,
'givenName'
:
'Patricio'
};
account_attributes
.
amavisBlacklistSender
=
[
'1.com'
,
'2.com'
,
'3.com'
];
let
api
=
new
ZimbraAdminApi
(
auth_data
);
api
.
createAccount
(
account_name
,
account_password
,
account_attributes
,
function
(
err
,
data
){
if
(
err
)
return
console
.
log
(
err
);
expect
(
data
.
attrs
.
sn
).
to
.
equal
(
'Bruna'
);
expect
(
data
.
attrs
.
givenName
).
to
.
equal
(
'Patricio'
);
console
.
log
(
data
);
done
();
});
});
it
(
'should modify Account attributes'
,
function
(
done
){
let
api
=
new
ZimbraAdminApi
(
auth_data
);
let
description
=
Date
.
now
().
toString
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment