github.com/artpar/rclone@v1.67.3/backend/uptobox/api/types.go (about) 1 // Package api provides types used by the Uptobox API. 2 package api 3 4 import "fmt" 5 6 // Error contains the error code and message returned by the API 7 type Error struct { 8 Success bool `json:"success,omitempty"` 9 StatusCode int `json:"statusCode,omitempty"` 10 Message string `json:"message,omitempty"` 11 Data string `json:"data,omitempty"` 12 } 13 14 // Error returns a string for the error and satisfies the error interface 15 func (e Error) Error() string { 16 out := fmt.Sprintf("api error %d", e.StatusCode) 17 if e.Message != "" { 18 out += ": " + e.Message 19 } 20 if e.Data != "" { 21 out += ": " + e.Data 22 } 23 return out 24 } 25 26 // FolderEntry represents a Uptobox subfolder when listing folder contents 27 type FolderEntry struct { 28 FolderID uint64 `json:"fld_id"` 29 Description string `json:"fld_descr"` 30 Password string `json:"fld_password"` 31 FullPath string `json:"fullPath"` 32 Path string `json:"fld_name"` 33 Name string `json:"name"` 34 Hash string `json:"hash"` 35 } 36 37 // FolderInfo represents the current folder when listing folder contents 38 type FolderInfo struct { 39 FolderID uint64 `json:"fld_id"` 40 Hash string `json:"hash"` 41 FileCount uint64 `json:"fileCount"` 42 TotalFileSize int64 `json:"totalFileSize"` 43 } 44 45 // FileInfo represents a file when listing folder contents 46 type FileInfo struct { 47 Name string `json:"file_name"` 48 Description string `json:"file_descr"` 49 Created string `json:"file_created"` 50 Size int64 `json:"file_size"` 51 Downloads uint64 `json:"file_downloads"` 52 Code string `json:"file_code"` 53 Password string `json:"file_password"` 54 Public int `json:"file_public"` 55 LastDownload string `json:"file_last_download"` 56 ID uint64 `json:"id"` 57 } 58 59 // ReadMetadataResponse is the response when listing folder contents 60 type ReadMetadataResponse struct { 61 StatusCode int `json:"statusCode"` 62 Message string `json:"message"` 63 Data struct { 64 CurrentFolder FolderInfo `json:"currentFolder"` 65 Folders []FolderEntry `json:"folders"` 66 Files []FileInfo `json:"files"` 67 PageCount int `json:"pageCount"` 68 TotalFileCount int `json:"totalFileCount"` 69 TotalFileSize int64 `json:"totalFileSize"` 70 } `json:"data"` 71 } 72 73 // UploadInfo is the response when initiating an upload 74 type UploadInfo struct { 75 StatusCode int `json:"statusCode"` 76 Message string `json:"message"` 77 Data struct { 78 UploadLink string `json:"uploadLink"` 79 MaxUpload string `json:"maxUpload"` 80 } `json:"data"` 81 } 82 83 // UploadResponse is the response to a successful upload 84 type UploadResponse struct { 85 Files []struct { 86 Name string `json:"name"` 87 Size int64 `json:"size"` 88 URL string `json:"url"` 89 DeleteURL string `json:"deleteUrl"` 90 } `json:"files"` 91 } 92 93 // UpdateResponse is a generic response to various action on files (rename/copy/move) 94 type UpdateResponse struct { 95 Message string `json:"message"` 96 StatusCode int `json:"statusCode"` 97 } 98 99 // Download is the response when requesting a download link 100 type Download struct { 101 StatusCode int `json:"statusCode"` 102 Message string `json:"message"` 103 Data struct { 104 DownloadLink string `json:"dlLink"` 105 } `json:"data"` 106 } 107 108 // MetadataRequestOptions represents all the options when listing folder contents 109 type MetadataRequestOptions struct { 110 Limit uint64 111 Offset uint64 112 SearchField string 113 Search string 114 } 115 116 // CreateFolderRequest is used for creating a folder 117 type CreateFolderRequest struct { 118 Token string `json:"token"` 119 Path string `json:"path"` 120 Name string `json:"name"` 121 } 122 123 // DeleteFolderRequest is used for deleting a folder 124 type DeleteFolderRequest struct { 125 Token string `json:"token"` 126 FolderID uint64 `json:"fld_id"` 127 } 128 129 // CopyMoveFileRequest is used for moving/copying a file 130 type CopyMoveFileRequest struct { 131 Token string `json:"token"` 132 FileCodes string `json:"file_codes"` 133 DestinationFolderID uint64 `json:"destination_fld_id"` 134 Action string `json:"action"` 135 } 136 137 // MoveFolderRequest is used for moving a folder 138 type MoveFolderRequest struct { 139 Token string `json:"token"` 140 FolderID uint64 `json:"fld_id"` 141 DestinationFolderID uint64 `json:"destination_fld_id"` 142 Action string `json:"action"` 143 } 144 145 // RenameFolderRequest is used for renaming a folder 146 type RenameFolderRequest struct { 147 Token string `json:"token"` 148 FolderID uint64 `json:"fld_id"` 149 NewName string `json:"new_name"` 150 } 151 152 // UpdateFileInformation is used for renaming a file 153 type UpdateFileInformation struct { 154 Token string `json:"token"` 155 FileCode string `json:"file_code"` 156 NewName string `json:"new_name,omitempty"` 157 Description string `json:"description,omitempty"` 158 Password string `json:"password,omitempty"` 159 Public string `json:"public,omitempty"` 160 } 161 162 // RemoveFileRequest is used for deleting a file 163 type RemoveFileRequest struct { 164 Token string `json:"token"` 165 FileCodes string `json:"file_codes"` 166 } 167 168 // Token represents the authentication token 169 type Token struct { 170 Token string `json:"token"` 171 }