github.com/Files-com/files-sdk-go/v3@v3.1.81/priority.go (about)

     1  package files_sdk
     2  
     3  import (
     4  	"encoding/json"
     5  
     6  	lib "github.com/Files-com/files-sdk-go/v3/lib"
     7  )
     8  
     9  type Priority struct {
    10  	Path  string `json:"path,omitempty" path:"path,omitempty" url:"path,omitempty"`
    11  	Color string `json:"color,omitempty" path:"color,omitempty" url:"color,omitempty"`
    12  }
    13  
    14  func (p Priority) Identifier() interface{} {
    15  	return p.Path
    16  }
    17  
    18  type PriorityCollection []Priority
    19  
    20  type PriorityListParams struct {
    21  	Path string `url:"path,omitempty" required:"true" json:"path,omitempty" path:"path"`
    22  	ListParams
    23  }
    24  
    25  func (p *Priority) UnmarshalJSON(data []byte) error {
    26  	type priority Priority
    27  	var v priority
    28  	if err := json.Unmarshal(data, &v); err != nil {
    29  		return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, map[string]interface{}{})
    30  	}
    31  
    32  	*p = Priority(v)
    33  	return nil
    34  }
    35  
    36  func (p *PriorityCollection) UnmarshalJSON(data []byte) error {
    37  	type prioritys PriorityCollection
    38  	var v prioritys
    39  	if err := json.Unmarshal(data, &v); err != nil {
    40  		return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, []map[string]interface{}{})
    41  	}
    42  
    43  	*p = PriorityCollection(v)
    44  	return nil
    45  }
    46  
    47  func (p *PriorityCollection) ToSlice() *[]interface{} {
    48  	ret := make([]interface{}, len(*p))
    49  	for i, v := range *p {
    50  		ret[i] = v
    51  	}
    52  
    53  	return &ret
    54  }