Conformed the Amiibo public model and its child models to the DTO namespace.
This commit is contained in:
parent
c5701a4881
commit
31edafee3e
@ -10,8 +10,10 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
/// 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 {
|
||||
|
||||
/// 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
|
||||
|
||||
@ -44,11 +46,13 @@ public struct Amiibo {
|
||||
|
||||
/// 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
|
||||
|
@ -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"
|
@ -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"
|
@ -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"
|
@ -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
|
||||
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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]
|
||||
|
@ -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<Amiibo>.self
|
||||
as: Result<DTO.Amiibo>.self
|
||||
).items
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user