Add lead workflows, PDF signing, AR projects and photo gallery integration
This commit is contained in:
34
GasTankAR/Domain/Leads/LeadDetailRepository.swift
Normal file
34
GasTankAR/Domain/Leads/LeadDetailRepository.swift
Normal file
@ -0,0 +1,34 @@
|
||||
import Foundation
|
||||
|
||||
@MainActor
|
||||
protocol LeadDetailRepository {
|
||||
func detail(id: String, salesCode: String) async throws -> LeadDetail
|
||||
func file(_ reference: LeadFileReference, leadID: String, salesCode: String) async throws -> URL
|
||||
}
|
||||
|
||||
struct GetLeadDetailUseCase {
|
||||
let repository: any LeadDetailRepository
|
||||
|
||||
func execute(id: String, salesCode: String) async throws -> LeadDetail {
|
||||
try await repository.detail(id: id, salesCode: salesCode)
|
||||
}
|
||||
}
|
||||
|
||||
struct DownloadLeadDocumentUseCase {
|
||||
let repository: any LeadDetailRepository
|
||||
|
||||
func execute(_ document: LeadDocument, leadID: String, salesCode: String) async throws -> URL {
|
||||
guard document.file.kind == .pdf else { throw LeadFileError.invalidFile }
|
||||
return try await repository.file(document.file, leadID: leadID, salesCode: salesCode)
|
||||
}
|
||||
}
|
||||
|
||||
struct LoadLeadPhotoUseCase {
|
||||
let repository: any LeadDetailRepository
|
||||
|
||||
func execute(_ photo: LeadPhoto, original: Bool = false,
|
||||
leadID: String, salesCode: String) async throws -> URL {
|
||||
try await repository.file(original ? photo.original : photo.thumbnail,
|
||||
leadID: leadID, salesCode: salesCode)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user