Skip to content

Commit

Permalink
Add firstAired and network properties into Trakt Season
Browse files Browse the repository at this point in the history
  • Loading branch information
Pietro Caselani committed Jan 1, 2020
1 parent a5227a4 commit e309b68
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion TraktSwift/Models/Show/Season.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ public struct Season: Codable, Hashable {
public let airedEpisodes: Int?
public let episodes: [Episode]?
public let title: String?
public let firstAired: Date?
public let network: String?

private enum CodingKeys: String, CodingKey {
case number, ids, overview, rating, votes, episodes, title
case number, ids, overview, rating, votes, episodes, title, network
case episodeCount = "episode_count"
case airedEpisodes = "aired_episodes"
case firstAired = "first_aired"
}

public init(from decoder: Decoder) throws {
Expand All @@ -27,5 +30,9 @@ public struct Season: Codable, Hashable {
airedEpisodes = try container.decodeIfPresent(Int.self, forKey: .airedEpisodes)
episodes = try container.decodeIfPresent([Episode].self, forKey: .episodes)
title = try container.decodeIfPresent(String.self, forKey: .title)
network = try container.decodeIfPresent(String.self, forKey: .network)

let firstAired = try container.decodeIfPresent(String.self, forKey: .firstAired)
self.firstAired = TraktDateTransformer.dateTimeTransformer.transformFromJSON(firstAired)
}
}

0 comments on commit e309b68

Please sign in to comment.