Updated the project documentation in the package.
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user