diff --git a/Sources/Models/Amiibo.swift b/Sources/Models/DTO/Amiibo.swift similarity index 71% rename from Sources/Models/Amiibo.swift rename to Sources/Models/DTO/Amiibo.swift index c971d7e..707b444 100644 --- a/Sources/Models/Amiibo.swift +++ b/Sources/Models/DTO/Amiibo.swift @@ -10,45 +10,49 @@ // //===----------------------------------------------------------------------===// -/// This model struct represents an amiibo that is retrieved from the respective [remote API endpoint](https://www.amiiboapi.com/docs/#amiibo). -public struct Amiibo { +extension DTO { - // MARK: Properties + /// This model struct represents an amiibo that is retrieved from the respective [remote API endpoint](https://www.amiiboapi.com/docs/#amiibo). + public struct Amiibo { + + // MARK: Properties + + /// The type the amiibo belongs to. + public let type: String + + /// The first 8 values of the hexadecimal that identifies the amiibo. + public let head: String + + /// The last 8 values of the hexadecimal that identifies the amiibo. + public let tail: String + + /// The name of the amiibo. + public let name: String + + /// The character of the amiibo. + public let character: String + + /// The series the amiibo belongs to. + public let series: String + + /// The game series of the amiibo. + public let gameSeries: String + + /// The URL to an image of the amiibo. + public let image: String + + /// The release dates of the amiibo (if released) in Australia, Europe, Japan and North America. + public let release: Release + + /// The games related to the amiibo, if requested. + public let games: Games? + } - /// The type the amiibo belongs to. - public let type: String - - /// The first 8 values of the hexadecimal that identifies the amiibo. - public let head: String - - /// The last 8 values of the hexadecimal that identifies the amiibo. - public let tail: String - - /// The name of the amiibo. - public let name: String - - /// The character of the amiibo. - public let character: String - - /// The series the amiibo belongs to. - public let series: String - - /// The game series of the amiibo. - public let gameSeries: String - - /// The URL to an image of the amiibo. - public let image: String - - /// The release dates of the amiibo (if released) in Australia, Europe, Japan and North America. - public let release: Release - - /// The games related to the amiibo, if requested. - public let games: Games? } // MARK: - Structs -extension Amiibo { +extension DTO.Amiibo { /// This model represents the list of games related to a particular amiibo, grouped by system. public struct Games: Decodable { @@ -67,7 +71,7 @@ extension Amiibo { // MARK: - Decodable -extension Amiibo: Decodable { +extension DTO.Amiibo: Decodable { // MARK: Enumerations diff --git a/Sources/Models/AmiiboGame.swift b/Sources/Models/DTO/AmiiboGame.swift similarity index 94% rename from Sources/Models/AmiiboGame.swift rename to Sources/Models/DTO/AmiiboGame.swift index d9b1b15..d44d0f4 100644 --- a/Sources/Models/AmiiboGame.swift +++ b/Sources/Models/DTO/AmiiboGame.swift @@ -10,7 +10,8 @@ // //===----------------------------------------------------------------------===// -extension Amiibo { +extension DTO.Amiibo { + /// This model structs represents a game that is related to an amiibo, when requested to the respective [remote API endpoint](https://www.amiiboapi.com/docs/#showGames). public struct Game { @@ -26,11 +27,12 @@ extension Amiibo { public let usage: [Usage]? } + } // MARK: - Decodable -extension Amiibo.Game: Decodable { +extension DTO.Amiibo.Game: Decodable { enum CodingKeys: String, CodingKey { case ids = "gameID" case name = "gameName" diff --git a/Sources/Models/AmiiboGameUsage.swift b/Sources/Models/DTO/AmiiboGameUsage.swift similarity index 93% rename from Sources/Models/AmiiboGameUsage.swift rename to Sources/Models/DTO/AmiiboGameUsage.swift index 8865e2f..b640050 100644 --- a/Sources/Models/AmiiboGameUsage.swift +++ b/Sources/Models/DTO/AmiiboGameUsage.swift @@ -10,7 +10,8 @@ // //===----------------------------------------------------------------------===// -extension Amiibo.Game { +extension DTO.Amiibo.Game { + /// This model struct represents how an amiibo is used with a particular game, when requested to the respective [remote API endpoint](https://www.amiiboapi.com/docs/#showUsage). public struct Usage { @@ -23,11 +24,12 @@ extension Amiibo.Game { public let isWritable: Bool } + } // MARK: - Decodable -extension Amiibo.Game.Usage: Decodable { +extension DTO.Amiibo.Game.Usage: Decodable { enum CodingKeys: String, CodingKey { case explanation = "Usage" case isWritable = "write" diff --git a/Sources/Models/AmiiboRelease.swift b/Sources/Models/DTO/AmiiboRelease.swift similarity index 95% rename from Sources/Models/AmiiboRelease.swift rename to Sources/Models/DTO/AmiiboRelease.swift index cce47ec..15e0285 100644 --- a/Sources/Models/AmiiboRelease.swift +++ b/Sources/Models/DTO/AmiiboRelease.swift @@ -12,7 +12,8 @@ import Foundation -extension Amiibo { +extension DTO.Amiibo { + /// This model struct represents a collection of official release dates (if released) of an amiibo in different markets around the world. public struct Release { @@ -31,11 +32,12 @@ extension Amiibo { public let america: Date? } + } // MARK: - Decodable -extension Amiibo.Release: Decodable { +extension DTO.Amiibo.Release: Decodable { enum CodingKeys: String, CodingKey { case australia = "au" case europe = "eu" diff --git a/Sources/Models/DTO/KeyName.swift b/Sources/Models/DTO/KeyName.swift index 73e7fee..bd83f4d 100644 --- a/Sources/Models/DTO/KeyName.swift +++ b/Sources/Models/DTO/KeyName.swift @@ -10,10 +10,10 @@ // //===----------------------------------------------------------------------===// -public extension DTO { +extension DTO { /// This model is a concrete genetic definition that represents the following models: ``AmiiboSeries``, ``AmiiboType``, ``Character`` and ``GameSeries``. - struct KeyName { + public struct KeyName { // MARK: Properties @@ -29,19 +29,19 @@ public extension DTO { // MARK: - Type aliases -public extension DTO { +extension DTO { /// This model represents the series an amiibo belongs to. - typealias AmiiboSeries = DTO.KeyName + public typealias AmiiboSeries = DTO.KeyName /// This model represents the type an amiibo belongs to. - typealias AmiiboType = KeyName + public typealias AmiiboType = KeyName /// This model represents the character an amiibo is associated to. - typealias Character = KeyName + public typealias Character = KeyName /// This model represents the games series an amiibo is associated to. - typealias GameSeries = KeyName + public typealias GameSeries = KeyName } diff --git a/Sources/Models/DTO/LastUpdated.swift b/Sources/Models/DTO/LastUpdated.swift index 94224d0..ed4f197 100644 --- a/Sources/Models/DTO/LastUpdated.swift +++ b/Sources/Models/DTO/LastUpdated.swift @@ -12,10 +12,10 @@ import Foundation -public extension DTO { +extension DTO { /// This model represents the latest date when the remote API has been updated. - struct LastUpdated { + public struct LastUpdated { // MARK: Properties diff --git a/Sources/Protocols/Service.swift b/Sources/Protocols/Service.swift index 3e04350..57bdc01 100644 --- a/Sources/Protocols/Service.swift +++ b/Sources/Protocols/Service.swift @@ -16,7 +16,7 @@ protocol Service { // MARK: Functions - func amiibos(filter: AmiiboFilter) async throws -> [Amiibo] + func amiibos(filter: AmiiboFilter) async throws -> [DTO.Amiibo] func amiiboSeries(filter: AmiiboSeriesFilter) async throws -> [DTO.AmiiboSeries] func amiiboTypes(filter: AmiiboTypeFilter) async throws -> [DTO.AmiiboType] func gameSeries(filter: GameSeriesFilter) async throws -> [DTO.GameSeries] diff --git a/Sources/Services/AmiiboService.swift b/Sources/Services/AmiiboService.swift index 82108da..ef4ee3c 100644 --- a/Sources/Services/AmiiboService.swift +++ b/Sources/Services/AmiiboService.swift @@ -47,12 +47,12 @@ extension AmiiboService: Service { /// - Throws: A ``AmiiboClientError`` is thrown in case a request failed, or a `DecodingError` is thrown in case the decoding of some object failed. public func amiibos( filter: AmiiboFilter = .init() - ) async throws -> [Amiibo] { + ) async throws -> [DTO.Amiibo] { client.setDateDecodingStrategy(.formatted(.dateOnly)) return try await client.request( endpoint: GetAmiiboEndpoint(parameters: filter.makeParameters()), - as: Result.self + as: Result.self ).items }