Skip to content

Commit

Permalink
refactor: dtos structure imporved
Browse files Browse the repository at this point in the history
  • Loading branch information
onurkanbakirci committed Dec 17, 2023
1 parent d772f70 commit 9ee9796
Show file tree
Hide file tree
Showing 74 changed files with 861 additions and 766 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/integration-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ jobs:
- name: Push nuget package to github registry
uses: ./.github/workflows/composite/publish-lib
with:
package_source: ${{env.github_registry_url}}
package_source: ${{ env.github_registry_url }}
path: ${{ env.project_path }}
nupkg_path: ${{env.nupkg_path}}
nupkg_path: ${{ env.nupkg_path }}
api_key: ${{ env.nupkg_github_secret }}

publish_lib_to_nuget:
Expand All @@ -87,7 +87,7 @@ jobs:
- name: Push nuget package to nuget registry
uses: ./.github/workflows/composite/publish-lib
with:
package_source: ${{env.nuget_registry_url}}
package_source: ${{ env.nuget_registry_url }}
path: ${{ env.project_path }}
nupkg_path: ${{env.nupkg_path}}
nupkg_path: ${{ env.nupkg_path }}
api_key: ${{ env.nupkg_nuget_secret }}
8 changes: 4 additions & 4 deletions .github/workflows/trendyol-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ jobs:
- name: Push nuget package to github registry
uses: ./.github/workflows/composite/publish-lib
with:
package_source: ${{env.github_registry_url}}
package_source: ${{ env.github_registry_url }}
path: ${{ env.project_path }}
nupkg_path: ${{env.nupkg_path}}
nupkg_path: ${{ env.nupkg_path }}
api_key: ${{ env.nupkg_github_secret }}

publish_lib_to_nuget:
Expand All @@ -88,7 +88,7 @@ jobs:
- name: Push nuget package to nuget registry
uses: ./.github/workflows/composite/publish-lib
with:
package_source: ${{env.nuget_registry_url}}
package_source: ${{ env.nuget_registry_url }}
path: ${{ env.project_path }}
nupkg_path: ${{env.nupkg_path}}
nupkg_path: ${{ env.nupkg_path }}
api_key: ${{ env.nupkg_nuget_secret }}
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Enhance your integration workflows by leveraging the Integration Library, which
- [Introduction](#introduction)
- [How to install](#how-to-install)
- [How to use](#how-to-use)
- [Trendyol](#trendyol)
- [Hepsiburada](#hepsiburada)


## Introduction
Expand All @@ -35,6 +37,8 @@ dotnet add package Integration.Marketplaces.Trendyol --version 1.0.0

## How to use

### Trendyol

```c#
using Integration.Marketplaces.Trendyol.Infrastructure.ProductIntegration;
using Integration.Marketplaces.Trendyol.Infrastructure.ProductIntegration.Helpers;
Expand All @@ -45,7 +49,7 @@ var trendyolProductIntegration = new TrendyolProductIntegration("supplierId", "a
var categories = trendyolProductIntegration.GetCategoryTreeAsync();

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

//Filter products
var productFilter = new ProductFilterBuilder()
Expand All @@ -59,4 +63,6 @@ var productFilter = new ProductFilterBuilder()
.Build();

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

### Hepsiburada
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
var categories = trendyolProductIntegration.GetCategoryTreeAsync();

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

//Filter products
var productFilter = new ProductFilterBuilder()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace Integration.Core;
public class BulkDto<T> : IDto
public class BulkModel<T> : IRequestModel, IResponseModel
{
public List<T> Items { get; set; }

Check warning on line 4 in src/Integration.Core/BulkModel.cs

View workflow job for this annotation

GitHub Actions / Build Lib

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

Check warning on line 4 in src/Integration.Core/BulkModel.cs

View workflow job for this annotation

GitHub Actions / Build Lib

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

Check warning on line 4 in src/Integration.Core/BulkModel.cs

View workflow job for this annotation

GitHub Actions / Build Lib

Non-nullable property 'Items' must contain a non-null value when exiting constructor. Consider declaring the property as nullable.
}
4 changes: 0 additions & 4 deletions src/Integration.Core/IDto.cs

This file was deleted.

4 changes: 4 additions & 0 deletions src/Integration.Core/IRequestModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
namespace Integration.Core;
public class IRequestModel : IModel
{
}
4 changes: 4 additions & 0 deletions src/Integration.Core/IResponseModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
namespace Integration.Core;
public interface IResponseModel : IModel
{
}
10 changes: 5 additions & 5 deletions src/Integration.Core/IntegrationBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ static IntegrationBase()
_httpClient = new HttpClient();
}

public async Task<TResponse> InvokeRequestAsync<TResponse>(Func<HttpClient, Task<HttpResponseMessage>> httpRequest)
public async Task<TResponse> InvokeRequestAsync<TResponse>(Func<HttpClient, Task<HttpResponseMessage>> httpRequest) where TResponse : IResponseModel
{
var response = await httpRequest.Invoke(_httpClient);
var responseAsString = await response.Content.ReadAsStringAsync();
Expand All @@ -32,9 +32,9 @@ public async Task<bool> InvokeRequestAsync(Func<HttpClient, Task<HttpResponseMes
return isSuccess;
}

public async Task<TResponse> InvokeRequestAsync<TResponse>(Func<HttpClient, StringContent?, Task<HttpResponseMessage>> httpRequest, IDto dto)
public async Task<TResponse> InvokeRequestAsync<TResponse>(Func<HttpClient, StringContent?, Task<HttpResponseMessage>> httpRequest, IRequestModel requestModel) where TResponse : IResponseModel
{
var jsonData = JsonSerializer.Serialize(dto);
var jsonData = JsonSerializer.Serialize(requestModel);
var requestBody = new StringContent(jsonData, Encoding.UTF8, "application/json");

var response = await httpRequest.Invoke(_httpClient, requestBody);
Expand All @@ -45,9 +45,9 @@ public async Task<TResponse> InvokeRequestAsync<TResponse>(Func<HttpClient, Stri
return JsonSerializer.Deserialize<TResponse>(responseAsString)!;
}

public async Task<bool> InvokeRequestAsync(Func<HttpClient, StringContent?, Task<HttpResponseMessage>> httpRequest, IDto dto)
public async Task<bool> InvokeRequestAsync(Func<HttpClient, StringContent?, Task<HttpResponseMessage>> httpRequest, IRequestModel requestModel)
{
var jsonData = JsonSerializer.Serialize(dto);
var jsonData = JsonSerializer.Serialize(requestModel);
var requestBody = new StringContent(jsonData, Encoding.UTF8, "application/json");

var response = await httpRequest.Invoke(_httpClient, requestBody);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
namespace Integration.Core;
public class PaginationDto : IDto
public class PaginationModel : IResponseModel
{
public int TotalElements { get; set; }
public int TotalPages { get; set; }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Integration.Core;

namespace Integration.Marketplaces.Trendyol.Infrastructure;
public class HepsiburadaIntegrationBase : IntegrationBase
{
public const string ProdBaseUrl = "https://mpop-sit.hepsiburada.com/";
public const string StageBaseUrl = "https://mpop-sit.hepsiburada.com/";
protected readonly string _username;
protected readonly string _password;
protected readonly bool _isInProduction;

public HepsiburadaIntegrationBase(string username, string password, bool isInProduction = true)
{
_username = username ?? throw new ArgumentNullException(nameof(username));
_password = password ?? throw new ArgumentNullException(nameof(password));
_isInProduction = isInProduction;
}

public string GetBaseUrl() => _isInProduction ? ProdBaseUrl : StageBaseUrl;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Integration.Core;
using Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration;
using Integration.Marketplaces.Trendyol.Infrastructure;

public class HepsiburadaProductIntegration : HepsiburadaIntegrationBase, IHepsiburadaProductIntegration, IMarketplaceIntegration
{
public HepsiburadaProductIntegration(string username, string password, bool isInProduction = true) : base(username, password, isInProduction)
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace Integration.Marketplaces.Hepsiburada.Infrastructure.ProductIntegration;
public interface IHepsiburadaProductIntegration
{

}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 9ee9796

Please sign in to comment.