Added support for Switch 2 games to the Amiibo type. (#21)

This PR contains the work done to add support for *Switch 2* games to the `Amiibo` model type of the library. In addition, some test cases and documentation have been updated/revised due to this update.

Reviewed-on: #21
Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
Co-committed-by: Javier Cicchelli <javier@rock-n-code.com>
This commit was merged in pull request #21.
This commit is contained in:
2025-11-09 20:19:13 +00:00
committed by Javier Cicchelli
parent 0d9c9e22a4
commit fae4b44698
127 changed files with 158 additions and 138 deletions
@@ -13,36 +13,42 @@
// ===----------------------------------------------------------------------===
extension Amiibo {
/// A model that represents a collection of `WiiU`, `3DS`, and `Switch` games related to an amiibo item.
/// A model that represents a collection of `Switch`, `Switch 2`, `3DS`, and `WiiU` games related to an amiibo.
public struct Platform: Sendable {
// MARK: Properties
/// A list of `Switch` games related to an amiibo item.
/// A list of `Switch` games related to an amiibo.
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.
public let threeDS: [Game]
/// A list of `WiiU` games related to an amiibo item.
/// A list of `WiiU` games related to an amiibo.
public let wiiU: [Game]
// MARK: Initialisers
// MARK: Initializers
/// Initializes this model.
///
/// > important: In case no data is provided, then an instance of this model is not created.
///
/// - Parameters:
/// - 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.
/// - switch: A list of `Switch` games related to an amiibo, if any.
/// - switch2: A list of `Switch 2` games related to an amiibo, if any.
/// - threeDS: A list of `3DS` games related to an amiibo, if any.
/// - wiiU: A list of `WiiU` 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) }