Skip to content

Commit 1b16a51

Browse files
committed
fix: Generic API service clients was missing
1 parent c447226 commit 1b16a51

8 files changed

Lines changed: 746 additions & 11 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ npm-debug.log*
229229
# =============================================================================
230230
# DocFX
231231
_site/
232-
api/
233232
docfx.log
234233

235234
# =============================================================================

README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The BAUER GROUP Shared Platform is a modular, multi-project solution designed to
2020
- **Modular Architecture**: Pick only the packages you need
2121
- **Enterprise-Ready Logging**: NLog-based logging with Sentry integration for error tracking
2222
- **Data Layer**: Support for SQLite (encrypted), LiteDB, and in-memory databases
23-
- **API Integrations**: Pre-built connectors for e-commerce platforms and shipping providers
23+
- **API Integrations**: Pre-built API integrations for generic use
2424
- **Cloud Services**: Cloudinary integration for media management
2525
- **Desktop Components**: WPF/WinForms utilities with embedded Chromium browser support
2626
- **Reporting**: Stimulsoft Reports integration for professional reporting
@@ -33,7 +33,7 @@ The BAUER GROUP Shared Platform is a modular, multi-project solution designed to
3333
|---------|-------------------|-------------|
3434
| `BAUERGROUP.Shared.Core` | net10.0, net8.0, netstandard2.0 | Core utilities, extensions, logging (NLog + Sentry), error tracking |
3535
| `BAUERGROUP.Shared.Data` | net10.0, net8.0, netstandard2.0 | Data persistence: SQLite, LiteDB, in-memory database, caching |
36-
| `BAUERGROUP.Shared.API` | net10.0, net8.0, netstandard2.0 | E-commerce integrations: Shopify, Shopware 5/6, WooCommerce |
36+
| `BAUERGROUP.Shared.API` | net10.0, net8.0, netstandard2.0 | Generic API integrations |
3737
| `BAUERGROUP.Shared.API.Shipping` | net10.0, net8.0, netstandard2.0 | Shipping providers: DHL, DPD, GLS, Deutsche Post, UPS |
3838
| `BAUERGROUP.Shared.Cloud` | net10.0, net8.0 | Cloud services: Cloudinary media management |
3939
| `BAUERGROUP.Shared.Desktop` | net10.0-windows, net8.0-windows | WPF/WinForms utilities, behaviors, converters |
@@ -155,14 +155,13 @@ WPFToolboxBrowser.ChromeEmbeddedWebbrowserWindow(
155155
```
156156
BAUERGROUP.Shared.Plattform/
157157
├── src/
158-
│ ├── BAUERGROUP.Shared.Core/ # Core utilities & logging
159-
│ ├── BAUERGROUP.Shared.Data/ # Data persistence layer
160-
│ ├── BAUERGROUP.Shared.API/ # E-commerce integrations
161-
│ ├── BAUERGROUP.Shared.API.Shipping/ # Shipping provider APIs
162-
│ ├── BAUERGROUP.Shared.Cloud/ # Cloud service integrations
163-
│ ├── BAUERGROUP.Shared.Desktop/ # WPF/WinForms utilities
164-
│ ├── BAUERGROUP.Shared.Desktop.Browser/ # Embedded browser
165-
│ └── BAUERGROUP.Shared.Desktop.Reporting/ # Reporting components
158+
│ ├── BAUERGROUP.Shared.Core/ # Core utilities & logging
159+
│ ├── BAUERGROUP.Shared.Data/ # Data persistence layer
160+
│ ├── BAUERGROUP.Shared.API/ # Generic API integrations
161+
│ ├── BAUERGROUP.Shared.Cloud/ # Cloud service integrations
162+
│ ├── BAUERGROUP.Shared.Desktop/ # WPF/WinForms utilities
163+
│ ├── BAUERGROUP.Shared.Desktop.Browser/ # Embedded browser
164+
│ └── BAUERGROUP.Shared.Desktop.Reporting/ # Reporting components
166165
├── tests/
167166
│ └── BAUERGROUP.Shared.Tests/ # Unit tests
168167
├── assets/

src/BAUERGROUP.Shared.API/API/GenericAPIClient.cs

Lines changed: 388 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace BAUERGROUP.Shared.API.API
6+
{
7+
/// <summary>
8+
/// Represents errors that occur during API client operations.
9+
/// </summary>
10+
public class GenericAPIClientException : Exception
11+
{
12+
/// <summary>
13+
/// Initializes a new instance of the <see cref="GenericAPIClientException"/> class.
14+
/// </summary>
15+
public GenericAPIClientException()
16+
: base()
17+
{
18+
19+
}
20+
21+
/// <summary>
22+
/// Initializes a new instance of the <see cref="GenericAPIClientException"/> class with a specified error message.
23+
/// </summary>
24+
/// <param name="message">The message that describes the error.</param>
25+
public GenericAPIClientException(String message)
26+
: base(message)
27+
{
28+
29+
}
30+
31+
/// <summary>
32+
/// Initializes a new instance of the <see cref="GenericAPIClientException"/> class with a specified error message and a reference to the inner exception.
33+
/// </summary>
34+
/// <param name="message">The message that describes the error.</param>
35+
/// <param name="innerException">The exception that is the cause of the current exception.</param>
36+
public GenericAPIClientException(String message, Exception innerException)
37+
: base(message, innerException)
38+
{
39+
40+
}
41+
}
42+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace BAUERGROUP.Shared.API.API
6+
{
7+
/// <summary>
8+
/// Specifies the HTTP method to use for API requests.
9+
/// </summary>
10+
public enum GenericAPIClientMethod
11+
{
12+
/// <summary>
13+
/// HTTP GET method for retrieving resources.
14+
/// </summary>
15+
GET,
16+
17+
/// <summary>
18+
/// HTTP POST method for creating resources.
19+
/// </summary>
20+
POST,
21+
22+
/// <summary>
23+
/// HTTP PUT method for updating resources.
24+
/// </summary>
25+
PUT,
26+
27+
/// <summary>
28+
/// HTTP DELETE method for removing resources.
29+
/// </summary>
30+
DELETE
31+
}
32+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
using BAUERGROUP.Shared.API.API;
2+
3+
namespace BAUERGROUP.Shared.Plattform.Test.API;
4+
5+
public class GenericAPIClientExceptionTests
6+
{
7+
[Fact]
8+
public void Constructor_Default_CreatesException()
9+
{
10+
var exception = new GenericAPIClientException();
11+
12+
exception.Should().NotBeNull();
13+
exception.Message.Should().NotBeNullOrEmpty();
14+
}
15+
16+
[Fact]
17+
public void Constructor_WithMessage_SetsMessage()
18+
{
19+
var message = "Test error message";
20+
21+
var exception = new GenericAPIClientException(message);
22+
23+
exception.Message.Should().Be(message);
24+
}
25+
26+
[Fact]
27+
public void Constructor_WithMessageAndInnerException_SetsBoth()
28+
{
29+
var message = "Outer error";
30+
var innerException = new InvalidOperationException("Inner error");
31+
32+
var exception = new GenericAPIClientException(message, innerException);
33+
34+
exception.Message.Should().Be(message);
35+
exception.InnerException.Should().Be(innerException);
36+
}
37+
38+
[Fact]
39+
public void InnerException_CanBeAccessed()
40+
{
41+
var inner = new ArgumentException("Inner");
42+
var exception = new GenericAPIClientException("Outer", inner);
43+
44+
exception.InnerException.Should().BeOfType<ArgumentException>();
45+
exception.InnerException!.Message.Should().Be("Inner");
46+
}
47+
48+
[Fact]
49+
public void IsException_DerivesFromException()
50+
{
51+
var exception = new GenericAPIClientException();
52+
53+
exception.Should().BeAssignableTo<Exception>();
54+
}
55+
56+
[Fact]
57+
public void CanBeThrown_AndCaught()
58+
{
59+
Action action = () => throw new GenericAPIClientException("Test throw");
60+
61+
action.Should().Throw<GenericAPIClientException>()
62+
.WithMessage("Test throw");
63+
}
64+
65+
[Fact]
66+
public void CanBeCaughtAsException()
67+
{
68+
Action action = () => throw new GenericAPIClientException("Generic catch");
69+
70+
action.Should().Throw<Exception>();
71+
}
72+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using BAUERGROUP.Shared.API.API;
2+
3+
namespace BAUERGROUP.Shared.Plattform.Test.API;
4+
5+
public class GenericAPIClientMethodTests
6+
{
7+
[Fact]
8+
public void Enum_HasGetValue()
9+
{
10+
Enum.IsDefined(typeof(GenericAPIClientMethod), GenericAPIClientMethod.GET).Should().BeTrue();
11+
}
12+
13+
[Fact]
14+
public void Enum_HasPostValue()
15+
{
16+
Enum.IsDefined(typeof(GenericAPIClientMethod), GenericAPIClientMethod.POST).Should().BeTrue();
17+
}
18+
19+
[Fact]
20+
public void Enum_HasPutValue()
21+
{
22+
Enum.IsDefined(typeof(GenericAPIClientMethod), GenericAPIClientMethod.PUT).Should().BeTrue();
23+
}
24+
25+
[Fact]
26+
public void Enum_HasDeleteValue()
27+
{
28+
Enum.IsDefined(typeof(GenericAPIClientMethod), GenericAPIClientMethod.DELETE).Should().BeTrue();
29+
}
30+
31+
[Fact]
32+
public void Enum_HasFourValues()
33+
{
34+
var values = Enum.GetValues(typeof(GenericAPIClientMethod));
35+
values.Length.Should().Be(4);
36+
}
37+
38+
[Fact]
39+
public void Enum_CanBeConvertedToString()
40+
{
41+
GenericAPIClientMethod.GET.ToString().Should().Be("GET");
42+
GenericAPIClientMethod.POST.ToString().Should().Be("POST");
43+
GenericAPIClientMethod.PUT.ToString().Should().Be("PUT");
44+
GenericAPIClientMethod.DELETE.ToString().Should().Be("DELETE");
45+
}
46+
47+
[Fact]
48+
public void Enum_CanBeParsedFromString()
49+
{
50+
var parsed = Enum.Parse<GenericAPIClientMethod>("GET");
51+
parsed.Should().Be(GenericAPIClientMethod.GET);
52+
}
53+
54+
[Theory]
55+
[InlineData(GenericAPIClientMethod.GET, 0)]
56+
[InlineData(GenericAPIClientMethod.POST, 1)]
57+
[InlineData(GenericAPIClientMethod.PUT, 2)]
58+
[InlineData(GenericAPIClientMethod.DELETE, 3)]
59+
public void Enum_HasExpectedIntValues(GenericAPIClientMethod method, int expectedValue)
60+
{
61+
((int)method).Should().Be(expectedValue);
62+
}
63+
}

0 commit comments

Comments
 (0)