Skip to content

Commit 5080e5e

Browse files
feature: Adds HisRead
1 parent 5a6142f commit 5080e5e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Sources/HaystackClient/HaystackClient.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ public class HaystackClient {
166166
return try await post(path: "nav", args: ["navId": navId])
167167
}
168168

169+
public func hisRead(id: Ref, range: HisReadRange) async throws -> Grid {
170+
return try await post(path: "hisRead", args: ["id": id, "range": range.toRequestString()])
171+
}
172+
169173

170174
public func watchSubCreate(
171175
watchDis: String,
@@ -396,3 +400,23 @@ enum HTTPHeader {
396400
static let userAgent = "User-Agent"
397401
static let wwwAuthenticate = "Www-Authenticate"
398402
}
403+
404+
public enum HisReadRange {
405+
case today
406+
case yesterday
407+
case date(Haystack.Date)
408+
case dateRange(from: Haystack.Date, to: Haystack.Date)
409+
case dateTimeRange(from: DateTime, to: DateTime)
410+
case after(DateTime)
411+
412+
func toRequestString() -> String {
413+
switch self {
414+
case .today: return "today"
415+
case .yesterday: return "yesterday"
416+
case let .date(date): return "\(date.toZinc())"
417+
case let .dateRange(fromDate, toDate): return "\(fromDate.toZinc()),\(toDate.toZinc())"
418+
case let .dateTimeRange(fromDateTime, toDateTime): return "\(fromDateTime.toZinc()),\(toDateTime.toZinc())"
419+
case let .after(dateTime): return "\(dateTime.toZinc())"
420+
}
421+
}
422+
}

0 commit comments

Comments
 (0)