From 561b603329643d915e4b5828e8e07e230670a9d8 Mon Sep 17 00:00:00 2001 From: Jericho Date: Fri, 10 Jun 2022 21:22:46 -0400 Subject: [PATCH] =?UTF-8?q?=EF=BB=BF(GH-220)=20Add=20the=20contact=20cente?= =?UTF-8?q?r=20resource?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/ZoomNet/IZoomClient.cs | 8 +++ Source/ZoomNet/Resources/ContactCenter.cs | 62 ++++++++++++++++++++++ Source/ZoomNet/Resources/IContactCenter.cs | 37 +++++++++++++ Source/ZoomNet/ZoomClient.cs | 4 ++ 4 files changed, 111 insertions(+) create mode 100644 Source/ZoomNet/Resources/ContactCenter.cs create mode 100644 Source/ZoomNet/Resources/IContactCenter.cs diff --git a/Source/ZoomNet/IZoomClient.cs b/Source/ZoomNet/IZoomClient.cs index 42cc97d9..3a64be4c 100644 --- a/Source/ZoomNet/IZoomClient.cs +++ b/Source/ZoomNet/IZoomClient.cs @@ -32,6 +32,14 @@ public interface IZoomClient /// ICloudRecordings CloudRecordings { get; } + /// + /// Gets the resource which allows you to manage access to data on Zoom Contact Center. + /// + /// + /// The contact center resource. + /// + IContactCenter ContactCenter { get; } + /// /// Gets the resource which allows you to manage contacts. /// diff --git a/Source/ZoomNet/Resources/ContactCenter.cs b/Source/ZoomNet/Resources/ContactCenter.cs new file mode 100644 index 00000000..fc4b791b --- /dev/null +++ b/Source/ZoomNet/Resources/ContactCenter.cs @@ -0,0 +1,62 @@ +using Pathoschild.Http.Client; +using System; +using System.Text.Json.Nodes; +using System.Threading; +using System.Threading.Tasks; +using ZoomNet.Models; + +namespace ZoomNet.Resources +{ + /// + /// Allows you to manage data on the Zoom Contact Center. + /// + /// + /// + /// See Zoom documentation for more information. + /// + public class ContactCenter : IContactCenter + { + private readonly Pathoschild.Http.Client.IClient _client; + + /// + /// Initializes a new instance of the class. + /// + /// The HTTP client. + internal ContactCenter(Pathoschild.Http.Client.IClient client) + { + _client = client; + } + + /// + public Task> SearchUserProfilesAsync(string keyword, 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($"contacts") + .WithArgument("search_key", keyword) + .WithArgument("page_size", recordsPerPage) + .WithArgument("next_page_token", pagingToken) + .WithCancellationToken(cancellationToken) + .AsPaginatedResponseWithToken("users"); + } + + /// + public Task CreateUserAsync(string email, CancellationToken cancellationToken = default) + { + var data = new JsonObject + { + { "user_email", email }, + }; + + return _client + .PostAsync("contact_center/users") + .WithJsonBody(data) + .WithCancellationToken(cancellationToken) + .AsObject(); + } + } +} diff --git a/Source/ZoomNet/Resources/IContactCenter.cs b/Source/ZoomNet/Resources/IContactCenter.cs new file mode 100644 index 00000000..f6e1ee84 --- /dev/null +++ b/Source/ZoomNet/Resources/IContactCenter.cs @@ -0,0 +1,37 @@ +using System.Threading; +using System.Threading.Tasks; +using ZoomNet.Models; + +namespace ZoomNet.Resources +{ + /// + /// Allows you to manage data on the Zoom Contact Center. + /// + /// + /// See Zoom documentation for more information. + /// + public interface IContactCenter + { + /// + /// Search users and their information. + /// + /// The search keyword: either email address or username. + /// The number of records returned within a single API call. + /// The paging token. + /// The cancellation token. + /// + /// An array of contacts. + /// + Task> SearchUserProfilesAsync(string keyword, int recordsPerPage = 30, string pagingToken = null, CancellationToken cancellationToken = default); + + /// + /// Creates a user. + /// + /// The email address. + /// The cancellation token. + /// + /// The new user. + /// + Task CreateUserAsync(string email, CancellationToken cancellationToken = default); + } +} diff --git a/Source/ZoomNet/ZoomClient.cs b/Source/ZoomNet/ZoomClient.cs index 7b65b1cd..aa1defb7 100644 --- a/Source/ZoomNet/ZoomClient.cs +++ b/Source/ZoomNet/ZoomClient.cs @@ -73,6 +73,9 @@ public static string Version /// public ICloudRecordings CloudRecordings { get; private set; } + /// + public IContactCenter ContactCenter { get; private set; } + /// public IContacts Contacts { get; private set; } @@ -212,6 +215,7 @@ private ZoomClient(IConnectionInfo connectionInfo, HttpClient httpClient, bool d Accounts = new Accounts(_fluentClient); Chat = new Chat(_fluentClient); CloudRecordings = new CloudRecordings(_fluentClient); + ContactCenter = new ContactCenter(_fluentClient); Contacts = new Contacts(_fluentClient); DataCompliance = new DataCompliance(_fluentClient); Meetings = new Meetings(_fluentClient);