Unifying the debrid services under a protocol will help slim down on excess redundant code and allow for easy addition of new services in the future. Signed-off-by: kingbri <bdashore3@proton.me>
34 lines
695 B
Swift
34 lines
695 B
Swift
//
|
|
// Debrid.swift
|
|
// Ferrite
|
|
//
|
|
// Created by Brian Dashore on 6/1/24.
|
|
//
|
|
|
|
import Foundation
|
|
|
|
public protocol DebridSource {
|
|
// ID of the service
|
|
var id: String { get }
|
|
|
|
// Common authentication functions
|
|
func setApiKey(_ key: String) -> Bool
|
|
func logout() async
|
|
}
|
|
|
|
public protocol PollingDebridSource: DebridSource {
|
|
// Task reference for polling
|
|
var authTask: Task<Void, Error>? { get set }
|
|
|
|
// Fetches the Auth URL
|
|
func getAuthUrl() async throws -> URL
|
|
}
|
|
|
|
public protocol OAuthDebridSource: DebridSource {
|
|
|
|
// Fetches the auth URL
|
|
func getAuthUrl() throws -> URL
|
|
|
|
// Handles an OAuth callback
|
|
func handleAuthCallback(url: URL) throws
|
|
}
|