-
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.
- Loading branch information
Showing
16 changed files
with
301 additions
and
43 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
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,21 @@ | ||
using System.IO; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using ZoomNet.Models; | ||
|
||
namespace ZoomNet.IntegrationTests.Tests | ||
{ | ||
public class ExternalContacts : IIntegrationTest | ||
{ | ||
public async Task RunAsync(User myUser, string[] myPermissions, IZoomClient client, TextWriter log, CancellationToken cancellationToken) | ||
{ | ||
if (cancellationToken.IsCancellationRequested) return; | ||
|
||
await log.WriteLineAsync("\n***** EXTERNAL CONTACTS *****\n").ConfigureAwait(false); | ||
|
||
// GET ALL THE EXTERNAL CONTACTS | ||
var paginatedContacts = await client.ExternalContacts.GetAllAsync(100, null, cancellationToken).ConfigureAwait(false); | ||
await log.WriteLineAsync($"There are {paginatedContacts.TotalRecords} external contacts under the main account").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
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
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
16 changes: 0 additions & 16 deletions
16
Source/ZoomNet/Models/CallHandlingSettings/ExternalContact.cs
This file was deleted.
Oops, something went wrong.
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,23 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace ZoomNet.Models | ||
{ | ||
/// <summary> | ||
/// Zoom phone external contact model. | ||
/// </summary> | ||
public class ExternalContact | ||
{ | ||
/// <summary> | ||
/// Gets or sets the Zoom-generated external contact Id. | ||
/// Don't set it on external contact creation, it will be generated automatically. | ||
/// </summary> | ||
[JsonPropertyName("external_contact_id")] | ||
public string ExternalContactId { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the external contact's username or extension display name. | ||
/// </summary> | ||
[JsonPropertyName("name")] | ||
public string Name { 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,54 @@ | ||
using System.Collections.Generic; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace ZoomNet.Models | ||
{ | ||
/// <summary> | ||
/// Zoom phone external contact details model. | ||
/// </summary> | ||
public class ExternalContactDetails : ExternalContact | ||
{ | ||
/// <summary> | ||
/// Gets or sets the external contact's description. | ||
/// </summary> | ||
[JsonPropertyName("description")] | ||
public string Description { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the external contact's email address. | ||
/// </summary> | ||
[JsonPropertyName("email")] | ||
public string Email { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the external contact's extension number. | ||
/// </summary> | ||
[JsonPropertyName("extension_number")] | ||
public string ExtensionNumber { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the customer-configured external contact ID. | ||
/// If it is not set id will be generated automatically. | ||
/// </summary> | ||
[JsonPropertyName("id")] | ||
public string Id { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the external contact's phone numbers. | ||
/// </summary> | ||
[JsonPropertyName("phone_numbers")] | ||
public List<string> PhoneNumbers { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the external contact's SIP group, to define the call routing path. This is for customers that use SIP trunking. | ||
/// </summary> | ||
[JsonPropertyName("routing_path")] | ||
public string RoutingPath { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets a value indicating whether to allow the automatic call recording. | ||
/// </summary> | ||
[JsonPropertyName("auto_call_recorded")] | ||
public bool AutoCallRecorded { 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,98 @@ | ||
using Pathoschild.Http.Client; | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using ZoomNet; | ||
using ZoomNet.Models; | ||
|
||
namespace ZoomNet.Resources | ||
{ | ||
/// <inheritdoc/> | ||
public class ExternalContacts : IExternalContacts | ||
{ | ||
private readonly IClient _client; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ExternalContacts" /> class. | ||
/// </summary> | ||
/// <param name="client">The HTTP client.</param> | ||
internal ExternalContacts(IClient client) | ||
{ | ||
_client = client; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public Task<PaginatedResponseWithToken<ExternalContactDetails>> GetAllAsync(int pageSize = 30, string nextPageToken = null, CancellationToken cancellationToken = default) | ||
{ | ||
if (pageSize < 1 || pageSize > 300) | ||
{ | ||
throw new ArgumentOutOfRangeException(nameof(pageSize), "Page size must be between 1 and 300"); | ||
} | ||
|
||
return _client | ||
.GetAsync("phone/external_contacts") | ||
.WithArgument("page_size", pageSize) | ||
.WithArgument("next_page_token", nextPageToken) | ||
.WithCancellationToken(cancellationToken) | ||
.AsPaginatedResponseWithToken<ExternalContactDetails>("external_contacts"); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public Task<ExternalContactDetails> GetDetailsAsync(string externalContactId, CancellationToken cancellationToken = default) | ||
{ | ||
if (string.IsNullOrEmpty(externalContactId)) | ||
{ | ||
throw new ArgumentNullException(nameof(externalContactId)); | ||
} | ||
|
||
return _client | ||
.GetAsync($"phone/external_contacts/{externalContactId}") | ||
.WithCancellationToken(cancellationToken) | ||
.AsObject<ExternalContactDetails>(); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public Task<ExternalContact> AddAsync(ExternalContactDetails externalContact, CancellationToken cancellationToken = default) | ||
{ | ||
return _client | ||
.PostAsync("phone/external_contacts") | ||
.WithJsonBody(externalContact) | ||
.WithCancellationToken(cancellationToken) | ||
.AsObject<ExternalContact>(); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public Task DeleteAsync(string externalContactId, CancellationToken cancellationToken = default) | ||
{ | ||
if (string.IsNullOrEmpty(externalContactId)) | ||
{ | ||
throw new ArgumentNullException(nameof(externalContactId)); | ||
} | ||
|
||
return _client | ||
.DeleteAsync($"phone/external_contacts/{externalContactId}") | ||
.WithCancellationToken(cancellationToken) | ||
.AsMessage(); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public Task UpdateAsync( | ||
ExternalContactDetails externalContact, CancellationToken cancellationToken = default) | ||
{ | ||
if (externalContact == null) | ||
{ | ||
throw new ArgumentNullException(nameof(externalContact)); | ||
} | ||
else if (string.IsNullOrEmpty(externalContact.ExternalContactId)) | ||
{ | ||
throw new ArgumentNullException($"{nameof(externalContact)}.{nameof(externalContact.ExternalContactId)}"); | ||
} | ||
|
||
return _client | ||
.PatchAsync($"phone/external_contacts/{externalContact.ExternalContactId}") | ||
.WithJsonBody(externalContact) | ||
.WithCancellationToken(cancellationToken) | ||
.AsMessage(); | ||
} | ||
} | ||
} |
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,69 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using ZoomNet.Models; | ||
|
||
namespace ZoomNet.Resources | ||
{ | ||
/// <summary> | ||
/// Allows you to access Zoom Phone API endpoints responsible for setting and retrieving data of external contacts. | ||
/// </summary> | ||
/// <remarks> | ||
/// See <a href="https://developers.zoom.us/docs/api/rest/reference/phone/methods/#tag/External-Contacts"> | ||
/// Zoom API documentation</a> for more information. | ||
/// </remarks> | ||
public interface IExternalContacts | ||
{ | ||
/// <summary> | ||
/// Retrieves a list of all of an account's external contacts. | ||
/// </summary> | ||
/// <param name="pageSize">The number of records returned from a single API call. Default is 30.</param> | ||
/// <param name="nextPageToken"> | ||
/// The next page token paginates through a large set of results. | ||
/// A next page token is returned whenever the set of available results exceeds the current page size. | ||
/// </param> | ||
/// <param name="cancellationToken">A cancellation token that can be used to cancel the asynchronous operation.</param> | ||
/// <returns> | ||
/// A task representing the asynchronous operation. The task result contains an array of external contacts in type of <see cref="ExternalContact"/>. | ||
/// </returns> | ||
Task<PaginatedResponseWithToken<ExternalContactDetails>> GetAllAsync( | ||
int pageSize = 30, | ||
string nextPageToken = null, | ||
CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Gets an external contact's information. | ||
/// </summary> | ||
/// <param name="externalContactId">The external contact id.</param> | ||
/// <param name="cancellationToken">A cancellation token that can be used to cancel the asynchronous operation.</param> | ||
/// <returns>A task representing the asynchronous operation. The task result contains external contact details.</returns> | ||
Task<ExternalContactDetails> GetDetailsAsync( | ||
string externalContactId, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Adds an external contact. | ||
/// </summary> | ||
/// <param name="externalContact">The external contact information.</param> | ||
/// <param name="cancellationToken">A cancellation token that can be used to cancel the asynchronous operation.</param> | ||
/// <returns>A task representing the asynchronous operation. The task result contains external contact details.</returns> | ||
Task<ExternalContact> AddAsync( | ||
ExternalContactDetails externalContact, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Removes an external contact. | ||
/// </summary> | ||
/// <param name="externalContactId">The external contact id.</param> | ||
/// <param name="cancellationToken">A cancellation token that can be used to cancel the asynchronous operation.</param> | ||
/// <returns>A task representing the asynchronous operation.</returns> | ||
Task DeleteAsync( | ||
string externalContactId, CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// Update an external contact information by <see cref="ExternalContact.ExternalContactId"/>. | ||
/// </summary> | ||
/// <param name="externalContact">External contact information.</param> | ||
/// <param name="cancellationToken">A cancellation token that can be used to cancel the asynchronous operation.</param> | ||
/// <returns>A task representing the asynchronous operation.</returns> | ||
Task UpdateAsync( | ||
ExternalContactDetails externalContact, CancellationToken cancellationToken = default); | ||
} | ||
} |
Oops, something went wrong.