28 lines
919 B
Swift
28 lines
919 B
Swift
import Foundation
|
|
|
|
enum LeadPDFUploadResult: Sendable {
|
|
case uploaded
|
|
case simulated
|
|
}
|
|
|
|
@MainActor
|
|
protocol LeadSignedPDFUploadService {
|
|
var isSimulation: Bool { get }
|
|
func upload(_ files: [URL], leadID: String, offerID: String, salesCode: String) async throws -> LeadPDFUploadResult
|
|
}
|
|
|
|
/// UI demonstration until the PDF upload endpoint is available. Sends no data.
|
|
struct StubLeadSignedPDFUploadService: LeadSignedPDFUploadService {
|
|
let isSimulation = true
|
|
var delay: Duration = .seconds(2)
|
|
|
|
func upload(_ files: [URL], leadID: String, offerID: String, salesCode: String) async throws -> LeadPDFUploadResult {
|
|
guard !files.isEmpty, files.allSatisfy({ FileManager.default.fileExists(atPath: $0.path) }) else {
|
|
throw PDFSigningError.invalidDocument
|
|
}
|
|
try await Task.sleep(for: delay)
|
|
try Task.checkCancellation()
|
|
return .simulated
|
|
}
|
|
}
|