Skip to content

Commit

Permalink
Add close status to CommentStatus to cover more
Browse files Browse the repository at this point in the history
  • Loading branch information
rocxteady committed Aug 12, 2024
1 parent 4098da5 commit dacacb6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Sources/WPSwift/Models/Post.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit dacacb6

Please sign in to comment.