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).
|
extension DTO {
|
||||||
public struct Amiibo {
|
|
||||||
|
/// 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
|
// MARK: Properties
|
||||||
|
|
||||||
@ -44,11 +46,13 @@ public struct Amiibo {
|
|||||||
|
|
||||||
/// The games related to the amiibo, if requested.
|
/// The games related to the amiibo, if requested.
|
||||||
public let games: Games?
|
public let games: Games?
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Structs
|
// MARK: - Structs
|
||||||
|
|
||||||
extension Amiibo {
|
extension DTO.Amiibo {
|
||||||
/// This model represents the list of games related to a particular amiibo, grouped by system.
|
/// This model represents the list of games related to a particular amiibo, grouped by system.
|
||||||
public struct Games: Decodable {
|
public struct Games: Decodable {
|
||||||
|
|
||||||
@ -67,7 +71,7 @@ extension Amiibo {
|
|||||||
|
|
||||||
// MARK: - Decodable
|
// MARK: - Decodable
|
||||||
|
|
||||||
extension Amiibo: Decodable {
|
extension DTO.Amiibo: Decodable {
|
||||||
|
|
||||||
// MARK: Enumerations
|
// 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).
|
/// 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 {
|
public struct Game {
|
||||||
|
|
||||||
@ -26,11 +27,12 @@ extension Amiibo {
|
|||||||
public let usage: [Usage]?
|
public let usage: [Usage]?
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Decodable
|
// MARK: - Decodable
|
||||||
|
|
||||||
extension Amiibo.Game: Decodable {
|
extension DTO.Amiibo.Game: Decodable {
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case ids = "gameID"
|
case ids = "gameID"
|
||||||
case name = "gameName"
|
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).
|
/// 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 {
|
public struct Usage {
|
||||||
|
|
||||||
@ -23,11 +24,12 @@ extension Amiibo.Game {
|
|||||||
public let isWritable: Bool
|
public let isWritable: Bool
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Decodable
|
// MARK: - Decodable
|
||||||
|
|
||||||
extension Amiibo.Game.Usage: Decodable {
|
extension DTO.Amiibo.Game.Usage: Decodable {
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case explanation = "Usage"
|
case explanation = "Usage"
|
||||||
case isWritable = "write"
|
case isWritable = "write"
|
@ -12,7 +12,8 @@
|
|||||||
|
|
||||||
import Foundation
|
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.
|
/// This model struct represents a collection of official release dates (if released) of an amiibo in different markets around the world.
|
||||||
public struct Release {
|
public struct Release {
|
||||||
|
|
||||||
@ -31,11 +32,12 @@ extension Amiibo {
|
|||||||
public let america: Date?
|
public let america: Date?
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Decodable
|
// MARK: - Decodable
|
||||||
|
|
||||||
extension Amiibo.Release: Decodable {
|
extension DTO.Amiibo.Release: Decodable {
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case australia = "au"
|
case australia = "au"
|
||||||
case europe = "eu"
|
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``.
|
/// This model is a concrete genetic definition that represents the following models: ``AmiiboSeries``, ``AmiiboType``, ``Character`` and ``GameSeries``.
|
||||||
struct KeyName {
|
public struct KeyName {
|
||||||
|
|
||||||
// MARK: Properties
|
// MARK: Properties
|
||||||
|
|
||||||
@ -29,19 +29,19 @@ public extension DTO {
|
|||||||
|
|
||||||
// MARK: - Type aliases
|
// MARK: - Type aliases
|
||||||
|
|
||||||
public extension DTO {
|
extension DTO {
|
||||||
|
|
||||||
/// This model represents the series an amiibo belongs to.
|
/// 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.
|
/// 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.
|
/// 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.
|
/// This model represents the games series an amiibo is associated to.
|
||||||
typealias GameSeries = KeyName
|
public typealias GameSeries = KeyName
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,10 +12,10 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public extension DTO {
|
extension DTO {
|
||||||
|
|
||||||
/// This model represents the latest date when the remote API has been updated.
|
/// This model represents the latest date when the remote API has been updated.
|
||||||
struct LastUpdated {
|
public struct LastUpdated {
|
||||||
|
|
||||||
// MARK: Properties
|
// MARK: Properties
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ protocol Service {
|
|||||||
|
|
||||||
// MARK: Functions
|
// 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 amiiboSeries(filter: AmiiboSeriesFilter) async throws -> [DTO.AmiiboSeries]
|
||||||
func amiiboTypes(filter: AmiiboTypeFilter) async throws -> [DTO.AmiiboType]
|
func amiiboTypes(filter: AmiiboTypeFilter) async throws -> [DTO.AmiiboType]
|
||||||
func gameSeries(filter: GameSeriesFilter) async throws -> [DTO.GameSeries]
|
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.
|
/// - 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(
|
public func amiibos(
|
||||||
filter: AmiiboFilter = .init()
|
filter: AmiiboFilter = .init()
|
||||||
) async throws -> [Amiibo] {
|
) async throws -> [DTO.Amiibo] {
|
||||||
client.setDateDecodingStrategy(.formatted(.dateOnly))
|
client.setDateDecodingStrategy(.formatted(.dateOnly))
|
||||||
|
|
||||||
return try await client.request(
|
return try await client.request(
|
||||||
endpoint: GetAmiiboEndpoint(parameters: filter.makeParameters()),
|
endpoint: GetAmiiboEndpoint(parameters: filter.makeParameters()),
|
||||||
as: Result<Amiibo>.self
|
as: Result<DTO.Amiibo>.self
|
||||||
).items
|
).items
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user