From 6c8beb133073ebb3b6d8bb16e852b29dbc23f133 Mon Sep 17 00:00:00 2001 From: sinner Date: Wed, 8 Apr 2026 13:47:51 -0400 Subject: feat: add admin edit command for updating account properties --- internal/client/admin.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'internal/client') diff --git a/internal/client/admin.go b/internal/client/admin.go index bf8c5ce..c776b7c 100644 --- a/internal/client/admin.go +++ b/internal/client/admin.go @@ -123,6 +123,29 @@ func (c *Client) ToggleAccount(apiKey string, enable bool) (*models.AdminRespons return &response, nil } +func (c *Client) UpdateAccount(apiKey string, req *models.AccountUpdateRequest) (*models.AdminResponse, error) { + path := fmt.Sprintf("/admin/accounts/%s", url.PathEscape(apiKey)) + data, err := c.Patch(path, req) + if err != nil { + return nil, err + } + + var account models.Account + if err := json.Unmarshal(data, &account); err == nil && account.APIKey != "" { + return &models.AdminResponse{ + Success: true, + Account: &account, + }, nil + } + + var response models.AdminResponse + if err := json.Unmarshal(data, &response); err != nil { + return nil, fmt.Errorf("failed to parse admin response: %w", err) + } + + return &response, nil +} + func (c *Client) GetAccountStats() (*models.AccountStatsResponse, error) { data, err := c.Get("/me", nil) if err != nil { -- cgit v1.2.3