Documentation ¶
Index ¶
- Constants
- Variables
- type Account
- type AccountInfoRequest
- type AccountInfoResponse
- type Client
- func (c *Client) AccountInfo() (*Account, error)
- func (c *Client) Authenticate() error
- func (c *Client) AuthenticateWithChallenge(challenge, response string) error
- func (c *Client) Authenticated() bool
- func (c *Client) AvailableTraffic() int
- func (c *Client) GetFileStatus(id string) (*FileStatus, error)
- func (c *Client) GetFilesInfo(ids []string, extended bool) ([]FileInfo, error)
- func (c *Client) GetURL(fileID string) (string, error)
- func (c *Client) Login(username, password, challenge, response string) (string, error)
- func (c *Client) RefreshAccountInfo()
- func (c *Client) RequestRecaptcha() (*RequestRecaptchaResponse, error)
- func (c *Client) Token() (string, error)
- type Error
- type ExtendedInfo
- type FileInfo
- type FileStatus
- type GetFileStatusRequest
- type GetFileStatusResponse
- type GetFilesInfoRequest
- type GetFilesInfoResponse
- type GetURLRequest
- type GetURLResponse
- type Logger
- type LoginRequest
- type LoginResponse
- type RequestRecaptchaResponse
- type Response
- type Token
- type VideoInfo
Constants ¶
const AccountInfoPath = "/accountInfo"
AccountInfoPath is the subpath for the accountInfo endpoint
const ContentTypeJSON = "application/json"
ContentTypeJSON represents the application/json MIME type.
const DefaultBaseURL = "https://keep2share.cc/api/v2"
DefaultBaseURL is the Keep2Share API base URL as of early 2022.
const GetFileStatusPath = "/getFileStatus"
GetFileStatusPath is the subpath for the getFileStatus endpoint
const GetFilesInfoPath = "/getFilesInfo"
GetFilesInfoPath is the subpath for the getFilesInfo endpoint
const GetURLPath = "/getUrl"
GetURLPath is the subpath for the getUrl endpoint
const LoginPath = "/login"
LoginPath is the subpath for the login endpoint
const RequestRecaptchaPath = "/requestReCaptcha"
RequestRecaptchaPath is the subpath for the requestRecaptcha endpoint
Variables ¶
var ( ErrInvalidParams = Error{Code: http.StatusBadRequest, ErrorCode: 2} ErrDownloadTrafficExceeded = Error{Code: http.StatusNotAcceptable, ErrorCode: 2} ErrFileNotAvailable = Error{Code: http.StatusNotAcceptable, ErrorCode: 21} ErrNotAuthorized = Error{Code: http.StatusForbidden, ErrorCode: 10} )
Error constants
Functions ¶
This section is empty.
Types ¶
type Account ¶ added in v0.8.0
type Account struct { AvailableTraffic int `json:"available_traffic"` AccountExpires int `json:"account_expires"` }
Account represents the non-http portion of the accountInfo response
type AccountInfoRequest ¶ added in v0.8.0
type AccountInfoRequest struct {
AuthToken string `json:"auth_token"`
}
AccountInfoRequest represents the request body for the accountInfo endpoint
type AccountInfoResponse ¶ added in v0.8.0
AccountInfoResponse represents the response body for the accountInfo endpoint
type Client ¶
Client encapsulates a Keep2Share API client. The client is thread-safe and automatically logs in and refreshes its authorization token, blocking requests when an invalid token exists.
func (*Client) AccountInfo ¶ added in v0.8.0
AccountInfo calls the accountInfo endpoint and returns the account info
func (*Client) Authenticate ¶ added in v0.9.0
func (*Client) AuthenticateWithChallenge ¶ added in v0.9.0
func (*Client) Authenticated ¶ added in v0.9.0
func (*Client) AvailableTraffic ¶ added in v0.8.1
func (*Client) GetFileStatus ¶
func (c *Client) GetFileStatus(id string) (*FileStatus, error)
GetFileStatus calls the getFileStatus endpoint and returns the status information for the requested file.
func (*Client) GetFilesInfo ¶ added in v0.7.0
GetFilesInfo calls the getFilesInfo endpoint and returns the info for the requested files
func (*Client) RefreshAccountInfo ¶ added in v0.8.0
func (c *Client) RefreshAccountInfo()
func (*Client) RequestRecaptcha ¶
func (c *Client) RequestRecaptcha() (*RequestRecaptchaResponse, error)
RequestRecaptcha calls the requestRecaptcha endpoint and returns the reCaptcha challenge and link
type Error ¶
type Error struct { Status string `json:"status"` Code int `json:"code"` ErrorCode int `json:"errorCode"` Message string `json:"message"` }
Error represents an error response from the Keep2Share API
type ExtendedInfo ¶ added in v0.7.0
type ExtendedInfo struct { StorageObject string `json:"storage_object"` Size int `json:"size"` Access string `json:"access"` ContentType string `json:"content_type"` }
ExtendedInfo represents the extended file info returned by getFilesInfo
type FileInfo ¶ added in v0.7.0
type FileInfo struct { ID string `json:"id"` Name string `json:"name"` Size int `json:"size"` IsAvailable bool `json:"is_available"` Access string `json:"access"` IsFolder bool `json:"is_folder"` MD5 *string `json:"md5"` IsAvailableForFree bool `json:"isAvailableForFree"` ExtendedInfo ExtendedInfo }
FileInfo represents the file info returned by getFilesInfo
type FileStatus ¶
type FileStatus struct { Name string `json:"name"` IsAvailable bool `json:"is_available"` IsFolder bool `json:"is_folder"` DateCreated time.Time `json:"date_created"` Size int `json:"size"` Access string `json:"access"` IsAvailableForFree bool `json:"isAvailableForFree"` VideoInfo VideoInfo `json:"video_info"` }
FileStatus represents the status information returned for a file
type GetFileStatusRequest ¶
type GetFileStatusRequest struct { AuthToken string `json:"auth_token,omitempty"` ID string `json:"id"` Limit int `json:"limit,omitempty"` Offset int `json:"offset,omitempty"` }
GetFileStatusRequest represents the request body for the getFileStatus endpoint
type GetFileStatusResponse ¶
type GetFileStatusResponse struct { Response FileStatus }
GetFileStatusResponse represents the response body for the getFileStatus endpoint
type GetFilesInfoRequest ¶ added in v0.7.0
type GetFilesInfoRequest struct { AuthToken string `json:"auth_token,omitempty"` IDs []string `json:"ids"` ExtendedInfo bool `json:"extended_info,omitempty"` }
GetFilesInfoRequest represents the request body for the getFilesInfo endpoint
type GetFilesInfoResponse ¶ added in v0.7.0
GetFilesInfoResponse represents the response body for the getFilesInfo endpoint
type GetURLRequest ¶
type GetURLRequest struct { FileID string `json:"file_id"` AuthToken string `json:"auth_token,omitempty"` FreeDownloadKey string `json:"free_download_key,omitempty"` CaptchaChallenge string `json:"captcha_challenge,omitempty"` CaptchaResponse string `json:"captcha_response,omitempty"` URLReferrer string `json:"url_referrer,omitempty"` }
GetURLRequest represents the request body for the getUrl endpoint
type GetURLResponse ¶
GetURLResponse represents the request response for the getUrl endpoint
type LoginRequest ¶
type LoginRequest struct { Username string `json:"username"` Password string `json:"password"` ReCaptchaChallenge string `json:"re_captcha_challenge,omitempty"` ReCaptchaResponse string `json:"re_captcha_response,omitempty"` }
LoginRequest represents the request body for the login endpoint
type LoginResponse ¶
LoginResponse represents the response body for the login endpoint
type RequestRecaptchaResponse ¶
type RequestRecaptchaResponse struct { Response Challenge string `json:"challenge"` CaptchaURL string `json:"captcha_url"` }
RequestRecaptchaResponse represents the response from the requestRecaptcha endpoint