github.com/artpar/rclone@v1.67.3/backend/premiumizeme/api/types.go (about) 1 // Package api contains definitions for using the premiumize.me API 2 package api 3 4 import "fmt" 5 6 // Response is returned by all messages and embedded in the 7 // structures below 8 type Response struct { 9 Message string `json:"message,omitempty"` 10 Status string `json:"status"` 11 } 12 13 // Error satisfies the error interface 14 func (e *Response) Error() string { 15 return fmt.Sprintf("%s: %s", e.Status, e.Message) 16 } 17 18 // AsErr checks the status and returns an err if bad or nil if good 19 func (e *Response) AsErr() error { 20 if e.Status != "success" { 21 return e 22 } 23 return nil 24 } 25 26 // Item Types 27 const ( 28 ItemTypeFolder = "folder" 29 ItemTypeFile = "file" 30 ) 31 32 // Item refers to a file or folder 33 type Item struct { 34 Breadcrumbs []Breadcrumb `json:"breadcrumbs"` 35 CreatedAt int64 `json:"created_at,omitempty"` 36 ID string `json:"id"` 37 Link string `json:"link,omitempty"` 38 Name string `json:"name"` 39 Size int64 `json:"size,omitempty"` 40 StreamLink string `json:"stream_link,omitempty"` 41 Type string `json:"type"` 42 TranscodeStatus string `json:"transcode_status"` 43 IP string `json:"ip"` 44 MimeType string `json:"mime_type"` 45 } 46 47 // Breadcrumb is part the breadcrumb trail for a file or folder. It 48 // is returned as part of folder/list if required 49 type Breadcrumb struct { 50 ID string `json:"id,omitempty"` 51 Name string `json:"name,omitempty"` 52 ParentID string `json:"parent_id,omitempty"` 53 } 54 55 // FolderListResponse is the response to folder/list 56 type FolderListResponse struct { 57 Response 58 Content []Item `json:"content"` 59 Name string `json:"name,omitempty"` 60 ParentID string `json:"parent_id,omitempty"` 61 FolderID string `json:"folder_id,omitempty"` 62 } 63 64 // FolderCreateResponse is the response to folder/create 65 type FolderCreateResponse struct { 66 Response 67 ID string `json:"id,omitempty"` 68 } 69 70 // FolderUploadinfoResponse is the response to folder/uploadinfo 71 type FolderUploadinfoResponse struct { 72 Response 73 Token string `json:"token,omitempty"` 74 URL string `json:"url,omitempty"` 75 } 76 77 // AccountInfoResponse is the response to account/info 78 type AccountInfoResponse struct { 79 Response 80 CustomerID string `json:"customer_id,omitempty"` 81 LimitUsed float64 `json:"limit_used,omitempty"` // fraction 0..1 of download traffic limit 82 PremiumUntil int64 `json:"premium_until,omitempty"` 83 SpaceUsed float64 `json:"space_used,omitempty"` 84 }