From 485bde7ff2218e40b17c8731b858f15b860584d6 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sun, 14 Oct 2018 18:38:33 -0700 Subject: [PATCH] Complete (probably) work on Feedbin sync data types. --- .../Account/Feedbin/FeedbinArticle.swift | 26 ++++++++++++------- Frameworks/Account/Feedbin/FeedbinFeed.swift | 12 ++++----- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/Frameworks/Account/Feedbin/FeedbinArticle.swift b/Frameworks/Account/Feedbin/FeedbinArticle.swift index 0a997fc65..574c230d8 100644 --- a/Frameworks/Account/Feedbin/FeedbinArticle.swift +++ b/Frameworks/Account/Feedbin/FeedbinArticle.swift @@ -13,6 +13,7 @@ import RSCore struct FeedbinArticle { // https://github.com/feedbin/feedbin-api/blob/master/content/entries.md + // https://github.com/feedbin/feedbin-api/blob/master/content/updated-entries.md // // "id": 2077, // "feed_id": 135, @@ -24,38 +25,39 @@ struct FeedbinArticle { // "published": "2013-02-03T01:00:19.000000Z", // "created_at": "2013-02-04T01:00:19.127893Z" - let syncID: String - let feedID: String + let articleID: Int + let feedID: Int let title: String? let url: String? let authorName: String? let contentHTML: String? + let contentDiffHTML: String? let summary: String? let datePublished: Date? let dateArrived: Date? struct Key { - static let syncID = "id" + static let articleID = "id" static let feedID = "feed_id" static let title = "title" static let url = "url" static let authorName = "author" static let contentHTML = "content" + static let contentDiffHTML = "content_diff" static let summary = "summary" static let datePublished = "published" static let dateArrived = "created_at" } init?(jsonDictionary: JSONDictionary) { - - guard let syncIDInt = jsonDictionary[Key.syncID] as? Int else { + guard let articleID = jsonDictionary[Key.articleID] as? Int else { return nil } - guard let feedIDInt = jsonDictionary[Key.feedID] as? Int else { + guard let feedID = jsonDictionary[Key.feedID] as? Int else { return nil } - self.syncID = "\(syncIDInt)" - self.feedID = "\(feedIDInt)" + self.articleID = articleID + self.feedID = feedID self.title = jsonDictionary[Key.title] as? String self.url = jsonDictionary[Key.url] as? String @@ -68,6 +70,13 @@ struct FeedbinArticle { self.contentHTML = nil } + if let contentDiffHTML = jsonDictionary[Key.contentDiffHTML] as? String, !contentDiffHTML.isEmpty { + self.contentDiffHTML = contentDiffHTML + } + else { + self.contentDiffHTML = nil + } + if let summary = jsonDictionary[Key.summary] as? String, !summary.isEmpty { self.summary = summary } @@ -91,7 +100,6 @@ struct FeedbinArticle { } static func articles(with array: JSONArray) -> [FeedbinArticle]? { - let articlesArray = array.compactMap { FeedbinArticle(jsonDictionary: $0) } return articlesArray.isEmpty ? nil : articlesArray } diff --git a/Frameworks/Account/Feedbin/FeedbinFeed.swift b/Frameworks/Account/Feedbin/FeedbinFeed.swift index 56ca33b54..d3a81b71e 100644 --- a/Frameworks/Account/Feedbin/FeedbinFeed.swift +++ b/Frameworks/Account/Feedbin/FeedbinFeed.swift @@ -21,8 +21,8 @@ struct FeedbinFeed { // "feed_url": "http://daringfireball.net/index.xml", // "site_url": "http://daringfireball.net/" - let subscriptionID: String - let feedID: String + let subscriptionID: Int + let feedID: Int let creationDate: Date? let name: String? let url: String @@ -39,18 +39,18 @@ struct FeedbinFeed { init?(dictionary: JSONDictionary) { - guard let subscriptionIDInt = dictionary[Key.subscriptionID] as? Int else { + guard let subscriptionID = dictionary[Key.subscriptionID] as? Int else { return nil } - guard let feedIDInt = dictionary[Key.feedID] as? Int else { + guard let feedID = dictionary[Key.feedID] as? Int else { return nil } guard let url = dictionary[Key.url] as? String else { return nil } - self.subscriptionID = String(subscriptionIDInt) - self.feedID = String(feedIDInt) + self.subscriptionID = subscriptionID + self.feedID = feedID self.url = url if let creationDateString = dictionary[Key.creationDate] as? String {