[Feature] Models of the service (#1)

This PR contains the implementation of all the models used by this service: `Amiibo`, `Amiibo.Game`, `Amiibo.Release`, `Amiibo.Usage`, `KeyName` and `LastUpdated`.

Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
Reviewed-on: #1
This commit is contained in:
Javier Cicchelli 2023-04-18 18:37:08 +00:00
parent 472ed2c068
commit 29f766ebdb
6 changed files with 99 additions and 0 deletions

View File

@ -0,0 +1,18 @@
public struct Amiibo {
public let type: String
public let head: String
public let tail: String
public let name: String
public let character: String
public let amiiboSeries: String
public let gameSeries: String
public let image: String
public let release: Release
public let games3DS: [Game]?
public let gamesWiiU: [Game]?
public let gamesSwitch: [Game]?
}
// MARK: - Decodable
extension Amiibo: Decodable {}

View File

@ -0,0 +1,17 @@
extension Amiibo {
public struct Game {
public let identifiers: [String]
public let name: String
public let usage: [Usage]
}
}
// MARK: - Decodable
extension Amiibo.Game: Decodable {
enum CodingKeys: String, CodingKey {
case identifiers = "gameID"
case name = "gameName"
case usage = "amiiboUsage"
}
}

View File

@ -0,0 +1,21 @@
import Foundation
extension Amiibo {
public struct Release {
public let australia: Date?
public let europe: Date?
public let japan: Date?
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

@ -0,0 +1,15 @@
extension Amiibo {
public struct Usage {
public let explanation: String
public let isWritable: Bool
}
}
// MARK: - Decodable
extension Amiibo.Usage: Decodable {
enum CodingKeys: String, CodingKey {
case explanation = "Usage"
case isWritable = "write"
}
}

View File

@ -0,0 +1,15 @@
public struct KeyName {
public let key: String
public let name: String?
}
// MARK: - Decodable
extension KeyName: Decodable {}
// MARK: - Type aliases
public typealias AmiiboType = KeyName
public typealias AmiiboSeries = KeyName
public typealias GameSeries = KeyName
public typealias Character = KeyName

View File

@ -0,0 +1,13 @@
import Foundation
public struct LastUpdated {
public let timestamp: Date
}
// MARK: - Decodable
extension LastUpdated: Decodable {
enum CodingKeys: String, CodingKey {
case timestamp = "lastUpdated"
}
}