Skip to content

Commit fed7fe3

Browse files
committed
add ask to join the team
1 parent 2c3b520 commit fed7fe3

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

lib/accessControl.js

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,4 +576,83 @@ AccessControl.prototype.updateUserRole = function (userId, capabilityId, scope,
576576
});
577577
};
578578

579+
/**
580+
* Get all the access request list for a specify organization
581+
* @param {string} [orgName] - The organization name.
582+
* @return {Promise} A promise that returns the call response object, or an Error if rejected.
583+
* @example
584+
* accessControl.accessRequestsList().then(result=>{
585+
* console.log(result)
586+
* })
587+
*
588+
*/
589+
AccessControl.prototype.accessRequestsList = function (orgName) {
590+
if(!orgName && !this.defaultOrganization) {
591+
return Promise.reject(
592+
new Error(
593+
ErrorMessage.getInvalidParameterMessage(
594+
"GET",
595+
'Please provide a organization name'
596+
),
597+
),
598+
);
599+
}
600+
const org = orgName ? orgName : this.defaultOrganization
601+
return this.dispatch(`${this.baseURL}/organizations/${UTILS.encodeURISegment(org)}/access_requests`, CONST.GET);
602+
};
603+
604+
/**
605+
* Get all the access request list for a specify organization
606+
* @param {string} [email] - the user email.
607+
* @param {string} [affiliation] - the user affiliation, company, university etc..
608+
* @param {string} [note] - the message for the team admin
609+
* @param {string} [orgName] - The organization name.
610+
* @return {Promise} A promise that returns the call response object, or an Error if rejected.
611+
* @example
612+
* accessControl.sendAccessRequest("[email protected]","my_company","please add me to your team").then(result=>{
613+
* console.log(result)
614+
* })
615+
*
616+
*/
617+
AccessControl.prototype.sendAccessRequest = function (email,affiliation,note,orgName) {
618+
if(!orgName && !this.defaultOrganization) {
619+
return Promise.reject(
620+
new Error(
621+
ErrorMessage.getInvalidParameterMessage(
622+
"POST",
623+
'Please provide a organization name'
624+
),
625+
),
626+
);
627+
}
628+
const payload = {email,affiliation,note}
629+
const org = orgName ? orgName : this.defaultOrganization
630+
return this.dispatch(`${this.baseURL}/organizations/${UTILS.encodeURISegment(org)}/access_requests`, CONST.POST,payload);
631+
};
632+
633+
/**
634+
* Delete an access request to join your team, only an admin user can delete it
635+
* @param {string} [orgName] - The organization name.
636+
* @return {Promise} A promise that returns the call response object, or an Error if rejected.
637+
* @example
638+
* accessControl.deleteAccessRequest("djjdshhsuuwewueueuiHYHYYW.......").then(result=>{
639+
* console.log(result)
640+
* })
641+
*
642+
*/
643+
AccessControl.prototype.deleteAccessRequest = function (acceId,orgName) {
644+
if(!orgName && !this.defaultOrganization) {
645+
return Promise.reject(
646+
new Error(
647+
ErrorMessage.getInvalidParameterMessage(
648+
"POST",
649+
'Please provide a organization name'
650+
),
651+
),
652+
);
653+
}
654+
const org = orgName ? orgName : this.defaultOrganization
655+
return this.dispatch(`${this.baseURL}/organizations/${UTILS.encodeURISegment(org)}/access_requests/${acceId}`, CONST.DELETE);
656+
};
657+
579658
module.exports = AccessControl

0 commit comments

Comments
 (0)