Implemented the "encode(to: )" function of the Encodable protocol for the Feed model in the iTunes library.

This commit is contained in:
Javier Cicchelli 2024-03-17 23:01:47 +01:00
parent f6a72e8465
commit bd72c4fb7c
2 changed files with 14 additions and 0 deletions

View File

@ -7,6 +7,7 @@
//
import Foundation
import ReviewsFoundationKit
import ReviewsFeedKit
extension ServiceConfiguration {

View File

@ -36,3 +36,16 @@ extension Feed: Decodable {
}
}
// MARK: - Encodable
extension Feed: Encodable {
// MARK: Functions
func encode(to encoder: any Encoder) throws {
var feed = encoder.container(keyedBy: FeedKeys.self)
var feedEntry = feed.nestedContainer(keyedBy: EntryKeys.self, forKey: .feed)
try feedEntry.encode(entries, forKey: .entry)
}
}