Files
2025-05-26 15:52:24 +02:00

50 lines
1.0 KiB
Swift

//
// AccountProtocol.swift
// Nextcloud Cookbook iOS Client
//
// Created by Vincent Meilinger on 16.01.25.
//
import Foundation
import SwiftUI
import KeychainSwift
enum AccountType: String, Codable, CaseIterable {
case cookbook = "cookbook"
case local = "local"
var accountType: any Decodable.Type {
switch self {
case .cookbook: return CookbookAccount.self
case .local: return LocalAccount.self
}
}
}
protocol Account: Codable, Identifiable {
/// A unique identifier for this account
var id: UUID { get }
/// A name for the account that can be displayed in the UI
var displayName: String { get }
/// For differentiating account types when decoding
var accountType: AccountType { get }
/// Base endpoint URL
var baseURL: URL { get }
/// Account username
var username: String { get }
/// For storing/retrieving tokens from Keychain
func saveTokenToKeychain(_ token: String)
func getTokenFromKeychain() -> String?
}