From ff4fe406500bc97688d52d7d1ff2b14a066224b2 Mon Sep 17 00:00:00 2001 From: Jonathan Dorsey Date: Mon, 19 Oct 2020 17:21:17 -0400 Subject: [PATCH 1/2] Fix team preferences API call --- team.go | 9 ++------- teams_test.go | 10 ++++++---- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/team.go b/team.go index d3f036a3..99ad3045 100644 --- a/team.go +++ b/team.go @@ -169,13 +169,8 @@ func (c *Client) TeamPreferences(id int64) (*Preferences, error) { } // UpdateTeamPreferences updates team preferences for the Grafana team whose ID it's passed. -func (c *Client) UpdateTeamPreferences(id int64, theme string, homeDashboardID int64, timezone string) error { - path := fmt.Sprintf("/api/teams/%d", id) - preferences := Preferences{ - Theme: theme, - HomeDashboardId: homeDashboardID, - Timezone: timezone, - } +func (c *Client) UpdateTeamPreferences(id int64, preferences Preferences) error { + path := fmt.Sprintf("/api/teams/%d/preferences", id) data, err := json.Marshal(preferences) if err != nil { return err diff --git a/teams_test.go b/teams_test.go index 7e44321b..46fdf27d 100644 --- a/teams_test.go +++ b/teams_test.go @@ -286,11 +286,13 @@ func TestUpdateTeamPreferences(t *testing.T) { defer server.Close() id := int64(1) - theme := "" - homeDashboardId := int64(0) - timezone := "" + preferences := Preferences{ + Theme: "", + HomeDashboardId: int64(0), + Timezone: "", + } - if err := client.UpdateTeamPreferences(id, theme, homeDashboardId, timezone); err != nil { + if err := client.UpdateTeamPreferences(id, preferences); err != nil { t.Error(err) } } From 8a6a4eb5d595295ed4005a707f78e7eafb6d6913 Mon Sep 17 00:00:00 2001 From: Jonathan Dorsey Date: Mon, 19 Oct 2020 17:31:35 -0400 Subject: [PATCH 2/2] Fixing HomeDashboardId typo --- teams_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/teams_test.go b/teams_test.go index d361bb96..2a35ed9a 100644 --- a/teams_test.go +++ b/teams_test.go @@ -288,7 +288,7 @@ func TestUpdateTeamPreferences(t *testing.T) { id := int64(1) preferences := Preferences{ Theme: "", - HomeDashboardId: int64(0), + HomeDashboardID: int64(0), Timezone: "", }