Updated the project documentation in the package.

This commit is contained in:
2026-03-23 00:20:44 +01:00
parent ee28f87d8d
commit 69d7681139
4 changed files with 143 additions and 5 deletions
@@ -0,0 +1,22 @@
# ``AmiiboService``
## Topics
### Initializers
- ``AmiiboService/init(client:)``
### Amiibo endpoints
- ``AmiiboService/getAmiibos(_:)``
- ``AmiiboService/getAmiiboSeries(_:)``
- ``AmiiboService/getAmiiboTypes(_:)``
### Game endpoints
- ``AmiiboService/getGameCharacters(_:)``
- ``AmiiboService/getGameSeries(_:)``
### System endpoints
- ``AmiiboService/getLastUpdated()``
@@ -0,0 +1,19 @@
# ``AmiiboServiceError``
## Topics
### Request errors
- ``AmiiboServiceError/badRequest``
- ``AmiiboServiceError/cancelled``
### Response errors
- ``AmiiboServiceError/decoding``
- ``AmiiboServiceError/notFound``
### Service errors
- ``AmiiboServiceError/notAvailable``
- ``AmiiboServiceError/undocumented(_:)``
- ``AmiiboServiceError/unknown``
@@ -72,6 +72,31 @@ This leverages HTTP cache headers from the server and persists cached responses
Alternatively, cache the results returned by ``AmiiboService`` directly in your application using any storage mechanism that fits your needs, such as an in-memory dictionary, a database, or a file-based store.
## Testing
The ``AmiiboClient`` protocol enables creating custom mock clients for testing, eliminating the need for network calls in unit tests. Conform to ``AmiiboClient`` and return stubbed data or throw ``AmiiboServiceError`` errors to verify your application's behavior:
```swift
import AmiiboService
struct MyMockClient: AmiiboClient {
var error: AmiiboServiceError?
func getAmiibos(
by filter: AmiiboFilter
) async throws(AmiiboServiceError) -> [Amiibo] {
if let error { throw error }
return []
}
// Implement remaining protocol requirements...
}
let service = AmiiboService(client: MyMockClient())
```
Inject the mock client into ``AmiiboService`` via its ``AmiiboService/init(client:)`` initializer to test how your code handles empty results, specific errors, or any other scenario without relying on the live backend.
## Tasks
This library offers a set of ready-to-use tasks that simplify the interaction with the library, which the developer can use from any `Terminal` application.