Skip to content

Commit adde412

Browse files
feature: Adds invokeAction
1 parent 13bb3ba commit adde412

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Sources/HaystackClient/HaystackClient.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,23 @@ public class HaystackClient {
291291
return try await post(path: "watchPoll", grid: builder.toGrid())
292292
}
293293

294+
public func invokeAction(id: Ref, action: String, args: [String: any Val]) async throws -> Grid {
295+
let gridMeta: [String: any Val] = [
296+
"id": id,
297+
"action": action
298+
]
299+
let builder = GridBuilder()
300+
builder.setMeta(gridMeta)
301+
var row = [any Val]()
302+
for (argName, argVal) in args {
303+
try builder.addCol(name: argName)
304+
row.append(argVal)
305+
}
306+
try builder.addRow(row)
307+
308+
return try await post(path: "invokeAction", grid: builder.toGrid())
309+
}
310+
294311
@discardableResult
295312
private func post(path: String, args: [String: any Val] = [:]) async throws -> Grid {
296313
let grid: Grid

0 commit comments

Comments
 (0)