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

     1  package files_sdk
     2  
     3  import (
     4  	"encoding/json"
     5  	"time"
     6  
     7  	lib "github.com/Files-com/files-sdk-go/v3/lib"
     8  )
     9  
    10  type SyncLog struct {
    11  	Timestamp       *time.Time `json:"timestamp,omitempty" path:"timestamp,omitempty" url:"timestamp,omitempty"`
    12  	SyncId          int64      `json:"sync_id,omitempty" path:"sync_id,omitempty" url:"sync_id,omitempty"`
    13  	ExternalEventId int64      `json:"external_event_id,omitempty" path:"external_event_id,omitempty" url:"external_event_id,omitempty"`
    14  	ErrorType       string     `json:"error_type,omitempty" path:"error_type,omitempty" url:"error_type,omitempty"`
    15  	Message         string     `json:"message,omitempty" path:"message,omitempty" url:"message,omitempty"`
    16  	Operation       string     `json:"operation,omitempty" path:"operation,omitempty" url:"operation,omitempty"`
    17  	Path            string     `json:"path,omitempty" path:"path,omitempty" url:"path,omitempty"`
    18  	Size            string     `json:"size,omitempty" path:"size,omitempty" url:"size,omitempty"`
    19  	FileType        string     `json:"file_type,omitempty" path:"file_type,omitempty" url:"file_type,omitempty"`
    20  	Status          string     `json:"status,omitempty" path:"status,omitempty" url:"status,omitempty"`
    21  }
    22  
    23  func (s SyncLog) Identifier() interface{} {
    24  	return s.Path
    25  }
    26  
    27  type SyncLogCollection []SyncLog
    28  
    29  type SyncLogListParams struct {
    30  	Filter       SyncLog                `url:"filter,omitempty" required:"false" json:"filter,omitempty" path:"filter"`
    31  	FilterPrefix map[string]interface{} `url:"filter_prefix,omitempty" required:"false" json:"filter_prefix,omitempty" path:"filter_prefix"`
    32  	ListParams
    33  }
    34  
    35  func (s *SyncLog) UnmarshalJSON(data []byte) error {
    36  	type syncLog SyncLog
    37  	var v syncLog
    38  	if err := json.Unmarshal(data, &v); err != nil {
    39  		return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, map[string]interface{}{})
    40  	}
    41  
    42  	*s = SyncLog(v)
    43  	return nil
    44  }
    45  
    46  func (s *SyncLogCollection) UnmarshalJSON(data []byte) error {
    47  	type syncLogs SyncLogCollection
    48  	var v syncLogs
    49  	if err := json.Unmarshal(data, &v); err != nil {
    50  		return lib.ErrorWithOriginalResponse{}.ProcessError(data, err, []map[string]interface{}{})
    51  	}
    52  
    53  	*s = SyncLogCollection(v)
    54  	return nil
    55  }
    56  
    57  func (s *SyncLogCollection) ToSlice() *[]interface{} {
    58  	ret := make([]interface{}, len(*s))
    59  	for i, v := range *s {
    60  		ret[i] = v
    61  	}
    62  
    63  	return &ret
    64  }