示例#1
0
        public async Task <ZoomApiResultWithData <ZoomAddRegistrantResponse> > AddRegistrant(string accountId, string meetingId, ZoomAddRegistrantRequest registrant, string occurenceIds = null)
        {
            RestRequest restRequest = null;

            if (string.IsNullOrEmpty(accountId))
            {
                restRequest = await BuildRequestAuthorization("meetings/{meetingId}/registrants", Method.POST);

                restRequest.AddParameter(nameof(meetingId), (object)meetingId, ParameterType.UrlSegment);
            }
            else
            {
                restRequest = await BuildRequestAuthorization("accounts/{accountId}/meetings/{meetingId}/registrants", Method.POST);

                restRequest.AddParameter(nameof(meetingId), (object)meetingId, ParameterType.UrlSegment);
                restRequest.AddParameter(nameof(accountId), (object)accountId, ParameterType.UrlSegment);
            }

            restRequest.AddJsonBody((object)registrant);
            IRestResponse <ZoomAddRegistrantResponse> restResponse = await(await GetWebClient()).ExecuteTaskAsync <ZoomAddRegistrantResponse>((IRestRequest)restRequest);

            if (restResponse.ResponseStatus == ResponseStatus.Completed && restResponse.StatusCode == HttpStatusCode.Created)
            {
                return(restResponse.Data.ToSuccessZoomApiResult());
            }

            if (restResponse.ResponseStatus == ResponseStatus.Completed && restResponse.StatusCode == HttpStatusCode.BadRequest)
            {
                return(ZoomApiResultWithData <ZoomAddRegistrantResponse> .ApiError(restResponse.Content));
            }
            ;

            if (!string.IsNullOrWhiteSpace(restResponse.ErrorMessage))
            {
                throw new Exception(restResponse.ErrorMessage);
            }
            if (!string.IsNullOrWhiteSpace(restResponse.StatusDescription) && !string.IsNullOrWhiteSpace(restResponse.Content))
            {
                throw new Exception(string.Format("{0} || {1}", (object)restResponse.StatusDescription, (object)restResponse.Content));
            }
            return(null);
        }
示例#2
0
 public async Task <ZoomApiResultWithData <ZoomAddRegistrantResponse> > AddRegistrant(string meetingId, ZoomAddRegistrantRequest registrant, string occurenceIds = null)
 {
     return(await AddRegistrant(null, meetingId, registrant, occurenceIds));
 }