github.com/Files-com/files-sdk-go/v2@v2.1.2/filecommentreaction.go (about)

     1  package files_sdk
     2  
     3  import (
     4  	"encoding/json"
     5  
     6  	lib "github.com/Files-com/files-sdk-go/v2/lib"
     7  )
     8  
     9  type FileCommentReaction struct {
    10  	Id            int64  `json:"id,omitempty" path:"id,omitempty" url:"id,omitempty"`
    11  	Emoji         string `json:"emoji,omitempty" path:"emoji,omitempty" url:"emoji,omitempty"`
    12  	UserId        int64  `json:"user_id,omitempty" path:"user_id,omitempty" url:"user_id,omitempty"`
    13  	FileCommentId int64  `json:"file_comment_id,omitempty" path:"file_comment_id,omitempty" url:"file_comment_id,omitempty"`
    14  }
    15  
    16  func (f FileCommentReaction) Identifier() interface{} {
    17  	return f.Id
    18  }
    19  
    20  type FileCommentReactionCollection []FileCommentReaction
    21  
    22  type FileCommentReactionCreateParams struct {
    23  	UserId        int64  `url:"user_id,omitempty" required:"false" json:"user_id,omitempty" path:"user_id"`
    24  	FileCommentId int64  `url:"file_comment_id,omitempty" required:"true" json:"file_comment_id,omitempty" path:"file_comment_id"`
    25  	Emoji         string `url:"emoji,omitempty" required:"true" json:"emoji,omitempty" path:"emoji"`
    26  }
    27  
    28  type FileCommentReactionDeleteParams struct {
    29  	Id int64 `url:"-,omitempty" required:"false" json:"-,omitempty" path:"id"`
    30  }
    31  
    32  func (f *FileCommentReaction) UnmarshalJSON(data []byte) error {
    33  	type fileCommentReaction FileCommentReaction
    34  	var v fileCommentReaction
    35  	if err := json.Unmarshal(data, &v); err != nil {
    36  		return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, map[string]interface{}{})
    37  	}
    38  
    39  	*f = FileCommentReaction(v)
    40  	return nil
    41  }
    42  
    43  func (f *FileCommentReactionCollection) UnmarshalJSON(data []byte) error {
    44  	type fileCommentReactions FileCommentReactionCollection
    45  	var v fileCommentReactions
    46  	if err := json.Unmarshal(data, &v); err != nil {
    47  		return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, []map[string]interface{}{})
    48  	}
    49  
    50  	*f = FileCommentReactionCollection(v)
    51  	return nil
    52  }
    53  
    54  func (f *FileCommentReactionCollection) ToSlice() *[]interface{} {
    55  	ret := make([]interface{}, len(*f))
    56  	for i, v := range *f {
    57  		ret[i] = v
    58  	}
    59  
    60  	return &ret
    61  }