diff options
Diffstat (limited to '')
-rw-r--r-- | golang/pkg/api/agents.go | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/golang/pkg/api/agents.go b/golang/pkg/api/agents.go index db5b7db..a2d5b6a 100644 --- a/golang/pkg/api/agents.go +++ b/golang/pkg/api/agents.go @@ -1,32 +1,17 @@ package api import ( - "encoding/json" - "fmt" "net/url" -) -type AgentMessage struct { - AccountID string `json:"accountId"` - Credits int `json:"credits"` - Headquarters string `json:"headquarters"` - ShipCount int `json:"shipCount"` - StartingFaction string `json:"startingFaction"` - Symbol string `json:"symbol"` -} + "git.adyxax.org/adyxax/spacetraders/v2/pkg/model" +) -func (c *Client) MyAgent() (*AgentMessage, error) { +func (c *Client) MyAgent() (*model.Agent, error) { uriRef := url.URL{Path: "my/agent"} - msg, err := c.Send("GET", &uriRef, nil) + var response model.Agent + err := c.Send("GET", &uriRef, nil, &response) 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 } |