Made Amiibo models Codable and Identifiable, and filters Hashable.
This commit is contained in:
1 parent
8fa4d50734
commit
a28842eb0a
24 files changed
+352
-190
No files matched your search
@@ -15,7 +15,7 @@
|
||||
import Foundation
|
||||
|
||||
/// A model that represents an amiibo.
|
||||
public struct Amiibo: Sendable, Hashable {
|
||||
public struct Amiibo: Sendable, Hashable, Codable, Identifiable {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
@@ -36,7 +36,7 @@ public struct Amiibo: Sendable, Hashable {
|
||||
|
||||
/// The related games of this amiibo, grouped by platform.
|
||||
///
|
||||
/// This value is `nil` unless the request sets ``AmiiboFilter/showGames`` or ``AmiiboFilter/showUsage``, or when the amiibo has no related games.
|
||||
/// `nil` unless the request sets ``AmiiboFilter/showGames`` or ``AmiiboFilter/showUsage``, or when there are no related games.
|
||||
public let platform: Platform?
|
||||
|
||||
/// The release dates of this amiibo across different regions.
|
||||
@@ -99,7 +99,12 @@ public struct Amiibo: Sendable, Hashable {
|
||||
}
|
||||
|
||||
// MARK: Computed
|
||||
|
||||
|
||||
/// The ``identifier`` of this amiibo.
|
||||
public var id: String {
|
||||
identifier
|
||||
}
|
||||
|
||||
/// The full 16-character hexadecimal identifier, composed of the ``head`` and ``tail``.
|
||||
public var identifier: String {
|
||||
head + tail
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
extension Amiibo {
|
||||
/// A model that represents a game related to an amiibo.
|
||||
public struct Game: Sendable, Hashable {
|
||||
public struct Game: Sendable, Hashable, Codable {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
// ===----------------------------------------------------------------------===
|
||||
|
||||
extension Amiibo {
|
||||
/// A model that represents a collection of `Switch`, `Switch 2`, `3DS`, and `Wii U` games related to an amiibo.
|
||||
public struct Platform: Sendable, Hashable {
|
||||
/// A model that groups the games related to an amiibo by platform.
|
||||
public struct Platform: Sendable, Hashable, Codable {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ extension Amiibo {
|
||||
/// A model that represents the regional release dates of an amiibo.
|
||||
///
|
||||
/// The service provides these dates as date-only values, which are decoded as midnight UTC.
|
||||
public struct Release: Sendable, Hashable {
|
||||
public struct Release: Sendable, Hashable, Codable {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
|
||||
@@ -14,14 +14,14 @@
|
||||
|
||||
extension Amiibo {
|
||||
/// A model that represents the usage of an amiibo within a certain game.
|
||||
public struct Usage: Sendable, Hashable {
|
||||
public struct Usage: Sendable, Hashable, Codable {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// A description of how the amiibo is used within the game.
|
||||
public let explanation: String
|
||||
|
||||
/// A flag that indicates whether the amiibo can save game data.
|
||||
/// Whether the amiibo can save game data.
|
||||
public let isWriteable: Bool
|
||||
|
||||
// MARK: Initializers
|
||||
|
||||
@@ -37,5 +37,12 @@ public struct AmiiboSeries: KeyNameModel {
|
||||
self.key = payload.key
|
||||
self.name = payload.name
|
||||
}
|
||||
|
||||
|
||||
// MARK: Computed
|
||||
|
||||
/// The ``key`` of this amiibo series.
|
||||
public var id: String {
|
||||
key
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,5 +37,12 @@ public struct AmiiboType: KeyNameModel {
|
||||
self.key = payload.key
|
||||
self.name = payload.name
|
||||
}
|
||||
|
||||
|
||||
// MARK: Computed
|
||||
|
||||
/// The ``key`` of this amiibo type.
|
||||
public var id: String {
|
||||
key
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,5 +37,12 @@ public struct GameCharacter: KeyNameModel {
|
||||
self.key = payload.key
|
||||
self.name = payload.name
|
||||
}
|
||||
|
||||
|
||||
// MARK: Computed
|
||||
|
||||
/// The ``key`` of this game character.
|
||||
public var id: String {
|
||||
key
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,5 +37,12 @@ public struct GameSeries: KeyNameModel {
|
||||
self.key = payload.key
|
||||
self.name = payload.name
|
||||
}
|
||||
|
||||
|
||||
// MARK: Computed
|
||||
|
||||
/// The ``key`` of this game series.
|
||||
public var id: String {
|
||||
key
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user