Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitAuto: [FEATURE] Implement Sales Channel API #350

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name: Build
@@ -10,1 +11,1 @@
- path: ''
path: 'Src'
3 changes: 3 additions & 0 deletions .github/workflows/deep-source.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ jobs:
name: Deep Source Coverage report
runs-on: ubuntu-latest
steps:
- name: Restore dependencies
run: dotnet restore

- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@ Implements all features of VTEX API available at [VTEX Developer Docs](https://d
## Usage

Use your VTEX platform API keys.
### Sales Channel API

The Sales Channel API allows you to manage and interact with various sales channels effectively. It provides endpoints for creating, reading, updating, and deleting sales channel data.

#### Example Usage

```cs
var vtex = new VTEXContext("store name", "app-key-xyz", "app-token-secret-hash");
var salesChannels = vtex.GetSalesChannels();
foreach (var channel in salesChannels)
{
Console.WriteLine($"Channel ID: {channel.Id}, Name: {channel.Name}");
}
```
Follow this tutorial on how to: [Creating appKeys and appTokens to authenticate integrations](https://help.vtex.com/tutorial/creating-appkeys-and-apptokens-to-authenticate-integrations--43tQeyQJgAKGEuCqQKAOI2)

```cs
Expand Down
14 changes: 14 additions & 0 deletions Src/VTEX/Database/SalesChannelSchema.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Microsoft.EntityFrameworkCore;

namespace VTEX.Database
{
public class SalesChannelSchema
{
public int Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public bool IsActive { get; set; }

// Additional fields and relationships can be added here
}
}
21 changes: 21 additions & 0 deletions Src/VTEX/SalesChannelApi.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace VTEX
{
[Route("api/[controller]")]
[ApiController]
public class SalesChannelApiController : ControllerBase
[Authorize]
{
// GET: api/SalesChannels
[HttpGet]
public IActionResult GetSalesChannels()
{
// Logic to get all sales channels
return Ok();
}

// Additional endpoints for POST, PUT, DELETE will be added here
}
}
22 changes: 22 additions & 0 deletions Src/VTEX/Services/SalesChannelService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Collections.Generic;
using VTEX.Database;

namespace VTEX.Services
{
public class SalesChannelService
{
public IEnumerable<SalesChannelSchema> GetAllSalesChannels()
{
// Logic to retrieve all sales channels from the database
return new List<SalesChannelSchema>();
}

public SalesChannelSchema GetSalesChannelById(int id)
{
// Logic to retrieve a specific sales channel by ID
return new SalesChannelSchema();
}

// Additional methods for creating, updating, and deleting sales channels
}
}
5 changes: 4 additions & 1 deletion Src/VTEX/VTEX.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<ProjectGuid>{D1E5B509-0934-4E15-B78D-D3A88AC8CB16}</ProjectGuid>
<TargetFrameworks>netstandard2.0;netstandard2.1;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<LangVersion>latest</LangVersion>
<Company>Guilherme Branco Stracini</Company>
Expand All @@ -26,6 +26,9 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0" />
<PackageReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
Expand Down
24 changes: 24 additions & 0 deletions Tests/VTEX.Tests/SalesChannelApiTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using VTEX.Services;
using Xunit;

namespace VTEX.Tests
{
public class SalesChannelApiTests
{
private readonly SalesChannelService _service;

public SalesChannelApiTests()
{
_service = new SalesChannelService();
}

[Fact]
public void TestGetAllSalesChannels()
{
var result = _service.GetAllSalesChannels();
Assert.NotNull(result);
}

// Additional tests for other endpoints
}
}
2 changes: 2 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
version: 2.3.{build}
skip_tags: true
image: Visual Studio 2022
environment:
SALES_CHANNEL_API_ENABLED: true
configuration: Release

environment:

Check warning on line 8 in appveyor.yml

View check run for this annotation

codefactor.io / CodeFactor

appveyor.yml#L8

Duplication of key "environment" in mapping. (key-duplicates)
CODACY_PROJECT_TOKEN:
secure: 8fnQaRryh/pMRB9NtqyX0M0FSfPYW8Rtl1zeYcMXLVaK0o1UC3EAynZSB6rze5wM
CODECLIMATE_TOKEN:
Expand Down
Loading