feat: add iOS support and harden receipt scanning

This commit is contained in:
Timo
2026-08-20 23:48:26 +02:00
parent f5e06c32b0
commit cf1b799e1b
107 changed files with 11755 additions and 122 deletions

View File

@@ -0,0 +1,32 @@
import Foundation
/// `/api/projects` Pro-only folders. `list()` itself is not gated (a
/// downgraded Pro user can still see how their receipts were filed), but
/// create/rename/delete return `402 pro_required` for a free-plan account
/// surface that as a paywall prompt, not a generic error.
enum ProjectsAPI {
static func list() async throws -> [Project] {
let response: ProjectListResponse = try await APIClient.shared.send(
APIRequest(path: "/api/projects", method: .get)
)
return response.projects
}
@discardableResult
static func create(name: String, color: String?) async throws -> Project {
struct Response: Decodable { let success: Bool; let project: Project }
let request = try APIRequest.json(
path: "/api/projects",
method: .post,
body: CreateProjectRequest(name: name, color: color)
)
let response: Response = try await APIClient.shared.send(request)
return response.project
}
static func delete(id: String) async throws {
try await APIClient.shared.sendDiscardingResponse(
APIRequest(path: "/api/projects/\(id)", method: .delete)
)
}
}