-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(GH-197) Add the Workspaces resource
- Loading branch information
Showing
7 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System.IO; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using ZoomNet.Models; | ||
|
||
namespace ZoomNet.IntegrationTests.Tests | ||
{ | ||
public class Workspaces : IIntegrationTest | ||
{ | ||
public async Task RunAsync(User myUser, string[] myPermissions, IZoomClient client, TextWriter log, CancellationToken cancellationToken) | ||
{ | ||
if (cancellationToken.IsCancellationRequested) return; | ||
|
||
await log.WriteLineAsync("\n***** WORKSPACES *****\n").ConfigureAwait(false); | ||
|
||
// GET ALL THE WORKSPACES | ||
var paginatedWorkspaces = await client.Workspaces.GetAllAsync(locationId, 30, null, cancellationToken).ConfigureAwait(false); | ||
await log.WriteLineAsync($"There are {paginatedWorkspaces.TotalRecords} workspaces for location {locationId}").ConfigureAwait(false); | ||
|
||
//// CLEANUP PREVIOUS INTEGRATION TESTS THAT MIGHT HAVE BEEN INTERRUPTED BEFORE THEY HAD TIME TO CLEANUP AFTER THEMSELVES | ||
//var cleanUpTasks = paginatedWebinars.Records | ||
// .Union(paginatedWebinars.Records) | ||
// .Where(m => m.Topic.StartsWith("ZoomNet Integration Testing:")) | ||
// .Select(async oldWebinar => | ||
// { | ||
// await client.Webinars.DeleteAsync(oldWebinar.Id, null, false, cancellationToken).ConfigureAwait(false); | ||
// await log.WriteLineAsync($"Webinar {oldWebinar.Id} deleted").ConfigureAwait(false); | ||
// await Task.Delay(250, cancellationToken).ConfigureAwait(false); // Brief pause to ensure Zoom has time to catch up | ||
// }); | ||
//await Task.WhenAll(cleanUpTasks).ConfigureAwait(false); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace ZoomNet.Models | ||
{ | ||
/// <summary> | ||
/// A workspace. | ||
/// </summary> | ||
public class Workspace | ||
{ | ||
/// <summary>Gets or sets the workspace id.</summary> | ||
[JsonPropertyName("id")] | ||
public long Id { get; set; } | ||
|
||
/// <summary>Gets or sets the name of the workspace.</summary> | ||
[JsonPropertyName("workspace_name")] | ||
public string Name { get; set; } | ||
|
||
/// <summary>Gets or sets the type of the workspace.</summary> | ||
[JsonPropertyName("workspace_type")] | ||
public string Type { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using ZoomNet.Models; | ||
|
||
namespace ZoomNet.Resources | ||
{ | ||
/// <summary> | ||
/// Allows you to manage workspaces. | ||
/// </summary> | ||
/// <remarks> | ||
/// See <a href="https://marketplace.zoom.us/docs/api-reference/zoom-api/methods/#tag/Workspaces">Zoom documentation</a> for more information. | ||
/// </remarks> | ||
public interface IWorkspaces | ||
{ | ||
/// <summary> | ||
/// Retrieve all workspaces for a location. | ||
/// </summary> | ||
/// <param name="locationId">The location Id.</param> | ||
/// <param name="recordsPerPage">The number of records returned within a single API call.</param> | ||
/// <param name="pagingToken">The paging token.</param> | ||
/// <param name="cancellationToken">The cancellation token.</param> | ||
/// <returns> | ||
/// An array of <see cref="Workspace">workspaces</see>. | ||
/// </returns> | ||
Task<PaginatedResponseWithToken<Workspace>> GetAllAsync(string locationId, int recordsPerPage = 30, string pagingToken = null, CancellationToken cancellationToken = default); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using Pathoschild.Http.Client; | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using ZoomNet.Models; | ||
|
||
namespace ZoomNet.Resources | ||
{ | ||
/// <summary> | ||
/// Allows you to manage workspaces. | ||
/// </summary> | ||
/// <seealso cref="ZoomNet.Resources.IWorkspaces" /> | ||
/// <remarks> | ||
/// See <a href="https://marketplace.zoom.us/docs/api-reference/zoom-api/methods/#tag/Workspaces">Zoom documentation</a> for more information. | ||
/// </remarks> | ||
public class Workspaces : IWorkspaces | ||
{ | ||
private readonly Pathoschild.Http.Client.IClient _client; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="Workspaces" /> class. | ||
/// </summary> | ||
/// <param name="client">The HTTP client.</param> | ||
internal Workspaces(Pathoschild.Http.Client.IClient client) | ||
{ | ||
_client = client; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public Task<PaginatedResponseWithToken<Workspace>> GetAllAsync(string locationId, int recordsPerPage = 30, string pagingToken = null, CancellationToken cancellationToken = default) | ||
{ | ||
if (recordsPerPage < 1 || recordsPerPage > 300) | ||
{ | ||
throw new ArgumentOutOfRangeException(nameof(recordsPerPage), "Records per page must be between 1 and 300"); | ||
} | ||
|
||
return _client | ||
.GetAsync($"workspaces") | ||
.WithArgument("page_size", recordsPerPage) | ||
.WithArgument("next_page_token", pagingToken) | ||
.WithCancellationToken(cancellationToken) | ||
.AsPaginatedResponseWithToken<Workspace>("workspaces"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters