From 18534ba498ed133c3fb980c2e891c2cb3f538c92 Mon Sep 17 00:00:00 2001 From: lgtonkal Date: Thu, 8 Oct 2020 22:45:09 +0300 Subject: [PATCH] Get Meeting Report added. Retrieve on a past meeting for a specified period of time. --- .../Integration/ZoomClientTests.cs | 17 +++++ ZoomClient/Interfaces/IZoomReportsClient.cs | 12 ++++ ZoomClient/Models/Reports/Meeting.cs | 68 +++++++++++++++++++ ZoomClient/Models/Reports/MeetingReport.cs | 13 ++++ .../Models/Reports/MeetingReportTypes.cs | 9 +++ ZoomClient/ZoomReportsClient.cs | 45 ++++++++++++ 6 files changed, 164 insertions(+) create mode 100644 ZoomClient/Models/Reports/Meeting.cs create mode 100644 ZoomClient/Models/Reports/MeetingReport.cs create mode 100644 ZoomClient/Models/Reports/MeetingReportTypes.cs diff --git a/ZoomClient.Tests/Integration/ZoomClientTests.cs b/ZoomClient.Tests/Integration/ZoomClientTests.cs index 2f02164..8d8fe7e 100644 --- a/ZoomClient.Tests/Integration/ZoomClientTests.cs +++ b/ZoomClient.Tests/Integration/ZoomClientTests.cs @@ -575,6 +575,23 @@ public void Get_User_Participant_Report_For_Last_Meeting() result.Participants.Count.ShouldBeGreaterThan(0); } + [Test] + public void Get_User_Meeting_Report_Last_Month() + { + // Arrange + string user = _userEmail; + var from = DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd"); + var to = DateTime.Now.ToString("yyyy-MM-dd"); + + // Act + var result = _sut.Reports.GetMeetingReport(user, from, to); + + // Assert + result.ShouldNotBeNull(); + result.Meetings.ShouldNotBeNull(); + result.Meetings.Count.ShouldBeGreaterThan(0); + } + #endregion #region Webhook Tests diff --git a/ZoomClient/Interfaces/IZoomReportsClient.cs b/ZoomClient/Interfaces/IZoomReportsClient.cs index 421379e..1199959 100644 --- a/ZoomClient/Interfaces/IZoomReportsClient.cs +++ b/ZoomClient/Interfaces/IZoomReportsClient.cs @@ -12,5 +12,17 @@ public interface IZoomReportsClient /// /// MeetingParticipantsReport GetMeetingParticipantsReport(string meetingId, int pageSize = 30, string nextPageToken = null); + + /// + /// Retrieve on a past meeting for a specified period of time. https://marketplace.zoom.us/docs/api-reference/zoom-api/reports/reportmeetings + /// + /// + /// + /// + /// + /// + /// + /// + MeetingReport GetMeetingReport(string userId, string from, string to, MeetingReportTypes type = MeetingReportTypes.Past, int pageSize = 30, string nextPageToken = null); } } diff --git a/ZoomClient/Models/Reports/Meeting.cs b/ZoomClient/Models/Reports/Meeting.cs new file mode 100644 index 0000000..964be4f --- /dev/null +++ b/ZoomClient/Models/Reports/Meeting.cs @@ -0,0 +1,68 @@ +using System; +using AndcultureCode.ZoomClient.Models.Meetings; + +namespace AndcultureCode.ZoomClient.Models.Reports +{ + public class Meeting + { + /// + /// Zoom Property: uuid + /// + public string Uuid { get; set; } + + /// + /// Zoom Property: id + /// + public long Id { get; set; } + + /// + /// Zoom Property: host_id + /// + public string HostId { get; set; } + + /// + /// Zoom Property: type + /// + public MeetingTypes Type { get; set; } + + /// + /// Zoom Property: topic + /// + public string Topic { get; set; } + + /// + /// Zoom Property: user_name + /// + public string UserName { get; set; } + + /// + /// Zoom Property: user_email + /// + public string UserEmail { get; set; } + + /// + /// Zoom Property: start_time + /// + public DateTimeOffset StartTime { get; set; } + + /// + /// Zoom Property: end_time + /// + public DateTimeOffset EndTime { get; set; } + + /// + /// Zoom Property: duration + /// + public int Duration { get; set; } + + /// + /// Zoom Property: total_minutes + /// + public int TotalMinutes { get; set; } + + /// + /// Zoom Property: participants_count + /// + public int ParticipantsCount { get; set; } + } +} diff --git a/ZoomClient/Models/Reports/MeetingReport.cs b/ZoomClient/Models/Reports/MeetingReport.cs new file mode 100644 index 0000000..8a377ae --- /dev/null +++ b/ZoomClient/Models/Reports/MeetingReport.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace AndcultureCode.ZoomClient.Models.Reports +{ + public class MeetingReport : BaseTokenList + { + /// + /// Zoom Property: meetings + /// + public List Meetings { get; set; } + } +} diff --git a/ZoomClient/Models/Reports/MeetingReportTypes.cs b/ZoomClient/Models/Reports/MeetingReportTypes.cs new file mode 100644 index 0000000..75ead3e --- /dev/null +++ b/ZoomClient/Models/Reports/MeetingReportTypes.cs @@ -0,0 +1,9 @@ +using System; +namespace AndcultureCode.ZoomClient.Models.Reports +{ + public enum MeetingReportTypes + { + Past = 1, + PastOne = 2 + } +} diff --git a/ZoomClient/ZoomReportsClient.cs b/ZoomClient/ZoomReportsClient.cs index 880a515..2f0e3b4 100644 --- a/ZoomClient/ZoomReportsClient.cs +++ b/ZoomClient/ZoomReportsClient.cs @@ -12,6 +12,7 @@ public class ZoomReportsClient : IZoomReportsClient #region Constants protected const string GET_MEETING_PARTICIPANTS = "report/meetings/{meetingId}/participants"; + protected const string GET_MEETINGS = "report/users/{userId}/meetings"; #endregion @@ -74,6 +75,50 @@ public MeetingParticipantsReport GetMeetingParticipantsReport(string meetingId, return null; } + public MeetingReport GetMeetingReport(string userId, string from, string to, MeetingReportTypes type = MeetingReportTypes.Past, int pageSize = 30, string nextPageToken = null) + { + if (pageSize > 300) + { + throw new Exception("GetMeetingReport page size max 300"); + } + + var request = BuildRequestAuthorization(GET_MEETINGS, Method.GET); + request.AddParameter("userId", userId, ParameterType.UrlSegment); + request.AddParameter("from", from, ParameterType.QueryString); + request.AddParameter("to", to, ParameterType.QueryString); + request.AddParameter("type", type.ToString().ToLowerInvariant(), ParameterType.QueryString); + + request.AddParameter("page_size", pageSize, ParameterType.QueryString); + if (!string.IsNullOrWhiteSpace(nextPageToken)) + { + request.AddParameter("next_page_token", nextPageToken, ParameterType.QueryString); + } + + var response = WebClient.Execute(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}"); + } + + if (!string.IsNullOrWhiteSpace(response.Content)) + { + throw new Exception($"{response.StatusCode} || {response.Content}"); + } + + return null; + } + #endregion #region Private Methods