2020-05-04 23:32:28 +02:00
|
|
|
//
|
|
|
|
// RedditSubreddit.swift
|
|
|
|
// Account
|
|
|
|
//
|
|
|
|
// Created by Maurice Parker on 5/4/20.
|
|
|
|
// Copyright © 2020 Ranchero Software, LLC. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
|
|
|
struct RedditSubreddit: Codable {
|
|
|
|
|
2020-05-05 01:13:15 +02:00
|
|
|
let kind: String?
|
|
|
|
let data: RedditSubredditData?
|
|
|
|
|
|
|
|
enum CodingKeys: String, CodingKey {
|
|
|
|
case kind = "kind"
|
|
|
|
case data = "data"
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
struct RedditSubredditData: Codable {
|
|
|
|
|
2020-05-07 22:39:02 +02:00
|
|
|
let displayName: String?
|
2020-05-04 23:32:28 +02:00
|
|
|
let iconImg: String?
|
2020-05-05 01:13:15 +02:00
|
|
|
let communityIcon: String?
|
2020-05-04 23:32:28 +02:00
|
|
|
|
|
|
|
enum CodingKeys: String, CodingKey {
|
2020-05-07 22:39:02 +02:00
|
|
|
case displayName = "display_name_prefixed"
|
2020-05-05 01:13:15 +02:00
|
|
|
case iconImg = "icon_img"
|
|
|
|
case communityIcon = "community_icon"
|
|
|
|
}
|
|
|
|
|
|
|
|
var iconURL: String? {
|
|
|
|
if let communityIcon = communityIcon, !communityIcon.isEmpty {
|
|
|
|
return communityIcon
|
|
|
|
} else {
|
|
|
|
return iconImg
|
|
|
|
}
|
2020-05-04 23:32:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|