summaryrefslogtreecommitdiffstats
path: root/model/client4.go
diff options
context:
space:
mode:
authorMartin Kraft <mkraft@users.noreply.github.com>2018-05-02 07:31:14 -0400
committerGitHub <noreply@github.com>2018-05-02 07:31:14 -0400
commitf4dcb4edf2aafca85c9af631131a77888da24bc7 (patch)
tree83d507f4a06d84227ffa9dc8d28b098908853305 /model/client4.go
parentd2cc0c5834d6849f2fdb1e343ed5e193b742fa2f (diff)
downloadchat-f4dcb4edf2aafca85c9af631131a77888da24bc7.tar.gz
chat-f4dcb4edf2aafca85c9af631131a77888da24bc7.tar.bz2
chat-f4dcb4edf2aafca85c9af631131a77888da24bc7.zip
MM-10182 & MM-10183: Adds channel scheme and team scheme API endpoint. (#8680)
* MM-10183: Adds channel scheme API endpoint. MM-10182: Adds team scheme API endpoint. MM-10182_3: Switch from scheme_id in path to body. * MM-10182/MM-10183: Changes path from 'schemes' to 'scheme'. * MM-10182: Fix merge error.
Diffstat (limited to 'model/client4.go')
-rw-r--r--model/client4.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/model/client4.go b/model/client4.go
index cf34c9fd7..f17bb089a 100644
--- a/model/client4.go
+++ b/model/client4.go
@@ -326,6 +326,14 @@ func (c *Client4) GetTimezonesRoute() string {
return fmt.Sprintf(c.GetSystemRoute() + "/timezones")
}
+func (c *Client4) GetChannelSchemeRoute(channelId string) string {
+ return fmt.Sprintf(c.GetChannelsRoute()+"/%v/scheme", channelId)
+}
+
+func (c *Client4) GetTeamSchemeRoute(teamId string) string {
+ return fmt.Sprintf(c.GetTeamsRoute()+"/%v/scheme", teamId)
+}
+
func (c *Client4) DoApiGet(url string, etag string) (*http.Response, *AppError) {
return c.DoApiRequest(http.MethodGet, c.ApiUrl+url, "", etag)
}
@@ -3505,3 +3513,25 @@ func (c *Client4) DeactivatePlugin(id string) (bool, *Response) {
return CheckStatusOK(r), BuildResponse(r)
}
}
+
+// UpdateChannelScheme will update a channel's scheme.
+func (c *Client4) UpdateChannelScheme(channelId, schemeId string) (bool, *Response) {
+ sip := &SchemeIDPatch{SchemeID: &schemeId}
+ if r, err := c.DoApiPut(c.GetChannelSchemeRoute(channelId), sip.ToJson()); err != nil {
+ return false, BuildErrorResponse(r, err)
+ } else {
+ defer closeBody(r)
+ return CheckStatusOK(r), BuildResponse(r)
+ }
+}
+
+// UpdateTeamScheme will update a team's scheme.
+func (c *Client4) UpdateTeamScheme(teamId, schemeId string) (bool, *Response) {
+ sip := &SchemeIDPatch{SchemeID: &schemeId}
+ if r, err := c.DoApiPut(c.GetTeamSchemeRoute(teamId), sip.ToJson()); err != nil {
+ return false, BuildErrorResponse(r, err)
+ } else {
+ defer closeBody(r)
+ return CheckStatusOK(r), BuildResponse(r)
+ }
+}