From 29e6db5713c57d7bb46d7aea38b1001b9e8a1212 Mon Sep 17 00:00:00 2001 From: Carlos Tadeu Panato Junior Date: Thu, 30 Mar 2017 17:09:39 +0200 Subject: Implement POST /users/status/ids for apiv4 (#5894) --- model/client4.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'model/client4.go') diff --git a/model/client4.go b/model/client4.go index 27f8328f4..91b538ff8 100644 --- a/model/client4.go +++ b/model/client4.go @@ -194,10 +194,14 @@ func (c *Client4) GetPreferencesRoute(userId string) string { return fmt.Sprintf(c.GetUserRoute(userId) + "/preferences") } -func (c *Client4) GetStatusRoute(userId string) string { +func (c *Client4) GetUserStatusRoute(userId string) string { return fmt.Sprintf(c.GetUserRoute(userId) + "/status") } +func (c *Client4) GetUserStatusesRoute() string { + return fmt.Sprintf(c.GetUsersRoute() + "/status") +} + func (c *Client4) GetSamlRoute() string { return fmt.Sprintf("/saml") } @@ -1989,10 +1993,20 @@ func (c *Client4) CreateCommand(cmd *Command) (*Command, *Response) { // GetUserStatus returns a user based on the provided user id string. func (c *Client4) GetUserStatus(userId, etag string) (*Status, *Response) { - if r, err := c.DoApiGet(c.GetStatusRoute(userId), etag); err != nil { + if r, err := c.DoApiGet(c.GetUserStatusRoute(userId), etag); err != nil { return nil, &Response{StatusCode: r.StatusCode, Error: err} } else { defer closeBody(r) return StatusFromJson(r.Body), BuildResponse(r) } } + +// GetUsersStatusesByIds returns a list of users status based on the provided user ids. +func (c *Client4) GetUsersStatusesByIds(userIds []string) ([]*Status, *Response) { + if r, err := c.DoApiPost(c.GetUserStatusesRoute()+"/ids", ArrayToJson(userIds)); err != nil { + return nil, &Response{StatusCode: r.StatusCode, Error: err} + } else { + defer closeBody(r) + return StatusListFromJson(r.Body), BuildResponse(r) + } +} -- cgit v1.2.3-1-g7c22