add client method to add a private note

This commit is contained in:
Dan Anglin 2024-05-21 22:23:44 +01:00
parent 6e40792fec
commit b12f2328b3
Signed by: dananglin
GPG key ID: 0C1D44CFBEE68638

View file

@ -158,3 +158,25 @@ func (g *Client) GetBlockedAccounts(limit int) (model.AccountList, error) {
return blocked, nil
}
func (g *Client) SetPrivateNote(accountID, note string) error {
form := struct {
Comment string `json:"comment"`
}{
Comment: note,
}
data, err := json.Marshal(form)
if err != nil {
return fmt.Errorf("unable to marshal the form; %w", err)
}
requestBody := bytes.NewBuffer(data)
url := g.Authentication.Instance + fmt.Sprintf("/api/v1/accounts/%s/note", accountID)
if err := g.sendRequest(http.MethodPost, url, requestBody, nil); err != nil {
return fmt.Errorf("received an error after sending the request to set the private note; %w", err)
}
return nil
}