2021-12-08 02:58:02 +00:00
|
|
|
//
|
|
|
|
// Feed.swift
|
|
|
|
// Fervor
|
|
|
|
//
|
|
|
|
// Created by Shadowfacts on 10/29/21.
|
|
|
|
//
|
|
|
|
|
2022-03-06 20:05:33 +00:00
|
|
|
@preconcurrency import Foundation
|
2021-12-08 02:58:02 +00:00
|
|
|
|
2022-03-06 20:05:33 +00:00
|
|
|
public struct Feed: Decodable, Sendable {
|
2021-12-08 02:58:02 +00:00
|
|
|
public let id: FervorID
|
|
|
|
public let title: String
|
2022-01-09 22:13:30 +00:00
|
|
|
public let url: URL?
|
2021-12-08 02:58:02 +00:00
|
|
|
public let serviceURL: URL?
|
|
|
|
public let feedURL: URL
|
|
|
|
public let lastUpdated: Date
|
|
|
|
public let groupIDs: [FervorID]
|
|
|
|
|
|
|
|
public init(from decoder: Decoder) throws {
|
|
|
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
|
|
|
|
|
|
|
self.id = try container.decode(FervorID.self, forKey: .id)
|
|
|
|
self.title = try container.decode(String.self, forKey: .title)
|
2022-01-09 22:13:30 +00:00
|
|
|
self.url = try container.decode(URL?.self, forKey: .url)
|
2021-12-08 02:58:02 +00:00
|
|
|
self.serviceURL = try container.decodeIfPresent(URL.self, forKey: .serviceURL)
|
|
|
|
self.feedURL = try container.decode(URL.self, forKey: .feedURL)
|
|
|
|
self.lastUpdated = try container.decode(Date.self, forKey: .lastUpdated)
|
|
|
|
self.groupIDs = try container.decode([FervorID].self, forKey: .groupIDs)
|
|
|
|
}
|
|
|
|
|
|
|
|
private enum CodingKeys: String, CodingKey {
|
|
|
|
case id
|
|
|
|
case title
|
|
|
|
case url
|
|
|
|
case serviceURL = "service_url"
|
|
|
|
case feedURL = "feed_url"
|
|
|
|
case lastUpdated = "last_updated"
|
|
|
|
case groupIDs = "group_ids"
|
|
|
|
}
|
|
|
|
}
|