diff --git a/src/PureCloud.Client/Apis/ObjectsApi.cs b/src/PureCloud.Client/Apis/ObjectsApi.cs
index 8b69a69c..9cfdc10d 100644
--- a/src/PureCloud.Client/Apis/ObjectsApi.cs
+++ b/src/PureCloud.Client/Apis/ObjectsApi.cs
@@ -11,12 +11,12 @@ namespace PureCloud.Client.Apis;
///
public sealed class ObjectsApi : IObjectsApi
{
- private readonly HttpClient _httpClient;
+ private readonly IHttpClientFactory _httpClientFactory;
private readonly PureCloudJsonSerializerOptions _options;
public ObjectsApi(IHttpClientFactory httpClientFactory, IOptions options)
{
- _httpClient = httpClientFactory.CreateClient(PureCloudConstants.PureCloudClientName);
+ _httpClientFactory = httpClientFactory;
_options = options.Value;
}
@@ -32,9 +32,11 @@ public async Task GetAuthorizationDivisionAsync(string divisionId
parameters.Add("objectCount", UriHelper.ParameterToString(objectCount.Value));
}
- var uri = UriHelper.GetUri($"api/v2/authorization/divisions/{divisionId}", parameters);
+ var uri = UriHelper.GetUri($"api/v2/authorization/divisions/{Uri.EscapeDataString(divisionId)}", parameters);
- var response = await _httpClient.GetAsync(uri, cancellationToken);
+ var client = _httpClientFactory.CreateClient(PureCloudConstants.PureCloudClientName);
+
+ var response = await client.GetAsync(uri, cancellationToken);
response.EnsureSuccessStatusCode();
@@ -42,7 +44,7 @@ public async Task GetAuthorizationDivisionAsync(string divisionId
}
///
- public async Task GetAuthorizationDivisionsAsync(int? pageSize = null, int? pageNumber = null, string sortBy = null, IEnumerable expand = null, string nextPage = null, string previousPage = null, bool? objectCount = null, IEnumerable id = null, string name = null, CancellationToken cancellationToken = default)
+ public async Task GetAuthorizationDivisionsAsync(int? pageSize = null, int? pageNumber = null, string sortBy = null, IEnumerable expands = null, string nextPage = null, string previousPage = null, bool? objectCount = null, IEnumerable ids = null, string name = null, CancellationToken cancellationToken = default)
{
var parameters = new NameValueCollection();
@@ -61,11 +63,11 @@ public async Task GetAuthorizationDivisionsAsync(int
parameters.Add("sortBy", UriHelper.ParameterToString(sortBy));
}
- if (expand != null)
+ if (expands != null)
{
- foreach (var item in expand)
+ foreach (var expand in expands)
{
- parameters.Add("expand", UriHelper.ParameterToString(item));
+ parameters.Add("expand", UriHelper.ParameterToString(expand));
}
}
@@ -84,11 +86,11 @@ public async Task GetAuthorizationDivisionsAsync(int
parameters.Add("objectCount", UriHelper.ParameterToString(objectCount.Value));
}
- if (id != null)
+ if (ids != null)
{
- foreach (var item in id)
+ foreach (var id in ids)
{
- parameters.Add("id", UriHelper.ParameterToString(item));
+ parameters.Add("id", UriHelper.ParameterToString(id));
}
}
@@ -99,7 +101,9 @@ public async Task GetAuthorizationDivisionsAsync(int
var uri = UriHelper.GetUri("api/v2/authorization/divisions", parameters);
- var response = await _httpClient.GetAsync(uri, cancellationToken);
+ var client = _httpClientFactory.CreateClient(PureCloudConstants.PureCloudClientName);
+
+ var response = await client.GetAsync(uri, cancellationToken);
response.EnsureSuccessStatusCode();
@@ -111,9 +115,9 @@ public async Task CreateAuthorizationDivisionAsync(AuthzDivision
{
ArgumentNullException.ThrowIfNull(body);
- var uri = UriHelper.GetUri("api/v2/authorization/divisions", null);
+ var client = _httpClientFactory.CreateClient(PureCloudConstants.PureCloudClientName);
- var response = await _httpClient.PostAsJsonAsync(uri, body, _options.JsonSerializerOptions, cancellationToken);
+ var response = await client.PostAsJsonAsync("api/v2/authorization/divisions", body, _options.JsonSerializerOptions, cancellationToken);
response.EnsureSuccessStatusCode();
@@ -127,9 +131,9 @@ public async Task UpdateAuthorizationDivisionAsync(string divisio
ArgumentNullException.ThrowIfNull(body);
- var uri = UriHelper.GetUri($"api/v2/authorization/divisions/{divisionId}", null);
+ var client = _httpClientFactory.CreateClient(PureCloudConstants.PureCloudClientName);
- var response = await _httpClient.PutAsJsonAsync(uri, body, _options.JsonSerializerOptions, cancellationToken);
+ var response = await client.PutAsJsonAsync($"api/v2/authorization/divisions/{Uri.EscapeDataString(divisionId)}", body, _options.JsonSerializerOptions, cancellationToken);
response.EnsureSuccessStatusCode();
@@ -148,10 +152,136 @@ public async Task DeleteAuthorizationDivisionAsync(string divisionId, bool? forc
parameters.Add("force", UriHelper.ParameterToString(force.Value));
}
- var uri = UriHelper.GetUri($"api/v2/authorization/divisions/{divisionId}", parameters);
+ var uri = UriHelper.GetUri($"api/v2/authorization/divisions/{Uri.EscapeDataString(divisionId)}", parameters);
+
+ var client = _httpClientFactory.CreateClient(PureCloudConstants.PureCloudClientName);
+
+ var response = await client.DeleteAsync(uri, cancellationToken);
+
+ response.EnsureSuccessStatusCode();
+ }
+
+ ///
+ public async Task GetAuthorizationDivisionsDeletedAsync(int? pageNumber = null, int? pageSize = null, CancellationToken cancellationToken = default)
+ {
+ var parameters = new NameValueCollection();
+
+ if (pageNumber.HasValue)
+ {
+ parameters.Add("pageNumber", UriHelper.ParameterToString(pageNumber.Value));
+ }
+
+ if (pageSize.HasValue)
+ {
+ parameters.Add("pageSize", UriHelper.ParameterToString(pageSize.Value));
+ }
+
+ var uri = UriHelper.GetUri("api/v2/authorization/divisions/deleted", parameters);
+
+ var client = _httpClientFactory.CreateClient(PureCloudConstants.PureCloudClientName);
+
+ var response = await client.GetAsync(uri, cancellationToken);
- var response = await _httpClient.DeleteAsync(uri, cancellationToken);
+ response.EnsureSuccessStatusCode();
+
+ return await response.Content.ReadFromJsonAsync(_options.JsonSerializerOptions, cancellationToken);
+ }
+
+ ///
+ public async Task GetAuthorizationDivisionsHomeAsync(CancellationToken cancellationToken = default)
+ {
+ var client = _httpClientFactory.CreateClient(PureCloudConstants.PureCloudClientName);
+
+ var response = await client.GetAsync("api/v2/authorization/divisions/home", cancellationToken);
+
+ response.EnsureSuccessStatusCode();
+
+ return await response.Content.ReadFromJsonAsync(_options.JsonSerializerOptions, cancellationToken);
+ }
+
+ ///
+ public async Task GetAuthorizationDivisionsLimitAsync(CancellationToken cancellationToken = default)
+ {
+ var client = _httpClientFactory.CreateClient(PureCloudConstants.PureCloudClientName);
+
+ var response = await client.GetAsync("api/v2/authorization/divisions/limit", cancellationToken);
response.EnsureSuccessStatusCode();
+
+ return await response.Content.ReadFromJsonAsync(_options.JsonSerializerOptions, cancellationToken);
+ }
+
+ ///
+ public async Task CreateAuthorizationDivisionObjectsAsync(string divisionId, string objectType, IEnumerable body, CancellationToken cancellationToken = default)
+ {
+ ArgumentException.ThrowIfNullOrEmpty(divisionId);
+ ArgumentException.ThrowIfNullOrEmpty(objectType);
+ ArgumentNullException.ThrowIfNull(body);
+
+ var client = _httpClientFactory.CreateClient(PureCloudConstants.PureCloudClientName);
+
+ var response = await client.PostAsJsonAsync($"api/v2/authorization/divisions/{Uri.EscapeDataString(divisionId)}/objects/{Uri.EscapeDataString(objectType)}", body, _options.JsonSerializerOptions, cancellationToken);
+
+ response.EnsureSuccessStatusCode();
+ }
+
+ ///
+ public async Task GetAuthorizationDivisionsQueryAsync(string before = null, string after = null, string pageSize = null, IEnumerable ids = null, string name = null, CancellationToken cancellationToken = default)
+ {
+ var parameters = new NameValueCollection();
+
+ if (!string.IsNullOrEmpty(before))
+ {
+ parameters.Add("before", UriHelper.ParameterToString(before));
+ }
+
+ if (!string.IsNullOrEmpty(after))
+ {
+ parameters.Add("after", UriHelper.ParameterToString(after));
+ }
+
+ if (!string.IsNullOrEmpty(pageSize))
+ {
+ parameters.Add("pageSize", UriHelper.ParameterToString(pageSize));
+ }
+
+ if (ids != null)
+ {
+ foreach (var id in ids)
+ {
+ parameters.Add("id", UriHelper.ParameterToString(id));
+ }
+ }
+
+ if (!string.IsNullOrEmpty(name))
+ {
+ parameters.Add("name", UriHelper.ParameterToString(name));
+ }
+
+ var uri = UriHelper.GetUri("api/v2/authorization/divisions/query", parameters);
+
+ var client = _httpClientFactory.CreateClient(PureCloudConstants.PureCloudClientName);
+
+ var response = await client.GetAsync(uri, cancellationToken);
+
+ response.EnsureSuccessStatusCode();
+
+ return await response.Content.ReadFromJsonAsync(_options.JsonSerializerOptions, cancellationToken);
+ }
+
+ ///
+ public async Task PostAuthorizationDivisionRestoreAsync(string divisionId, AuthzDivision body, CancellationToken cancellationToken = default)
+ {
+ ArgumentException.ThrowIfNullOrEmpty(divisionId);
+
+ ArgumentNullException.ThrowIfNull(body);
+
+ var client = _httpClientFactory.CreateClient(PureCloudConstants.PureCloudClientName);
+
+ var response = await client.PostAsJsonAsync($"api/v2/authorization/divisions/{Uri.EscapeDataString(divisionId)}/restore", body, _options.JsonSerializerOptions, cancellationToken);
+
+ response.EnsureSuccessStatusCode();
+
+ return await response.Content.ReadFromJsonAsync(_options.JsonSerializerOptions, cancellationToken);
}
-}
\ No newline at end of file
+}
diff --git a/src/PureCloud.Client/Contracts/IObjectsApi.cs b/src/PureCloud.Client/Contracts/IObjectsApi.cs
index ffbe01e8..f2cc9411 100644
--- a/src/PureCloud.Client/Contracts/IObjectsApi.cs
+++ b/src/PureCloud.Client/Contracts/IObjectsApi.cs
@@ -7,25 +7,105 @@ public interface IObjectsApi
///
/// Get an authorization division by ID.
///
+ /// Division ID
+ /// Get count of objects in this division, defaults to false
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ /// AuthzDivision
Task GetAuthorizationDivisionAsync(string divisionId, bool? objectCount = null, CancellationToken cancellationToken = default);
///
/// Get a list of authorization divisions.
///
- Task GetAuthorizationDivisionsAsync(int? pageSize = null, int? pageNumber = null, string sortBy = null, IEnumerable expand = null, string nextPage = null, string previousPage = null, bool? objectCount = null, IEnumerable id = null, string name = null, CancellationToken cancellationToken = default);
+ /// The total page size requested
+ /// The page number requested
+ /// variable name requested to sort by
+ /// variable name requested by expand list
+ /// next page token
+ /// Previous page token
+ /// Include the count of objects contained in the division
+ /// Optionally request specific divisions by their IDs
+ /// Search term to filter by division name
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ /// AuthzDivisionEntityListing
+ Task GetAuthorizationDivisionsAsync(int? pageSize = null, int? pageNumber = null, string sortBy = null, IEnumerable expands = null, string nextPage = null, string previousPage = null, bool? objectCount = null, IEnumerable ids = null, string name = null, CancellationToken cancellationToken = default);
///
/// Create a new authorization division.
///
+ /// Division
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ /// AuthzDivision
Task CreateAuthorizationDivisionAsync(AuthzDivision body, CancellationToken cancellationToken = default);
///
/// Update an authorization division.
///
+ /// Division ID
+ /// Updated division data
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ /// AuthzDivision
Task UpdateAuthorizationDivisionAsync(string divisionId, AuthzDivision body, CancellationToken cancellationToken = default);
///
/// Delete an authorization division.
///
+ /// Division ID
+ /// Force delete this division as well as the grants and objects associated with it
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ /// Task
Task DeleteAuthorizationDivisionAsync(string divisionId, bool? force = null, CancellationToken cancellationToken = default);
-}
\ No newline at end of file
+
+ ///
+ /// Get a list of soft deleted divisions for the org.
+ ///
+ /// The page number requested
+ /// The total page size requested
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ /// AuthzDivisionEntityListing
+ Task GetAuthorizationDivisionsDeletedAsync(int? pageNumber = null, int? pageSize = null, CancellationToken cancellationToken = default);
+
+ ///
+ /// Retrieve the home division for the organization.
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ /// AuthzDivision
+ Task GetAuthorizationDivisionsHomeAsync(CancellationToken cancellationToken = default);
+
+ ///
+ /// Returns the maximum allowed number of divisions.
+ ///
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ /// int?
+ Task GetAuthorizationDivisionsLimitAsync(CancellationToken cancellationToken = default);
+
+ ///
+ /// Assign a list of objects to a division.
+ ///
+ /// Division ID
+ /// The type of the objects. must be one of the valid object types
+ /// Object Id List
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ /// Task
+ Task CreateAuthorizationDivisionObjectsAsync(string divisionId, string objectType, IEnumerable body, CancellationToken cancellationToken = default);
+
+ ///
+ /// Retrieve a list of all divisions defined for the organization with cursor-based pagination.
+ ///
+ /// The cursor that points to the start of the set of entities that has been returned.
+ /// The cursor that points to the end of the set of entities that has been returned.
+ /// Number of entities to return. Maximum of 100.
+ /// Optionally request specific divisions by their IDs
+ /// Search term to filter by division name
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ /// AuthzDivisionCursorListing
+ Task GetAuthorizationDivisionsQueryAsync(string before = null, string after = null, string pageSize = null, IEnumerable ids = null, string name = null, CancellationToken cancellationToken = default);
+
+ ///
+ /// Recreate a previously deleted division.
+ ///
+ /// Division ID
+ /// Recreated division data
+ /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
+ /// AuthzDivision
+ Task PostAuthorizationDivisionRestoreAsync(string divisionId, AuthzDivision body, CancellationToken cancellationToken = default);
+}
diff --git a/src/PureCloud.Client/PureCloud.Client.csproj b/src/PureCloud.Client/PureCloud.Client.csproj
index 4ac1d43a..ac8c32b1 100644
--- a/src/PureCloud.Client/PureCloud.Client.csproj
+++ b/src/PureCloud.Client/PureCloud.Client.csproj
@@ -4123,10 +4123,10 @@
-
-
-
-
+
+
+
+