From 8160d8e38eee69b276cde7a65480a341249a889a Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sun, 10 Dec 2017 14:05:01 -0800 Subject: [PATCH] Create Feedbin, FeedbinAccountDelegate, and FeedbinGetSubscriptionsDelegate. --- .../Account/Account.xcodeproj/project.pbxproj | 24 ++++++++++ Frameworks/Account/Feedbin/Feedbin.swift | 46 ++++++++++++++++++ .../Feedbin/FeedbinAccountDelegate.swift | 41 ++++++++++++++++ .../FeedbinGetSubscriptionsDelegate.swift | 47 +++++++++++++++++++ .../RSWeb/RSWeb/WebServices/APIAction.swift | 9 ---- .../RSWeb/RSWeb/WebServices/APIRequest.swift | 9 ---- 6 files changed, 158 insertions(+), 18 deletions(-) create mode 100644 Frameworks/Account/Feedbin/Feedbin.swift create mode 100644 Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift create mode 100644 Frameworks/Account/Feedbin/FeedbinGetSubscriptionsDelegate.swift delete mode 100644 Frameworks/RSWeb/RSWeb/WebServices/APIAction.swift delete mode 100644 Frameworks/RSWeb/RSWeb/WebServices/APIRequest.swift diff --git a/Frameworks/Account/Account.xcodeproj/project.pbxproj b/Frameworks/Account/Account.xcodeproj/project.pbxproj index a22ceb14c..445196710 100644 --- a/Frameworks/Account/Account.xcodeproj/project.pbxproj +++ b/Frameworks/Account/Account.xcodeproj/project.pbxproj @@ -12,6 +12,10 @@ 841973FF1F6DD1C5006346C4 /* RSParser.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 841973FA1F6DD1AC006346C4 /* RSParser.framework */; }; 841974011F6DD1EC006346C4 /* Folder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841974001F6DD1EC006346C4 /* Folder.swift */; }; 841974251F6DDCE4006346C4 /* AccountDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841974241F6DDCE4006346C4 /* AccountDelegate.swift */; }; + 84245C7F1FDDD2580074AFBB /* FeedbinAccountDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84245C7E1FDDD2580074AFBB /* FeedbinAccountDelegate.swift */; }; + 84245C811FDDD42A0074AFBB /* Feedbin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84245C801FDDD42A0074AFBB /* Feedbin.swift */; }; + 84245C831FDDD8160074AFBB /* FeedbinGetSubscriptionsDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84245C821FDDD8160074AFBB /* FeedbinGetSubscriptionsDelegate.swift */; }; + 84245C851FDDD8CB0074AFBB /* FeedbinSubscription.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84245C841FDDD8CB0074AFBB /* FeedbinSubscription.swift */; }; 8469F8171F6DD0AD0084783E /* Database.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8401A17D1F6DC388002B1BE2 /* Database.framework */; }; 8469F81C1F6DD15E0084783E /* Account.swift in Sources */ = {isa = PBXBuildFile; fileRef = 848935101F62486800CEBD24 /* Account.swift */; }; 846E77451F6EF9B900A165E2 /* Container.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8419740D1F6DD25F006346C4 /* Container.swift */; }; @@ -108,6 +112,10 @@ 841974241F6DDCE4006346C4 /* AccountDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountDelegate.swift; sourceTree = ""; }; 8419742C1F6DDE84006346C4 /* LocalAccountDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalAccountDelegate.swift; sourceTree = ""; }; 8419742D1F6DDE96006346C4 /* LocalAccountRefresher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalAccountRefresher.swift; sourceTree = ""; }; + 84245C7E1FDDD2580074AFBB /* FeedbinAccountDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedbinAccountDelegate.swift; sourceTree = ""; }; + 84245C801FDDD42A0074AFBB /* Feedbin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Feedbin.swift; sourceTree = ""; }; + 84245C821FDDD8160074AFBB /* FeedbinGetSubscriptionsDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedbinGetSubscriptionsDelegate.swift; sourceTree = ""; }; + 84245C841FDDD8CB0074AFBB /* FeedbinSubscription.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedbinSubscription.swift; sourceTree = ""; }; 846E77531F6F00E300A165E2 /* AccountManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountManager.swift; sourceTree = ""; }; 848934F61F62484F00CEBD24 /* Account.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Account.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 848934FA1F62484F00CEBD24 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -189,6 +197,17 @@ path = LocalAccount; sourceTree = ""; }; + 84245C7D1FDDD2580074AFBB /* Feedbin */ = { + isa = PBXGroup; + children = ( + 84245C7E1FDDD2580074AFBB /* FeedbinAccountDelegate.swift */, + 84245C801FDDD42A0074AFBB /* Feedbin.swift */, + 84245C821FDDD8160074AFBB /* FeedbinGetSubscriptionsDelegate.swift */, + 84245C841FDDD8CB0074AFBB /* FeedbinSubscription.swift */, + ); + path = Feedbin; + sourceTree = ""; + }; 8469F80F1F6DC3C10084783E /* Frameworks */ = { isa = PBXGroup; children = ( @@ -212,6 +231,7 @@ 84C8B3F31F89DE430053CCA6 /* DataExtensions.swift */, 8419740D1F6DD25F006346C4 /* Container.swift */, 8419742B1F6DDE84006346C4 /* LocalAccount */, + 84245C7D1FDDD2580074AFBB /* Feedbin */, 8469F80F1F6DC3C10084783E /* Frameworks */, 848934FA1F62484F00CEBD24 /* Info.plist */, 848935031F62484F00CEBD24 /* AccountTests */, @@ -435,12 +455,16 @@ 84C3654A1F899F3B001EC85C /* CombinedRefreshProgress.swift in Sources */, 8469F81C1F6DD15E0084783E /* Account.swift in Sources */, 846E77451F6EF9B900A165E2 /* Container.swift in Sources */, + 84245C7F1FDDD2580074AFBB /* FeedbinAccountDelegate.swift in Sources */, 841974251F6DDCE4006346C4 /* AccountDelegate.swift in Sources */, 846E77541F6F00E300A165E2 /* AccountManager.swift in Sources */, 84B99C9F1FAE8D3200ECDEDB /* ContainerPath.swift in Sources */, 846E77501F6EF9C400A165E2 /* LocalAccountRefresher.swift in Sources */, + 84245C811FDDD42A0074AFBB /* Feedbin.swift in Sources */, 841974011F6DD1EC006346C4 /* Folder.swift in Sources */, 846E774F1F6EF9C000A165E2 /* LocalAccountDelegate.swift in Sources */, + 84245C851FDDD8CB0074AFBB /* FeedbinSubscription.swift in Sources */, + 84245C831FDDD8160074AFBB /* FeedbinGetSubscriptionsDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Frameworks/Account/Feedbin/Feedbin.swift b/Frameworks/Account/Feedbin/Feedbin.swift new file mode 100644 index 000000000..ebdca306f --- /dev/null +++ b/Frameworks/Account/Feedbin/Feedbin.swift @@ -0,0 +1,46 @@ +// +// Feedbin.swift +// Account +// +// Created by Brent Simmons on 12/10/17. +// Copyright © 2017 Ranchero Software, LLC. All rights reserved. +// + +import Foundation +import RSWeb + +final class Feedbin: WebServiceProvider { + + let account: Account + + struct MethodName { + static let getSubscriptions = "getSubscriptions" + } + + init(account: Account) { + + self.account = account + } + + // MARK: - Feedbin API + + func getSubscriptions() { + + let delegate = FeedbinGetSubscriptionsDelegate(provider: self) + callAPI(MethodName.getSubscriptions, delegate) + } +} + +private extension Feedbin { + + func callAPI(_ methodName: String, _ delegate: APICallDelegate) { + + let call = APICall(provider: self, methodName: methodName, delegate: delegate) + run(call) + } + + func run(_ apiCall: APICall) { + + // TODO: add to url session + } +} diff --git a/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift b/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift new file mode 100644 index 000000000..e71326e57 --- /dev/null +++ b/Frameworks/Account/Feedbin/FeedbinAccountDelegate.swift @@ -0,0 +1,41 @@ +// +// FeedbinAccountDelegate.swift +// Account +// +// Created by Brent Simmons on 12/10/17. +// Copyright © 2017 Ranchero Software, LLC. All rights reserved. +// + +import Foundation +import RSWeb + +final class FeedbinAccountDelegate: AccountDelegate { + + let supportsSubFolders = false + + var refreshProgress: DownloadProgress { + get { + return DownloadProgress(numberOfTasks: 0) // TODO + } + } + + func refreshAll(for: Account) { + + // TODO + } + + // MARK: Disk + + func update(account: Account, withUserInfo: NSDictionary?) { + + // TODO: add username to account name + account.nameForDisplay = NSLocalizedString("Feedbin", comment: "Feedbin Account Name") + } + + func userInfo(for: Account) -> NSDictionary? { + + // TODO: save username + return nil + } +} + diff --git a/Frameworks/Account/Feedbin/FeedbinGetSubscriptionsDelegate.swift b/Frameworks/Account/Feedbin/FeedbinGetSubscriptionsDelegate.swift new file mode 100644 index 000000000..12f43b2f4 --- /dev/null +++ b/Frameworks/Account/Feedbin/FeedbinGetSubscriptionsDelegate.swift @@ -0,0 +1,47 @@ +// +// FeedbinGetSubscriptionsDelegate.swift +// Account +// +// Created by Brent Simmons on 12/10/17. +// Copyright © 2017 Ranchero Software, LLC. All rights reserved. +// + +import Foundation +import RSWeb +import RSParser + +struct FeedbinGetSubscriptionsDelegate: APICallDelegate { + + private let provider: Feedbin + + init(provider: Feedbin) { + + self.provider = provider + } + + func apiCallURLRequest(_ call: APICall) -> URLRequest? { + + return nil // TODO + } + + func apiCall(_ call: APICall, parseReturnedObjectWith result: HTTPResult) -> Any? { + + guard let data = result.data, let jsonArray = JSONUtilities.array(with: data) else { + return nil + } + + return FeedbinSubscription.subscriptions(with: jsonArray) + } + + func apiCall(_ call: APICall, handleErrorWith: HTTPResult, returnedObject: Any?) { + + // TODO + } + + func apiCall(_ call: APICall, performActionWith: HTTPResult, returnedObject: Any?) { + + // TODO + } + + +} diff --git a/Frameworks/RSWeb/RSWeb/WebServices/APIAction.swift b/Frameworks/RSWeb/RSWeb/WebServices/APIAction.swift deleted file mode 100644 index a5f0ea28b..000000000 --- a/Frameworks/RSWeb/RSWeb/WebServices/APIAction.swift +++ /dev/null @@ -1,9 +0,0 @@ -// -// APIAction.swift -// RSWeb -// -// Created by Brent Simmons on 12/9/17. -// Copyright © 2017 Ranchero Software. All rights reserved. -// - -import Foundation diff --git a/Frameworks/RSWeb/RSWeb/WebServices/APIRequest.swift b/Frameworks/RSWeb/RSWeb/WebServices/APIRequest.swift deleted file mode 100644 index 2bd656032..000000000 --- a/Frameworks/RSWeb/RSWeb/WebServices/APIRequest.swift +++ /dev/null @@ -1,9 +0,0 @@ -// -// APIRequest.swift -// RSWeb -// -// Created by Brent Simmons on 12/9/17. -// Copyright © 2017 Ranchero Software. All rights reserved. -// - -import Foundation