From dacacb6b87cb2e96e6803d47d71da59f15633979 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ulas=CC=A7=20Sancak?= Date: Mon, 12 Aug 2024 17:30:28 +0300 Subject: [PATCH] Add close status to CommentStatus to cover more --- Sources/WPSwift/Models/Post.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sources/WPSwift/Models/Post.swift b/Sources/WPSwift/Models/Post.swift index a48eb6a..de3763e 100644 --- a/Sources/WPSwift/Models/Post.swift +++ b/Sources/WPSwift/Models/Post.swift @@ -10,6 +10,11 @@ import Foundation public enum CommentStatus: String, Decodable { case `open` case closed + case close + + public var isOpen: Bool { + self == .open + } } public struct Post: Decodable { @@ -93,7 +98,7 @@ public struct Post: Decodable { self.excerpt = try container.decodeIfPresent(RenderedContent.self, forKey: .excerpt) self.author = try container.decodeIfPresent(Int.self, forKey: .author) self.featuredMedia = try container.decodeIfPresent(Int.self, forKey: .featuredMedia) - self.commentStatus = try container.decodeIfPresent(CommentStatus.self, forKey: .commentStatus) ?? .closed + self.commentStatus = (try? container.decodeIfPresent(CommentStatus.self, forKey: .commentStatus)) ?? .closed self.categories = try container.decodeIfPresent([Int].self, forKey: .categories) ?? [] self.tags = try container.decodeIfPresent([Int].self, forKey: .tags) ?? [] self.link = try container.decode(String.self, forKey: .link)