summaryrefslogtreecommitdiff
path: root/golang/pkg/api/agents.go
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--golang/pkg/api/agents.go22
1 files changed, 20 insertions, 2 deletions
diff --git a/golang/pkg/api/agents.go b/golang/pkg/api/agents.go
index aa8107a..db5b7db 100644
--- a/golang/pkg/api/agents.go
+++ b/golang/pkg/api/agents.go
@@ -1,5 +1,11 @@
package api
+import (
+ "encoding/json"
+ "fmt"
+ "net/url"
+)
+
type AgentMessage struct {
AccountID string `json:"accountId"`
Credits int `json:"credits"`
@@ -9,6 +15,18 @@ type AgentMessage struct {
Symbol string `json:"symbol"`
}
-func (c *Client) MyAgent() (APIMessage[AgentMessage, any], error) {
- return Send[AgentMessage](c, "GET", "/my/agent", nil)
+func (c *Client) MyAgent() (*AgentMessage, error) {
+ uriRef := url.URL{Path: "my/agent"}
+ msg, err := c.Send("GET", &uriRef, nil)
+ if err != nil {
+ return nil, err
+ }
+ if msg.Error != nil {
+ return nil, msg.Error
+ }
+ var response AgentMessage
+ if err := json.Unmarshal(msg.Data, &response); err != nil {
+ return nil, fmt.Errorf("failed to unmarshal agent data: %w", err)
+ }
+ return &response, nil
}