From 21c870ac67675e4d959e68ffff91ffce5ce889ae Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2024 00:24:57 +0000 Subject: [PATCH 01/14] Update Src/VTEXFeedV3Integration.cs --- Src/VTEXFeedV3Integration.cs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Src/VTEXFeedV3Integration.cs diff --git a/Src/VTEXFeedV3Integration.cs b/Src/VTEXFeedV3Integration.cs new file mode 100644 index 000000000..29caecd4a --- /dev/null +++ b/Src/VTEXFeedV3Integration.cs @@ -0,0 +1,32 @@ +using System; +using System.Net.Http; +using System.Threading.Tasks; + +namespace VTEXIntegration +{ + public class VTEXFeedV3Integration + { + private readonly HttpClient _httpClient; + private readonly string _apiKey; + private readonly string _apiToken; + + public VTEXFeedV3Integration(string apiKey, string apiToken) + { + _httpClient = new HttpClient(); + _apiKey = apiKey; + _apiToken = apiToken; + } + + public async Task GetFeedOrderStatus1Async() + { + var request = new HttpRequestMessage(HttpMethod.Get, "https://api.vtex.com/your-account/feed/orders/status"); + request.Headers.Add("X-VTEX-API-AppKey", _apiKey); + request.Headers.Add("X-VTEX-API-AppToken", _apiToken); + + var response = await _httpClient.SendAsync(request); + response.EnsureSuccessStatusCode(); + + return await response.Content.ReadAsStringAsync(); + } + } +} \ No newline at end of file From f783e4c323ee3462259ecd53c3080a39fafb86c0 Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2024 00:25:07 +0000 Subject: [PATCH 02/14] Update Src/VTEXFeedV3Config.cs --- Src/VTEXFeedV3Config.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 Src/VTEXFeedV3Config.cs diff --git a/Src/VTEXFeedV3Config.cs b/Src/VTEXFeedV3Config.cs new file mode 100644 index 000000000..59f3df6f8 --- /dev/null +++ b/Src/VTEXFeedV3Config.cs @@ -0,0 +1,15 @@ +namespace VTEXIntegration +{ + public static class VTEXFeedV3Config + { + // Replace with your actual VTEX API key + public const string ApiKey = "YOUR_API_KEY"; + + // Replace with your actual VTEX API token + public const string ApiToken = "YOUR_API_TOKEN"; + + // VTEX account name + public const string AccountName = "your-account"; + + } +} From ff9b51b2234dd09d2736c575e47f5fce7383661f Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2024 00:25:43 +0000 Subject: [PATCH 03/14] Update Src/VTEXFeedV3Integration.cs --- Src/VTEXFeedV3Integration.cs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Src/VTEXFeedV3Integration.cs b/Src/VTEXFeedV3Integration.cs index 29caecd4a..e091e93f2 100644 --- a/Src/VTEXFeedV3Integration.cs +++ b/Src/VTEXFeedV3Integration.cs @@ -23,10 +23,22 @@ public async Task GetFeedOrderStatus1Async() request.Headers.Add("X-VTEX-API-AppKey", _apiKey); request.Headers.Add("X-VTEX-API-AppToken", _apiToken); - var response = await _httpClient.SendAsync(request); - response.EnsureSuccessStatusCode(); + try + { + var response = await _httpClient.SendAsync(request); + response.EnsureSuccessStatusCode(); - return await response.Content.ReadAsStringAsync(); + var content = await response.Content.ReadAsStringAsync(); + if (string.IsNullOrWhiteSpace(content)) + { + throw new Exception("Received empty response from VTEX API."); + } + return content; + } + catch (HttpRequestException e) + { + throw new Exception("Error fetching order status from VTEX API.", e); + } } } -} \ No newline at end of file +} From 8808ce64027fc1230d41df6f86f79a900d4ffd0f Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2024 00:25:57 +0000 Subject: [PATCH 04/14] Update Tests/VTEXFeedV3IntegrationTest.cs --- Tests/VTEXFeedV3IntegrationTest.cs | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Tests/VTEXFeedV3IntegrationTest.cs diff --git a/Tests/VTEXFeedV3IntegrationTest.cs b/Tests/VTEXFeedV3IntegrationTest.cs new file mode 100644 index 000000000..0a791f2dd --- /dev/null +++ b/Tests/VTEXFeedV3IntegrationTest.cs @@ -0,0 +1,42 @@ +using System; +using System.Threading.Tasks; +using Xunit; + +namespace VTEXIntegration.Tests +{ + public class VTEXFeedV3IntegrationTest + { + [Fact] + public async Task GetFeedOrderStatus1Async_ValidResponse_ReturnsContent() + { + // Arrange + var integration = new VTEXFeedV3Integration("validApiKey", "validApiToken"); + + // Act + var result = await integration.GetFeedOrderStatus1Async(); + + // Assert + Assert.False(string.IsNullOrWhiteSpace(result), "Expected non-empty response content."); + } + + [Fact] + public async Task GetFeedOrderStatus1Async_InvalidCredentials_ThrowsException() + { + // Arrange + var integration = new VTEXFeedV3Integration("invalidApiKey", "invalidApiToken"); + + // Act & Assert + await Assert.ThrowsAsync(async () => await integration.GetFeedOrderStatus1Async()); + } + + [Fact] + public async Task GetFeedOrderStatus1Async_EmptyResponse_ThrowsException() + { + // Arrange + var integration = new VTEXFeedV3Integration("validApiKey", "validApiToken"); + + // Act & Assert + await Assert.ThrowsAsync(async () => await integration.GetFeedOrderStatus1Async()); + } + } +} From 4ba0e8a762d7beffcd37afee7f1b92e8578fa956 Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2024 00:26:33 +0000 Subject: [PATCH 05/14] Update README.md --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 79c4d7f5c..9e54c0cec 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,24 @@ Console.WriteLine("Sequence: {1} | Value: {0} | ", order.Value, order.Sequence); ``` +### VTEX Feed V3 API Integration + +To integrate with the VTEX Feed V3 API and retrieve order status information, use the `VTEXFeedV3Integration` class. + +```cs +using VTEXIntegration; + +var integration = new VTEXFeedV3Integration(VTEXFeedV3Config.ApiKey, VTEXFeedV3Config.ApiToken); + +try +{ + var orderStatus = await integration.GetFeedOrderStatus1Async(); + Console.WriteLine("Order Status: " + orderStatus); +} +catch (Exception ex) +{ + Console.WriteLine("Error: " + ex.Message); + --- ## Support From 4a7277810d3eaeabc1bcd87b9a2b87cf915007ea Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Thu, 7 Nov 2024 00:26:49 +0000 Subject: [PATCH 06/14] [CodeFactor] Apply fixes --- Src/VTEXFeedV3Config.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Src/VTEXFeedV3Config.cs b/Src/VTEXFeedV3Config.cs index 59f3df6f8..445ada52b 100644 --- a/Src/VTEXFeedV3Config.cs +++ b/Src/VTEXFeedV3Config.cs @@ -10,6 +10,5 @@ public static class VTEXFeedV3Config // VTEX account name public const string AccountName = "your-account"; - } } From dc0a44dbdd756bf92aa0a2aed745b0ca765c9a0f Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2024 00:27:40 +0000 Subject: [PATCH 07/14] Update Tests/VTEXFeedV3IntegrationTest.cs --- Tests/VTEXFeedV3IntegrationTest.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Tests/VTEXFeedV3IntegrationTest.cs b/Tests/VTEXFeedV3IntegrationTest.cs index 0a791f2dd..db0a14f0e 100644 --- a/Tests/VTEXFeedV3IntegrationTest.cs +++ b/Tests/VTEXFeedV3IntegrationTest.cs @@ -26,7 +26,9 @@ public async Task GetFeedOrderStatus1Async_InvalidCredentials_ThrowsException() var integration = new VTEXFeedV3Integration("invalidApiKey", "invalidApiToken"); // Act & Assert - await Assert.ThrowsAsync(async () => await integration.GetFeedOrderStatus1Async()); + await Assert.ThrowsAsync( + async () => await integration.GetFeedOrderStatus1Async() + ); } [Fact] From 89aee534044f645cd3d07e186cc8f4ffe338d950 Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2024 00:27:46 +0000 Subject: [PATCH 08/14] Update Src/VTEXFeedV3Integration.cs --- Src/VTEXFeedV3Integration.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Src/VTEXFeedV3Integration.cs b/Src/VTEXFeedV3Integration.cs index e091e93f2..48aaa104f 100644 --- a/Src/VTEXFeedV3Integration.cs +++ b/Src/VTEXFeedV3Integration.cs @@ -19,7 +19,9 @@ public VTEXFeedV3Integration(string apiKey, string apiToken) public async Task GetFeedOrderStatus1Async() { - var request = new HttpRequestMessage(HttpMethod.Get, "https://api.vtex.com/your-account/feed/orders/status"); + var request = new HttpRequestMessage( + HttpMethod.Get, + "https://api.vtex.com/your-account/feed/orders/status" request.Headers.Add("X-VTEX-API-AppKey", _apiKey); request.Headers.Add("X-VTEX-API-AppToken", _apiToken); From 614ff560493a9164e8243a0b56e6484c2aa55588 Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2024 00:27:56 +0000 Subject: [PATCH 09/14] Update Src/VTEXFeedV3Config.cs --- Src/VTEXFeedV3Config.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Src/VTEXFeedV3Config.cs b/Src/VTEXFeedV3Config.cs index 445ada52b..4c3e8f39a 100644 --- a/Src/VTEXFeedV3Config.cs +++ b/Src/VTEXFeedV3Config.cs @@ -10,5 +10,4 @@ public static class VTEXFeedV3Config // VTEX account name public const string AccountName = "your-account"; - } } From 4f968f814ffdc625167c347099d2034b0744e70b Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2024 00:28:34 +0000 Subject: [PATCH 10/14] Update Tests/VTEXFeedV3IntegrationTest.cs --- Tests/VTEXFeedV3IntegrationTest.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Tests/VTEXFeedV3IntegrationTest.cs b/Tests/VTEXFeedV3IntegrationTest.cs index db0a14f0e..5ee7e6831 100644 --- a/Tests/VTEXFeedV3IntegrationTest.cs +++ b/Tests/VTEXFeedV3IntegrationTest.cs @@ -38,7 +38,9 @@ public async Task GetFeedOrderStatus1Async_EmptyResponse_ThrowsException() var integration = new VTEXFeedV3Integration("validApiKey", "validApiToken"); // Act & Assert - await Assert.ThrowsAsync(async () => await integration.GetFeedOrderStatus1Async()); + await Assert.ThrowsAsync( + async () => await integration.GetFeedOrderStatus1Async() + ); } } } From 30dd95428af56bdee29e0d05dc8a7454e0bb2e73 Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2024 00:28:39 +0000 Subject: [PATCH 11/14] Update Src/VTEXFeedV3Integration.cs --- Src/VTEXFeedV3Integration.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Src/VTEXFeedV3Integration.cs b/Src/VTEXFeedV3Integration.cs index 48aaa104f..8cb4364b2 100644 --- a/Src/VTEXFeedV3Integration.cs +++ b/Src/VTEXFeedV3Integration.cs @@ -22,6 +22,7 @@ public async Task GetFeedOrderStatus1Async() var request = new HttpRequestMessage( HttpMethod.Get, "https://api.vtex.com/your-account/feed/orders/status" + ); request.Headers.Add("X-VTEX-API-AppKey", _apiKey); request.Headers.Add("X-VTEX-API-AppToken", _apiToken); From b3246a1f5bb6c0c4278e7a9638ff223f7a8a44fb Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2024 00:30:21 +0000 Subject: [PATCH 12/14] Update Src/VTEXFeedV3Config.cs --- Src/VTEXFeedV3Config.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Src/VTEXFeedV3Config.cs b/Src/VTEXFeedV3Config.cs index 4c3e8f39a..9cc8cedef 100644 --- a/Src/VTEXFeedV3Config.cs +++ b/Src/VTEXFeedV3Config.cs @@ -3,10 +3,10 @@ namespace VTEXIntegration public static class VTEXFeedV3Config { // Replace with your actual VTEX API key - public const string ApiKey = "YOUR_API_KEY"; + public static string ApiKey => Environment.GetEnvironmentVariable("VTEX_API_KEY") ?? throw new ArgumentNullException("VTEX_API_KEY"); // Replace with your actual VTEX API token - public const string ApiToken = "YOUR_API_TOKEN"; + public static string ApiToken => Environment.GetEnvironmentVariable("VTEX_API_TOKEN") ?? throw new ArgumentNullException("VTEX_API_TOKEN"); // VTEX account name public const string AccountName = "your-account"; From ee140ac3ea075866d351ac06a3141f99de9b0f13 Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2024 00:30:35 +0000 Subject: [PATCH 13/14] Update .github/workflows/ci.yml --- .github/workflows/ci.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..fc92e56fe --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,28 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + env: + VTEX_API_KEY: ${{ secrets.VTEX_API_KEY }} + VTEX_API_TOKEN: ${{ secrets.VTEX_API_TOKEN }} + steps: + - uses: actions/checkout@v2 + - name: Setup .NET + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '6.0.x' + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore + - name: Test + run: dotnet test --no-build --verbosity normal From 8097f5b940e23fb973bffae1921466fa6291e9ba Mon Sep 17 00:00:00 2001 From: "gitauto-ai[bot]" <161652217+gitauto-ai[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2024 00:31:34 +0000 Subject: [PATCH 14/14] Update .github/workflows/ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fc92e56fe..66bd44e97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: '6.0.x' + dotnet-version: '8.0.x' - name: Restore dependencies run: dotnet restore - name: Build