Parse Feedbin articles.
This commit is contained in:
parent
8160d8e38e
commit
0b4a9f143e
|
@ -27,6 +27,7 @@
|
||||||
84B99C9F1FAE8D3200ECDEDB /* ContainerPath.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84B99C9E1FAE8D3200ECDEDB /* ContainerPath.swift */; };
|
84B99C9F1FAE8D3200ECDEDB /* ContainerPath.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84B99C9E1FAE8D3200ECDEDB /* ContainerPath.swift */; };
|
||||||
84C3654A1F899F3B001EC85C /* CombinedRefreshProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84C365491F899F3B001EC85C /* CombinedRefreshProgress.swift */; };
|
84C3654A1F899F3B001EC85C /* CombinedRefreshProgress.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84C365491F899F3B001EC85C /* CombinedRefreshProgress.swift */; };
|
||||||
84C8B3F41F89DE430053CCA6 /* DataExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84C8B3F31F89DE430053CCA6 /* DataExtensions.swift */; };
|
84C8B3F41F89DE430053CCA6 /* DataExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84C8B3F31F89DE430053CCA6 /* DataExtensions.swift */; };
|
||||||
|
84CAD7161FDF2E22000F0755 /* FeedbinArticle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84CAD7151FDF2E22000F0755 /* FeedbinArticle.swift */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXContainerItemProxy section */
|
/* Begin PBXContainerItemProxy section */
|
||||||
|
@ -126,6 +127,7 @@
|
||||||
84B99C9E1FAE8D3200ECDEDB /* ContainerPath.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContainerPath.swift; sourceTree = "<group>"; };
|
84B99C9E1FAE8D3200ECDEDB /* ContainerPath.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContainerPath.swift; sourceTree = "<group>"; };
|
||||||
84C365491F899F3B001EC85C /* CombinedRefreshProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CombinedRefreshProgress.swift; sourceTree = "<group>"; };
|
84C365491F899F3B001EC85C /* CombinedRefreshProgress.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CombinedRefreshProgress.swift; sourceTree = "<group>"; };
|
||||||
84C8B3F31F89DE430053CCA6 /* DataExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataExtensions.swift; sourceTree = "<group>"; };
|
84C8B3F31F89DE430053CCA6 /* DataExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataExtensions.swift; sourceTree = "<group>"; };
|
||||||
|
84CAD7151FDF2E22000F0755 /* FeedbinArticle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedbinArticle.swift; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
|
@ -204,6 +206,7 @@
|
||||||
84245C801FDDD42A0074AFBB /* Feedbin.swift */,
|
84245C801FDDD42A0074AFBB /* Feedbin.swift */,
|
||||||
84245C821FDDD8160074AFBB /* FeedbinGetSubscriptionsDelegate.swift */,
|
84245C821FDDD8160074AFBB /* FeedbinGetSubscriptionsDelegate.swift */,
|
||||||
84245C841FDDD8CB0074AFBB /* FeedbinSubscription.swift */,
|
84245C841FDDD8CB0074AFBB /* FeedbinSubscription.swift */,
|
||||||
|
84CAD7151FDF2E22000F0755 /* FeedbinArticle.swift */,
|
||||||
);
|
);
|
||||||
path = Feedbin;
|
path = Feedbin;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -461,6 +464,7 @@
|
||||||
84B99C9F1FAE8D3200ECDEDB /* ContainerPath.swift in Sources */,
|
84B99C9F1FAE8D3200ECDEDB /* ContainerPath.swift in Sources */,
|
||||||
846E77501F6EF9C400A165E2 /* LocalAccountRefresher.swift in Sources */,
|
846E77501F6EF9C400A165E2 /* LocalAccountRefresher.swift in Sources */,
|
||||||
84245C811FDDD42A0074AFBB /* Feedbin.swift in Sources */,
|
84245C811FDDD42A0074AFBB /* Feedbin.swift in Sources */,
|
||||||
|
84CAD7161FDF2E22000F0755 /* FeedbinArticle.swift in Sources */,
|
||||||
841974011F6DD1EC006346C4 /* Folder.swift in Sources */,
|
841974011F6DD1EC006346C4 /* Folder.swift in Sources */,
|
||||||
846E774F1F6EF9C000A165E2 /* LocalAccountDelegate.swift in Sources */,
|
846E774F1F6EF9C000A165E2 /* LocalAccountDelegate.swift in Sources */,
|
||||||
84245C851FDDD8CB0074AFBB /* FeedbinSubscription.swift in Sources */,
|
84245C851FDDD8CB0074AFBB /* FeedbinSubscription.swift in Sources */,
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
//
|
||||||
|
// FeedbinArticle.swift
|
||||||
|
// Account
|
||||||
|
//
|
||||||
|
// Created by Brent Simmons on 12/11/17.
|
||||||
|
// Copyright © 2017 Ranchero Software, LLC. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
import RSParser
|
||||||
|
import RSCore
|
||||||
|
|
||||||
|
struct FeedbinArticle {
|
||||||
|
|
||||||
|
// "id": 2077,
|
||||||
|
// "feed_id": 135,
|
||||||
|
// "title": "Objective-C Runtime Releases",
|
||||||
|
// "url": "http:\/\/mjtsai.com\/blog\/2013\/02\/02\/objective-c-runtime-releases\/",
|
||||||
|
// "author": "Michael Tsai",
|
||||||
|
// "content": "<p><a href=\"https:\/\/twitter.com\/bavarious\/status\/297851496945577984\">Bavarious<\/a> created a <a href=\"https:\/\/github.com\/bavarious\/objc4\/commits\/master\">GitHub repository<\/a> that shows the differences between versions of <a href=\"http:\/\/www.opensource.apple.com\/source\/objc4\/\">Apple\u2019s Objective-C runtime<\/a> that shipped with different versions of Mac OS X.<\/p>",
|
||||||
|
// "summary": "Bavarious created a GitHub repository that shows the differences between versions of Apple\u2019s Objective-C runtime that shipped with different versions of Mac OS X.",
|
||||||
|
// "published": "2013-02-03T01:00:19.000000Z",
|
||||||
|
// "created_at": "2013-02-04T01:00:19.127893Z"
|
||||||
|
|
||||||
|
struct Key {
|
||||||
|
static let syncID = "id"
|
||||||
|
static let feedID = "feed_id"
|
||||||
|
static let title = "title"
|
||||||
|
static let url = "url"
|
||||||
|
static let authorName = "author"
|
||||||
|
static let contentHTML = "content"
|
||||||
|
static let summary = "summary"
|
||||||
|
static let datePublished = "published"
|
||||||
|
static let dateArrived = "created_at"
|
||||||
|
}
|
||||||
|
|
||||||
|
let syncID: String
|
||||||
|
let feedID: String
|
||||||
|
let title: String?
|
||||||
|
let url: String?
|
||||||
|
let authorName: String?
|
||||||
|
let contentHTML: String?
|
||||||
|
let summary: String?
|
||||||
|
let datePublished: Date?
|
||||||
|
let dateArrived: Date?
|
||||||
|
|
||||||
|
init?(jsonDictionary: JSONDictionary) {
|
||||||
|
|
||||||
|
guard let syncIDInt = jsonDictionary[Key.syncID] as? Int else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
guard let feedIDInt = jsonDictionary[Key.feedID] as? Int else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
self.syncID = "\(syncIDInt)"
|
||||||
|
self.feedID = "\(feedIDInt)"
|
||||||
|
|
||||||
|
self.title = jsonDictionary[Key.title] as? String
|
||||||
|
self.url = jsonDictionary[Key.url] as? String
|
||||||
|
self.authorName = jsonDictionary[Key.authorName] as? String
|
||||||
|
|
||||||
|
if let contentHTML = jsonDictionary[Key.contentHTML] as? String, !contentHTML.isEmpty {
|
||||||
|
self.contentHTML = contentHTML
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
self.contentHTML = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if let summary = jsonDictionary[Key.summary] as? String, !summary.isEmpty {
|
||||||
|
self.summary = summary
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
self.summary = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if let datePublishedString = jsonDictionary[Key.datePublished] as? String {
|
||||||
|
self.datePublished = RSDateWithString(datePublishedString)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
self.datePublished = nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if let dateArrivedString = jsonDictionary[Key.dateArrived] as? String {
|
||||||
|
self.dateArrived = RSDateWithString(dateArrivedString)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
self.dateArrived = nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static func articles(with array: JSONArray) -> [FeedbinArticle]? {
|
||||||
|
|
||||||
|
let articlesArray = array.flatMap { FeedbinArticle(jsonDictionary: $0) }
|
||||||
|
return articlesArray.isEmpty ? nil : articlesArray
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue