Complete (probably) work on Feedbin sync data types.
This commit is contained in:
parent
cd6e6daf31
commit
485bde7ff2
|
@ -13,6 +13,7 @@ import RSCore
|
||||||
struct FeedbinArticle {
|
struct FeedbinArticle {
|
||||||
|
|
||||||
// https://github.com/feedbin/feedbin-api/blob/master/content/entries.md
|
// 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,
|
// "id": 2077,
|
||||||
// "feed_id": 135,
|
// "feed_id": 135,
|
||||||
|
@ -24,38 +25,39 @@ struct FeedbinArticle {
|
||||||
// "published": "2013-02-03T01:00:19.000000Z",
|
// "published": "2013-02-03T01:00:19.000000Z",
|
||||||
// "created_at": "2013-02-04T01:00:19.127893Z"
|
// "created_at": "2013-02-04T01:00:19.127893Z"
|
||||||
|
|
||||||
let syncID: String
|
let articleID: Int
|
||||||
let feedID: String
|
let feedID: Int
|
||||||
let title: String?
|
let title: String?
|
||||||
let url: String?
|
let url: String?
|
||||||
let authorName: String?
|
let authorName: String?
|
||||||
let contentHTML: String?
|
let contentHTML: String?
|
||||||
|
let contentDiffHTML: String?
|
||||||
let summary: String?
|
let summary: String?
|
||||||
let datePublished: Date?
|
let datePublished: Date?
|
||||||
let dateArrived: Date?
|
let dateArrived: Date?
|
||||||
|
|
||||||
struct Key {
|
struct Key {
|
||||||
static let syncID = "id"
|
static let articleID = "id"
|
||||||
static let feedID = "feed_id"
|
static let feedID = "feed_id"
|
||||||
static let title = "title"
|
static let title = "title"
|
||||||
static let url = "url"
|
static let url = "url"
|
||||||
static let authorName = "author"
|
static let authorName = "author"
|
||||||
static let contentHTML = "content"
|
static let contentHTML = "content"
|
||||||
|
static let contentDiffHTML = "content_diff"
|
||||||
static let summary = "summary"
|
static let summary = "summary"
|
||||||
static let datePublished = "published"
|
static let datePublished = "published"
|
||||||
static let dateArrived = "created_at"
|
static let dateArrived = "created_at"
|
||||||
}
|
}
|
||||||
|
|
||||||
init?(jsonDictionary: JSONDictionary) {
|
init?(jsonDictionary: JSONDictionary) {
|
||||||
|
guard let articleID = jsonDictionary[Key.articleID] as? Int else {
|
||||||
guard let syncIDInt = jsonDictionary[Key.syncID] as? Int else {
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
guard let feedIDInt = jsonDictionary[Key.feedID] as? Int else {
|
guard let feedID = jsonDictionary[Key.feedID] as? Int else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
self.syncID = "\(syncIDInt)"
|
self.articleID = articleID
|
||||||
self.feedID = "\(feedIDInt)"
|
self.feedID = feedID
|
||||||
|
|
||||||
self.title = jsonDictionary[Key.title] as? String
|
self.title = jsonDictionary[Key.title] as? String
|
||||||
self.url = jsonDictionary[Key.url] as? String
|
self.url = jsonDictionary[Key.url] as? String
|
||||||
|
@ -68,6 +70,13 @@ struct FeedbinArticle {
|
||||||
self.contentHTML = nil
|
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 {
|
if let summary = jsonDictionary[Key.summary] as? String, !summary.isEmpty {
|
||||||
self.summary = summary
|
self.summary = summary
|
||||||
}
|
}
|
||||||
|
@ -91,7 +100,6 @@ struct FeedbinArticle {
|
||||||
}
|
}
|
||||||
|
|
||||||
static func articles(with array: JSONArray) -> [FeedbinArticle]? {
|
static func articles(with array: JSONArray) -> [FeedbinArticle]? {
|
||||||
|
|
||||||
let articlesArray = array.compactMap { FeedbinArticle(jsonDictionary: $0) }
|
let articlesArray = array.compactMap { FeedbinArticle(jsonDictionary: $0) }
|
||||||
return articlesArray.isEmpty ? nil : articlesArray
|
return articlesArray.isEmpty ? nil : articlesArray
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,8 @@ struct FeedbinFeed {
|
||||||
// "feed_url": "http://daringfireball.net/index.xml",
|
// "feed_url": "http://daringfireball.net/index.xml",
|
||||||
// "site_url": "http://daringfireball.net/"
|
// "site_url": "http://daringfireball.net/"
|
||||||
|
|
||||||
let subscriptionID: String
|
let subscriptionID: Int
|
||||||
let feedID: String
|
let feedID: Int
|
||||||
let creationDate: Date?
|
let creationDate: Date?
|
||||||
let name: String?
|
let name: String?
|
||||||
let url: String
|
let url: String
|
||||||
|
@ -39,18 +39,18 @@ struct FeedbinFeed {
|
||||||
|
|
||||||
init?(dictionary: JSONDictionary) {
|
init?(dictionary: JSONDictionary) {
|
||||||
|
|
||||||
guard let subscriptionIDInt = dictionary[Key.subscriptionID] as? Int else {
|
guard let subscriptionID = dictionary[Key.subscriptionID] as? Int else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
guard let feedIDInt = dictionary[Key.feedID] as? Int else {
|
guard let feedID = dictionary[Key.feedID] as? Int else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
guard let url = dictionary[Key.url] as? String else {
|
guard let url = dictionary[Key.url] as? String else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
self.subscriptionID = String(subscriptionIDInt)
|
self.subscriptionID = subscriptionID
|
||||||
self.feedID = String(feedIDInt)
|
self.feedID = feedID
|
||||||
self.url = url
|
self.url = url
|
||||||
|
|
||||||
if let creationDateString = dictionary[Key.creationDate] as? String {
|
if let creationDateString = dictionary[Key.creationDate] as? String {
|
||||||
|
|
Loading…
Reference in New Issue