[MM-48031] Work template read API (#21661)
Этот коммит содержится в:
@@ -8557,3 +8557,34 @@ func (c *Client4) AddUserToGroupSyncables(userID string) (*Response, error) {
|
||||
defer closeBody(r)
|
||||
return BuildResponse(r), nil
|
||||
}
|
||||
|
||||
// Worktemplates sections
|
||||
|
||||
func (c *Client4) worktemplatesRoute() string {
|
||||
return "/worktemplates"
|
||||
}
|
||||
|
||||
// GetWorktemplateCategories returns categories of worktemplates
|
||||
func (c *Client4) GetWorktemplateCategories() ([]*WorkTemplateCategory, *Response, error) {
|
||||
r, err := c.DoAPIGet(c.worktemplatesRoute()+"/categories", "")
|
||||
if err != nil {
|
||||
return nil, BuildResponse(r), err
|
||||
}
|
||||
defer closeBody(r)
|
||||
|
||||
var categories []*WorkTemplateCategory
|
||||
err = json.NewDecoder(r.Body).Decode(&categories)
|
||||
return categories, BuildResponse(r), err
|
||||
}
|
||||
|
||||
func (c *Client4) GetWorkTemplatesByCategory(category string) ([]*WorkTemplate, *Response, error) {
|
||||
r, err := c.DoAPIGet(c.worktemplatesRoute()+"/categories/"+category+"/templates", "")
|
||||
if err != nil {
|
||||
return nil, BuildResponse(r), err
|
||||
}
|
||||
defer closeBody(r)
|
||||
|
||||
var templates []*WorkTemplate
|
||||
err = json.NewDecoder(r.Body).Decode(&templates)
|
||||
return templates, BuildResponse(r), err
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user