Implemented the Result model.

This commit is contained in:
Javier Cicchelli 2023-04-20 00:14:37 +02:00
parent 60c1bf55db
commit 2dbf805870

View File

@ -0,0 +1,27 @@
struct Result<Model: Decodable> {
let items: [Model]
}
// MARK: - Decodable
extension Result: Decodable {
// MARK: Enumerations
enum CodingKeys: String, CodingKey {
case items = "amiibo"
}
// MARK: Initialisers
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
do {
self.items = try container.decode([Model].self, forKey: .items)
} catch {
self.items = [try container.decode(Model.self, forKey: .items)]
}
}
}