Nextcloud Login refactoring
This commit is contained in:
@@ -99,7 +99,7 @@ protocol CookbookApi {
|
||||
/// - Returns: A list of categories. A NetworkError if the request fails.
|
||||
static func getCategories(
|
||||
auth: String
|
||||
) async -> ([Category]?, NetworkError?)
|
||||
) async -> ([CookbookApiCategory]?, NetworkError?)
|
||||
|
||||
/// Get all recipes of a specified category.
|
||||
/// - Parameters:
|
||||
|
||||
@@ -77,7 +77,7 @@ class CookbookApiV1: CookbookApi {
|
||||
if let id = json as? Int {
|
||||
return nil
|
||||
} else if let dict = json as? [String: Any] {
|
||||
return .serverError
|
||||
return .unknownError
|
||||
}
|
||||
} catch {
|
||||
return .decodingFailed
|
||||
@@ -103,7 +103,7 @@ class CookbookApiV1: CookbookApi {
|
||||
|
||||
static func updateRecipe(auth: String, recipe: Recipe) async -> (NetworkError?) {
|
||||
let cookbookRecipe = CookbookApiRecipeDetailV1.fromRecipe(recipe)
|
||||
guard let recipeData = JSONEncoder.safeEncode(recipe) else {
|
||||
guard let recipeData = JSONEncoder.safeEncode(cookbookRecipe) else {
|
||||
return .dataError
|
||||
}
|
||||
let request = ApiRequest(
|
||||
@@ -121,7 +121,7 @@ class CookbookApiV1: CookbookApi {
|
||||
if let id = json as? Int {
|
||||
return nil
|
||||
} else if let dict = json as? [String: Any] {
|
||||
return .serverError
|
||||
return .unknownError
|
||||
}
|
||||
} catch {
|
||||
return .decodingFailed
|
||||
@@ -143,7 +143,7 @@ class CookbookApiV1: CookbookApi {
|
||||
return nil
|
||||
}
|
||||
|
||||
static func getCategories(auth: String) async -> ([Category]?, NetworkError?) {
|
||||
static func getCategories(auth: String) async -> ([CookbookApiCategory]?, NetworkError?) {
|
||||
let request = ApiRequest(
|
||||
path: basePath + "/categories",
|
||||
method: .GET,
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
struct Category: Codable, Identifiable, Hashable {
|
||||
struct CookbookApiCategory: Codable, Identifiable, Hashable {
|
||||
var id: String { name }
|
||||
let name: String
|
||||
let recipe_count: Int
|
||||
var name: String
|
||||
var recipe_count: Int
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case name, recipe_count
|
||||
|
||||
Reference in New Issue
Block a user