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