Restructured the hierarchy of the existing models based on the Amiibo API definitions.

This commit is contained in:
Javier Cicchelli 2023-04-23 14:49:03 +02:00
parent 5b10a02d13
commit 0310326680
7 changed files with 93 additions and 85 deletions

View File

@ -107,6 +107,7 @@ extension AmiiboFilter: Filter {
// MARK: - Enumerations // MARK: - Enumerations
extension AmiiboFilter {
/// This enumeration indicates if extra information for amiibos need to be retrieved. /// This enumeration indicates if extra information for amiibos need to be retrieved.
public enum ShowExtras { public enum ShowExtras {
/// No extra information needs to be retrieved. /// No extra information needs to be retrieved.
@ -116,6 +117,7 @@ public enum ShowExtras {
/// Amiibo games and its usage information needs to be retrieved. /// Amiibo games and its usage information needs to be retrieved.
case usage case usage
} }
}
// MARK: - String+Key // MARK: - String+Key

View File

@ -0,0 +1,27 @@
extension Amiibo {
/// This model structs represents a game that is related to an amiibo, when requested to the respective [remote API endpoint](https://www.amiiboapi.com/docs/#showGames).
public struct Game {
// MARK: Properties
/// The list of identifiers associated to the game.
public let ids: [String]
/// The name of the game.
public let name: String
/// The list of usages that explains how the amiibo is being used in the game.
public let usage: [Usage]?
}
}
// MARK: - Decodable
extension Amiibo.Game: Decodable {
enum CodingKeys: String, CodingKey {
case ids = "gameID"
case name = "gameName"
case usage = "amiiboUsage"
}
}

View File

@ -0,0 +1,23 @@
extension Amiibo.Game {
/// This model struct represents how an amiibo is used with a particular game, when requested to the respective [remote API endpoint](https://www.amiiboapi.com/docs/#showUsage).
public struct Usage {
// MARK: Properties
/// The explanation on how an amiibo is being used with a particular game.
public let explanation: String
/// A flag that indicates whether an amiibo is only read-only or the game can also write information to the amiibo.
public let isWritable: Bool
}
}
// MARK: - Decodable
extension Amiibo.Game.Usage: Decodable {
enum CodingKeys: String, CodingKey {
case explanation = "Usage"
case isWritable = "write"
}
}

View File

@ -0,0 +1,33 @@
import Foundation
extension Amiibo {
/// This model struct represents a collection of official release dates (if released) of an amiibo in different markets around the world.
public struct Release {
// MARK: Properties
/// The official release date (if released) of an amiibo in Australia.
public let australia: Date?
/// The official release date (if released) of an amiibo in Europe.
public let europe: Date?
/// The official release date (if released) of an amiibo in Japan.
public let japan: Date?
/// The official release date (if released) of an amiibo in North America.
public let america: Date?
}
}
// MARK: - Decodable
extension Amiibo.Release: Decodable {
enum CodingKeys: String, CodingKey {
case australia = "au"
case europe = "eu"
case japan = "jp"
case america = "na"
}
}

View File

@ -1,25 +0,0 @@
/// This model structs represents a game that is related to an amiibo, when requested to the respective [remote API endpoint](https://www.amiiboapi.com/docs/#showGames).
public struct Game {
// MARK: Properties
/// The list of identifiers associated to the game.
public let ids: [String]
/// The name of the game.
public let name: String
/// The list of usages that explains how the amiibo is being used in the game.
public let usage: [Usage]?
}
// MARK: - Decodable
extension Game: Decodable {
enum CodingKeys: String, CodingKey {
case ids = "gameID"
case name = "gameName"
case usage = "amiiboUsage"
}
}

View File

@ -1,31 +0,0 @@
import Foundation
/// This model struct represents a collection of official release dates (if released) of an amiibo in different markets around the world.
public struct Release {
// MARK: Properties
/// The official release date (if released) of an amiibo in Australia.
public let australia: Date?
/// The official release date (if released) of an amiibo in Europe.
public let europe: Date?
/// The official release date (if released) of an amiibo in Japan.
public let japan: Date?
/// The official release date (if released) of an amiibo in North America.
public let america: Date?
}
// MARK: - Decodable
extension Release: Decodable {
enum CodingKeys: String, CodingKey {
case australia = "au"
case europe = "eu"
case japan = "jp"
case america = "na"
}
}

View File

@ -1,21 +0,0 @@
/// This model struct represents how an amiibo is used with a particular game, when requested to the respective [remote API endpoint](https://www.amiiboapi.com/docs/#showUsage).
public struct Usage {
// MARK: Properties
/// The explanation on how an amiibo is being used with a particular game.
public let explanation: String
/// A flag that indicates whether an amiibo is only read-only or the game can also write information to the amiibo.
public let isWritable: Bool
}
// MARK: - Decodable
extension Usage: Decodable {
enum CodingKeys: String, CodingKey {
case explanation = "Usage"
case isWritable = "write"
}
}