Skip to content

Commit

Permalink
Merge branch 'main' into config/xcode-15
Browse files Browse the repository at this point in the history
  • Loading branch information
adamayoung authored Jan 7, 2024
2 parents 784fb40 + 59070ab commit ad26967
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Sources/TMDb/Models/Show.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Foundation
///
/// A model representing a show - movie or TV series.
///
public enum Show: Identifiable, Equatable, Hashable {
public enum Show: Identifiable, Codable, Equatable, Hashable {

///
/// Show identifier.
Expand Down Expand Up @@ -56,7 +56,7 @@ public enum Show: Identifiable, Equatable, Hashable {

}

extension Show: Decodable {
extension Show {

private enum CodingKeys: String, CodingKey {
case mediaType
Expand All @@ -80,4 +80,15 @@ extension Show: Decodable {
}
}

public func encode(to encoder: Encoder) throws {
var singleContainer = encoder.singleValueContainer()

switch self {
case .movie(let movie):
try singleContainer.encode(movie)

case .tvSeries(let tvSeries):
try singleContainer.encode(tvSeries)
}
}
}

0 comments on commit ad26967

Please sign in to comment.