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
6b773b25
Commit
6b773b25
authored
Apr 15, 2016
by
Patricio Bruna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Creating resources with attributes working
parent
3f589551
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
719 additions
and
5 deletions
+719
-5
zimbra-admin-api.js
lib/zimbra-admin-api.js
+674
-2
zimbra-admin-api.js.map
lib/zimbra-admin-api.js.map
+1
-1
index.js
src/index.js
+4
-2
dictionary.js
src/utils/dictionary.js
+10
-0
test.js
test/js/spec/test.js
+30
-0
No files found.
lib/zimbra-admin-api.js
View file @
6b773b25
This diff is collapsed.
Click to expand it.
lib/zimbra-admin-api.js.map
View file @
6b773b25
This diff is collapsed.
Click to expand it.
src/index.js
View file @
6b773b25
...
...
@@ -190,7 +190,8 @@ class ZimbraAdminApi {
createAccount
(
name
,
password
,
attributes
,
callback
)
{
let
resource_data
=
{
name
:
{
'_content'
:
name
},
password
:
{
'_content'
:
password
}
password
:
{
'_content'
:
password
},
a
:
this
.
dictionary
.
attributesToArray
(
attributes
)
};
this
.
create
(
'Account'
,
resource_data
,
callback
);
}
...
...
@@ -201,7 +202,8 @@ class ZimbraAdminApi {
createDomain
(
name
,
attributes
,
callback
)
{
let
resource_data
=
{
name
:
{
'_content'
:
name
}
name
:
{
'_content'
:
name
},
a
:
this
.
dictionary
.
attributesToArray
(
attributes
)
};
this
.
create
(
'Domain'
,
resource_data
,
callback
);
}
...
...
src/utils/dictionary.js
View file @
6b773b25
...
...
@@ -22,6 +22,16 @@ export default class Dictionary {
return
'name'
;
}
attributesToArray
(
attributes
)
{
if
(
$
.
isEmptyObject
(
attributes
))
return
[];
const
result
=
[]
const
map
=
new
Map
(
Object
.
entries
(
attributes
));
map
.
forEach
((
key
,
value
)
=>
{
result
.
push
({
'n'
:
value
,
'_content'
:
key
});
});
return
result
;
}
classFactory
(
resource
,
object
)
{
const
class_name
=
this
.
resourceToClass
(
resource
.
toLowerCase
());
return
new
class_name
(
object
);
...
...
test/js/spec/test.js
View file @
6b773b25
...
...
@@ -177,6 +177,36 @@
});
});
it
(
'should create and return Domain with attributes'
,
function
(
done
){
let
resource_name
=
Date
.
now
()
+
'.dev'
;
let
resource_attributes
=
{
zimbraSkinLogoURL
:
'http://www.zboxapp.com'
,
postOfficeBox
:
'ZBoxApp'
};
let
api
=
new
ZimbraAdminApi
(
auth_data
);
let
callback
=
function
(
err
,
data
){
if
(
err
)
return
console
.
log
(
err
);
expect
(
data
.
attrs
.
zimbraSkinLogoURL
).
to
.
equal
(
'http://www.zboxapp.com'
);
expect
(
data
.
attrs
.
postOfficeBox
).
to
.
equal
(
'ZBoxApp'
);
done
();
};
api
.
createDomain
(
resource_name
,
resource_attributes
,
callback
);
});
it
(
'should create and return an account with extra attributes'
,
function
(
done
){
let
account_name
=
Date
.
now
()
+
'@zboxapp.dev'
;
let
account_password
=
Date
.
now
();
let
account_attributes
=
{
'sn'
:
'Bruna'
,
'givenName'
:
'Patricio'
};
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'
);
done
();
});
});
});
})();
...
...
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