Skip to content

Commit

Permalink
(GH-220) Add the contact center resource
Browse files Browse the repository at this point in the history
  • Loading branch information
Jericho committed Jun 11, 2022
1 parent bae7f94 commit f428989
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Source/ZoomNet/IZoomClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ public interface IZoomClient
/// </value>
ICloudRecordings CloudRecordings { get; }

/// <summary>
/// Gets the resource which allows you to manage access to data on Zoom Contact Center.
/// </summary>
/// <value>
/// The contact center resource.
/// </value>
IContactCenter ContactCenter { get; }

/// <summary>
/// Gets the resource which allows you to manage contacts.
/// </summary>
Expand Down
62 changes: 62 additions & 0 deletions Source/ZoomNet/Resources/ContactCenter.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Allows you to manage data on the Zoom Contact Center.
/// </summary>
/// <seealso cref="ZoomNet.Resources.IContactCenter" />
/// <remarks>
/// See <a href="https://marketplace.zoom.us/docs/api-reference/contact-center/methods/">Zoom documentation</a> for more information.
/// </remarks>
public class ContactCenter : IContactCenter
{
private readonly Pathoschild.Http.Client.IClient _client;

/// <summary>
/// Initializes a new instance of the <see cref="ContactCenter" /> class.
/// </summary>
/// <param name="client">The HTTP client.</param>
internal ContactCenter(Pathoschild.Http.Client.IClient client)
{
_client = client;
}

/// <inheritdoc/>
public Task<PaginatedResponseWithToken<Contact>> 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<Contact>("users");
}

/// <inheritdoc/>
public Task<User> CreateUserAsync(string email, CancellationToken cancellationToken = default)
{
var data = new JsonObject
{
{ "user_email", email },
};

return _client
.PostAsync("contact_center/users")
.WithJsonBody(data)
.WithCancellationToken(cancellationToken)
.AsObject<User>();
}
}
}
37 changes: 37 additions & 0 deletions Source/ZoomNet/Resources/IContactCenter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.Threading;
using System.Threading.Tasks;
using ZoomNet.Models;

namespace ZoomNet.Resources
{
/// <summary>
/// Allows you to manage data on the Zoom Contact Center.
/// </summary>
/// <remarks>
/// See <a href="https://marketplace.zoom.us/docs/api-reference/zoom-api/contacts/">Zoom documentation</a> for more information.
/// </remarks>
public interface IContactCenter
{
/// <summary>
/// Search users and their information.
/// </summary>
/// <param name="keyword">The search keyword: either email address or username.</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="Contact">contacts</see>.
/// </returns>
Task<PaginatedResponseWithToken<Contact>> SearchUserProfilesAsync(string keyword, int recordsPerPage = 30, string pagingToken = null, CancellationToken cancellationToken = default);

/// <summary>
/// Creates a user.
/// </summary>
/// <param name="email">The email address.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// The new user.
/// </returns>
Task<User> CreateUserAsync(string email, CancellationToken cancellationToken = default);
}
}
4 changes: 4 additions & 0 deletions Source/ZoomNet/ZoomClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ public static string Version
/// </value>
public ICloudRecordings CloudRecordings { get; private set; }

/// <inheritdoc/>
public IContactCenter ContactCenter { get; private set; }

/// <summary>
/// Gets the resource which allows you to manage contacts.
/// </summary>
Expand Down Expand Up @@ -247,6 +250,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);
Expand Down

0 comments on commit f428989

Please sign in to comment.