Jul 13 - Update codes to catch up with the web app updates: scheduled inspection and issue's handler
This commit is contained in:
@@ -367,6 +367,33 @@ actor APIClient {
|
||||
return result.issues
|
||||
}
|
||||
|
||||
// ── Scheduled Inspections (phase36) ───────────────────────────────────
|
||||
|
||||
func fetchScheduledInspections() async throws -> [APIScheduledInspection] {
|
||||
let result: APIScheduledInspectionsResponseData =
|
||||
try await request("/api/v1/scheduled-inspections")
|
||||
return result.scheduled
|
||||
}
|
||||
|
||||
// ── Issue Handler ("Handled By") ──────────────────────────────────────
|
||||
|
||||
/// Set who handles an issue. `details` carries any of the optional
|
||||
/// facility_handler_* / vendor_* fields; only keys present are updated.
|
||||
func updateIssueHandler(
|
||||
issueId: Int,
|
||||
handlerType: String,
|
||||
details: [String: String] = [:]
|
||||
) async throws -> String {
|
||||
var body: [String: Any] = ["handler_type": handlerType]
|
||||
for (k, v) in details { body[k] = v }
|
||||
let result: APIIssueHandlerUpdate = try await request(
|
||||
"/api/v1/issues/\(issueId)/handler",
|
||||
method: "PATCH",
|
||||
body: body
|
||||
)
|
||||
return result.handlerType
|
||||
}
|
||||
|
||||
/// Fetch dashboard KPI counts for the current user (Phase B).
|
||||
func fetchDashboardStats() async throws -> APIDashboardStats {
|
||||
return try await request("/api/v1/stats/dashboard")
|
||||
|
||||
Reference in New Issue
Block a user