github.com/cjdelisle/matterfoss@v5.11.1+incompatible/model/user_access_token_search.go (about)

     1  // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
     2  // See License.txt for license information.
     3  
     4  package model
     5  
     6  import (
     7  	"encoding/json"
     8  	"io"
     9  )
    10  
    11  type UserAccessTokenSearch struct {
    12  	Term string `json:"term"`
    13  }
    14  
    15  // ToJson convert a UserAccessTokenSearch to json string
    16  func (c *UserAccessTokenSearch) ToJson() string {
    17  	b, err := json.Marshal(c)
    18  	if err != nil {
    19  		return ""
    20  	}
    21  
    22  	return string(b)
    23  }
    24  
    25  // UserAccessTokenSearchJson decodes the input and returns a UserAccessTokenSearch
    26  func UserAccessTokenSearchFromJson(data io.Reader) *UserAccessTokenSearch {
    27  	decoder := json.NewDecoder(data)
    28  	var cs UserAccessTokenSearch
    29  	err := decoder.Decode(&cs)
    30  	if err == nil {
    31  		return &cs
    32  	}
    33  
    34  	return nil
    35  }