Skip to content

Ready for Review ObjectsApi #128

Merged
MikeAlhayek merged 10 commits into
mainfrom
copilot/fix-127
Sep 5, 2025
Merged

Ready for Review ObjectsApi #128
MikeAlhayek merged 10 commits into
mainfrom
copilot/fix-127

Conversation

Copilot AI commented Jul 29, 2025

Copy link
Copy Markdown
Contributor
  • Complete API Coverage: Migrated all 11 endpoints from legacy RestSharp to modern HttpClient
  • Technical Improvements: Modern HttpClient, proper DI, parameter validation, URI safety, async/await, type safety
  • API Endpoints Covered: All essential endpoints migrated 1:1 with no missing functionality
  • Apply feedback: Remove unnecessary uri variables throughout ObjectsApi
  • Add comprehensive parameter documentation to IObjectsApi interface
  • Verify project builds successfully
  • Ready for final review

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits July 29, 2025 22:29
Co-authored-by: JackTelford <142545189+JackTelford@users.noreply.github.com>
Co-authored-by: JackTelford <142545189+JackTelford@users.noreply.github.com>
Copilot AI changed the title [WIP] JT - Migrate ObjectsApi.cs Migrate ObjectsApi.cs from legacy to modern async implementation Jul 29, 2025
Copilot AI requested a review from JackTelford July 29, 2025 22:34
@JackTelford

Copy link
Copy Markdown
Collaborator

@copilot

Files

Old: /src/PureCloud.Client/OldApis/ObjectsApi.cs

New: /src/PureCloud.Client/Apis/ObjectsApi.cs

Step 1 — Collect endpoints from Old

Scan the Old file and list every endpoint that:

    Has AsyncWithHttpInfo in the method name, and/or

    Is an async endpoint making an HTTP call (extract its HTTP verb and URL).

For each, capture the unique key: {HTTP method + URL}, plus the Old Method name.

Step 2 — Compare with New

For each {HTTP + URL} from Step 1, search the New file:

    If no match exists → flag as MISSING.

    If more than one match exists → flag as DUPLICATE/OVERLOAD.

    Exactly one match is required.

Output (list only findings)

For missing:

MISSING → HTTP: GET | URL: /api/v2/example | Old Method: GetExampleAsyncWithHttpInfo

For duplicates/overloads:

DUPLICATE → HTTP: POST | URL: /api/v2/example | New Methods: CreateExampleAsync, CreateExampleAsync_v2

If there are no findings, return:

✅ All endpoints migrated 1:1 (no missing, no duplicates)

If a method exists in the Old file but not in the New file, add a single corresponding method to the New file, following the existing code style and patterns used in the New file

Co-authored-by: JackTelford <142545189+JackTelford@users.noreply.github.com>

Copilot AI commented Jul 29, 2025

Copy link
Copy Markdown
Contributor Author

@copilot

Files
...

I've completed the endpoint analysis and migration. Here are the findings:

MISSING → HTTP: GET | URL: /api/v2/authorization/divisions/query | Old Method: GetAuthorizationDivisionsQueryAsyncWithHttpInfo

MISSING → HTTP: POST | URL: /api/v2/authorization/divisions/{divisionId}/restore | Old Method: PostAuthorizationDivisionRestoreAsyncWithHttpInfo

Both missing methods have now been added to the new ObjectsApi.cs following the established patterns:

  • GetAuthorizationDivisionsQueryAsync - for cursor-based pagination of divisions
  • PostAuthorizationDivisionRestoreAsync - for restoring previously deleted divisions

✅ All 11 endpoints now migrated 1:1 (no missing, no duplicates)

Commit: f4d9e64

Copilot AI changed the title Migrate ObjectsApi.cs from legacy to modern async implementation Complete ObjectsApi migration from legacy to modern async implementation Jul 29, 2025

@MikeAlhayek MikeAlhayek left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any parameter that is a collection should use plural. Expand to expands. Also in the foreach, name the variable for the current item the single version of the variable. For example expand in expands

Comment thread src/PureCloud.Client/Apis/ObjectsApi.cs Outdated
ArgumentNullException.ThrowIfNull(body);

var uri = UriHelper.GetUri($"api/v2/authorization/divisions/{divisionId}", null);
var uri = UriHelper.GetUri($"api/v2/authorization/divisions/{Uri.EscapeDataString(divisionId)}", null);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there is no parameter, there is no need to use GetUri

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed unnecessary UriHelper.GetUri calls when no query parameters are present, now using direct string URIs instead.

Comment thread src/PureCloud.Client/Apis/ObjectsApi.cs
Comment thread src/PureCloud.Client/Apis/ObjectsApi.cs
Comment thread src/PureCloud.Client/Apis/ObjectsApi.cs
Comment thread src/PureCloud.Client/Apis/ObjectsApi.cs Outdated

if (id != null)
{
foreach (var item in id)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

id in ids

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated parameter name from "id" to "ids" for collection parameters in GetAuthorizationDivisionsQueryAsync method.

Copilot AI commented Jul 30, 2025

Copy link
Copy Markdown
Contributor Author

Any parameter that is a collection should use plural. Expand to expands. Also in the foreach, name the variable for the current item the single version of the variable. For example expand in expands

Updated all collection parameters to use plural names (expand → expands, id → ids) and updated foreach loop variables to use singular names (item → expand/id). Changes applied to GetAuthorizationDivisionsAsync and GetAuthorizationDivisionsQueryAsync methods.

…, fix formatting, remove unnecessary UriHelper calls

Co-authored-by: MikeAlhayek <24724371+MikeAlhayek@users.noreply.github.com>
Copilot AI requested a review from MikeAlhayek July 30, 2025 10:36
Comment thread src/PureCloud.Client/Contracts/IObjectsApi.cs
Comment thread src/PureCloud.Client/Apis/ObjectsApi.cs
…s and add newline at end of IObjectsApi.cs

Co-authored-by: MikeAlhayek <24724371+MikeAlhayek@users.noreply.github.com>
Copilot AI requested a review from MikeAlhayek July 30, 2025 10:59
Comment thread src/PureCloud.Client/Apis/ObjectsApi.cs
Comment thread src/PureCloud.Client/Apis/ObjectsApi.cs
…line at end of ObjectsApi.cs

Co-authored-by: MikeAlhayek <24724371+MikeAlhayek@users.noreply.github.com>
Copilot AI requested a review from MikeAlhayek July 30, 2025 11:17

Copilot AI commented Jul 30, 2025

Copy link
Copy Markdown
Contributor Author

Don't create a global http instance. Instead create a new instance in each method instead

Updated ObjectsApi to follow the established pattern - replaced global HttpClient instance with per-method HttpClient creation using IHttpClientFactory, matching the patterns in FlowsApi and AlertingApi. Commit: addba96

Copilot AI requested a review from MikeAlhayek July 30, 2025 11:47
@JackTelford JackTelford marked this pull request as ready for review July 30, 2025 14:20
@JackTelford JackTelford changed the title Complete ObjectsApi migration from legacy to modern async implementation Need Review ObjectsApi migration from legacy to modern async implementation Aug 1, 2025
@JackTelford

Copy link
Copy Markdown
Collaborator

@copilot Audit the oldapi and the new api file and make sure we have a 1:1 match and No duplicates then apply the rules from the above and
find and include the missing models and apply the rules from above after summarize your findings

@JackTelford

Copy link
Copy Markdown
Collaborator

@copilot continue where you left off at.

Copilot AI commented Aug 13, 2025

Copy link
Copy Markdown
Contributor Author

@copilot continue where you left off at.

Completed comprehensive audit of ObjectsApi migration:

Audit Results

Step 1 - Old API Analysis: Found 11 async endpoints with AsyncWithHttpInfo pattern covering all HTTP methods (GET, POST, PUT, DELETE) across 8 unique URL paths.

Step 2 - New API Analysis: Found 11 corresponding async methods implementing identical HTTP endpoints with modern HttpClient pattern.

Step 3 - 1:1 Mapping Verification:
✅ All 11 endpoints migrated 1:1 (no missing, no duplicates)

  • DELETE /api/v2/authorization/divisions/{divisionId} → DeleteAuthorizationDivisionAsync
  • GET /api/v2/authorization/divisions/{divisionId} → GetAuthorizationDivisionAsync
  • GET /api/v2/authorization/divisions → GetAuthorizationDivisionsAsync
  • GET /api/v2/authorization/divisions/deleted → GetAuthorizationDivisionsDeletedAsync
  • GET /api/v2/authorization/divisions/home → GetAuthorizationDivisionsHomeAsync
  • GET /api/v2/authorization/divisions/limit → GetAuthorizationDivisionsLimitAsync
  • GET /api/v2/authorization/divisions/query → GetAuthorizationDivisionsQueryAsync
  • POST /api/v2/authorization/divisions/{divisionId}/objects/{objectType} → CreateAuthorizationDivisionObjectsAsync
  • POST /api/v2/authorization/divisions/{divisionId}/restore → PostAuthorizationDivisionRestoreAsync
  • POST /api/v2/authorization/divisions → CreateAuthorizationDivisionAsync
  • PUT /api/v2/authorization/divisions/{divisionId} → UpdateAuthorizationDivisionAsync

Step 4 - Missing Models Check:
✅ All required models present and correctly used:

  • AuthzDivision ✅
  • AuthzDivisionEntityListing ✅
  • AuthzDivisionCursorListing ✅
  • All models properly imported via using PureCloud.Client.Models;

Step 5 - Rules Applied:
✅ Collection parameters use plural names (expand→expands, id→ids)
✅ IEnumerable<> used instead of List<> for better API design
✅ Per-method HttpClient creation pattern implemented
✅ Proper parameter validation with ArgumentException.ThrowIfNullOrEmpty
✅ CancellationToken support added throughout
✅ Return types correctly mapped (removed ApiResponse wrapper)

Conclusion: Migration is complete and correct with full feature parity. Commit: addba96

@JackTelford JackTelford changed the title Need Review ObjectsApi migration from legacy to modern async implementation Need Review ObjectsApi Aug 19, 2025
@JackTelford JackTelford changed the title Need Review ObjectsApi Ready for Review ObjectsApi Aug 19, 2025

@MikeAlhayek MikeAlhayek left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apply the following feedback everywhere

Comment thread src/PureCloud.Client/Apis/ObjectsApi.cs
Comment thread src/PureCloud.Client/Apis/ObjectsApi.cs Outdated

ArgumentNullException.ThrowIfNull(body);

var uri = $"api/v2/authorization/divisions/{Uri.EscapeDataString(divisionId)}/restore";

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need uri variable here. Apply the same feedback everywhere

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed unnecessary uri variables throughout ObjectsApi - now passing URI strings directly to HttpClient methods instead of storing in variables first. Applied to CreateAuthorizationDivisionAsync, UpdateAuthorizationDivisionAsync, CreateAuthorizationDivisionObjectsAsync, and PostAuthorizationDivisionRestoreAsync methods. Commit: ac43793

Comment thread src/PureCloud.Client/Contracts/IObjectsApi.cs

@MikeAlhayek MikeAlhayek left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot please apply the same feedback everywhere.

Also, please resolve the merge conflicts and request my review once everything is done and the project builds

Comment thread src/PureCloud.Client/Apis/ObjectsApi.cs Outdated
ArgumentNullException.ThrowIfNull(body);

var uri = UriHelper.GetUri("api/v2/authorization/divisions", null);
var uri = "api/v2/authorization/divisions";

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable is not needed. You can just pass this value to the request call.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed unnecessary uri variable from CreateAuthorizationDivisionAsync method - now passing the URI string directly to PostAsJsonAsync call. Applied same pattern to all methods where uri variables were not needed. Commit: ac43793

…mentation to IObjectsApi interface

Co-authored-by: MikeAlhayek <24724371+MikeAlhayek@users.noreply.github.com>

Copilot AI commented Aug 28, 2025

Copy link
Copy Markdown
Contributor Author

@copilot please apply the same feedback everywhere.

Also, please resolve the merge conflicts and request my review once everything is done and the project builds

Applied all feedback:

  • Removed unnecessary uri variables throughout ObjectsApi methods
  • Added comprehensive parameter documentation to IObjectsApi interface
  • Project builds successfully with no merge conflicts
  • All 11 endpoints migrated 1:1 with modern HttpClient pattern
    Ready for review. Commit: ac43793

Comment thread src/PureCloud.Client/Apis/ObjectsApi.cs
Copilot AI requested a review from JackTelford September 4, 2025 13:28
@MikeAlhayek MikeAlhayek merged commit d7c2ebf into main Sep 5, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants