[Setup] Documentation #10
@ -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 {
|
public struct Amiibo {
|
||||||
|
|
||||||
|
// MARK: Properties
|
||||||
|
|
||||||
|
/// The type the amiibo belongs to.
|
||||||
public let type: String
|
public let type: String
|
||||||
|
|
||||||
|
/// The first 8 values of the hexadecimal that identifies the amiibo.
|
||||||
public let head: String
|
public let head: String
|
||||||
|
|
||||||
|
/// The last 8 values of the hexadecimal that identifies the amiibo.
|
||||||
public let tail: String
|
public let tail: String
|
||||||
|
|
||||||
|
/// The name of the amiibo.
|
||||||
public let name: String
|
public let name: String
|
||||||
|
|
||||||
|
/// The character of the amiibo.
|
||||||
public let character: String
|
public let character: String
|
||||||
|
|
||||||
|
/// The series the amiibo belongs to.
|
||||||
public let series: String
|
public let series: String
|
||||||
|
|
||||||
|
/// The game series of the amiibo.
|
||||||
public let gameSeries: String
|
public let gameSeries: String
|
||||||
|
|
||||||
|
/// The URL to an image of the amiibo.
|
||||||
public let image: String
|
public let image: String
|
||||||
|
|
||||||
|
/// The release dates of the amiibo (if released) in Australia, Europe, Japan and North America.
|
||||||
public let release: Release
|
public let release: Release
|
||||||
|
|
||||||
|
/// The games related to the amiibo, if requested.
|
||||||
public let games: Games?
|
public let games: Games?
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Structs
|
// MARK: - Structs
|
||||||
|
|
||||||
extension Amiibo {
|
extension Amiibo {
|
||||||
|
/// This model represents the list of games related to a particular amiibo, grouped by system.
|
||||||
public struct Games: Decodable {
|
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]
|
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]
|
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]
|
public let `switch`: [Game]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -44,6 +76,9 @@ extension Amiibo: Decodable {
|
|||||||
|
|
||||||
// MARK: Initialisers
|
// 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 {
|
public init(from decoder: Decoder) throws {
|
||||||
let container = try decoder.container(keyedBy: CodingKeys.self)
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
||||||
let games3ds = try container.decodeIfPresent([Game].self, forKey: .games3DS)
|
let games3ds = try container.decodeIfPresent([Game].self, forKey: .games3DS)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user