mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
* MM-18357: Adds pagination to team search. * MM-18357: Adds new client method for paginated requests. * MM-18357: Adds feedback about non-supported pagination-permissions combo. * MM-18357: Removes unnecessary conversion. * MM-18357: Removes paginate parameter and uses nil on page and perpage instead.
42 lines
806 B
Go
42 lines
806 B
Go
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
|
// See License.txt for license information.
|
|
|
|
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
"io"
|
|
)
|
|
|
|
type TeamSearch struct {
|
|
Term string `json:"term"`
|
|
Page *int `json:"page,omitempty"`
|
|
PerPage *int `json:"per_page,omitempty"`
|
|
}
|
|
|
|
func (t *TeamSearch) IsPaginated() bool {
|
|
return t.Page != nil && t.PerPage != nil
|
|
}
|
|
|
|
// ToJson convert a TeamSearch to json string
|
|
func (c *TeamSearch) ToJson() string {
|
|
b, err := json.Marshal(c)
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
|
|
return string(b)
|
|
}
|
|
|
|
// TeamSearchFromJson decodes the input and returns a TeamSearch
|
|
func TeamSearchFromJson(data io.Reader) *TeamSearch {
|
|
decoder := json.NewDecoder(data)
|
|
var cs TeamSearch
|
|
err := decoder.Decode(&cs)
|
|
if err == nil {
|
|
return &cs
|
|
}
|
|
|
|
return nil
|
|
}
|