Improved the overall documentation for the public and internal types in the package.
This commit is contained in:
@@ -16,18 +16,18 @@ import Foundation
|
||||
import OpenAPIRuntime
|
||||
import OpenAPIURLSession
|
||||
|
||||
/// A type that implements a live client to the online service.
|
||||
/// A type that implements a live client to the [Amiibo API](https://www.amiiboapi.org) online service.
|
||||
public struct AmiiboLiveClient: Sendable {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// A client generated by the `OpenAPIRuntime` library.
|
||||
/// A client generated by the OpenAPI Runtime library to perform API calls.
|
||||
private let client: Client
|
||||
|
||||
// MARK: Initializers
|
||||
|
||||
/// Initializes this client.
|
||||
/// - Parameter transport: A transport that performs HTTP operations.
|
||||
/// Initializes this client with a transport for performing HTTP operations.
|
||||
/// - Parameter transport: A transport that performs HTTP operations. Defaults to a `URLSessionTransport` using the shared session.
|
||||
public init(transport: any ClientTransport = URLSessionTransport()) {
|
||||
self.client = .init(
|
||||
// The force unwrapping implemented below assumes that the server definition from the OpenAPI specification is correct.
|
||||
@@ -415,9 +415,9 @@ private extension AmiiboLiveClient {
|
||||
}
|
||||
}
|
||||
|
||||
/// Maps a given error to a `AmiiboServiceError` error.
|
||||
/// Maps a given error to an ``AmiiboServiceError`` error.
|
||||
/// - Parameter error: An error to map.
|
||||
/// - Throws: An ``AmiiboServiceError`` error.
|
||||
/// - Throws: An ``AmiiboServiceError`` error that corresponds to the given error.
|
||||
func handle(error: any Error) throws -> Never {
|
||||
switch error {
|
||||
case is CancellationError:
|
||||
|
||||
@@ -14,19 +14,19 @@
|
||||
|
||||
/// A representation of all the possible errors that the ``AmiiboService`` service could throw.
|
||||
public enum AmiiboServiceError: Error {
|
||||
/// A bad request has been given to the client.
|
||||
/// The request was malformed or contained invalid filter parameters.
|
||||
case badRequest
|
||||
/// A call to an endpoint has been cancelled by the user.
|
||||
/// The request was cancelled before a response was received.
|
||||
case cancelled
|
||||
/// A response cannot be decoded.
|
||||
/// The response body could not be decoded into the expected model.
|
||||
case decoding
|
||||
/// An online service is not currently available.
|
||||
/// The backend service is currently unreachable due to a network or server issue.
|
||||
case notAvailable
|
||||
/// A response cannot be found.
|
||||
/// No results were found matching the given filter criteria.
|
||||
case notFound
|
||||
/// An undocumented/unsupported status code error.
|
||||
/// The server returned an undocumented HTTP status code.
|
||||
case undocumented(_ statusCode: Int)
|
||||
/// An unknown error.
|
||||
/// An unexpected error that does not fall into any other category.
|
||||
case unknown
|
||||
}
|
||||
|
||||
|
||||
@@ -19,34 +19,34 @@ public struct Amiibo: Sendable, Hashable {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// A game character.
|
||||
/// The name of the game character associated with this amiibo.
|
||||
public let gameCharacter: String
|
||||
|
||||
/// A game series.
|
||||
/// The name of the game series associated with this amiibo.
|
||||
public let gameSeries: String
|
||||
|
||||
/// The first 8 hexadecimal characters of an identifier.
|
||||
/// The first 8 hexadecimal characters of the amiibo identifier.
|
||||
public let head: String
|
||||
|
||||
/// An image link.
|
||||
/// A URL string pointing to the image of this amiibo.
|
||||
public let image: String
|
||||
|
||||
/// An amiibo name.
|
||||
/// The name of this amiibo.
|
||||
public let name: String
|
||||
|
||||
/// A game platform type, if any.
|
||||
/// The game platform data for this amiibo, if available.
|
||||
public let platform: Platform?
|
||||
|
||||
/// A release date.
|
||||
/// The release dates of this amiibo across different regions.
|
||||
public let release: Release
|
||||
|
||||
/// An amiibo series.
|
||||
/// The name of the amiibo series this amiibo belongs to.
|
||||
public let series: String
|
||||
|
||||
/// The last 8 hexadecimal characters of an identifier.
|
||||
/// The last 8 hexadecimal characters of the amiibo identifier.
|
||||
public let tail: String
|
||||
|
||||
/// An amiibo type.
|
||||
/// The type of this amiibo (e.g., Figure, Card, Yarn, Band).
|
||||
public let type: String
|
||||
|
||||
// MARK: Initializers
|
||||
@@ -73,12 +73,12 @@ public struct Amiibo: Sendable, Hashable {
|
||||
|
||||
// MARK: Computed
|
||||
|
||||
/// An identifier.
|
||||
/// The full 16-character hexadecimal identifier, composed of the ``head`` and ``tail``.
|
||||
public var identifier: String {
|
||||
head + tail
|
||||
}
|
||||
|
||||
/// A URL related to an image link, if any.
|
||||
/// A URL constructed from the ``image`` string, if valid.
|
||||
public var imageURL: URL? {
|
||||
.init(string: image)
|
||||
}
|
||||
|
||||
@@ -18,13 +18,13 @@ extension Amiibo {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// A list of identifiers.
|
||||
/// A list of game identifiers associated with this game.
|
||||
public let identifiers: [String]
|
||||
|
||||
/// A name.
|
||||
/// The name of this game.
|
||||
public let name: String
|
||||
|
||||
/// A list of amiibo usages, if any.
|
||||
/// A list of amiibo usages within this game, if available.
|
||||
public let usages: [Usage]?
|
||||
|
||||
// MARK: Initializers
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
// ===----------------------------------------------------------------------===
|
||||
|
||||
extension Amiibo {
|
||||
/// A model that represents a collection of `Switch`, `Switch 2`, `3DS`, and `WiiU` games related to an amiibo.
|
||||
/// A model that represents a collection of `Switch`, `Switch 2`, `3DS`, and `Wii U` games related to an amiibo.
|
||||
public struct Platform: Sendable, Hashable {
|
||||
|
||||
// MARK: Properties
|
||||
@@ -27,7 +27,7 @@ extension Amiibo {
|
||||
/// A list of `3DS` games related to an amiibo.
|
||||
public let threeDS: [Game]
|
||||
|
||||
/// A list of `WiiU` games related to an amiibo.
|
||||
/// A list of `Wii U` games related to an amiibo.
|
||||
public let wiiU: [Game]
|
||||
|
||||
// MARK: Initializers
|
||||
@@ -40,7 +40,7 @@ extension Amiibo {
|
||||
/// - switch: A list of `Switch` games related to an amiibo, if any.
|
||||
/// - switch2: A list of `Switch 2` games related to an amiibo, if any.
|
||||
/// - threeDS: A list of `3DS` games related to an amiibo, if any.
|
||||
/// - wiiU: A list of `WiiU` games related to an amiibo, if any.
|
||||
/// - wiiU: A list of `Wii U` games related to an amiibo, if any.
|
||||
init?(
|
||||
_ `switch`: [Components.Schemas.AmiiboGame]?,
|
||||
_ switch2: [Components.Schemas.AmiiboGame]?,
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
import Foundation
|
||||
|
||||
extension Amiibo {
|
||||
/// A model that represents a collection of release dates related to an amiibo.
|
||||
/// A model that represents the regional release dates of an amiibo.
|
||||
public struct Release: Sendable, Hashable {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
@@ -18,10 +18,10 @@ extension Amiibo {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// An explanation of how to use an amiibo.
|
||||
/// A description of how the amiibo is used within the game.
|
||||
public let explanation: String
|
||||
|
||||
/// A flag that indicates whether an amiibo can save game data in it.
|
||||
/// A flag that indicates whether the amiibo can save game data.
|
||||
public let isWriteable: Bool
|
||||
|
||||
// MARK: Initializers
|
||||
|
||||
@@ -17,10 +17,10 @@ public struct AmiiboSeries: KeyNameModel {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// An amiibo series key.
|
||||
/// The hexadecimal key that uniquely identifies this amiibo series.
|
||||
public let key: String
|
||||
|
||||
/// An amiibo series name.
|
||||
/// The name of this amiibo series.
|
||||
public let name: String
|
||||
|
||||
// MARK: Initializers
|
||||
|
||||
@@ -17,10 +17,10 @@ public struct AmiiboType: KeyNameModel {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// An amiibo type key.
|
||||
/// The hexadecimal key that uniquely identifies this amiibo type.
|
||||
public let key: String
|
||||
|
||||
/// An amiibo type name.
|
||||
/// The name of this amiibo type (e.g., Figure, Card, Yarn, Band).
|
||||
public let name: String
|
||||
|
||||
// MARK: Initializers
|
||||
|
||||
@@ -17,10 +17,10 @@ public struct GameCharacter: KeyNameModel {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// A game character key.
|
||||
/// The hexadecimal key that uniquely identifies this game character.
|
||||
public let key: String
|
||||
|
||||
/// A game character name.
|
||||
/// The name of this game character.
|
||||
public let name: String
|
||||
|
||||
// MARK: Initializers
|
||||
|
||||
@@ -17,10 +17,10 @@ public struct GameSeries: KeyNameModel {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// A game series key.
|
||||
/// The hexadecimal key that uniquely identifies this game series.
|
||||
public let key: String
|
||||
|
||||
/// A game series name.
|
||||
/// The name of this game series.
|
||||
public let name: String
|
||||
|
||||
// MARK: Initializers
|
||||
|
||||
Reference in New Issue
Block a user