Documented the Amiibo model and its sub-models in the library target.
This commit is contained in:
@@ -20,7 +20,7 @@ public enum AmiiboServiceError: Error {
|
||||
case notAvailable
|
||||
/// A response cannot be found.
|
||||
case notFound
|
||||
/// An undocumented/unsupported error.
|
||||
/// An undocumented/unsupported status code error.
|
||||
case undocumented(_ statusCode: Int)
|
||||
/// An unknown error.
|
||||
case unknown
|
||||
|
||||
@@ -12,23 +12,45 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
/// A model that represents an amiibo item.
|
||||
public struct Amiibo: Sendable {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// A game character.
|
||||
public let gameCharacter: String
|
||||
|
||||
/// A game series.
|
||||
public let gameSeries: String
|
||||
|
||||
/// The first 8 hexadecimal characters of an identifier.
|
||||
public let head: String
|
||||
|
||||
/// An image link.
|
||||
public let image: String
|
||||
|
||||
/// An amiibo name.
|
||||
public let name: String
|
||||
|
||||
/// A game platform type, if any.
|
||||
public let platform: Platform?
|
||||
|
||||
/// A release date.
|
||||
public let release: Release
|
||||
|
||||
/// An amiibo series.
|
||||
public let series: String
|
||||
|
||||
/// The last 8 hexadecimal characters of an identifier.
|
||||
public let tail: String
|
||||
|
||||
/// An amiibo type.
|
||||
public let type: String
|
||||
|
||||
// MARK: Initialisers
|
||||
|
||||
// MARK: Initializers
|
||||
|
||||
/// Initializes this model from a given payload.
|
||||
/// - Parameter payload: A payload that contains the values for the model.
|
||||
init(_ payload: Components.Schemas.Amiibo) {
|
||||
self.gameCharacter = payload.character
|
||||
self.gameSeries = payload.gameSeries
|
||||
@@ -48,10 +70,12 @@ public struct Amiibo: Sendable {
|
||||
|
||||
// MARK: Computed
|
||||
|
||||
/// An identifier.
|
||||
public var identifier: String {
|
||||
head + tail
|
||||
}
|
||||
|
||||
/// A URL related to an image link, if any.
|
||||
public var imageURL: URL? {
|
||||
.init(string: image)
|
||||
}
|
||||
|
||||
@@ -11,16 +11,24 @@
|
||||
//===----------------------------------------------------------------------===
|
||||
|
||||
extension Amiibo {
|
||||
/// A model that represents a game related to an amiibo item.
|
||||
public struct Game: Sendable {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// A list of identifiers.
|
||||
public let identifiers: [String]
|
||||
|
||||
/// A name.
|
||||
public let name: String
|
||||
|
||||
/// A list of amiibo usages, if any.
|
||||
public let usages: [Usage]?
|
||||
|
||||
// MARK: Initialisers
|
||||
|
||||
// MARK: Initializers
|
||||
|
||||
/// Initializes this model from a given payload.
|
||||
/// - Parameter payload: A payload that contains the values for the model.
|
||||
init(_ payload: Components.Schemas.AmiiboGame) {
|
||||
self.identifiers = payload.gameID
|
||||
self.name = payload.gameName
|
||||
|
||||
@@ -11,16 +11,30 @@
|
||||
//===----------------------------------------------------------------------===
|
||||
|
||||
extension Amiibo {
|
||||
/// A model that represents a collection of `WiiU`, `3DS`, and `Switch` games related to an amiibo item.
|
||||
public struct Platform: Sendable {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// A list of `Switch` games related to an amiibo item.
|
||||
public let `switch`: [Game]
|
||||
|
||||
/// A list of `3DS` games related to an amiibo item.
|
||||
public let threeDS: [Game]
|
||||
|
||||
/// A list of `WiiU` games related to an amiibo item.
|
||||
public let wiiU: [Game]
|
||||
|
||||
// MARK: Initialisers
|
||||
|
||||
/// Initializes this model.
|
||||
///
|
||||
/// > important: In case no data is provided, then an instance of this model is not created.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - `switch`: A list of `Switch` games related to an amiibo item, if any.
|
||||
/// - threeDS: A list of `3DS` games related to an amiibo item, if any.
|
||||
/// - wiiU: A list of `WiiU` games related to an amiibo item, if any.
|
||||
init?(
|
||||
_ `switch`: [Components.Schemas.AmiiboGame]?,
|
||||
_ threeDS: [Components.Schemas.AmiiboGame]?,
|
||||
|
||||
@@ -13,17 +13,27 @@
|
||||
import Foundation
|
||||
|
||||
extension Amiibo {
|
||||
/// A model that represents a collection of release dates related to an amiibo item.
|
||||
public struct Release: Sendable {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// A release date for North America, if any.
|
||||
public let america: Date?
|
||||
|
||||
/// A release date for Australia, if any.
|
||||
public let australia: Date?
|
||||
|
||||
/// A release date for Europe, if any.
|
||||
public let europe: Date?
|
||||
|
||||
/// A release date for Japan, if any.
|
||||
public let japan: Date?
|
||||
|
||||
// MARK: Initialisers
|
||||
|
||||
// MARK: Initializers
|
||||
|
||||
/// Initializes this model from a given payload.
|
||||
/// - Parameter payload: A payload that contains the values for the model.
|
||||
init(_ payload: Components.Schemas.AmiiboRelease) {
|
||||
self.america = payload.na
|
||||
self.australia = payload.au
|
||||
|
||||
@@ -11,15 +11,21 @@
|
||||
//===----------------------------------------------------------------------===
|
||||
|
||||
extension Amiibo {
|
||||
/// A model that represents the usage of an amiibo item within a certain game.
|
||||
public struct Usage: Sendable {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// An explanation of how to use an amiibo item.
|
||||
public let explanation: String
|
||||
|
||||
/// A flag that indicates whether an amiibo item can save game data in it.
|
||||
public let isWriteable: Bool
|
||||
|
||||
// MARK: Initialisers
|
||||
|
||||
// MARK: Initializers
|
||||
|
||||
/// Initializes this model from a given payload.
|
||||
/// - Parameter payload: A payload that contains the values for the model.
|
||||
init(_ payload: Components.Schemas.AmiiboUsage) {
|
||||
self.explanation = payload.Usage
|
||||
self.isWriteable = payload.write
|
||||
|
||||
Reference in New Issue
Block a user