From ff7637ed62eb15617680560a0f8a900af71413bd Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sun, 23 Apr 2023 13:59:36 +0200 Subject: [PATCH] Written the documentation for the Amiibo model. --- Sources/Models/Amiibo.swift | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Sources/Models/Amiibo.swift b/Sources/Models/Amiibo.swift index 4a7ef2b..5725f26 100644 --- a/Sources/Models/Amiibo.swift +++ b/Sources/Models/Amiibo.swift @@ -1,22 +1,54 @@ +/// This model struct represents an amiibo that is retrieved from the respective [remote API endpoint](https://www.amiiboapi.com/docs/#amiibo). public struct Amiibo { + + // MARK: Properties + + /// The type the amiibo belongs to. public let type: String + + /// The first 8 values of the hexadecimal that identifies the amiibo. public let head: String + + /// The last 8 values of the hexadecimal that identifies the amiibo. public let tail: String + + /// The name of the amiibo. public let name: String + + /// The character of the amiibo. public let character: String + + /// The series the amiibo belongs to. public let series: String + + /// The game series of the amiibo. public let gameSeries: String + + /// The URL to an image of the amiibo. public let image: String + + /// The release dates of the amiibo (if released) in Australia, Europe, Japan and North America. public let release: Release + + /// The games related to the amiibo, if requested. public let games: Games? } // MARK: - Structs extension Amiibo { + /// This model represents the list of games related to a particular amiibo, grouped by system. public struct Games: Decodable { + + // MARK: Properties + + /// A list of [Nintendo 3DS system](https://en.wikipedia.org/wiki/Nintendo_3DS) games the amiibo can be used with. public let n3ds: [Game] + + /// A list of [Nintendo WiiU system](https://en.wikipedia.org/wiki/Wii_U) games the amiibo can be used with. public let wiiu: [Game] + + /// /// A list of [Nintendo Switch system](https://en.wikipedia.org/wiki/Nintendo_Switch) games the amiibo can be used with. public let `switch`: [Game] } } @@ -44,6 +76,9 @@ extension Amiibo: Decodable { // MARK: Initialisers + /// Initialises this model by decoding from the given decoder. + /// - Parameter decoder: The decoder to read data from. + /// - Throws: A `DecodingError` error in case the decode failed at decoding data into an expected model type. public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) let games3ds = try container.decodeIfPresent([Game].self, forKey: .games3DS)