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