File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -311,3 +311,32 @@ func (*Sdk) Log(message string) error {
311
311
_ , err := fmt .Printf (message )
312
312
return err
313
313
}
314
+
315
+ // TeamInfo contains user info returned by daemon.
316
+ type TeamInfo struct {
317
+ ID string `json:"id"`
318
+ Name string `json:"name"`
319
+ }
320
+
321
+ // Team returns the team info for the current user running the Op.
322
+ func (* Sdk ) Team () (TeamInfo , error ) {
323
+ var body interface {}
324
+ method := "GET"
325
+ result , err := daemon .SyncRequest ("team" , body , method )
326
+
327
+ if err != nil {
328
+ return TeamInfo {}, fmt .Errorf ("error getting team information: %w" , err )
329
+ }
330
+
331
+ // map results to TeamInfo
332
+ mapValue := result .(map [string ]interface {})
333
+ teamInfo := TeamInfo {}
334
+ if id , ok := mapValue ["id" ].(string ); ok {
335
+ teamInfo .ID = id
336
+ }
337
+ if name , ok := mapValue ["name" ].(string ); ok {
338
+ teamInfo .Name = name
339
+ }
340
+
341
+ return teamInfo , nil
342
+ }
You can’t perform that action at this time.
0 commit comments