feat(ai): add ai gateway provider methods support#366
Conversation
There was a problem hiding this comment.
Pull request overview
Adds SDK support for the Crowdin AI Gateway provider methods (GET/POST/PUT/PATCH/DELETE) so consumers can manage provider gateway configuration through the .NET client.
Changes:
- Introduces
IAiGatewayApiExecutorandAiGatewayApiExecutorto call AI Gateway endpoints and return rawJObjectresponses. - Exposes AI-related executors on
ICrowdinApiClient/CrowdinApiClientvia newAIandAiGatewayproperties. - Adds unit tests covering the new gateway executor methods.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Crowdin.Api.UnitTesting/Tests/AI/AiGatewayTests.cs | Adds unit tests validating request routing for AI Gateway methods. |
| src/Crowdin.Api/ICrowdinApiClient.cs | Exposes new AI executors on the public client interface. |
| src/Crowdin.Api/CrowdinApiClient.cs | Instantiates and exposes AI and AiGateway executors on the concrete client. |
| src/Crowdin.Api/AI/Gateway/IAiGatewayApiExecutor.cs | Defines the AI Gateway executor contract (GET/POST/PUT/PATCH/DELETE). |
| src/Crowdin.Api/AI/Gateway/AiGatewayApiExecutor.cs | Implements the AI Gateway calls and URL formation logic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private readonly IJsonParser _jsonParser; | ||
|
|
||
| public AiGatewayApiExecutor(ICrowdinApiClient apiClient) | ||
| { | ||
| _apiClient = apiClient; | ||
| _jsonParser = apiClient.DefaultJsonParser; | ||
| } | ||
|
|
||
| public AiGatewayApiExecutor(ICrowdinApiClient apiClient, IJsonParser jsonParser) | ||
| { | ||
| _apiClient = apiClient; | ||
| _jsonParser = jsonParser; | ||
| } |
There was a problem hiding this comment.
AiGatewayApiExecutor stores _jsonParser (and has a ctor overload that accepts it) but never uses it anywhere in the class. This leaves dead code and will produce an unused-field warning; consider removing _jsonParser and the (ICrowdinApiClient, IJsonParser) constructor, or add typed Execute*<T>() methods that actually use the parser.
| private readonly IJsonParser _jsonParser; | |
| public AiGatewayApiExecutor(ICrowdinApiClient apiClient) | |
| { | |
| _apiClient = apiClient; | |
| _jsonParser = apiClient.DefaultJsonParser; | |
| } | |
| public AiGatewayApiExecutor(ICrowdinApiClient apiClient, IJsonParser jsonParser) | |
| { | |
| _apiClient = apiClient; | |
| _jsonParser = jsonParser; | |
| } | |
| public AiGatewayApiExecutor(ICrowdinApiClient apiClient) | |
| { | |
| _apiClient = apiClient; | |
| } |
| // ReSharper disable once InconsistentNaming | ||
| IAiApiExecutor AI { get; } | ||
|
|
||
| IAiGatewayApiExecutor AiGateway { get; } | ||
|
|
There was a problem hiding this comment.
Adding new members to ICrowdinApiClient (AI / AiGateway) is a binary breaking change for any external implementations of this public interface. If backwards compatibility is a goal, consider exposing these executors only on CrowdinApiClient (or via a separate interface/extension methods), or ensure the package versioning reflects this breaking API change.
| // ReSharper disable once InconsistentNaming | |
| IAiApiExecutor AI { get; } | |
| IAiGatewayApiExecutor AiGateway { get; } | |
Closes #359