Added the "error" property to the AmiiboMockClient client in the package target.
This commit is contained in:
parent
b29815f044
commit
4a8f402036
@ -19,6 +19,7 @@ public struct AmiiboMockClient {
|
|||||||
private let amiibos: [Amiibo]?
|
private let amiibos: [Amiibo]?
|
||||||
private let amiiboSeries: [AmiiboSeries]?
|
private let amiiboSeries: [AmiiboSeries]?
|
||||||
private let amiiboTypes: [AmiiboType]?
|
private let amiiboTypes: [AmiiboType]?
|
||||||
|
private let error: AmiiboServiceError?
|
||||||
private let gameCharacters: [GameCharacter]?
|
private let gameCharacters: [GameCharacter]?
|
||||||
private let gameSeries: [GameSeries]?
|
private let gameSeries: [GameSeries]?
|
||||||
private let lastUpdated: Date?
|
private let lastUpdated: Date?
|
||||||
@ -31,11 +32,13 @@ public struct AmiiboMockClient {
|
|||||||
amiiboTypes: [AmiiboType]? = nil,
|
amiiboTypes: [AmiiboType]? = nil,
|
||||||
gameCharacters: [GameCharacter]? = nil,
|
gameCharacters: [GameCharacter]? = nil,
|
||||||
gameSeries: [GameSeries]? = nil,
|
gameSeries: [GameSeries]? = nil,
|
||||||
lastUpdated: Date? = nil
|
lastUpdated: Date? = nil,
|
||||||
|
error: AmiiboServiceError? = nil
|
||||||
) {
|
) {
|
||||||
self.amiibos = amiibos
|
self.amiibos = amiibos
|
||||||
self.amiiboSeries = amiiboSeries
|
self.amiiboSeries = amiiboSeries
|
||||||
self.amiiboTypes = amiiboTypes
|
self.amiiboTypes = amiiboTypes
|
||||||
|
self.error = error
|
||||||
self.gameCharacters = gameCharacters
|
self.gameCharacters = gameCharacters
|
||||||
self.gameSeries = gameSeries
|
self.gameSeries = gameSeries
|
||||||
self.lastUpdated = lastUpdated
|
self.lastUpdated = lastUpdated
|
||||||
@ -50,6 +53,8 @@ extension AmiiboMockClient: APIClient {
|
|||||||
// MARK: Functions
|
// MARK: Functions
|
||||||
|
|
||||||
public func getAmiibos(by filter: AmiiboFilter) async throws -> [Amiibo] {
|
public func getAmiibos(by filter: AmiiboFilter) async throws -> [Amiibo] {
|
||||||
|
try throwErrorIfExists()
|
||||||
|
|
||||||
guard let amiibos else {
|
guard let amiibos else {
|
||||||
throw AmiiboServiceError.notFound
|
throw AmiiboServiceError.notFound
|
||||||
}
|
}
|
||||||
@ -58,6 +63,8 @@ extension AmiiboMockClient: APIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func getAmiiboSeries(by filter: AmiiboSeriesFilter) async throws -> [AmiiboSeries] {
|
public func getAmiiboSeries(by filter: AmiiboSeriesFilter) async throws -> [AmiiboSeries] {
|
||||||
|
try throwErrorIfExists()
|
||||||
|
|
||||||
guard let amiiboSeries else {
|
guard let amiiboSeries else {
|
||||||
throw AmiiboServiceError.notFound
|
throw AmiiboServiceError.notFound
|
||||||
}
|
}
|
||||||
@ -66,6 +73,8 @@ extension AmiiboMockClient: APIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func getAmiiboTypes(by filter: AmiiboTypeFilter) async throws -> [AmiiboType] {
|
public func getAmiiboTypes(by filter: AmiiboTypeFilter) async throws -> [AmiiboType] {
|
||||||
|
try throwErrorIfExists()
|
||||||
|
|
||||||
guard let amiiboTypes else {
|
guard let amiiboTypes else {
|
||||||
throw AmiiboServiceError.notFound
|
throw AmiiboServiceError.notFound
|
||||||
}
|
}
|
||||||
@ -74,6 +83,8 @@ extension AmiiboMockClient: APIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func getGameCharacters(by filter: GameCharacterFilter) async throws -> [GameCharacter] {
|
public func getGameCharacters(by filter: GameCharacterFilter) async throws -> [GameCharacter] {
|
||||||
|
try throwErrorIfExists()
|
||||||
|
|
||||||
guard let gameCharacters else {
|
guard let gameCharacters else {
|
||||||
throw AmiiboServiceError.notFound
|
throw AmiiboServiceError.notFound
|
||||||
}
|
}
|
||||||
@ -82,6 +93,8 @@ extension AmiiboMockClient: APIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func getGameSeries(by filter: GameSeriesFilter) async throws -> [GameSeries] {
|
public func getGameSeries(by filter: GameSeriesFilter) async throws -> [GameSeries] {
|
||||||
|
try throwErrorIfExists()
|
||||||
|
|
||||||
guard let gameSeries else {
|
guard let gameSeries else {
|
||||||
throw AmiiboServiceError.notFound
|
throw AmiiboServiceError.notFound
|
||||||
}
|
}
|
||||||
@ -90,6 +103,8 @@ extension AmiiboMockClient: APIClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func getLastUpdated() async throws -> Date {
|
public func getLastUpdated() async throws -> Date {
|
||||||
|
try throwErrorIfExists()
|
||||||
|
|
||||||
guard let lastUpdated else {
|
guard let lastUpdated else {
|
||||||
throw AmiiboServiceError.notFound
|
throw AmiiboServiceError.notFound
|
||||||
}
|
}
|
||||||
@ -99,3 +114,17 @@ extension AmiiboMockClient: APIClient {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MARK: - Helpers
|
||||||
|
|
||||||
|
private extension AmiiboMockClient {
|
||||||
|
|
||||||
|
// MARK: Functions
|
||||||
|
|
||||||
|
func throwErrorIfExists() throws {
|
||||||
|
if let error {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user