Add lead workflows, PDF signing, AR projects and photo gallery integration

This commit is contained in:
Dennis Nemec
2026-11-08 17:49:39 +01:00
parent a343bde741
commit 8d18873412
82 changed files with 6401 additions and 34 deletions

View File

@ -0,0 +1,29 @@
import Foundation
@MainActor
protocol LeadDetailRemoteService {
func fetchDetail(id: String, salesCode: String) async throws -> LeadDetailDTO
func download(_ reference: LeadFileReference, leadID: String, salesCode: String) async throws -> Data
}
/// Transport boundary. A future HTTP adapter maps its response into this payload.
struct LeadDetailDTO {
let detail: LeadDetail
func toDomain(expectedID: String) throws -> LeadDetail {
let documents = detail.offers.flatMap(\.documents)
let groups = detail.offers.flatMap(\.groups)
guard detail.lead.id == expectedID,
Set(detail.offers.map(\.id)).count == detail.offers.count,
Set(groups.map(\.id)).count == groups.count,
Set(documents.map(\.id)).count == documents.count,
Set(detail.photos.map(\.id)).count == detail.photos.count,
Set(detail.tankOptions.map(\.id)).count == detail.tankOptions.count,
detail.offers.allSatisfy({ !$0.id.isEmpty && !$0.title.isEmpty && $0.amount >= 0 }),
documents.allSatisfy({ !$0.id.isEmpty && !$0.title.isEmpty && $0.pageCount > 0
&& $0.file.kind == .pdf && !$0.file.id.isEmpty && !$0.file.version.isEmpty }),
detail.photos.allSatisfy({ $0.thumbnail.kind == .image && $0.original.kind == .image })
else { throw LeadError.invalidResponse }
return detail
}
}