2024-09-14 22:26:39 +00:00
|
|
|
//===----------------------------------------------------------------------===
|
|
|
|
|
//
|
2025-09-09 17:20:05 +00:00
|
|
|
// This source file is part of the AmiiboService open source project
|
2024-09-14 22:26:39 +00:00
|
|
|
//
|
2025-09-09 17:20:05 +00:00
|
|
|
// Copyright (c) 2024-2025 Röck+Cöde VoF. and the AmiiboAPI project authors
|
2024-09-14 22:26:39 +00:00
|
|
|
// Licensed under the EUPL 1.2 or later.
|
|
|
|
|
//
|
|
|
|
|
// See LICENSE for license information
|
|
|
|
|
// See CONTRIBUTORS for the list of AmiiboAPI project authors
|
|
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===
|
|
|
|
|
|
|
|
|
|
extension Amiibo {
|
2025-09-09 17:30:19 +00:00
|
|
|
/// A model that represents a collection of `WiiU`, `3DS`, and `Switch` games related to an amiibo item.
|
2024-09-14 22:26:39 +00:00
|
|
|
public struct Platform: Sendable {
|
|
|
|
|
|
|
|
|
|
// MARK: Properties
|
|
|
|
|
|
2025-09-09 17:30:19 +00:00
|
|
|
/// A list of `Switch` games related to an amiibo item.
|
2024-09-14 22:26:39 +00:00
|
|
|
public let `switch`: [Game]
|
2025-09-09 17:30:19 +00:00
|
|
|
|
|
|
|
|
/// A list of `3DS` games related to an amiibo item.
|
2024-09-14 22:26:39 +00:00
|
|
|
public let threeDS: [Game]
|
2025-09-09 17:30:19 +00:00
|
|
|
|
|
|
|
|
/// A list of `WiiU` games related to an amiibo item.
|
2024-09-14 22:26:39 +00:00
|
|
|
public let wiiU: [Game]
|
|
|
|
|
|
|
|
|
|
// MARK: Initialisers
|
|
|
|
|
|
2025-09-09 17:30:19 +00:00
|
|
|
/// Initializes this model.
|
|
|
|
|
///
|
|
|
|
|
/// > important: In case no data is provided, then an instance of this model is not created.
|
|
|
|
|
///
|
|
|
|
|
/// - Parameters:
|
2025-09-10 19:47:45 +00:00
|
|
|
/// - switch: A list of `Switch` games related to an amiibo item, if any.
|
2025-09-09 17:30:19 +00:00
|
|
|
/// - 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.
|
2024-09-14 22:26:39 +00:00
|
|
|
init?(
|
|
|
|
|
_ `switch`: [Components.Schemas.AmiiboGame]?,
|
|
|
|
|
_ threeDS: [Components.Schemas.AmiiboGame]?,
|
|
|
|
|
_ wiiU: [Components.Schemas.AmiiboGame]?
|
|
|
|
|
) {
|
|
|
|
|
guard (`switch` != nil && `switch`?.isEmpty == false)
|
|
|
|
|
|| (threeDS != nil && threeDS?.isEmpty == false)
|
|
|
|
|
|| (wiiU != nil && wiiU?.isEmpty == false)
|
|
|
|
|
else {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
self.switch = {
|
|
|
|
|
guard let `switch` else { return [] }
|
|
|
|
|
return `switch`.map { .init($0) }
|
|
|
|
|
}()
|
|
|
|
|
self.threeDS = {
|
|
|
|
|
guard let threeDS else { return [] }
|
|
|
|
|
return threeDS.map { .init($0) }
|
|
|
|
|
}()
|
|
|
|
|
self.wiiU = {
|
|
|
|
|
guard let wiiU else { return [] }
|
|
|
|
|
return wiiU.map { .init($0) }
|
|
|
|
|
}()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|