mirror of
https://github.com/marcusDenslow/terminalShop.git
synced 2026-10-26 02:08:46 +01:00
just updating the branch with current changes
This commit is contained in:
@@ -728,3 +728,23 @@ func (c *Client) DeleteAddress(id uint) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func(c *Client) SetDefaultAddress(id uint) error {
|
||||
url := fmt.Sprintf("%s/api/v1/addresses/%d/default", c.BaseURL, id)
|
||||
req, err := http.NewRequest("PUT", url, nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create request: %w", err)
|
||||
}
|
||||
req.Header.Set("Authorization", "Bearer "+c.Token)
|
||||
|
||||
resp, err := c.HTTPClient.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("request failed: %w", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf("failed to set default address: status %d", resp.StatusCode)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user