Пример #1
0
        public static async Task <bool> ActivateSuiteAsync(string accessToken, ActivateSuiteRequest requestData)
        {
            var result = await CommonApi.AccessDingtalkServerAsync <ErrorResponse>(
                "https://oapi.dingtalk.com/service/activate_suite?suite_access_token=" + accessToken, requestData);

            return(result.errcode == 0);
        }
Пример #2
0
        public static async Task <DepartmentListResponse> GetDepartmentList(DepartmentBaseGetRequest request)
        {
            var result = await CommonApi.AccessDingtalkServerAsync <DepartmentListResponse>(
                $"https://oapi.dingtalk.com/department/list?access_token={request.access_token}&lang={request.lang}&id={request.id}",
                null, "GET");

            return(result);
        }
Пример #3
0
        public static async Task <UserListResponse> GetUserList(UserListGetRequest request)
        {
            var result = await CommonApi.AccessDingtalkServerAsync <UserListResponse>(
                $"https://oapi.dingtalk.com/user/list?access_token={request.access_token}&department_id={request.department_id}", //+
                                                                                                                                  //$"&lang={request.lang}&offset={request.offset}&size={request.size}&order={request.order}",
                null, "GET");

            return(result);
        }
Пример #4
0
        public static async Task <string> GetToken(string corpId, string corpSecret, IAccessTokenCacher cacher = null)
        {
            if (cacher == null)
            {
                cacher = new MemoryAccessTokenCacher();
            }
            var token = await cacher.GetAsync(corpId, corpSecret);

            if (!string.IsNullOrEmpty(token))
            {
                return(token);
            }

            var result = await CommonApi.AccessDingtalkServerAsync <GetTokenResponse>(
                $"https://oapi.dingtalk.com/gettoken?corpid={corpId}&corpsecret={corpSecret}", null, "GET");

            if (result.errcode == 0)
            {
                await cacher.SetAsync(corpId, corpSecret, result.access_token, DateTime.Now.AddSeconds(7200));

                return(result.access_token);
            }
            throw new Exception($"errcode: {result.errcode}, errmsg: {result.errmsg}");
        }
Пример #5
0
        public static async Task <string> GetJsApiTicket(string accessToken, IJsApiTicketCacher cacher = null)
        {
            if (cacher == null)
            {
                cacher = new MemoryJsApiTicketCacher();
            }
            var ticket = await cacher.GetAsync(accessToken);

            if (!string.IsNullOrEmpty(ticket))
            {
                return(ticket);
            }

            var result = await CommonApi.AccessDingtalkServerAsync <GetJsApiTicketResponse>(
                $"https://oapi.dingtalk.com/get_jsapi_ticket?access_token={accessToken}&type=jsapi", null, "GET");

            if (result.errcode == 0)
            {
                await cacher.SetAsync(accessToken, result.ticket, DateTime.Now.AddSeconds(7200));

                return(result.ticket);
            }
            throw new Exception($"errcode: {result.errcode}, errmsg: {result.errmsg}");
        }
Пример #6
0
 public static async Task <GetSuiteTokenResponse> GetSuiteAccessTokenAsync(GetSuiteTokenRequest requestData)
 {
     return(await CommonApi.AccessDingtalkServerAsync <GetSuiteTokenResponse>(
                "https://oapi.dingtalk.com/service/get_suite_token", requestData));
 }
Пример #7
0
 public static async Task <GetCorpTokenResponse> GetCorpTokenAsync(string accessToken, CommonIsvRequest isvRequestData)
 {
     return(await CommonApi.AccessDingtalkServerAsync <GetCorpTokenResponse>(
                "https://oapi.dingtalk.com/service/get_corp_token?suite_access_token=" + accessToken, isvRequestData));
 }
Пример #8
0
 public static async Task <GetPermanentCodeResponse> GetPermanentCodeAsync(string accessToken, GetPermanentCodeRequest requestData)
 {
     return(await CommonApi.AccessDingtalkServerAsync <GetPermanentCodeResponse>(
                "https://oapi.dingtalk.com/service/get_permanent_code?suite_access_token=" + accessToken, requestData));
 }
Пример #9
0
 public static async Task <GetUserInfoResponse> GetUserInfo(string accessToken, string code)
 {
     return(await CommonApi.AccessDingtalkServerAsync <GetUserInfoResponse>(
                $"https://oapi.dingtalk.com/user/getuserinfo?access_token={accessToken}&code={code}", null, "GET"));
 }
Пример #10
0
 public static async Task <UserGetResponse> GetUser(UserBaseGetRequest request)
 {
     return(await CommonApi.AccessDingtalkServerAsync <UserGetResponse>(
                $"https://oapi.dingtalk.com/user/get?access_token={request.access_token}&userid={request.userid}", null, "GET"));
 }