frenzy-ios/Fervor/Group.swift

32 lines
894 B
Swift
Raw Normal View History

2021-12-08 02:58:02 +00:00
//
// Group.swift
// Fervor
//
// Created by Shadowfacts on 10/29/21.
//
@preconcurrency import Foundation
2021-12-08 02:58:02 +00:00
public struct Group: Decodable, Sendable {
2021-12-08 02:58:02 +00:00
public let id: FervorID
public let title: String
public let feedIDs: [FervorID]
public let serviceURL: URL?
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)
self.feedIDs = try container.decode([FervorID].self, forKey: .feedIDs)
self.serviceURL = try container.decodeIfPresent(URL.self, forKey: .serviceURL)
}
private enum CodingKeys: String, CodingKey {
case id
case title
case feedIDs = "feed_ids"
case serviceURL = "service_url"
}
}