frenzy-ios/Fervor/Group.swift

32 lines
868 B
Swift

//
// Group.swift
// Fervor
//
// Created by Shadowfacts on 10/29/21.
//
import Foundation
public struct Group: Decodable {
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"
}
}