diff --git a/characters/characters.go b/characters/characters.go index bfde0db..ce0d027 100644 --- a/characters/characters.go +++ b/characters/characters.go @@ -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 +} diff --git a/characters/characters_test.go b/characters/characters_test.go new file mode 100644 index 0000000..e92373b --- /dev/null +++ b/characters/characters_test.go @@ -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) + } +}