[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:
parent
472ed2c068
commit
29f766ebdb
18
Sources/Models/Amiibo.swift
Normal file
18
Sources/Models/Amiibo.swift
Normal 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 {}
|
17
Sources/Models/AmiiboGame.swift
Normal file
17
Sources/Models/AmiiboGame.swift
Normal 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"
|
||||
}
|
||||
}
|
21
Sources/Models/AmiiboRelease.swift
Normal file
21
Sources/Models/AmiiboRelease.swift
Normal 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"
|
||||
}
|
||||
}
|
15
Sources/Models/AmiiboUsage.swift
Normal file
15
Sources/Models/AmiiboUsage.swift
Normal 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"
|
||||
}
|
||||
}
|
15
Sources/Models/KeyName.swift
Normal file
15
Sources/Models/KeyName.swift
Normal 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
|
13
Sources/Models/LastUpdated.swift
Normal file
13
Sources/Models/LastUpdated.swift
Normal 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"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user