public static ZoomApiResultWithData <T> ToSuccessZoomApiResult <T>(this T data) { if ((object)data == null) { throw new ArgumentNullException(nameof(data)); } return(ZoomApiResultWithData <T> .Success(data)); }
private async Task <ZoomApiResultWithData <T> > HandleErrorRequest <T>(IRestResponse <T> restResponse) where T : class { //todo: log if (!string.IsNullOrWhiteSpace(restResponse.Content)) { return(ZoomApiResultWithData <T> .ApiError(restResponse.Content)); } throw new ZoomApiException { Content = restResponse.Content, ErrorMessage = restResponse.ErrorMessage, StatusDescription = restResponse.StatusDescription }; }
public async Task <ZoomApiResultWithData <Meeting> > CreateMeeting(string accountId, string userId, Meeting meeting) { RestRequest restRequest = null; if (string.IsNullOrEmpty(accountId)) { restRequest = await BuildRequestAuthorization("users/{userId}/meetings", Method.POST); restRequest.AddParameter(nameof(userId), (object)userId, ParameterType.UrlSegment); } else { restRequest = await BuildRequestAuthorization("accounts/{accountId}/users/{userId}/meetings", Method.POST); restRequest.AddParameter(nameof(userId), (object)userId, ParameterType.UrlSegment); restRequest.AddParameter(nameof(accountId), (object)accountId, ParameterType.UrlSegment); } restRequest.AddJsonBody((object)meeting); IRestResponse <Meeting> restResponse = await(await GetWebClient()).ExecuteTaskAsync <Meeting>((IRestRequest)restRequest); if (restResponse.ResponseStatus == ResponseStatus.Completed && restResponse.StatusCode == HttpStatusCode.Created) { return(restResponse.Data.ToSuccessZoomApiResult()); } if (restResponse.ResponseStatus == ResponseStatus.Completed && (restResponse.StatusCode == HttpStatusCode.NotFound || restResponse.StatusCode == HttpStatusCode.BadRequest)) { return(ZoomApiResultWithData <Meeting> .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(ZoomApiResultWithData <Meeting> .Error($"Faild with creating meeting {userId}")); }
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); }
public async Task <ZoomApiResultWithData <bool> > UpdateMeeting(string accountId, string meetingId, Meeting meeting) { //HACK: ZOOM API does not update AGENDA field with empty value. I requested zoom support //https://devforum.zoom.us/t/update-agenda-field-in-meeting/2800 if (string.IsNullOrEmpty(meeting.Agenda)) { meeting.Agenda = " "; } RestRequest restRequest = null; if (string.IsNullOrEmpty(accountId)) { restRequest = await BuildRequestAuthorization("meetings/{meetingId}", Method.PATCH); restRequest.AddParameter(nameof(meetingId), (object)meetingId, ParameterType.UrlSegment); } else { restRequest = await BuildRequestAuthorization("accounts/{accountId}/meetings/{meetingId} ", Method.PATCH); restRequest.AddParameter(nameof(meetingId), (object)meetingId, ParameterType.UrlSegment); restRequest.AddParameter(nameof(accountId), (object)accountId, ParameterType.UrlSegment); } restRequest.AddJsonBody((object)meeting); IRestResponse restResponse = await(await GetWebClient()).ExecuteTaskAsync((IRestRequest)restRequest); if (restResponse.ResponseStatus == ResponseStatus.Completed && restResponse.StatusCode == HttpStatusCode.NoContent) { return(true.ToSuccessZoomApiResult()); } if (restResponse.ResponseStatus == ResponseStatus.Completed && restResponse.StatusCode == HttpStatusCode.BadRequest) { return(ZoomApiResultWithData <bool> .ApiError(restResponse.Content)); } return(ZoomApiResultWithData <bool> .Error($"Faild during update meeting {meetingId}")); }
public async Task <ZoomApiResultWithData <ListMeetings> > GetMeetings(string userId, MeetingListTypes type = MeetingListTypes.Scheduled, int pageSize = 30, int pageNumber = 1) { if (pageSize > 300) { throw new Exception("GetMeetings page size max 300"); } RestRequest restRequest = await BuildRequestAuthorization("users/{userId}/meetings", Method.GET); restRequest.AddParameter(nameof(userId), (object)userId, ParameterType.UrlSegment); restRequest.AddParameter(nameof(type), (object)type.ToString().ToLowerInvariant(), ParameterType.QueryString); restRequest.AddParameter("page_size", (object)pageSize, ParameterType.QueryString); restRequest.AddParameter("page_number", (object)pageNumber, ParameterType.QueryString); IRestResponse <ListMeetings> restResponse = await(await GetWebClient()).ExecuteTaskAsync <ListMeetings>((IRestRequest)restRequest); if (restResponse.ResponseStatus == ResponseStatus.Completed && restResponse.StatusCode == HttpStatusCode.OK) { return(restResponse.Data.ToSuccessZoomApiResult()); } if (restResponse.ResponseStatus == ResponseStatus.Completed && restResponse.StatusCode == HttpStatusCode.NotFound) { return(ZoomApiResultWithData <ListMeetings> .ApiError(restResponse.Content)); } if (!string.IsNullOrWhiteSpace(restResponse.ErrorMessage)) { return(ZoomApiResultWithData <ListMeetings> .Error(restResponse.ErrorMessage)); } if (!string.IsNullOrWhiteSpace(restResponse.StatusDescription) && !string.IsNullOrWhiteSpace(restResponse.Content)) { return(ZoomApiResultWithData <ListMeetings> .Error(string.Format("{0} || {1}", (object)restResponse.StatusDescription, (object)restResponse.Content))); } return(ZoomApiResultWithData <ListMeetings> .Error($"Not found meetings for user {userId}")); }