Skip to content

Commit fcdc9c0

Browse files
committed
feat: Publication operations / Lite documentation
1 parent 9e0c042 commit fcdc9c0

18 files changed

+910
-96
lines changed

Directory.Packages.props

+3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
<ItemGroup>
1010
<PackageVersion Include="Ben.Demystifier" Version="0.4.1" />
1111
<PackageVersion Include="BenchmarkDotNet" Version="0.13.7" />
12+
<PackageVersion Include="BlazorStatic" Version="1.0.0-beta.4" />
1213
<PackageVersion Include="FluentValidation" Version="11.6.0" />
1314
<PackageVersion Include="MinVer" Version="4.3.0" />
15+
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.2" />
16+
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.2" />
1417
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="$(DotNet8Version)" />
1518
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="$(DotNet8Version)" />
1619
<PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="$(DotNet8Version)" />

IssuuSDK.sln

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
5151
EndProject
5252
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "apps", "apps", "{4ECCC480-8768-433D-8064-FEC3BA1D16A5}"
5353
EndProject
54-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IssuuSDK.ConsoleSample", "apps\IssuuSDK.ConsoleSample\IssuuSDK.ConsoleSample.csproj", "{51DA3FE9-F207-4478-BC23-22CB55A22365}"
54+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IssuuSDK.ConsoleSample", "apps\IssuuSDK.ConsoleSample\IssuuSDK.ConsoleSample.csproj", "{51DA3FE9-F207-4478-BC23-22CB55A22365}"
5555
EndProject
56-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IssuuSDK", "libs\IssuuSDK\IssuuSDK.csproj", "{758A0B86-53FF-4CF0-9F49-2F1330876569}"
56+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IssuuSDK", "libs\IssuuSDK\IssuuSDK.csproj", "{758A0B86-53FF-4CF0-9F49-2F1330876569}"
5757
EndProject
5858
Global
5959
GlobalSection(SolutionConfigurationPlatforms) = preSolution

README.md

+57-2
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,72 @@ The SDK is available as a NuGet package. You can install it using the following
1212
dotnet add package IssuuSDK
1313
```
1414

15+
## Authentication
16+
17+
This SDK does not currently provide the ability to **generate** an Issuu auth token. Please visit https://issuu.com/home/settings/apicredentials to generate an auth token.
18+
1519
## Usage
1620

1721
### .NET Core & .NET 5+
18-
TBC
22+
You can easily add the IssuuSDK to your project by referencing the NuGet package and adding the following configuration and service registration:
23+
24+
```json
25+
{
26+
"Issuu": {
27+
"Token": "<token-value>"
28+
}
29+
}
30+
```
31+
32+
```csharp
33+
services.AddIssuu();
34+
```
35+
36+
This will register a default per-request `IIssuuApiClient` instance in the service collection. You can then inject this into your services and use it to interact with the Issuu API.
1937

2038
### .NET Framework
2139

22-
TBC
40+
For use on .NET Framework would largely depend on your dependency injection strategy (if you use one).
41+
42+
You can easily create an instance of the `IssuuApiClient` class and use it to interact with the Issuu API.
43+
44+
```csharp
45+
var http = new HttpClient();ite d
46+
var client = new IssuuApiClient(http, new IssuuSettings());
47+
```
48+
49+
Or, alternatively through the API client factory:
50+
51+
```csharp
52+
var clientFactory = new IssuuApiClientFactory(new IssuuHttpClientFactory());
53+
var client = clientFactory.CreateClient(new IssuuSettings());
54+
```
55+
56+
**NOTE** - On .NET Framework, it is recommended to use a single instance of `HttpClient` for the lifetime of your application. This is because the `HttpClient` class is designed to be reused and not disposed of after each request.
57+
58+
A `IIssuuHttpClientFactory` can be implemented to manage the lifecycle of the `HttpClient` instance.
59+
60+
### Debugging
61+
62+
To aid in debugging results from the Issuu API, you can enable the following settings:
63+
64+
```json
65+
{
66+
"Issuu": {
67+
"CaptureRequestContent": true,
68+
"CaptureResponseContent": true
69+
}
70+
}
71+
```
72+
73+
These settings, when enabled will capture the request and response content for each API call, and the content of these will be available to the `IssuuResponse` as `RequestContent` and `ResponseContent` properties. The SDK will automatically map these results, but for unexpected results, it is useful to understand what has been sent/received.
2374

2475
## Open Source
2576

2677
This SDK is open source and is available under the MIT license. Feel free to contribute to the project by submitting pull requests or issues.
2778

79+
- .NET Platform by Microsoft and contributors - https://github.com/dotnet
80+
- Ben.Demystifier by Ben Adams - https://github.com/benaadams/Ben.Demystifier
81+
- FluentValidation by the Jeremy Skinner and contributors - https://github.com/FluentValidation/FluentValidation
82+
- MinVer by Adam Ralph and contributors - https://github.com/adamralph/minver
2883
- SlugGenerator by Artem Polishchuk - https://github.com/polischuk/SlugGenerator

libs/IssuuSDK/Api/IssuuApiClient.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ public partial interface IIssuuApiClient
1111
public partial class IssuuApiClient : ApiClient, IIssuuApiClient
1212
{
1313
public IssuuApiClient(HttpClient http, IssuuSettings settings)
14-
: base(http, settings, settings.BaseUrl) { }
14+
: base(http, settings) { }
1515
}
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// This work is licensed under the terms of the MIT license.
2+
// For a copy, see <https://opensource.org/licenses/MIT>.
3+
4+
namespace IssuuSDK.Api;
5+
6+
/// <summary>
7+
/// Provides factory methods for creating a Issuu API client.
8+
/// </summary>
9+
public interface IIssuuApiClientFactory
10+
{
11+
/// <summary>
12+
/// Creates a Issuu API client.
13+
/// </summary>
14+
/// <returns>The API settings.</returns>
15+
IIssuuApiClient CreateApiClient(IssuuSettings settings);
16+
}
17+
18+
public class IssuuApiClientFactory : IIssuuApiClientFactory
19+
{
20+
readonly IIssuuHttpClientFactory _httpClientFactory;
21+
22+
public IssuuApiClientFactory(IIssuuHttpClientFactory httpClientFactory) =>
23+
_httpClientFactory = Ensure.IsNotNull(httpClientFactory, nameof(httpClientFactory));
24+
25+
public IIssuuApiClient CreateApiClient(IssuuSettings settings)
26+
{
27+
Ensure.IsNotNull(settings, nameof(settings));
28+
29+
var http = _httpClientFactory.CreateHttpClient("Issuu");
30+
31+
return new IssuuApiClient(http, settings);
32+
}
33+
}

0 commit comments

Comments
 (0)