adding refresh function

This commit is contained in:
Nils Stinnesbeck 2024-08-01 22:50:56 +02:00
parent cd137e4b1a
commit 695b991f2a
Signed by: nils
GPG Key ID: C52E07422A136076
2 changed files with 29 additions and 0 deletions

View File

@ -59,3 +59,14 @@ func Create(name string, skin Skin) (Character, error) {
return api.Post[Character]("/characters/create", newChar, responseCodes)
}
func (c *Character) Refresh() error {
char, err := Get(c.Name)
if err != nil {
return err
}
*c = char
return nil
}

View File

@ -0,0 +1,18 @@
package characters_test
import (
"testing"
"git.stinnesbeck.com/nils/artifacts/characters"
)
func TestGetRefresh(t *testing.T) {
char, err := characters.Get("Nils")
if err != nil {
t.Fatal(err)
}
if err := char.Refresh(); err != nil {
t.Fatal(err)
}
}