-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(GH-220) Add the contact center resource
- Loading branch information
Showing
4 changed files
with
111 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,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>(); | ||
} | ||
} | ||
} |
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,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); | ||
} | ||
} |
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