-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from kwtc/feature/project-structure-and-offer-s…
…earch Changed naming, extended interface and updated docs
- Loading branch information
Showing
8 changed files
with
113 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,48 @@ | ||
![.NET build and test](https://github.com/kwtc/tjek-client-dotnet/actions/workflows/ci.yml/badge.svg) | ||
|
||
# Kwtc.Tjek.Client.Dotnet | ||
Tjek.com API client for dotnet | ||
# Tjek.com .NET API client | ||
As the heading states this is a .NET API client for tjek.com | ||
|
||
> **Warning** | ||
> This is work in progress | ||
> | ||
> Minor and patch version bumps may break your code until version 1.0.0 is released | ||
## Supported endpoint status | ||
- [x] /v2/offers/search | ||
- [ ] /v2/offers | ||
- [ ] /v2/offers/{offerId} | ||
|
||
## How to use | ||
Add configuration to appsettings.json | ||
|
||
```json | ||
{ | ||
"TjekClientConfig": { | ||
"ApiKey": "<API_KEY>" | ||
} | ||
} | ||
``` | ||
An API key can be requested here: https://etilbudsavis.dk/developers | ||
|
||
The client project includes an extension method that makes registering the client and services in the DI container easy. | ||
|
||
```csharp | ||
builder.Services.AddTjekClientServices(builder.Configuration); | ||
``` | ||
|
||
After registering the services you can inject the client and configuration. | ||
|
||
```csharp | ||
public class MyService | ||
{ | ||
private readonly ITjekClient _tjekClient; | ||
private readonly TjekClientConfig _tjekClientConfig; | ||
|
||
public MyService(ITjekClient tjekClient, IOptions<TjekClientConfig> tjekClientConfig) | ||
{ | ||
_tjekClient = tjekClient; | ||
_tjekClientConfig = tjekClientConfig.Value; | ||
} | ||
} | ||
``` |
4 changes: 2 additions & 2 deletions
4
src/Kwtc.Tjek.Client/ClientConfig.cs → ...t.Abstractions/Config/TjekClientConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Kwtc.Tjek.Client.Abstractions.Models; | ||
|
||
namespace Kwtc.Tjek.Client.Abstractions; | ||
|
||
public interface ITjekClient | ||
{ | ||
/// <summary> | ||
/// Search for offers | ||
/// </summary> | ||
public Task<IReadOnlyList<Offer>> Search( | ||
string query, | ||
string? dealerId = null, | ||
string? catalogId = null, | ||
string? publicationType = null, | ||
int? limit = null, | ||
CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// NOT IMPLEMENTED | ||
/// | ||
/// Get list current offers | ||
/// </summary> | ||
public Task<IReadOnlyList<Offer>> List( | ||
string? dealerId = null, | ||
string? catalogId = null, | ||
string? publicationType = null, | ||
int? limit = null, | ||
int? offset = null, | ||
string? orderBy = null, | ||
CancellationToken cancellationToken = default); | ||
|
||
/// <summary> | ||
/// NOT IMPLEMENTED | ||
/// | ||
/// Get offer by id | ||
/// </summary> | ||
public Task<Offer?> Offer(string id, CancellationToken cancellationToken = default); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters