Updated the Amiibo.Platform type in the library target to initialize Switch 2 games from a given payload.
This commit is contained in:
@@ -61,6 +61,7 @@ public struct Amiibo: Sendable {
|
|||||||
self.name = payload.name
|
self.name = payload.name
|
||||||
self.platform = .init(
|
self.platform = .init(
|
||||||
payload.gamesSwitch,
|
payload.gamesSwitch,
|
||||||
|
payload.gamesSwitch2,
|
||||||
payload.games3DS,
|
payload.games3DS,
|
||||||
payload.gamesWiiU
|
payload.gamesWiiU
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ extension Amiibo {
|
|||||||
|
|
||||||
/// A list of `Switch` games related to an amiibo item.
|
/// A list of `Switch` games related to an amiibo item.
|
||||||
public let `switch`: [Game]
|
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.
|
/// A list of `3DS` games related to an amiibo item.
|
||||||
public let threeDS: [Game]
|
public let threeDS: [Game]
|
||||||
@@ -37,12 +40,15 @@ extension Amiibo {
|
|||||||
/// - switch: A list of `Switch` games related to an amiibo item, if any.
|
/// - 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.
|
/// - 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.
|
/// - 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?(
|
init?(
|
||||||
_ `switch`: [Components.Schemas.AmiiboGame]?,
|
_ `switch`: [Components.Schemas.AmiiboGame]?,
|
||||||
|
_ switch2: [Components.Schemas.AmiiboGame]?,
|
||||||
_ threeDS: [Components.Schemas.AmiiboGame]?,
|
_ threeDS: [Components.Schemas.AmiiboGame]?,
|
||||||
_ wiiU: [Components.Schemas.AmiiboGame]?
|
_ wiiU: [Components.Schemas.AmiiboGame]?
|
||||||
) {
|
) {
|
||||||
guard (`switch` != nil && `switch`?.isEmpty == false)
|
guard (`switch` != nil && `switch`?.isEmpty == false)
|
||||||
|
|| (switch2 != nil && switch2?.isEmpty == false)
|
||||||
|| (threeDS != nil && threeDS?.isEmpty == false)
|
|| (threeDS != nil && threeDS?.isEmpty == false)
|
||||||
|| (wiiU != nil && wiiU?.isEmpty == false)
|
|| (wiiU != nil && wiiU?.isEmpty == false)
|
||||||
else {
|
else {
|
||||||
@@ -53,6 +59,10 @@ extension Amiibo {
|
|||||||
guard let `switch` else { return [] }
|
guard let `switch` else { return [] }
|
||||||
return `switch`.map { .init($0) }
|
return `switch`.map { .init($0) }
|
||||||
}()
|
}()
|
||||||
|
self.switch2 = {
|
||||||
|
guard let switch2 else { return [] }
|
||||||
|
return switch2.map { .init($0) }
|
||||||
|
}()
|
||||||
self.threeDS = {
|
self.threeDS = {
|
||||||
guard let threeDS else { return [] }
|
guard let threeDS else { return [] }
|
||||||
return threeDS.map { .init($0) }
|
return threeDS.map { .init($0) }
|
||||||
|
|||||||
@@ -365,6 +365,8 @@ private extension AmiiboServiceLiveTests {
|
|||||||
|
|
||||||
if filter.showUsage == true {
|
if filter.showUsage == true {
|
||||||
#expect(firstAmiiboPlatform.switch.first?.usages?.isEmpty == false)
|
#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.threeDS.first?.usages?.isEmpty == false)
|
||||||
#expect(firstAmiiboPlatform.wiiU.first?.usages?.isEmpty == false)
|
#expect(firstAmiiboPlatform.wiiU.first?.usages?.isEmpty == false)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user