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
@@ -18,7 +18,7 @@ To use the `AmiiboService` library with your package, then add it as a dependenc
let package = Package(
// name, platforms, products, etc.
dependencies: [
.package(url: "https://github.com/rock-n-code/amiibo-service", from: "1.2.0"),
.package(url: "https://github.com/rock-n-code/amiibo-service", from: "1.3.0"),
// other dependencies
],
targets: [
@@ -14,7 +14,7 @@
import Foundation
/// A model that represents an amiibo item.
/// A model that represents an amiibo.
public struct Amiibo: Sendable {
// MARK: Properties
@@ -61,6 +61,7 @@ public struct Amiibo: Sendable {
self.name = payload.name
self.platform = .init(
payload.gamesSwitch,
payload.gamesSwitch2,
payload.games3DS,
payload.gamesWiiU
)
@@ -13,7 +13,7 @@
// ===----------------------------------------------------------------------===
extension Amiibo {
/// A model that represents a game related to an amiibo item.
/// A model that represents a game related to an amiibo.
public struct Game: Sendable {
// MARK: Properties
@@ -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) }
@@ -15,7 +15,7 @@
import Foundation
extension Amiibo {
/// A model that represents a collection of release dates related to an amiibo item.
/// A model that represents a collection of release dates related to an amiibo.
public struct Release: Sendable {
// MARK: Properties
@@ -13,15 +13,15 @@
// ===----------------------------------------------------------------------===
extension Amiibo {
/// A model that represents the usage of an amiibo item within a certain game.
/// A model that represents the usage of an amiibo within a certain game.
public struct Usage: Sendable {
// MARK: Properties
/// An explanation of how to use an amiibo item.
/// An explanation of how to use an amiibo.
public let explanation: String
/// A flag that indicates whether an amiibo item can save game data in it.
/// A flag that indicates whether an amiibo can save game data in it.
public let isWriteable: Bool
// MARK: Initializers
+5
View File
@@ -346,6 +346,11 @@ components:
type: array
items:
$ref: '#/components/schemas/AmiiboGame'
gamesSwitch2:
description: A list of Switch 2 games an amiibo could be used in, if any.
type: array
items:
$ref: '#/components/schemas/AmiiboGame'
gamesWiiU:
description: A list of Wii U games an amiibo could be used in, if any.
type: array