2019-10-18 23:21:02 +02:00
|
|
|
//
|
|
|
|
// FeedlyGetEntriesOperation.swift
|
|
|
|
// Account
|
|
|
|
//
|
|
|
|
// Created by Kiel Gillard on 28/10/19.
|
|
|
|
// Copyright © 2019 Ranchero Software, LLC. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
2019-11-27 09:04:55 +01:00
|
|
|
import os.log
|
2019-10-18 23:21:02 +02:00
|
|
|
|
|
|
|
/// Single responsibility is to get full entries for the entry identifiers.
|
|
|
|
final class FeedlyGetEntriesOperation: FeedlyOperation, FeedlyEntryProviding {
|
|
|
|
let account: Account
|
|
|
|
let service: FeedlyGetEntriesService
|
|
|
|
let provider: FeedlyEntryIdenifierProviding
|
2019-11-27 09:04:55 +01:00
|
|
|
let log: OSLog
|
2019-10-18 23:21:02 +02:00
|
|
|
|
2019-11-27 09:04:55 +01:00
|
|
|
init(account: Account, service: FeedlyGetEntriesService, provider: FeedlyEntryIdenifierProviding, log: OSLog) {
|
2019-10-18 23:21:02 +02:00
|
|
|
self.account = account
|
|
|
|
self.service = service
|
|
|
|
self.provider = provider
|
2019-11-27 09:04:55 +01:00
|
|
|
self.log = log
|
2019-10-18 23:21:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private (set) var entries = [FeedlyEntry]()
|
|
|
|
|
|
|
|
override func main() {
|
|
|
|
guard !isCancelled else {
|
|
|
|
didFinish()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
service.getEntries(for: provider.entryIds) { result in
|
|
|
|
switch result {
|
|
|
|
case .success(let entries):
|
|
|
|
self.entries = entries
|
|
|
|
self.didFinish()
|
|
|
|
|
|
|
|
case .failure(let error):
|
2019-11-27 09:04:55 +01:00
|
|
|
os_log(.debug, log: self.log, "Unable to get entries: %{public}@.", error as NSError)
|
2019-10-18 23:21:02 +02:00
|
|
|
self.didFinish(error)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|