Restructured the hierarchy of the existing models based on the Amiibo API definitions.
This commit is contained in:
parent
5b10a02d13
commit
0310326680
@ -107,14 +107,16 @@ extension AmiiboFilter: Filter {
|
||||
|
||||
// MARK: - Enumerations
|
||||
|
||||
/// This enumeration indicates if extra information for amiibos need to be retrieved.
|
||||
public enum ShowExtras {
|
||||
extension AmiiboFilter {
|
||||
/// This enumeration indicates if extra information for amiibos need to be retrieved.
|
||||
public enum ShowExtras {
|
||||
/// No extra information needs to be retrieved.
|
||||
case none
|
||||
/// Amiibo games information needs to be retrieved.
|
||||
case games
|
||||
/// Amiibo games and its usage information needs to be retrieved.
|
||||
case usage
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - String+Key
|
||||
|
27
Sources/Models/AmiiboGame.swift
Normal file
27
Sources/Models/AmiiboGame.swift
Normal 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"
|
||||
}
|
||||
}
|
23
Sources/Models/AmiiboGameUsage.swift
Normal file
23
Sources/Models/AmiiboGameUsage.swift
Normal 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"
|
||||
}
|
||||
}
|
33
Sources/Models/AmiiboRelease.swift
Normal file
33
Sources/Models/AmiiboRelease.swift
Normal 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"
|
||||
}
|
||||
}
|
@ -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"
|
||||
}
|
||||
}
|
@ -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"
|
||||
}
|
||||
}
|
@ -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"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user