2019-11-29 21:31:15 +01:00
|
|
|
//
|
|
|
|
// SingleArticleFetcher.swift
|
|
|
|
// Account
|
|
|
|
//
|
|
|
|
// Created by Maurice Parker on 11/29/19.
|
|
|
|
// Copyright © 2019 Ranchero Software, LLC. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import Articles
|
2019-12-17 07:45:59 +01:00
|
|
|
import ArticlesDatabase
|
2019-11-29 21:31:15 +01:00
|
|
|
|
|
|
|
public struct SingleArticleFetcher: ArticleFetcher {
|
|
|
|
|
|
|
|
private let account: Account
|
|
|
|
private let articleID: String
|
|
|
|
|
|
|
|
public init(account: Account, articleID: String) {
|
|
|
|
self.account = account
|
|
|
|
self.articleID = articleID
|
|
|
|
}
|
|
|
|
|
2019-12-17 07:45:59 +01:00
|
|
|
public func fetchArticles() throws -> Set<Article> {
|
|
|
|
return try account.fetchArticles(.articleIDs(Set([articleID])))
|
2019-11-29 21:31:15 +01:00
|
|
|
}
|
|
|
|
|
2019-12-17 07:45:59 +01:00
|
|
|
public func fetchArticlesAsync(_ completion: @escaping ArticleSetResultBlock) {
|
2019-12-15 02:01:34 +01:00
|
|
|
return account.fetchArticlesAsync(.articleIDs(Set([articleID])), completion)
|
2019-11-29 21:31:15 +01:00
|
|
|
}
|
|
|
|
|
2019-12-17 07:45:59 +01:00
|
|
|
public func fetchUnreadArticles() throws -> Set<Article> {
|
|
|
|
return try account.fetchArticles(.articleIDs(Set([articleID])))
|
2019-11-29 21:31:15 +01:00
|
|
|
}
|
|
|
|
|
2019-12-17 07:45:59 +01:00
|
|
|
public func fetchUnreadArticlesAsync(_ completion: @escaping ArticleSetResultBlock) {
|
2019-12-15 02:01:34 +01:00
|
|
|
return account.fetchArticlesAsync(.articleIDs(Set([articleID])), completion)
|
2019-11-29 21:31:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|