From 2c66c3940ca5d8866cbc365f849ea42f46f1c123 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Tue, 7 Oct 2025 23:56:47 +0200 Subject: [PATCH] Added the "head" and "tail" properties to the AmiiboFilter type in the library target. --- .../Public/Clients/AmiiboLiveClient.swift | 2 ++ .../Public/Filters/AmiiboFilter.swift | 36 ++++++++++++------- .../Services/AmiiboServiceLiveTests.swift | 10 ++++-- 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/Sources/AmiiboService/Public/Clients/AmiiboLiveClient.swift b/Sources/AmiiboService/Public/Clients/AmiiboLiveClient.swift index 1d05fbe..c8f9268 100644 --- a/Sources/AmiiboService/Public/Clients/AmiiboLiveClient.swift +++ b/Sources/AmiiboService/Public/Clients/AmiiboLiveClient.swift @@ -182,10 +182,12 @@ private extension AmiiboLiveClient { amiiboSeries: filter.series, character: filter.gameCharacter, gameseries: filter.gameSeries, + head: filter.head, id: filter.identifier, name: filter.name, showgames: filter.showGames, showusage: filter.showUsage, + tail: filter.tail, _type: filter.type ))) } catch { diff --git a/Sources/AmiiboService/Public/Filters/AmiiboFilter.swift b/Sources/AmiiboService/Public/Filters/AmiiboFilter.swift index 91470b2..dea63b4 100644 --- a/Sources/AmiiboService/Public/Filters/AmiiboFilter.swift +++ b/Sources/AmiiboService/Public/Filters/AmiiboFilter.swift @@ -15,19 +15,22 @@ public struct AmiiboFilter: Sendable { // MARK: Properties - /// A game character to return, if any. + /// A game character to filter the result, if any. public let gameCharacter: String? - /// A game series to return, if any. + /// A game series to filter the result, if any. public let gameSeries: String? + + /// A first part of an identifier to filter the result, if any. + public let head: String? - /// An amiibo identifier to return, if any. + /// An amiibo identifier to filter the result, if any. public let identifier: String? - /// An amiibo name to return, if any. + /// An amiibo name to filter the result, if any. public let name: String? - /// An amiibo series to return, if any. + /// An amiibo series to filter the result, if any. public let series: String? /// A flag indicating whether to include games in the response, if any. @@ -35,23 +38,30 @@ public struct AmiiboFilter: Sendable { /// A flag indicating whether to include amiibo usages in games in the response, if any. public let showUsage: Bool? + + /// A last part of an identifier to filter the result, if any. + public let tail: String? - /// An amiibo type to return, if any. + /// An amiibo type to filter the result, if any. public let type: String? // MARK: Initializers /// Initializes this filter. /// - Parameters: - /// - identifier: An amiibo identifier to return, if any. - /// - name: An amiibo name to return, if any. - /// - type: An amiibo type to return, if any. - /// - series: An amiibo series to return, if any. - /// - gameCharacter: A game character to return, if any. - /// - gameSeries: A game series to return, if any. + /// - head: A first part of an identifier to filter the result, if any. + /// - tail: A last part of an identifier to filter the result, if any. + /// - identifier: An amiibo identifier to filter the result, if any. + /// - name: An amiibo name to filter the result, if any. + /// - type: An amiibo type to filter the result, if any. + /// - series: An amiibo series to filter the result, if any. + /// - gameCharacter: A game character to filter the result, if any. + /// - gameSeries: A game series to filter the result, if any. /// - showGames: A flag indicating whether to include games in the response, if any. /// - showUsage: A flag indicating whether to include amiibo usages in games in the response, if any. public init( + head: String? = nil, + tail: String? = nil, identifier: String? = nil, name: String? = nil, type: String? = nil, @@ -63,11 +73,13 @@ public struct AmiiboFilter: Sendable { ) { self.gameCharacter = gameCharacter self.gameSeries = gameSeries + self.head = head self.identifier = identifier self.name = name self.series = series self.showGames = showGames self.showUsage = showUsage + self.tail = tail self.type = type } diff --git a/Tests/AmiiboService/Tests/Public/Services/AmiiboServiceLiveTests.swift b/Tests/AmiiboService/Tests/Public/Services/AmiiboServiceLiveTests.swift index 565dc68..7bc8d50 100644 --- a/Tests/AmiiboService/Tests/Public/Services/AmiiboServiceLiveTests.swift +++ b/Tests/AmiiboService/Tests/Public/Services/AmiiboServiceLiveTests.swift @@ -545,6 +545,10 @@ enum Input { /// A list of amiibo filters to input to the `assertAmiibos` assertion. static let amiibos: [AmiiboFilter] = [ .init(), + .init(head: "00000000"), + .init(head: "0000"), + .init(tail: "00000002"), + .init(tail: "0002"), .init(identifier: "0000000000000002"), .init(name: "zelda"), .init(name: "Something"), @@ -579,6 +583,8 @@ enum Input { ] /// A list of amiibo series filters to input to the `assertAmiibosThrows` assertion. static let amiibosThrows: [AmiiboFilter] = [ + .init(head: .empty), + .init(tail: .empty), .init(identifier: "0000000000000000"), .init(identifier: "0000000"), .init(identifier: .empty), @@ -651,9 +657,9 @@ enum Input { enum Output { /// A list of number of items that are expected from the `assertAmiibos` assertion. - static let amiibos: [Int] = [.totalAmiibos, 1, 5, .zero, 7, .totalAmiibos, 235, 235, .zero, .zero, .zero, .zero, 96, 26, .zero, .zero, 25, .totalAmiibos, 12, 6, .zero, .zero, .zero, .totalAmiibos, 49, 32, .zero, .zero, 147, .totalAmiibos, .totalAmiibos, .totalAmiibos] + static let amiibos: [Int] = [.totalAmiibos, 7, 7, 1, 1, 1, 5, .zero, 7, .totalAmiibos, 235, 235, .zero, .zero, .zero, .zero, 96, 26, .zero, .zero, 25, .totalAmiibos, 12, 6, .zero, .zero, .zero, .totalAmiibos, 49, 32, .zero, .zero, 147, .totalAmiibos, .totalAmiibos, .totalAmiibos] /// A list of errors are expected to be thrown from the `assertAmiibosThrows` assertion. - static let amiibosThrows: [AmiiboServiceError] = [.decoding, .decoding, .badRequest, .badRequest, .badRequest, .badRequest, .badRequest] + static let amiibosThrows: [AmiiboServiceError] = [.badRequest, .badRequest, .decoding, .decoding, .badRequest, .badRequest, .badRequest, .badRequest, .badRequest] /// A list of number of items that are expected from the `assertAmiiboSeries` assertion. static let amiiboSeries: [Int] = [.totalAmiiboSeries, 1, 1, 1, .totalAmiiboSeries] /// A list of errors are expected to be thrown from the `assertAmiiboSeriesThrows` assertion.