mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-15 10:49:14 +01:00
37 lines
897 B
Swift
37 lines
897 B
Swift
//
|
|
// FeedlyFeedContainerValidator.swift
|
|
// Account
|
|
//
|
|
// Created by Kiel Gillard on 10/10/19.
|
|
// Copyright © 2019 Ranchero Software, LLC. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
struct FeedlyFeedContainerValidator {
|
|
var container: Container
|
|
var userId: String?
|
|
|
|
func getValidContainer() throws -> (Folder, String) {
|
|
guard let folder = container as? Folder else {
|
|
throw FeedlyAccountDelegateError.addFeedChooseFolder
|
|
}
|
|
|
|
guard let collectionId = folder.externalID else {
|
|
throw FeedlyAccountDelegateError.addFeedInvalidFolder(folder)
|
|
}
|
|
|
|
guard let userId = userId else {
|
|
throw FeedlyAccountDelegateError.notLoggedIn
|
|
}
|
|
|
|
let uncategorized = FeedlyCategoryResourceId.Global.uncategorized(for: userId)
|
|
|
|
guard collectionId != uncategorized.id else {
|
|
throw FeedlyAccountDelegateError.addFeedInvalidFolder(folder)
|
|
}
|
|
|
|
return (folder, collectionId)
|
|
}
|
|
}
|