From adaedcda07df4937a1b1b5813cecadbdbc2a22c2 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sun, 9 Nov 2025 21:06:07 +0100 Subject: [PATCH] Updated the Amiibo.Platform type in the library target to initialize Switch 2 games from a given payload. --- Sources/AmiiboService/Public/Models/Amiibo.swift | 1 + .../Public/Models/Amiibo/Amiibo+Platform.swift | 10 ++++++++++ .../Tests/Public/Services/AmiiboServiceLiveTests.swift | 2 ++ 3 files changed, 13 insertions(+) diff --git a/Sources/AmiiboService/Public/Models/Amiibo.swift b/Sources/AmiiboService/Public/Models/Amiibo.swift index 80e531c..253628f 100644 --- a/Sources/AmiiboService/Public/Models/Amiibo.swift +++ b/Sources/AmiiboService/Public/Models/Amiibo.swift @@ -61,6 +61,7 @@ public struct Amiibo: Sendable { self.name = payload.name self.platform = .init( payload.gamesSwitch, + payload.gamesSwitch2, payload.games3DS, payload.gamesWiiU ) diff --git a/Sources/AmiiboService/Public/Models/Amiibo/Amiibo+Platform.swift b/Sources/AmiiboService/Public/Models/Amiibo/Amiibo+Platform.swift index 0a8ae83..cac8d42 100644 --- a/Sources/AmiiboService/Public/Models/Amiibo/Amiibo+Platform.swift +++ b/Sources/AmiiboService/Public/Models/Amiibo/Amiibo+Platform.swift @@ -20,6 +20,9 @@ extension Amiibo { /// A list of `Switch` games related to an amiibo item. public let `switch`: [Game] + + /// A list of `Switch 2` games related to an amiibo. + public let switch2: [Game] /// A list of `3DS` games related to an amiibo item. public let threeDS: [Game] @@ -37,12 +40,15 @@ extension Amiibo { /// - switch: A list of `Switch` games related to an amiibo item, if any. /// - threeDS: A list of `3DS` games related to an amiibo item, if any. /// - wiiU: A list of `WiiU` games related to an amiibo item, if any. + /// - switch2: A list of `Switch 2` games related to an amiibo, if any. init?( _ `switch`: [Components.Schemas.AmiiboGame]?, + _ switch2: [Components.Schemas.AmiiboGame]?, _ threeDS: [Components.Schemas.AmiiboGame]?, _ wiiU: [Components.Schemas.AmiiboGame]? ) { guard (`switch` != nil && `switch`?.isEmpty == false) + || (switch2 != nil && switch2?.isEmpty == false) || (threeDS != nil && threeDS?.isEmpty == false) || (wiiU != nil && wiiU?.isEmpty == false) else { @@ -53,6 +59,10 @@ extension Amiibo { guard let `switch` else { return [] } return `switch`.map { .init($0) } }() + self.switch2 = { + guard let switch2 else { return [] } + return switch2.map { .init($0) } + }() self.threeDS = { guard let threeDS else { return [] } return threeDS.map { .init($0) } diff --git a/Tests/AmiiboService/Tests/Public/Services/AmiiboServiceLiveTests.swift b/Tests/AmiiboService/Tests/Public/Services/AmiiboServiceLiveTests.swift index 7c78531..ed003d2 100644 --- a/Tests/AmiiboService/Tests/Public/Services/AmiiboServiceLiveTests.swift +++ b/Tests/AmiiboService/Tests/Public/Services/AmiiboServiceLiveTests.swift @@ -365,6 +365,8 @@ private extension AmiiboServiceLiveTests { if filter.showUsage == true { #expect(firstAmiiboPlatform.switch.first?.usages?.isEmpty == false) + // Given the live data is still not returning any Switch 2 games. + #expect(firstAmiiboPlatform.switch2.isEmpty == true) #expect(firstAmiiboPlatform.threeDS.first?.usages?.isEmpty == false) #expect(firstAmiiboPlatform.wiiU.first?.usages?.isEmpty == false) }