From c5ac3c09db8ac2f943d34dd71dfb456f0fead17b Mon Sep 17 00:00:00 2001 From: onurkanbakirci Date: Thu, 21 Dec 2023 12:02:51 +0300 Subject: [PATCH] refactor: hepsiburada methods added --- Integration.sln | 7 ++++ README.md | 22 ++++++++++-- ...siburadaIntegrationSampleConsoleApp.csproj | 16 +++++++++ .../Program.cs | 14 ++++++++ .../Program.cs | 6 ++-- ...TrendyolIntegrationSampleConsoleApp.csproj | 1 - .../HepsiburadaProductIntegration.cs | 35 +++++++++++++++++++ .../IHepsiburadaProductIntegration.cs | 21 +++++++++++ .../Response/GetCategoriesResponseModel.cs | 30 ++++++++++++++++ ...GetCategoryAttributeValuesResponseModel.cs | 13 +++++++ .../GetCategoryAttributesResponseModel.cs | 24 +++++++++++++ .../Response/HepsiburadaBaseResponseModel.cs | 10 ++++++ .../ITrendyolProductIntegration.cs | 19 +++++----- 13 files changed, 202 insertions(+), 16 deletions(-) create mode 100644 samples/Marketplaces/HepsiburadaIntegrationSampleConsoleApp/HepsiburadaIntegrationSampleConsoleApp.csproj create mode 100644 samples/Marketplaces/HepsiburadaIntegrationSampleConsoleApp/Program.cs create mode 100644 src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoriesResponseModel.cs create mode 100644 src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoryAttributeValuesResponseModel.cs create mode 100644 src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoryAttributesResponseModel.cs create mode 100644 src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/HepsiburadaBaseResponseModel.cs diff --git a/Integration.sln b/Integration.sln index 022bd78..caa959b 100644 --- a/Integration.sln +++ b/Integration.sln @@ -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 @@ -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} @@ -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 diff --git a/README.md b/README.md index 646cc11..4e52ba4 100644 --- a/README.md +++ b/README.md @@ -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() @@ -66,7 +66,7 @@ var productFilter = new ProductFilterBuilder() .AddSupplierId(0) .Build(); -var products = trendyolProductIntegration.FilterProductsAsync(productFilter); +var products = await trendyolProductIntegration.FilterProductsAsync(productFilter); ``` ### Hepsiburada @@ -74,3 +74,19 @@ var products = trendyolProductIntegration.FilterProductsAsync(productFilter); ``` 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"); +``` diff --git a/samples/Marketplaces/HepsiburadaIntegrationSampleConsoleApp/HepsiburadaIntegrationSampleConsoleApp.csproj b/samples/Marketplaces/HepsiburadaIntegrationSampleConsoleApp/HepsiburadaIntegrationSampleConsoleApp.csproj new file mode 100644 index 0000000..2a380d1 --- /dev/null +++ b/samples/Marketplaces/HepsiburadaIntegrationSampleConsoleApp/HepsiburadaIntegrationSampleConsoleApp.csproj @@ -0,0 +1,16 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + + \ No newline at end of file diff --git a/samples/Marketplaces/HepsiburadaIntegrationSampleConsoleApp/Program.cs b/samples/Marketplaces/HepsiburadaIntegrationSampleConsoleApp/Program.cs new file mode 100644 index 0000000..c5fd0d2 --- /dev/null +++ b/samples/Marketplaces/HepsiburadaIntegrationSampleConsoleApp/Program.cs @@ -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"); + diff --git a/samples/Marketplaces/TrendyolIntegrationSampleConsoleApp/Program.cs b/samples/Marketplaces/TrendyolIntegrationSampleConsoleApp/Program.cs index 7a62ad1..71d8c1d 100644 --- a/samples/Marketplaces/TrendyolIntegrationSampleConsoleApp/Program.cs +++ b/samples/Marketplaces/TrendyolIntegrationSampleConsoleApp/Program.cs @@ -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() @@ -25,4 +25,4 @@ .AddSupplierId(0) .Build(); -var products = trendyolProductIntegration.FilterProductsAsync(productFilter); \ No newline at end of file +var products = await trendyolProductIntegration.FilterProductsAsync(productFilter); \ No newline at end of file diff --git a/samples/Marketplaces/TrendyolIntegrationSampleConsoleApp/TrendyolIntegrationSampleConsoleApp.csproj b/samples/Marketplaces/TrendyolIntegrationSampleConsoleApp/TrendyolIntegrationSampleConsoleApp.csproj index 07742ac..5f69f29 100644 --- a/samples/Marketplaces/TrendyolIntegrationSampleConsoleApp/TrendyolIntegrationSampleConsoleApp.csproj +++ b/samples/Marketplaces/TrendyolIntegrationSampleConsoleApp/TrendyolIntegrationSampleConsoleApp.csproj @@ -11,5 +11,4 @@ - diff --git a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/HepsiburadaProductIntegration.cs b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/HepsiburadaProductIntegration.cs index 607379f..4dd06a4 100644 --- a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/HepsiburadaProductIntegration.cs +++ b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/HepsiburadaProductIntegration.cs @@ -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) { } + + /// + /// + /// + /// + public async Task GetCategoriesAsync() + { + return await InvokeRequestAsync((client) => client.GetAsync(GetCategoriesUrl())); + } + + /// + /// + /// + /// + /// + public async Task GetCategoryAttributesAsync(int categoryId) + { + return await InvokeRequestAsync((client) => client.GetAsync(GetCategoryAttributesUrl(categoryId))); + } + + /// + /// + /// + /// + /// + /// + public async Task GetCategoryAttributeValuesAsync(int categoryId, string attributeId) + { + return await InvokeRequestAsync((client) => client.GetAsync(GetCategoryAttributeValueUrl(categoryId, attributeId))); + } } \ No newline at end of file diff --git a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/IHepsiburadaProductIntegration.cs b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/IHepsiburadaProductIntegration.cs index 071cb60..cda0432 100644 --- a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/IHepsiburadaProductIntegration.cs +++ b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/IHepsiburadaProductIntegration.cs @@ -1,5 +1,26 @@ +using Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Response; + namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration; public interface IHepsiburadaProductIntegration { + /// + /// Bu metod ile Hepsiburada kategorileri bilgilerini alabilirsiniz. + /// + /// + public Task GetCategoriesAsync(); + + /// + /// Bu metod ile Hepsiburada’ daki uç kategorilerin özellik bilgilerini alabilirsiniz. + /// Kategori özellikleri, sadece ‘leaf’ ve ‘available’ değerleri ‘true’ olan kategorilerde mevcuttur. + /// + /// + public Task GetCategoryAttributesAsync(int categoryId); + /// + /// Bu metod ile ‘type’ alanı değeri ‘enum’ olan özellikler için kullanılabilecek değerleri alabilirsiniz. + /// + /// Category id + /// Attribute id + /// + public Task GetCategoryAttributeValuesAsync(int categoryId, string attributeId); } \ No newline at end of file diff --git a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoriesResponseModel.cs b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoriesResponseModel.cs new file mode 100644 index 0000000..548c54e --- /dev/null +++ b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoriesResponseModel.cs @@ -0,0 +1,30 @@ +using Integration.Core; + +namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Response; + +public class GetCategoriesResponseModel : HepsiburadaBaseResponseModel +{ + public List Data { get; set; } +} + +public class GetCategoryResponseModel : IResponseModel +{ + public int CategoryId { get; set; } + public string Name { get; set; } + public string DisplayName { get; set; } + public int ParentCategoryId { get; set; } + public List Paths { get; set; } + public bool Leaf { get; set; } + public string Status { get; set; } + public string Type { get; set; } + public string SortId { get; set; } + public bool Available { get; set; } + public List ProductTypes { get; set; } + public bool Merge { get; set; } +} + +public class GetCategoryProductTypeResponseModel : IResponseModel +{ + public string Name { get; set; } + public int ProductTypeId { get; set; } +} \ No newline at end of file diff --git a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoryAttributeValuesResponseModel.cs b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoryAttributeValuesResponseModel.cs new file mode 100644 index 0000000..4c51080 --- /dev/null +++ b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoryAttributeValuesResponseModel.cs @@ -0,0 +1,13 @@ +using Integration.Core; + +namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Response; + +public class GetCategoryAttributeValuesResponseModel : HepsiburadaBaseResponseModel +{ + public List Data { get; set; } +} + +public class GetCategoryAttributeValueResponseModel : IResponseModel +{ + public string Value { get; set; } +} \ No newline at end of file diff --git a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoryAttributesResponseModel.cs b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoryAttributesResponseModel.cs new file mode 100644 index 0000000..a570622 --- /dev/null +++ b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/GetCategoryAttributesResponseModel.cs @@ -0,0 +1,24 @@ +using Integration.Core; + +namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration.Models.Response; + +public class GetCategoryAttributesResponseModel : HepsiburadaBaseResponseModel +{ + public List Data { get; set; } +} + +public class GetCategoryAttributesMappingResponseModel : IResponseModel +{ + public List BaseAttributes { get; set; } + public List Attributes { get; set; } + public List 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; } +} \ No newline at end of file diff --git a/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/HepsiburadaBaseResponseModel.cs b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/HepsiburadaBaseResponseModel.cs new file mode 100644 index 0000000..7c4be0e --- /dev/null +++ b/src/Marketplaces/Integration.Marketplaces.Hepsiburada/Infrastructure/ProductIntegration/Models/Response/HepsiburadaBaseResponseModel.cs @@ -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; } +} \ No newline at end of file diff --git a/src/Marketplaces/Integration.Marketplaces.Trendyol/Infrastructure/ProductIntegration/ITrendyolProductIntegration.cs b/src/Marketplaces/Integration.Marketplaces.Trendyol/Infrastructure/ProductIntegration/ITrendyolProductIntegration.cs index 1091cd4..2ab44c4 100644 --- a/src/Marketplaces/Integration.Marketplaces.Trendyol/Infrastructure/ProductIntegration/ITrendyolProductIntegration.cs +++ b/src/Marketplaces/Integration.Marketplaces.Trendyol/Infrastructure/ProductIntegration/ITrendyolProductIntegration.cs @@ -19,6 +19,7 @@ public interface ITrendyolProductIntegration /// firmasından farklı olmamalıdır. Bu durum ürünlerinizi /// yayına çıkmasını engelleyecektir. /// + /// public List GetProviders(); /// @@ -28,7 +29,7 @@ public interface ITrendyolProductIntegration /// Marka araması yaparken servise page parametresini kullanarak query /// oluşturmanız gerekmektedir. /// - /// + /// public Task GetBrandsAsync(); /// @@ -40,7 +41,7 @@ public interface ITrendyolProductIntegration /// Yeni kategoriler eklenebileceği sebebiyle güncel kategori listesini /// haftalık olarak almanızı öneririz. /// - /// + /// public Task GetCategoryTreeAsync(); /// @@ -53,7 +54,7 @@ public interface ITrendyolProductIntegration /// özellik listesini haftalık olarak almanızı öneririz. /// /// Category id - /// + /// public Task GetCategoryAttributes(int categoryId); /// @@ -62,7 +63,7 @@ public interface ITrendyolProductIntegration /// kullanılarak alınacaktır. /// /// - /// bool + /// public Task CreateProductsV2Async(BulkModel products); /// @@ -80,7 +81,7 @@ public interface ITrendyolProductIntegration /// Onaylı ürünlerde productMainId değeri güncellenmemektedir. /// /// - /// + /// public Task UpdateProductAsync(BulkModel products); /// @@ -96,7 +97,7 @@ public interface ITrendyolProductIntegration /// Ürünleriniz için maksimum 20 Bin adet stok ekleyebilirsiniz. /// /// - /// + /// public Task UpdatePriceAndInventoryAsync(BulkModel products); /// @@ -106,7 +107,7 @@ public interface ITrendyolProductIntegration /// Trendyol tarafından satışa durdurulmamış onaylı ürünlerinizi silebilirsiniz. /// /// - /// + /// public Task DeleteProductsAsync(BulkModel products); /// @@ -123,13 +124,13 @@ public interface ITrendyolProductIntegration /// status alanlarını kontrol etmeniz gerekmektedir. Batch status alanı tarafınıza dönmeyecektir. /// /// - /// + /// public Task GetBatchRequestResultAsync(string batchRequestId); /// /// Bu servis ile Trendyol mağazanızdaki ürünlerinizi listeleyebilirsiniz. /// /// - /// + /// public Task FilterProductsAsync(string filterQuery); } \ No newline at end of file