diff --git a/WordPressKit.podspec b/WordPressKit.podspec index 700fd158..8fcb6df6 100644 --- a/WordPressKit.podspec +++ b/WordPressKit.podspec @@ -2,7 +2,7 @@ Pod::Spec.new do |s| s.name = 'WordPressKit' - s.version = '4.51.0-beta.1' + s.version = '4.51.0-beta.2' s.summary = 'WordPressKit offers a clean and simple WordPress.com and WordPress.org API.' s.description = <<-DESC diff --git a/WordPressKit/Insights/StatsLastPostInsight.swift b/WordPressKit/Insights/StatsLastPostInsight.swift index a2dcbd5a..36cc9590 100644 --- a/WordPressKit/Insights/StatsLastPostInsight.swift +++ b/WordPressKit/Insights/StatsLastPostInsight.swift @@ -6,6 +6,7 @@ public struct StatsLastPostInsight { public let commentsCount: Int public let viewsCount: Int public let postID: Int + public let featuredImageURL: URL? public init(title: String, url: URL, @@ -13,7 +14,8 @@ public struct StatsLastPostInsight { likesCount: Int, commentsCount: Int, viewsCount: Int, - postID: Int) { + postID: Int, + featuredImageURL: URL?) { self.title = title self.url = url self.publishedDate = publishedDate @@ -21,6 +23,7 @@ public struct StatsLastPostInsight { self.commentsCount = commentsCount self.viewsCount = viewsCount self.postID = postID + self.featuredImageURL = featuredImageURL } } @@ -31,7 +34,7 @@ extension StatsLastPostInsight: StatsInsightData { return ["order_by": "date", "number": "1", "type": "post", - "fields": "ID, title, URL, discussion, like_count, date"] + "fields": "ID, title, URL, discussion, like_count, date, featured_image"] } public static var pathComponent: String { @@ -69,5 +72,12 @@ extension StatsLastPostInsight: StatsInsightData { self.commentsCount = commentsCount self.viewsCount = views self.postID = postID + + if let featuredImage = jsonDictionary["featured_image"] as? String, + let featuredURL = URL(string: featuredImage) { + self.featuredImageURL = featuredURL + } else { + self.featuredImageURL = nil + } } }