Adopted Swift 6.2 tools version at the Package in the library target to drop legacy conditional code.
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// swift-tools-version: 5.10
|
// swift-tools-version: 6.2
|
||||||
|
|
||||||
// ===----------------------------------------------------------------------===
|
// ===----------------------------------------------------------------------===
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ extension AmiiboLiveClient: AmiiboClient {
|
|||||||
|
|
||||||
// MARK: Functions
|
// MARK: Functions
|
||||||
|
|
||||||
#if swift(>=6.0)
|
|
||||||
/// Gets a list of amiibo items based on a given filter.
|
/// Gets a list of amiibo items based on a given filter.
|
||||||
/// - Parameter filter: A filter to remove unwanted items from the result.
|
/// - Parameter filter: A filter to remove unwanted items from the result.
|
||||||
/// - Returns: A list of filtered amiibo items.
|
/// - Returns: A list of filtered amiibo items.
|
||||||
@@ -115,64 +114,6 @@ extension AmiiboLiveClient: AmiiboClient {
|
|||||||
public func getLastUpdated() async throws(AmiiboServiceError) -> Date {
|
public func getLastUpdated() async throws(AmiiboServiceError) -> Date {
|
||||||
try await fetchLastUpdated()
|
try await fetchLastUpdated()
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
/// Gets a list of amiibo items based on a given filter.
|
|
||||||
/// - Parameter filter: A filter to remove unwanted items from the result.
|
|
||||||
/// - Returns: A list of filtered amiibo items.
|
|
||||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
|
||||||
public func getAmiibos(
|
|
||||||
by filter: AmiiboFilter
|
|
||||||
) async throws -> [Amiibo] {
|
|
||||||
try await fetchAmiibos(filter)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets a list of amiibo series based on a given filter.
|
|
||||||
/// - Parameter filter: A filter to remove unwanted items from the result.
|
|
||||||
/// - Returns: A list of filtered amiibo series.
|
|
||||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
|
||||||
public func getAmiiboSeries(
|
|
||||||
by filter: AmiiboSeriesFilter
|
|
||||||
) async throws -> [AmiiboSeries] {
|
|
||||||
try await fetchAmiiboSeries(filter)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets a list of amiibo types based on a given filter.
|
|
||||||
/// - Parameter filter: A filter to remove unwanted items from the result.
|
|
||||||
/// - Returns: A list of filtered amiibo types.
|
|
||||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
|
||||||
public func getAmiiboTypes(
|
|
||||||
by filter: AmiiboTypeFilter
|
|
||||||
) async throws -> [AmiiboType] {
|
|
||||||
try await fetchAmiiboTypes(filter)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets a list of game characters based on a given filter.
|
|
||||||
/// - Parameter filter: A filter to remove unwanted items from the result.
|
|
||||||
/// - Returns: A list of filtered game characters.
|
|
||||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
|
||||||
public func getGameCharacters(
|
|
||||||
by filter: GameCharacterFilter
|
|
||||||
) async throws -> [GameCharacter] {
|
|
||||||
try await fetchGameCharacters(filter)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets a list of game series based on a given filter.
|
|
||||||
/// - Parameter filter: A filter to remove unwanted items from the result.
|
|
||||||
/// - Returns: A list of filtered game series.
|
|
||||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
|
||||||
public func getGameSeries(
|
|
||||||
by filter: GameSeriesFilter
|
|
||||||
) async throws -> [GameSeries] {
|
|
||||||
try await fetchGameSeries(filter)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets the date when the data was last updated.
|
|
||||||
/// - Returns: A last updated date.
|
|
||||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
|
||||||
public func getLastUpdated() async throws -> Date {
|
|
||||||
try await fetchLastUpdated()
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,7 +129,7 @@ private extension AmiiboLiveClient {
|
|||||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
||||||
func fetchAmiibos(
|
func fetchAmiibos(
|
||||||
_ filter: AmiiboFilter
|
_ filter: AmiiboFilter
|
||||||
) async throws -> [Amiibo] {
|
) async throws(AmiiboServiceError) -> [Amiibo] {
|
||||||
let response: Operations.getAmiibos.Output
|
let response: Operations.getAmiibos.Output
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@@ -240,7 +181,7 @@ private extension AmiiboLiveClient {
|
|||||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
||||||
func fetchAmiiboSeries(
|
func fetchAmiiboSeries(
|
||||||
_ filter: AmiiboSeriesFilter
|
_ filter: AmiiboSeriesFilter
|
||||||
) async throws -> [AmiiboSeries] {
|
) async throws(AmiiboServiceError) -> [AmiiboSeries] {
|
||||||
let response: Operations.getAmiiboSeries.Output
|
let response: Operations.getAmiiboSeries.Output
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@@ -282,7 +223,7 @@ private extension AmiiboLiveClient {
|
|||||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
||||||
func fetchAmiiboTypes(
|
func fetchAmiiboTypes(
|
||||||
_ filter: AmiiboTypeFilter
|
_ filter: AmiiboTypeFilter
|
||||||
) async throws -> [AmiiboType] {
|
) async throws(AmiiboServiceError) -> [AmiiboType] {
|
||||||
let response: Operations.getAmiiboTypes.Output
|
let response: Operations.getAmiiboTypes.Output
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@@ -324,7 +265,7 @@ private extension AmiiboLiveClient {
|
|||||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
||||||
func fetchGameCharacters(
|
func fetchGameCharacters(
|
||||||
_ filter: GameCharacterFilter
|
_ filter: GameCharacterFilter
|
||||||
) async throws -> [GameCharacter] {
|
) async throws(AmiiboServiceError) -> [GameCharacter] {
|
||||||
let response: Operations.getGameCharacters.Output
|
let response: Operations.getGameCharacters.Output
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@@ -366,7 +307,7 @@ private extension AmiiboLiveClient {
|
|||||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
||||||
func fetchGameSeries(
|
func fetchGameSeries(
|
||||||
_ filter: GameSeriesFilter
|
_ filter: GameSeriesFilter
|
||||||
) async throws -> [GameSeries] {
|
) async throws(AmiiboServiceError) -> [GameSeries] {
|
||||||
let response: Operations.getGameSeries.Output
|
let response: Operations.getGameSeries.Output
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@@ -405,7 +346,7 @@ private extension AmiiboLiveClient {
|
|||||||
/// Fetches the date when the data was last updated.
|
/// Fetches the date when the data was last updated.
|
||||||
/// - Returns: A fetched last updated date.
|
/// - Returns: A fetched last updated date.
|
||||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
||||||
func fetchLastUpdated() async throws -> Date {
|
func fetchLastUpdated() async throws(AmiiboServiceError) -> Date {
|
||||||
let response: Operations.getLastUpdated.Output
|
let response: Operations.getLastUpdated.Output
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@@ -430,7 +371,7 @@ private extension AmiiboLiveClient {
|
|||||||
/// Maps a given error to an ``AmiiboServiceError`` error.
|
/// Maps a given error to an ``AmiiboServiceError`` error.
|
||||||
/// - Parameter error: An error to map.
|
/// - Parameter error: An error to map.
|
||||||
/// - Throws: An ``AmiiboServiceError`` error that corresponds to the given error.
|
/// - Throws: An ``AmiiboServiceError`` error that corresponds to the given error.
|
||||||
func handle(error: any Error) throws -> Never {
|
func handle(error: any Error) throws(AmiiboServiceError) -> Never {
|
||||||
switch error {
|
switch error {
|
||||||
case is CancellationError:
|
case is CancellationError:
|
||||||
throw AmiiboServiceError.cancelled
|
throw AmiiboServiceError.cancelled
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ public protocol AmiiboClient: Sendable {
|
|||||||
|
|
||||||
// MARK: Functions
|
// MARK: Functions
|
||||||
|
|
||||||
#if swift(>=6.0)
|
|
||||||
/// Gets a list of amiibo items based on a given filter.
|
/// Gets a list of amiibo items based on a given filter.
|
||||||
/// - Parameter filter: A filter to remove unwanted items from the result.
|
/// - Parameter filter: A filter to remove unwanted items from the result.
|
||||||
/// - Returns: A list of filtered amiibo items.
|
/// - Returns: A list of filtered amiibo items.
|
||||||
@@ -56,41 +55,5 @@ public protocol AmiiboClient: Sendable {
|
|||||||
/// - Returns: A last updated date.
|
/// - Returns: A last updated date.
|
||||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
||||||
func getLastUpdated() async throws(AmiiboServiceError) -> Date
|
func getLastUpdated() async throws(AmiiboServiceError) -> Date
|
||||||
#else
|
|
||||||
/// Gets a list of amiibo items based on a given filter.
|
|
||||||
/// - Parameter filter: A filter to remove unwanted items from the result.
|
|
||||||
/// - Returns: A list of filtered amiibo items.
|
|
||||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
|
||||||
func getAmiibos(by filter: AmiiboFilter) async throws -> [Amiibo]
|
|
||||||
|
|
||||||
/// Gets a list of amiibo series based on a given filter.
|
|
||||||
/// - Parameter filter: A filter to remove unwanted items from the result.
|
|
||||||
/// - Returns: A list of filtered amiibo series.
|
|
||||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
|
||||||
func getAmiiboSeries(by filter: AmiiboSeriesFilter) async throws -> [AmiiboSeries]
|
|
||||||
|
|
||||||
/// Gets a list of amiibo types based on a given filter.
|
|
||||||
/// - Parameter filter: A filter to remove unwanted items from the result.
|
|
||||||
/// - Returns: A list of filtered amiibo types.
|
|
||||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
|
||||||
func getAmiiboTypes(by filter: AmiiboTypeFilter) async throws -> [AmiiboType]
|
|
||||||
|
|
||||||
/// Gets a list of game characters based on a given filter.
|
|
||||||
/// - Parameter filter: A filter to remove unwanted items from the result.
|
|
||||||
/// - Returns: A list of filtered game characters.
|
|
||||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
|
||||||
func getGameCharacters(by filter: GameCharacterFilter) async throws -> [GameCharacter]
|
|
||||||
|
|
||||||
/// Gets a list of game series based on a given filter.
|
|
||||||
/// - Parameter filter: A filter to remove unwanted items from the result.
|
|
||||||
/// - Returns: A list of filtered game series.
|
|
||||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
|
||||||
func getGameSeries(by filter: GameSeriesFilter) async throws -> [GameSeries]
|
|
||||||
|
|
||||||
/// Gets the date when the data was last updated.
|
|
||||||
/// - Returns: A last updated date.
|
|
||||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
|
||||||
func getLastUpdated() async throws -> Date
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ public struct AmiiboService: Sendable {
|
|||||||
|
|
||||||
// MARK: Functions
|
// MARK: Functions
|
||||||
|
|
||||||
#if swift(>=6.0)
|
|
||||||
/// Gets a list of amiibo items based on a given filter.
|
/// Gets a list of amiibo items based on a given filter.
|
||||||
/// - Parameter filter: A filter to remove unwanted items from the result.
|
/// - Parameter filter: A filter to remove unwanted items from the result.
|
||||||
/// - Returns: A list of filtered amiibo items.
|
/// - Returns: A list of filtered amiibo items.
|
||||||
@@ -89,63 +88,5 @@ public struct AmiiboService: Sendable {
|
|||||||
public func getLastUpdated() async throws(AmiiboServiceError) -> Date {
|
public func getLastUpdated() async throws(AmiiboServiceError) -> Date {
|
||||||
try await client.getLastUpdated()
|
try await client.getLastUpdated()
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
/// Gets a list of amiibo items based on a given filter.
|
|
||||||
/// - Parameter filter: A filter to remove unwanted items from the result.
|
|
||||||
/// - Returns: A list of filtered amiibo items.
|
|
||||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
|
||||||
public func getAmiibos(
|
|
||||||
_ filter: AmiiboFilter = .init()
|
|
||||||
) async throws -> [Amiibo] {
|
|
||||||
try await client.getAmiibos(by: filter)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets a list of amiibo series based on a given filter.
|
|
||||||
/// - Parameter filter: A filter to remove unwanted items from the result.
|
|
||||||
/// - Returns: A list of filtered amiibo series.
|
|
||||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
|
||||||
public func getAmiiboSeries(
|
|
||||||
_ filter: AmiiboSeriesFilter = .init()
|
|
||||||
) async throws -> [AmiiboSeries] {
|
|
||||||
try await client.getAmiiboSeries(by: filter)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets a list of amiibo types based on a given filter.
|
|
||||||
/// - Parameter filter: A filter to remove unwanted items from the result.
|
|
||||||
/// - Returns: A list of filtered amiibo types.
|
|
||||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
|
||||||
public func getAmiiboTypes(
|
|
||||||
_ filter: AmiiboTypeFilter = .init()
|
|
||||||
) async throws -> [AmiiboType] {
|
|
||||||
try await client.getAmiiboTypes(by: filter)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets a list of game characters based on a given filter.
|
|
||||||
/// - Parameter filter: A filter to remove unwanted items from the result.
|
|
||||||
/// - Returns: A list of filtered game characters.
|
|
||||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
|
||||||
public func getGameCharacters(
|
|
||||||
_ filter: GameCharacterFilter = .init()
|
|
||||||
) async throws -> [GameCharacter] {
|
|
||||||
try await client.getGameCharacters(by: filter)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets a list of game series based on a given filter.
|
|
||||||
/// - Parameter filter: A filter to remove unwanted items from the result.
|
|
||||||
/// - Returns: A list of filtered game series.
|
|
||||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
|
||||||
public func getGameSeries(
|
|
||||||
_ filter: GameSeriesFilter = .init()
|
|
||||||
) async throws -> [GameSeries] {
|
|
||||||
try await client.getGameSeries(by: filter)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Gets the date when the data was last updated.
|
|
||||||
/// - Returns: A last updated date.
|
|
||||||
/// - Throws: An ``AmiiboServiceError`` error in case some issue is encountered while generating the result.
|
|
||||||
public func getLastUpdated() async throws -> Date {
|
|
||||||
try await client.getLastUpdated()
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ struct AmiiboServiceLiveTests {
|
|||||||
|
|
||||||
// MARK: Functions tests
|
// MARK: Functions tests
|
||||||
|
|
||||||
#if swift(>=6.2)
|
|
||||||
@Test(arguments: zip(
|
@Test(arguments: zip(
|
||||||
Input.amiibos,
|
Input.amiibos,
|
||||||
Output.amiibos
|
Output.amiibos
|
||||||
@@ -180,156 +179,6 @@ struct AmiiboServiceLiveTests {
|
|||||||
year: 2026
|
year: 2026
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
@Test("get amiibos", arguments: zip(
|
|
||||||
Input.amiibos,
|
|
||||||
Output.amiibos
|
|
||||||
))
|
|
||||||
func getAmiibos(
|
|
||||||
filter: AmiiboFilter,
|
|
||||||
expects numberOfItems: Int
|
|
||||||
) async throws {
|
|
||||||
try await assertAmiibos(
|
|
||||||
with: filter,
|
|
||||||
expects: numberOfItems
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test("get amiibos throws", arguments: zip(
|
|
||||||
Input.amiibosThrows,
|
|
||||||
Output.amiibosThrows
|
|
||||||
))
|
|
||||||
func getAmiibosThrows(
|
|
||||||
filter: AmiiboFilter,
|
|
||||||
expects error: AmiiboServiceError
|
|
||||||
) async throws {
|
|
||||||
try await assertsAmiibosThrows(
|
|
||||||
error: error,
|
|
||||||
when: filter
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test("get amiibo series", arguments: zip(
|
|
||||||
Input.amiiboSeries,
|
|
||||||
Output.amiiboSeries
|
|
||||||
))
|
|
||||||
func getAmiiboSeries(
|
|
||||||
filter: AmiiboSeriesFilter,
|
|
||||||
expects numberOfItems: Int
|
|
||||||
) async throws {
|
|
||||||
try await assertAmiiboSeries(
|
|
||||||
with: filter,
|
|
||||||
expects: numberOfItems
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test("get amiibo series throws", arguments: zip(
|
|
||||||
Input.amiiboSeriesThrows,
|
|
||||||
Output.amiiboSeriesThrows
|
|
||||||
))
|
|
||||||
func getAmiiboSeriesThrows(
|
|
||||||
filter: AmiiboSeriesFilter,
|
|
||||||
expects error: AmiiboServiceError
|
|
||||||
) async throws {
|
|
||||||
try await assertsAmiiboSeriesThrows(
|
|
||||||
error: error,
|
|
||||||
when: filter
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test("get amiibo types", arguments: zip(
|
|
||||||
Input.amiiboTypes,
|
|
||||||
Output.amiiboTypes
|
|
||||||
))
|
|
||||||
func getAmiiboTypes(
|
|
||||||
filter: AmiiboTypeFilter,
|
|
||||||
expects numberOfItems: Int
|
|
||||||
) async throws {
|
|
||||||
try await assertAmiiboTypes(
|
|
||||||
with: filter,
|
|
||||||
expects: numberOfItems
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test("get amiibo types throws", arguments: zip(
|
|
||||||
Input.amiiboTypesThrows,
|
|
||||||
Output.amiiboTypesThrows
|
|
||||||
))
|
|
||||||
func getAmiiboTypesThrows(
|
|
||||||
filter: AmiiboTypeFilter,
|
|
||||||
expects error: AmiiboServiceError
|
|
||||||
) async throws {
|
|
||||||
try await assertsAmiiboTypesThrows(
|
|
||||||
error: error,
|
|
||||||
when: filter
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test("get game characters", arguments: zip(
|
|
||||||
Input.gameCharacters,
|
|
||||||
Output.gameCharacters
|
|
||||||
))
|
|
||||||
func getGameCharacters(
|
|
||||||
filter: GameCharacterFilter,
|
|
||||||
expects numberOfItems: Int
|
|
||||||
) async throws {
|
|
||||||
try await assertGameCharacters(
|
|
||||||
with: filter,
|
|
||||||
expects: numberOfItems
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test("get game characters throws", arguments: zip(
|
|
||||||
Input.gameCharactersThrows,
|
|
||||||
Output.gameCharactersThrows
|
|
||||||
))
|
|
||||||
func getGameCharactersThrows(
|
|
||||||
filter: GameCharacterFilter,
|
|
||||||
expects error: AmiiboServiceError
|
|
||||||
) async throws {
|
|
||||||
try await assertsGameCharactersThrows(
|
|
||||||
error: error,
|
|
||||||
when: filter
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test("get game series", arguments: zip(
|
|
||||||
Input.gameSeries,
|
|
||||||
Output.gameSeries
|
|
||||||
))
|
|
||||||
func getGameSeries(
|
|
||||||
filter: GameSeriesFilter,
|
|
||||||
expects numberOfItems: Int
|
|
||||||
) async throws {
|
|
||||||
try await assertGameSeries(
|
|
||||||
with: filter,
|
|
||||||
expects: numberOfItems
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test("get game series throws", arguments: zip(
|
|
||||||
Input.gameSeriesThrows,
|
|
||||||
Output.gameSeriesThrows
|
|
||||||
))
|
|
||||||
func getGameSeriesThrows(
|
|
||||||
filter: GameSeriesFilter,
|
|
||||||
expects error: AmiiboServiceError
|
|
||||||
) async throws {
|
|
||||||
try await assertsGameSeriesThrows(
|
|
||||||
error: error,
|
|
||||||
when: filter
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test("get last updated timestamp")
|
|
||||||
func getLastUpdated() async throws {
|
|
||||||
try await assertLastUpdated(
|
|
||||||
day: 24,
|
|
||||||
month: 7,
|
|
||||||
year: 2026
|
|
||||||
)
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ extension AmiiboMockClient: AmiiboClient {
|
|||||||
|
|
||||||
// MARK: Functions
|
// MARK: Functions
|
||||||
|
|
||||||
#if swift(>=6.0)
|
|
||||||
func getAmiibos(
|
func getAmiibos(
|
||||||
by filter: AmiiboFilter
|
by filter: AmiiboFilter
|
||||||
) async throws(AmiiboServiceError) -> [Amiibo] {
|
) async throws(AmiiboServiceError) -> [Amiibo] {
|
||||||
@@ -110,43 +109,8 @@ extension AmiiboMockClient: AmiiboClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getLastUpdated() async throws(AmiiboServiceError) -> Date {
|
func getLastUpdated() async throws(AmiiboServiceError) -> Date {
|
||||||
fetchLastUpdatedIfAny()
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
func getAmiibos(
|
|
||||||
by filter: AmiiboFilter
|
|
||||||
) async throws -> [Amiibo] {
|
|
||||||
try fetchAmiibosIfAny()
|
|
||||||
}
|
|
||||||
|
|
||||||
func getAmiiboSeries(
|
|
||||||
by filter: AmiiboSeriesFilter
|
|
||||||
) async throws -> [AmiiboSeries] {
|
|
||||||
try fetchAmiiboSeriesIfAny()
|
|
||||||
}
|
|
||||||
|
|
||||||
func getAmiiboTypes(
|
|
||||||
by filter: AmiiboTypeFilter
|
|
||||||
) async throws -> [AmiiboType] {
|
|
||||||
try fetchAmiiboTypesIfAny()
|
|
||||||
}
|
|
||||||
|
|
||||||
func getGameCharacters(
|
|
||||||
by filter: GameCharacterFilter
|
|
||||||
) async throws -> [GameCharacter] {
|
|
||||||
try fetchGameCharactersIfAny()
|
|
||||||
}
|
|
||||||
|
|
||||||
func getGameSeries(
|
|
||||||
by filter: GameSeriesFilter
|
|
||||||
) async throws -> [GameSeries] {
|
|
||||||
try fetchGameSeriesIfAny()
|
|
||||||
}
|
|
||||||
|
|
||||||
func getLastUpdated() async throws -> Date {
|
|
||||||
try fetchLastUpdatedIfAny()
|
try fetchLastUpdatedIfAny()
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,7 +123,7 @@ private extension AmiiboMockClient {
|
|||||||
/// Fetches a list of amiibo items, if any.
|
/// Fetches a list of amiibo items, if any.
|
||||||
/// - Returns: A list of amiibo items.
|
/// - Returns: A list of amiibo items.
|
||||||
/// - Throws: An ``AmiiboServiceError`` error in case an error has been provided.
|
/// - Throws: An ``AmiiboServiceError`` error in case an error has been provided.
|
||||||
func fetchAmiibosIfAny() throws -> [Amiibo] {
|
func fetchAmiibosIfAny() throws(AmiiboServiceError) -> [Amiibo] {
|
||||||
try throwErrorIfExists()
|
try throwErrorIfExists()
|
||||||
|
|
||||||
guard let amiibos else {
|
guard let amiibos else {
|
||||||
@@ -172,7 +136,7 @@ private extension AmiiboMockClient {
|
|||||||
/// Fetches a list of amiibo series, if any.
|
/// Fetches a list of amiibo series, if any.
|
||||||
/// - Returns: A list of amiibo series.
|
/// - Returns: A list of amiibo series.
|
||||||
/// - Throws: An ``AmiiboServiceError`` error in case an error has been provided.
|
/// - Throws: An ``AmiiboServiceError`` error in case an error has been provided.
|
||||||
func fetchAmiiboSeriesIfAny() throws -> [AmiiboSeries] {
|
func fetchAmiiboSeriesIfAny() throws(AmiiboServiceError) -> [AmiiboSeries] {
|
||||||
try throwErrorIfExists()
|
try throwErrorIfExists()
|
||||||
|
|
||||||
guard let amiiboSeries else {
|
guard let amiiboSeries else {
|
||||||
@@ -185,7 +149,7 @@ private extension AmiiboMockClient {
|
|||||||
/// Fetches a list of amiibo types, if any.
|
/// Fetches a list of amiibo types, if any.
|
||||||
/// - Returns: A list of amiibo types.
|
/// - Returns: A list of amiibo types.
|
||||||
/// - Throws: An ``AmiiboServiceError`` error in case an error has been provided.
|
/// - Throws: An ``AmiiboServiceError`` error in case an error has been provided.
|
||||||
func fetchAmiiboTypesIfAny() throws -> [AmiiboType] {
|
func fetchAmiiboTypesIfAny() throws(AmiiboServiceError) -> [AmiiboType] {
|
||||||
try throwErrorIfExists()
|
try throwErrorIfExists()
|
||||||
|
|
||||||
guard let amiiboTypes else {
|
guard let amiiboTypes else {
|
||||||
@@ -198,7 +162,7 @@ private extension AmiiboMockClient {
|
|||||||
/// Fetches a list of game characters, if any.
|
/// Fetches a list of game characters, if any.
|
||||||
/// - Returns: A list of game characters.
|
/// - Returns: A list of game characters.
|
||||||
/// - Throws: An ``AmiiboServiceError`` error in case an error has been provided.
|
/// - Throws: An ``AmiiboServiceError`` error in case an error has been provided.
|
||||||
func fetchGameCharactersIfAny() throws -> [GameCharacter] {
|
func fetchGameCharactersIfAny() throws(AmiiboServiceError) -> [GameCharacter] {
|
||||||
try throwErrorIfExists()
|
try throwErrorIfExists()
|
||||||
|
|
||||||
guard let gameCharacters else {
|
guard let gameCharacters else {
|
||||||
@@ -211,7 +175,7 @@ private extension AmiiboMockClient {
|
|||||||
/// Fetches a list of game series, if any.
|
/// Fetches a list of game series, if any.
|
||||||
/// - Returns: A list of game series, if any.
|
/// - Returns: A list of game series, if any.
|
||||||
/// - Throws: An ``AmiiboServiceError`` error in case an error has been provided.
|
/// - Throws: An ``AmiiboServiceError`` error in case an error has been provided.
|
||||||
func fetchGameSeriesIfAny() throws -> [GameSeries] {
|
func fetchGameSeriesIfAny() throws(AmiiboServiceError) -> [GameSeries] {
|
||||||
try throwErrorIfExists()
|
try throwErrorIfExists()
|
||||||
|
|
||||||
guard let gameSeries else {
|
guard let gameSeries else {
|
||||||
@@ -224,7 +188,7 @@ private extension AmiiboMockClient {
|
|||||||
/// Fetches a last updated date, if any.
|
/// Fetches a last updated date, if any.
|
||||||
/// - Returns: A last updated date.
|
/// - Returns: A last updated date.
|
||||||
/// - Throws: An ``AmiiboServiceError`` error in case an error has been provided.
|
/// - Throws: An ``AmiiboServiceError`` error in case an error has been provided.
|
||||||
func fetchLastUpdatedIfAny() throws -> Date {
|
func fetchLastUpdatedIfAny() throws(AmiiboServiceError) -> Date {
|
||||||
try throwErrorIfExists()
|
try throwErrorIfExists()
|
||||||
|
|
||||||
guard let lastUpdated else {
|
guard let lastUpdated else {
|
||||||
|
|||||||
Reference in New Issue
Block a user