From b15af8f169913c9cdfefbcde6840de939b4b4546 Mon Sep 17 00:00:00 2001 From: Tomas Dabasinskas Date: Mon, 21 Oct 2019 14:50:11 +0300 Subject: [PATCH] Support getting actual organization preferences Utilize `GET /api/org/preferences` endpoint to retrieve preferences of the actual organization. --- rest-org.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/rest-org.go b/rest-org.go index f00c0472..f204efa2 100644 --- a/rest-org.go +++ b/rest-org.go @@ -346,3 +346,27 @@ func (r *Client) UpdateActualOrgPreferences(prefs Preferences) (StatusMessage, e } return resp, nil } + +// GetActualOrgPreferences gets preferences of the actual organization. +// It reflects GET /api/org/preferences API call. +func (r *Client) GetActualOrgPreferences() (Preferences, error) { + var ( + raw []byte + pref Preferences + code int + err error + ) + if raw, code, err = r.get("/api/org/preferences", nil); err != nil { + return pref, err + } + + if code != http.StatusOK { + return pref, fmt.Errorf("HTTP error %d: returns %s", code, raw) + } + dec := json.NewDecoder(bytes.NewReader(raw)) + dec.UseNumber() + if err := dec.Decode(&pref); err != nil { + return pref, fmt.Errorf("unmarshal prefs: %s\n%s", err, raw) + } + return pref, err +}