Skip to content

Commit

Permalink
Merge branch 'release/0.8.0' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Jericho committed Sep 7, 2020
2 parents 9fd19f1 + fa3a069 commit 3c325f7
Show file tree
Hide file tree
Showing 49 changed files with 3,268 additions and 26 deletions.
22 changes: 22 additions & 0 deletions Source/ZoomNet.IntegrationTests/Tests/Dashboards.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using ZoomNet.Models;

namespace ZoomNet.IntegrationTests.Tests
{
public class Dashboards : IIntegrationTest
{
public async Task RunAsync(string userId, IZoomClient client, TextWriter log, CancellationToken cancellationToken)
{
if (cancellationToken.IsCancellationRequested) return;

await log.WriteLineAsync("\n***** DASHBOARDS *****\n").ConfigureAwait(false);

// GET ALL THE MEETINGS
var pastMeetingsStats = await client.Dashboards.GetAllMeetingsAsync(DateTime.UtcNow.AddMonths(-1), DateTime.UtcNow, DashboardMeetingType.Past, 100, null, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"There are {pastMeetingsStats.TotalRecords} meetings in the last month").ConfigureAwait(false);
}
}
}
6 changes: 3 additions & 3 deletions Source/ZoomNet.IntegrationTests/Tests/Meetings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ public async Task RunAsync(string userId, IZoomClient client, TextWriter log, Ca
await log.WriteLineAsync("\n***** MEETINGS *****\n").ConfigureAwait(false);

// GET ALL THE MEETINGS
var paginatedScheduledMeetings = await client.Meetings.GetAllAsync(userId, MeetingListType.Scheduled, 100, 1, cancellationToken).ConfigureAwait(false);
var paginatedScheduledMeetings = await client.Meetings.GetAllAsync(userId, MeetingListType.Scheduled, 100, null, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"There are {paginatedScheduledMeetings.TotalRecords} scheduled meetings").ConfigureAwait(false);

var paginatedLiveMeetings = await client.Meetings.GetAllAsync(userId, MeetingListType.Live, 100, 1, cancellationToken).ConfigureAwait(false);
var paginatedLiveMeetings = await client.Meetings.GetAllAsync(userId, MeetingListType.Live, 100, null, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"There are {paginatedLiveMeetings.TotalRecords} live meetings").ConfigureAwait(false);

var paginatedUpcomingMeetings = await client.Meetings.GetAllAsync(userId, MeetingListType.Upcoming, 100, 1, cancellationToken).ConfigureAwait(false);
var paginatedUpcomingMeetings = await client.Meetings.GetAllAsync(userId, MeetingListType.Upcoming, 100, null, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"There are {paginatedUpcomingMeetings.TotalRecords} upcoming meetings").ConfigureAwait(false);

// CLEANUP PREVIOUS INTEGRATION TESTS THAT MIGHT HAVE BEEN INTERRUPTED BEFORE THEY HAD TIME TO CLEANUP AFTER THEMSELVES
Expand Down
2 changes: 1 addition & 1 deletion Source/ZoomNet.IntegrationTests/Tests/Webinars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public async Task RunAsync(string userId, IZoomClient client, TextWriter log, Ca
await log.WriteLineAsync("\n***** WEBINARS *****\n").ConfigureAwait(false);

// GET ALL THE WEBINARS
var paginatedWebinars = await client.Webinars.GetAllAsync(userId, 30, 1, cancellationToken).ConfigureAwait(false);
var paginatedWebinars = await client.Webinars.GetAllAsync(userId, 30, null, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"There are {paginatedWebinars.TotalRecords} webinars for user {userId}").ConfigureAwait(false);

// CLEANUP PREVIOUS INTEGRATION TESTS THAT MIGHT HAVE BEEN INTERRUPTED BEFORE THEY HAD TIME TO CLEANUP AFTER THEMSELVES
Expand Down
2 changes: 1 addition & 1 deletion Source/ZoomNet.IntegrationTests/TestsRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using System.Threading;
using System.Threading.Tasks;
using ZoomNet.IntegrationTests.Tests;
using ZoomNet.Utilities;

namespace ZoomNet.IntegrationTests
{
Expand Down Expand Up @@ -96,6 +95,7 @@ public async Task<int> RunAsync()
// These are the integration tests that we will execute
var integrationTests = new Type[]
{
typeof(Dashboards),
typeof(Meetings),
typeof(Users),
typeof(Webinars),
Expand Down
43 changes: 42 additions & 1 deletion Source/ZoomNet/Extensions/Internal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Pathoschild.Http.Client;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net.Http;
Expand Down Expand Up @@ -238,6 +239,19 @@ internal static async Task<PaginatedResponseWithToken<T>> AsPaginatedResponseWit
return await response.Content.AsPaginatedResponseWithToken<T>(propertyName, jsonConverter).ConfigureAwait(false);
}

/// <summary>Asynchronously retrieve the JSON encoded response body and convert it to a 'PaginatedResponseWithToken' object.</summary>
/// <typeparam name="T">The response model to deserialize into.</typeparam>
/// <param name="request">The request.</param>
/// <param name="propertyName">The name of the JSON property (or null if not applicable) where the desired data is stored.</param>
/// <param name="jsonConverter">Converter that will be used during deserialization.</param>
/// <returns>Returns the paginated response.</returns>
/// <exception cref="ApiException">An error occurred processing the response.</exception>
internal static async Task<PaginatedResponseWithTokenAndDateRange<T>> AsPaginatedResponseWithTokenAndDateRange<T>(this IRequest request, string propertyName, JsonConverter jsonConverter = null)
{
var response = await request.AsMessage().ConfigureAwait(false);
return await response.Content.AsPaginatedResponseWithTokenAndDateRange<T>(propertyName, jsonConverter).ConfigureAwait(false);
}

/// <summary>Set the body content of the HTTP request.</summary>
/// <typeparam name="T">The type of object to serialize into a JSON string.</typeparam>
/// <param name="request">The request.</param>
Expand Down Expand Up @@ -614,7 +628,34 @@ private static async Task<PaginatedResponseWithToken<T>> AsPaginatedResponseWith
var result = new PaginatedResponseWithToken<T>()
{
NextPageToken = jObject.Property("next_page_token").Value.ToString(),
PageCount = jObject.Property("page_count").Value.ToObject<int>(),
PageSize = jObject.Property("page_size").Value.ToObject<int>(),
Records = jObject.Property(propertyName).Value.ToObject<T[]>(serializer),
TotalRecords = jObject.Property("total_records").Value.ToObject<int>()
};

return result;
}

/// <summary>Asynchronously retrieve the JSON encoded content and converts it to a 'PaginatedResponseWithToken' object.</summary>
/// <typeparam name="T">The response model to deserialize into.</typeparam>
/// <param name="httpContent">The content.</param>
/// <param name="propertyName">The name of the JSON property (or null if not applicable) where the desired data is stored.</param>
/// <param name="jsonConverter">Converter that will be used during deserialization.</param>
/// <returns>Returns the response body, or <c>null</c> if the response has no body.</returns>
/// <exception cref="ApiException">An error occurred processing the response.</exception>
private static async Task<PaginatedResponseWithTokenAndDateRange<T>> AsPaginatedResponseWithTokenAndDateRange<T>(this HttpContent httpContent, string propertyName, JsonConverter jsonConverter = null)
{
var responseContent = await httpContent.ReadAsStringAsync(null).ConfigureAwait(false);
var jObject = JObject.Parse(responseContent);

var serializer = new JsonSerializer();
if (jsonConverter != null) serializer.Converters.Add(jsonConverter);

var result = new PaginatedResponseWithTokenAndDateRange<T>()
{
From = DateTime.ParseExact(jObject.Property("from").Value.ToString(), "yyyy-MM-dd", CultureInfo.InvariantCulture),
To = DateTime.ParseExact(jObject.Property("to").Value.ToString(), "yyyy-MM-dd", CultureInfo.InvariantCulture),
NextPageToken = jObject.Property("next_page_token").Value.ToString(),
PageSize = jObject.Property("page_size").Value.ToObject<int>(),
Records = jObject.Property(propertyName).Value.ToObject<T[]>(serializer),
TotalRecords = jObject.Property("total_records").Value.ToObject<int>()
Expand Down
5 changes: 5 additions & 0 deletions Source/ZoomNet/IZoomClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,10 @@ public interface IZoomClient
/// The webinars resource.
/// </value>
IWebinars Webinars { get; }

/// <summary>
/// Gets the resource which allows you to view metrics.
/// </summary>
IDashboards Dashboards { get; }
}
}
39 changes: 39 additions & 0 deletions Source/ZoomNet/Models/ClientFeedbackDetail.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Newtonsoft.Json;
using System;

namespace ZoomNet.Models
{
/// <summary>
/// Details of participant feedback on Zoom meetings client.
/// </summary>
public class ClientFeedbackDetail
{
/// <summary>
/// Gets or sets the participant's name.
/// </summary>
/// <value>The participant's name.</value>
[JsonProperty(PropertyName = "participant_name")]
public string Name { get; set; }

/// <summary>
/// Gets or sets the meeting id.
/// </summary>
/// <value>The meeting id.</value>
[JsonProperty(PropertyName = "meeting_id")]
public string MeetingId { get; set; }

/// <summary>
/// Gets or sets the time the feedback was submitted by the participant.
/// </summary>
/// <value>The time the feedback was submitted by the participant.</value>
[JsonProperty(PropertyName = "time")]
public DateTime Time { get; set; }

/// <summary>
/// Gets or sets the participant's email address.
/// </summary>
/// <value>The participants email.</value>
[JsonProperty(PropertyName = "email")]
public string Email { get; set; }
}
}
36 changes: 36 additions & 0 deletions Source/ZoomNet/Models/ClientFeedbackMetrics.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZoomNet.Models
{
/// <summary>
/// Metrics for a feedback item.
/// </summary>
public class ClientFeedbackMetrics
{
/// <summary>
/// Gets or sets the feedback id.
/// </summary>
/// <value>The feedback id.</value>
[JsonProperty(PropertyName = "feedback_id")]
public string FeedbackId { get; set; }

/// <summary>
/// Gets or sets the feedback name.
/// </summary>
/// <value>The feedback name.</value>
[JsonProperty(PropertyName = "feedback_name")]
public string FeebackName { get; set; }

/// <summary>
/// Gets or sets the participant count.
/// </summary>
/// <value>The number of participants that upvoted the feedback.</value>
[JsonProperty(PropertyName = "participants_count")]
public int ParticipantsCount { get; set; }
}
}
39 changes: 39 additions & 0 deletions Source/ZoomNet/Models/ClientFeedbackMetricsReport.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Newtonsoft.Json;
using System;

namespace ZoomNet.Models
{
/// <summary>
/// Report with client feedback metrics for a given range.
/// </summary>
public class ClientFeedbackMetricsReport
{
/// <summary>
/// Gets or sets the start date for this report.
/// </summary>
/// <value>The start date for this report.</value>
[JsonProperty(PropertyName = "from")]
public DateTime From { get; set; }

/// <summary>
/// Gets or sets the end date for this report.
/// </summary>
/// <value>The end date for this report.</value>
[JsonProperty(PropertyName = "to")]
public DateTime To { get; set; }

/// <summary>
/// Gets or sets the number of all records available across pages.
/// </summary>
/// <value>The number of all records available across pages.</value>
[JsonProperty(PropertyName = "total_records")]
public int TotalRecords { get; set; }

/// <summary>
/// Gets or sets the collection of client feedback metrics.
/// </summary>
/// <value>The collection of client feedback metrics.</value>
[JsonProperty(PropertyName = "client_feedbacks")]
public ClientFeedbackMetrics[] ClientFeedbacks { get; set; }
}
}
47 changes: 47 additions & 0 deletions Source/ZoomNet/Models/ClientSatisfactionMetrics.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using Newtonsoft.Json;
using System;

namespace ZoomNet.Models
{
/// <summary>
/// Metrics for a client satisfaction item.
/// </summary>
public class ClientSatisfactionMetrics
{
/// <summary>
/// Gets or sets the date of the report.
/// </summary>
/// <value>The date of the report.</value>
[JsonProperty(PropertyName = "date")]
public DateTime Date { get; set; }

/// <summary>
/// Gets or sets the satisfaction percentage. <br/>
/// The satisfaction percentage is calculated as `(good_count + none_count)` / `total_count`.
/// </summary>
/// <value>The satisfaction percentage.</value>
[JsonProperty(PropertyName = "satisfaction_percent")]
public long SatisfactionPercent { get; set; }

/// <summary>
/// Gets or sets the total number of "thumbs up" received for this meeting.
/// </summary>
/// <value>The total number of "thumbs up" received for this meeting.</value>
[JsonProperty(PropertyName = "good_count")]
public int GoodCount { get; set; }

/// <summary>
/// Gets or sets the total number of "thumbs down" received for this meeting.
/// </summary>
/// <value>The total number of "thumbs down" received for this meeting.</value>
[JsonProperty(PropertyName = "not_good_count")]
public int NotGoodCount { get; set; }

/// <summary>
/// Gets or sets the total number of attendees who didn't submit any response (neither thumbs up nor thumbs down).
/// </summary>
/// <value>The total number of attendees who didn't submit any response (neither thumbs up nor thumbs down).</value>
[JsonProperty(PropertyName = "none_count")]
public int NoneCount { get; set; }
}
}
39 changes: 39 additions & 0 deletions Source/ZoomNet/Models/ClientSatisfactionReport.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Newtonsoft.Json;
using System;

namespace ZoomNet.Models
{
/// <summary>
/// Report on client statisfaction feedback.
/// </summary>
public class ClientSatisfactionReport
{
/// <summary>
/// Gets or sets the start date for this report.
/// </summary>
/// <value>The start date for this report.</value>
[JsonProperty(PropertyName = "from")]
public DateTime From { get; set; }

/// <summary>
/// Gets or sets the end date for this report.
/// </summary>
/// <value>The end date for this report.</value>
[JsonProperty(PropertyName = "to")]
public DateTime To { get; set; }

/// <summary>
/// Gets or sets the number of all records available across pages.
/// </summary>
/// <value>The number of all records available across pages.</value>
[JsonProperty(PropertyName = "total_records")]
public int TotalRecords { get; set; }

/// <summary>
/// Gets or sets the collection of client feedback metrics.
/// </summary>
/// <value>The collection of client feedback metrics.</value>
[JsonProperty(PropertyName = "client_satisfaction")]
public ClientSatisfactionMetrics[] ClientSatisfactions { get; set; }
}
}
29 changes: 29 additions & 0 deletions Source/ZoomNet/Models/CrcPortMetrics.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZoomNet.Models
{
/// <summary>
/// Metrics for the CRC port usage.
/// </summary>
public class CrcPortMetrics
{
/// <summary>
/// Gets or sets the start date for this report.
/// </summary>
/// <value>The start date for this report.</value>
[JsonProperty(PropertyName = "from")]
public DateTime From { get; set; }

/// <summary>
/// Gets or sets the end date for this report.
/// </summary>
/// <value>The end date for this report.</value>
[JsonProperty(PropertyName = "to")]
public DateTime To { get; set; }
}
}
Loading

0 comments on commit 3c325f7

Please sign in to comment.