Skip to content

Commit

Permalink
refactor: hepsiburada methods added
Browse files Browse the repository at this point in the history
  • Loading branch information
onurkanbakirci committed Dec 21, 2023
1 parent b217774 commit c5ac3c0
Show file tree
Hide file tree
Showing 13 changed files with 202 additions and 16 deletions.
7 changes: 7 additions & 0 deletions Integration.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Marketplaces", "Marketplace
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrendyolIntegrationSampleConsoleApp", "samples\Marketplaces\TrendyolIntegrationSampleConsoleApp\TrendyolIntegrationSampleConsoleApp.csproj", "{E2A95CF6-3420-43FB-836F-FB8FCB0ABF5A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HepsiburadaIntegrationSampleConsoleApp", "samples\Marketplaces\HepsiburadaIntegrationSampleConsoleApp\HepsiburadaIntegrationSampleConsoleApp.csproj", "{1EA1F383-84B1-47DD-BB85-E0CE2F0AC207}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -44,6 +46,10 @@ Global
{E2A95CF6-3420-43FB-836F-FB8FCB0ABF5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E2A95CF6-3420-43FB-836F-FB8FCB0ABF5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E2A95CF6-3420-43FB-836F-FB8FCB0ABF5A}.Release|Any CPU.Build.0 = Release|Any CPU
{1EA1F383-84B1-47DD-BB85-E0CE2F0AC207}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1EA1F383-84B1-47DD-BB85-E0CE2F0AC207}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1EA1F383-84B1-47DD-BB85-E0CE2F0AC207}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1EA1F383-84B1-47DD-BB85-E0CE2F0AC207}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{2E841AED-7444-4875-8D11-D756A01105FD} = {8D1AC917-32E3-4579-9A06-B6190C1B9F31}
Expand All @@ -52,5 +58,6 @@ Global
{D80122E8-72B1-4B86-A277-4FD3BAC21FB4} = {E2F4960B-14E1-40D3-9A7B-8528FA989D0F}
{6A70107C-D16B-4588-817E-11731CAEDB71} = {51C29F15-6693-428D-9705-1986F8C71428}
{E2A95CF6-3420-43FB-836F-FB8FCB0ABF5A} = {6A70107C-D16B-4588-817E-11731CAEDB71}
{1EA1F383-84B1-47DD-BB85-E0CE2F0AC207} = {6A70107C-D16B-4588-817E-11731CAEDB71}
EndGlobalSection
EndGlobal
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ var trendyolProductIntegration = new TrendyolProductIntegration(
entegratorFirm: "entegratorFirm");

//Get All Categories
var categories = trendyolProductIntegration.GetCategoryTreeAsync();
var categories = await trendyolProductIntegration.GetCategoryTreeAsync();

//Get All Brands
var brands = trendyolProductIntegration.GetBrandsAsync();
var brands = await trendyolProductIntegration.GetBrandsAsync();

//Filter products
var productFilter = new ProductFilterBuilder()
Expand All @@ -66,11 +66,27 @@ var productFilter = new ProductFilterBuilder()
.AddSupplierId(0)
.Build();

var products = trendyolProductIntegration.FilterProductsAsync(productFilter);
var products = await trendyolProductIntegration.FilterProductsAsync(productFilter);
```

### Hepsiburada

```
dotnet add package Integration.Marketplaces.Hepsiburada --version 1.0.0
```

```c#
var hepsiburadaProductIntegration = new HepsiburadaProductIntegration(
username: "username",
password: "password",
isInProduction: false);

//Get All Categories
var categories = await hepsiburadaProductIntegration.GetCategoriesAsync();

//Get Category Attributes
var categoryAttributes = await hepsiburadaProductIntegration.GetCategoryAttributesAsync(categoryId: 80844002);

// Get Category Attribute Values
var categoryAttributeValues = await hepsiburadaProductIntegration.GetCategoryAttributeValuesAsync(categoryId: 80844002, attributeId: "gram");
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference
Include="..\..\..\src\Marketplaces\Integration.Marketplaces.Hepsiburada\Integration.Marketplaces.Hepsiburada.csproj" />
</ItemGroup>


</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var hepsiburadaProductIntegration = new HepsiburadaProductIntegration(
username: "username",
password: "password",
isInProduction: false);

//Get All Categories
var categories = await hepsiburadaProductIntegration.GetCategoriesAsync();

//Get Category Attributes
var categoryAttributes = await hepsiburadaProductIntegration.GetCategoryAttributesAsync(categoryId: 80844002);

// Get Category Attribute Values
var categoryAttributeValues = await hepsiburadaProductIntegration.GetCategoryAttributeValuesAsync(categoryId: 80844002, attributeId: "gram");

Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
entegratorFirm: "entegratorFirm");

//Get All Categories
var categories = trendyolProductIntegration.GetCategoryTreeAsync();
var categories = await trendyolProductIntegration.GetCategoryTreeAsync();

//Get All Brands
var brands = trendyolProductIntegration.GetBrandsAsync();
var brands = await trendyolProductIntegration.GetBrandsAsync();

//Filter products
var productFilter = new ProductFilterBuilder()
Expand All @@ -25,4 +25,4 @@
.AddSupplierId(0)
.Build();

var products = trendyolProductIntegration.FilterProductsAsync(productFilter);
var products = await trendyolProductIntegration.FilterProductsAsync(productFilter);
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@
<ProjectReference Include="..\..\..\src\Marketplaces\Integration.Marketplaces.Trendyol\Integration.Marketplaces.Trendyol.csproj" />
</ItemGroup>


</Project>
Original file line number Diff line number Diff line change
@@ -1,10 +1,45 @@
using Integration.Core;
using Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration;
using Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Response;
using Integration.Marketplaces.Trendyol.Infrastructure;

public class HepsiburadaProductIntegration : HepsiburadaIntegrationBase, IHepsiburadaProductIntegration, IMarketplaceIntegration
{
private string GetCategoriesUrl() => $"{GetBaseUrl}product/api/categories/get-all-categories";
private string GetCategoryAttributesUrl(int categoryId) => $"{GetBaseUrl}product/api/categories/{categoryId}/attributes";
private string GetCategoryAttributeValueUrl(int categoryId, string attributeId) => $"{GetBaseUrl}product/api/categories/{categoryId}/attribute/{attributeId}/v";

public HepsiburadaProductIntegration(string username, string password, bool isInProduction = true) : base(username, password, isInProduction)
{
}

/// <summary>
/// <inheritdoc/>
/// </summary>
/// <returns><inheritdoc/></returns>
public async Task<GetCategoriesResponseModel> GetCategoriesAsync()
{
return await InvokeRequestAsync<GetCategoriesResponseModel>((client) => client.GetAsync(GetCategoriesUrl()));
}

/// <summary>
/// <inheritdoc/>
/// </summary>
/// <param name="categoryId"><inheritdoc/></param>
/// <returns><inheritdoc/></returns>
public async Task<GetCategoryAttributesResponseModel> GetCategoryAttributesAsync(int categoryId)
{
return await InvokeRequestAsync<GetCategoryAttributesResponseModel>((client) => client.GetAsync(GetCategoryAttributesUrl(categoryId)));
}

/// <summary>
/// <inheritdoc/>
/// </summary>
/// <param name="categoryId"><inheritdoc/></param>
/// <param name="attributeId"><inheritdoc/></param>
/// <returns><inheritdoc/></returns>
public async Task<GetCategoryAttributeValuesResponseModel> GetCategoryAttributeValuesAsync(int categoryId, string attributeId)
{
return await InvokeRequestAsync<GetCategoryAttributeValuesResponseModel>((client) => client.GetAsync(GetCategoryAttributeValueUrl(categoryId, attributeId)));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
using Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Response;

namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration;
public interface IHepsiburadaProductIntegration
{
/// <summary>
/// Bu metod ile Hepsiburada kategorileri bilgilerini alabilirsiniz.
/// </summary>
/// <returns><see cref="GetCategoriesResponseModel"/></returns>
public Task<GetCategoriesResponseModel> GetCategoriesAsync();

/// <summary>
/// Bu metod ile Hepsiburada’ daki uç kategorilerin özellik bilgilerini alabilirsiniz.
/// Kategori özellikleri, sadece ‘leaf’ ve ‘available’ değerleri ‘true’ olan kategorilerde mevcuttur.
/// </summary>
/// <returns><see cref="GetCategoryAttributesResponseModel"/></returns>
public Task<GetCategoryAttributesResponseModel> GetCategoryAttributesAsync(int categoryId);

/// <summary>
/// Bu metod ile ‘type’ alanı değeri ‘enum’ olan özellikler için kullanılabilecek değerleri alabilirsiniz.
/// </summary>
/// <param name="categoryId">Category id</param>
/// <param name="attributeId">Attribute id</param>
/// <returns><see cref="GetCategoryAttributeValuesResponseModel"/></returns>
public Task<GetCategoryAttributeValuesResponseModel> GetCategoryAttributeValuesAsync(int categoryId, string attributeId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Integration.Core;

namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Response;

public class GetCategoriesResponseModel : HepsiburadaBaseResponseModel
{
public List<GetCategoryResponseModel> Data { get; set; }

Check warning on line 7 in src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoriesResponseModel.cs

View workflow job for this annotation

GitHub Actions / Build Lib

Non-nullable property 'Data' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
}

public class GetCategoryResponseModel : IResponseModel
{
public int CategoryId { get; set; }
public string Name { get; set; }

Check warning on line 13 in src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoriesResponseModel.cs

View workflow job for this annotation

GitHub Actions / Build Lib

Non-nullable property 'Name' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public string DisplayName { get; set; }

Check warning on line 14 in src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoriesResponseModel.cs

View workflow job for this annotation

GitHub Actions / Build Lib

Non-nullable property 'DisplayName' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public int ParentCategoryId { get; set; }
public List<string> Paths { get; set; }

Check warning on line 16 in src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoriesResponseModel.cs

View workflow job for this annotation

GitHub Actions / Build Lib

Non-nullable property 'Paths' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public bool Leaf { get; set; }
public string Status { get; set; }

Check warning on line 18 in src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoriesResponseModel.cs

View workflow job for this annotation

GitHub Actions / Build Lib

Non-nullable property 'Status' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public string Type { get; set; }

Check warning on line 19 in src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoriesResponseModel.cs

View workflow job for this annotation

GitHub Actions / Build Lib

Non-nullable property 'Type' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public string SortId { get; set; }
public bool Available { get; set; }
public List<GetCategoryProductTypeResponseModel> ProductTypes { get; set; }
public bool Merge { get; set; }
}

public class GetCategoryProductTypeResponseModel : IResponseModel
{
public string Name { get; set; }

Check warning on line 28 in src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoriesResponseModel.cs

View workflow job for this annotation

GitHub Actions / Build Lib

Non-nullable property 'Name' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
public int ProductTypeId { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Integration.Core;

namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Response;

public class GetCategoryAttributeValuesResponseModel : HepsiburadaBaseResponseModel
{
public List<GetCategoryAttributeValueResponseModel> Data { get; set; }
}

public class GetCategoryAttributeValueResponseModel : IResponseModel
{
public string Value { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Integration.Core;

namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Response;

public class GetCategoryAttributesResponseModel : HepsiburadaBaseResponseModel
{
public List<GetCategoryAttributesMappingResponseModel> Data { get; set; }

Check warning on line 7 in src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoryAttributesResponseModel.cs

View workflow job for this annotation

GitHub Actions / Build Lib

Non-nullable property 'Data' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
}

public class GetCategoryAttributesMappingResponseModel : IResponseModel
{
public List<GetCategoryAttributeResponseModel> BaseAttributes { get; set; }
public List<GetCategoryAttributeResponseModel> Attributes { get; set; }
public List<GetCategoryAttributeResponseModel> VariantAttributes { get; set; }
}

public class GetCategoryAttributeResponseModel : IResponseModel
{
public string Id { get; set; }
public string Name { get; set; }
public bool Mandatory { get; set; }
public string Type { get; set; }
public bool MultiValue { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Integration.Core;

namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Response;
public class HepsiburadaBaseResponseModel : IResponseModel
{
public bool Success { get; set; }
public int Code { get; set; }
public int Version { get; set; }
public string Message { get; set; }

Check warning on line 9 in src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/HepsiburadaBaseResponseModel.cs

View workflow job for this annotation

GitHub Actions / Build Lib

Non-nullable property 'Message' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public interface ITrendyolProductIntegration
/// firmasından farklı olmamalıdır. Bu durum ürünlerinizi
/// yayına çıkmasını engelleyecektir.
/// </summary>
/// <returns><see cref="GetProviderResponseModel"/></returns>
public List<GetProviderResponseModel> GetProviders();

/// <summary>
Expand All @@ -28,7 +29,7 @@ public interface ITrendyolProductIntegration
/// Marka araması yaparken servise page parametresini kullanarak query
/// oluşturmanız gerekmektedir.
/// </summary>
/// <returns></returns>
/// <returns><see cref="GetBrandsResponseModel"/></returns>
public Task<GetBrandsResponseModel?> GetBrandsAsync();

/// <summary>
Expand All @@ -40,7 +41,7 @@ public interface ITrendyolProductIntegration
/// Yeni kategoriler eklenebileceği sebebiyle güncel kategori listesini
/// haftalık olarak almanızı öneririz.
/// </summary>
/// <returns></returns>
/// <returns><see cref="GetCategoryTreeResponseModel"/></returns>
public Task<GetCategoryTreeResponseModel?> GetCategoryTreeAsync();

/// <summary>
Expand All @@ -53,7 +54,7 @@ public interface ITrendyolProductIntegration
/// özellik listesini haftalık olarak almanızı öneririz.
/// </summary>
/// <param name="categoryId">Category id</param>
/// <returns></returns>
/// <returns><see cref="GetCategoryAttributesResponseModel"/></returns>
public Task<GetCategoryAttributesResponseModel?> GetCategoryAttributes(int categoryId);

/// <summary>
Expand All @@ -62,7 +63,7 @@ public interface ITrendyolProductIntegration
/// kullanılarak alınacaktır.
/// </summary>
/// <param name="products"></param>
/// <returns>bool</returns>
/// <returns><see cref="bool"/></returns>
public Task<bool> CreateProductsV2Async(BulkModel<CreateProductRequestModel> products);

/// <summary>
Expand All @@ -80,7 +81,7 @@ public interface ITrendyolProductIntegration
/// Onaylı ürünlerde productMainId değeri güncellenmemektedir.
/// </summary>
/// <param name="products"></param>
/// <returns></returns>
/// <returns><see cref="bool"/></returns>
public Task<bool> UpdateProductAsync(BulkModel<UpdateProductRequestModel> products);

/// <summary>
Expand All @@ -96,7 +97,7 @@ public interface ITrendyolProductIntegration
/// Ürünleriniz için maksimum 20 Bin adet stok ekleyebilirsiniz.
/// </summary>
/// <param name="products"></param>
/// <returns></returns>
/// <returns><see cref="bool"/></returns>
public Task<bool> UpdatePriceAndInventoryAsync(BulkModel<UpdateStockAndPriceRequestModel> products);

/// <summary>
Expand All @@ -106,7 +107,7 @@ public interface ITrendyolProductIntegration
/// Trendyol tarafından satışa durdurulmamış onaylı ürünlerinizi silebilirsiniz.
/// </summary>
/// <param name="products"></param>
/// <returns></returns>
/// <returns><see cref="bool"/></returns>
public Task<bool> DeleteProductsAsync(BulkModel<DeleteProductRequestModel> products);

/// <summary>
Expand All @@ -123,13 +124,13 @@ public interface ITrendyolProductIntegration
/// status alanlarını kontrol etmeniz gerekmektedir. Batch status alanı tarafınıza dönmeyecektir.
/// </summary>
/// <param name="batchRequestId"></param>
/// <returns></returns>
/// <returns><see cref="bool"/></returns>
public Task<GetBatchRequestResultResponseModel> GetBatchRequestResultAsync(string batchRequestId);

/// <summary>
/// Bu servis ile Trendyol mağazanızdaki ürünlerinizi listeleyebilirsiniz.
/// </summary>
/// <param name="filterQuery"></param>
/// <returns></returns>
/// <returns><see cref="bool"/></returns>
public Task<FilterProductsResponseModel?> FilterProductsAsync(string filterQuery);
}

0 comments on commit c5ac3c0

Please sign in to comment.