File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -181,6 +181,41 @@ public class HaystackClient {
181181 return try await post ( path: " hisWrite " , grid: builder. toGrid ( ) )
182182 }
183183
184+ public func pointWrite(
185+ id: Ref ,
186+ level: Number ,
187+ val: any Val ,
188+ who: String ? = nil ,
189+ duration: Number ? = nil
190+ ) async throws -> Grid {
191+ // level must be int between 1 & 17, check duration is duration unit and is present when level is 8
192+ guard
193+ level. isInt,
194+ 1 <= level. val,
195+ level. val <= 17
196+ else {
197+ throw HaystackClientError . pointWriteLevelIsNotIntBetween1And17
198+ }
199+
200+ var args : [ String : any Val ] = [
201+ " id " : id,
202+ " level " : level,
203+ " val " : val
204+ ]
205+ if let who = who {
206+ args [ " who " ] = who
207+ }
208+ if level. val == 8 , let duration = duration {
209+ // TODO: Check that duration has time units
210+ args [ " duration " ] = duration
211+ }
212+
213+ return try await post ( path: " pointWrite " , args: args)
214+ }
215+
216+ public func pointWriteStatus( id: Ref ) async throws -> Grid {
217+ return try await post ( path: " pointWrite " , args: [ " id " : id] )
218+ }
184219
185220 public func watchSubCreate(
186221 watchDis: String ,
@@ -382,6 +417,7 @@ enum HaystackClientError: Error {
382417 case baseUrlCannotBeFile
383418 case responseIsNotZinc
384419 case requestFailed( httpCode: Int , message: String ? )
420+ case pointWriteLevelIsNotIntBetween1And17
385421}
386422
387423enum AuthMechanism : String {
You can’t perform that action at this time.
0 commit comments