From bd72c4fb7c4f05fa2b6d5bc3417d66bb8a0d2377 Mon Sep 17 00:00:00 2001 From: Javier Cicchelli Date: Sun, 17 Mar 2024 23:01:47 +0100 Subject: [PATCH] Implemented the "encode(to: )" function of the Encodable protocol for the Feed model in the iTunes library. --- .../Kit/Extensions/ServiceConfiguration+Inits.swift | 1 + Libraries/iTunes/Kit/Models/Feed.swift | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/Libraries/iTunes/Kit/Extensions/ServiceConfiguration+Inits.swift b/Libraries/iTunes/Kit/Extensions/ServiceConfiguration+Inits.swift index 50ec996..f156e71 100644 --- a/Libraries/iTunes/Kit/Extensions/ServiceConfiguration+Inits.swift +++ b/Libraries/iTunes/Kit/Extensions/ServiceConfiguration+Inits.swift @@ -7,6 +7,7 @@ // import Foundation +import ReviewsFoundationKit import ReviewsFeedKit extension ServiceConfiguration { diff --git a/Libraries/iTunes/Kit/Models/Feed.swift b/Libraries/iTunes/Kit/Models/Feed.swift index 4928aef..718004c 100644 --- a/Libraries/iTunes/Kit/Models/Feed.swift +++ b/Libraries/iTunes/Kit/Models/Feed.swift @@ -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) + } + +}