public ListMeetings GetMeetings(string userId, MeetingListTypes type = MeetingListTypes.Live, int pageSize = 30, int pageNumber = 1) { if (pageSize > 300) { throw new Exception("GetMeetings page size max 300"); } var request = BuildRequestAuthorization(GET_LIST_MEETINGS, Method.GET); request.AddParameter("userId", userId, ParameterType.UrlSegment); request.AddParameter("type", type.ToString().ToLowerInvariant(), ParameterType.QueryString); request.AddParameter("page_size", pageSize, ParameterType.QueryString); request.AddParameter("page_number", pageNumber, ParameterType.QueryString); var response = WebClient.Execute <ListMeetings>(request); if (response.ResponseStatus == ResponseStatus.Completed && response.StatusCode == System.Net.HttpStatusCode.OK) { return(response.Data); } if (!string.IsNullOrWhiteSpace(response.ErrorMessage)) { throw new Exception(response.ErrorMessage); } if (!string.IsNullOrWhiteSpace(response.StatusDescription) && !string.IsNullOrWhiteSpace(response.Content)) { throw new Exception($"{response.StatusDescription} || {response.Content}"); } return(null); }
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}")); }