// // NextcloudDataInterface.swift // Nextcloud Cookbook iOS Client // // Created by Vincent Meilinger on 07.05.24. // import Foundation import SwiftUI /* class NextcloudDataInterface: CookbookInterface { var id: String var auth: Authentication var api: CookbookApi.Type init(auth: Authentication, version: String) { self.id = UUID().uuidString self.auth = auth switch version { case "1.0": self.api = CookbookApiV1.self default: self.api = CookbookApiV1.self } } } // MARK: - Nextcloud Read Interface extension NextcloudDataInterface: ReadInterface { func getImage(id: String, size: RecipeImage.RecipeImageSize) async -> UIImage? { return await api.getImage(auth: auth.token, id: id, size: size).0 } func getRecipeStubs() async -> [RecipeStub]? { return await api.getRecipes(auth: auth.token).0 } func getRecipe(id: String) async -> Recipe?{ return await api.getRecipe(auth: auth.token, id: id).0 } func getCategories() async -> [Category]? { return await api.getCategories(auth: auth.token).0 } func getRecipeStubsForCategory(named categoryName: String) async -> [RecipeStub]? { return await api.getCategory( auth: UserSettings.shared.authString, named: categoryName ).0 } func getTags() async -> [RecipeKeyword]? { return await api.getTags(auth: auth.token).0 } func getRecipesTagged(keyword: String) async -> [RecipeStub]? { return await api.getRecipesTagged(auth: auth.token, keyword: keyword).0 } } // MARK: - Nextcloud Write Interface extension NextcloudDataInterface: WriteInterface { func postImage(id: String, image: UIImage, size: RecipeImage.RecipeImageSize) async -> ((any UserAlert)?) { return nil } func postRecipe(recipe: Recipe) async -> (UserAlert?) { return await api.createRecipe(auth: auth.token, recipe: recipe) } func updateRecipe(recipe: Recipe) async -> (UserAlert?) { return await api.updateRecipe(auth: auth.token, recipe: recipe) } func deleteRecipe(id: String) async -> (UserAlert?) { return await api.deleteRecipe(auth: auth.token, id: id) } func renameCategory(named categoryName: String, newName: String) async -> (UserAlert?) { return await api.renameCategory(auth: auth.token, named: categoryName, newName: newName) } } */