Documentation ¶
Index ¶
- Constants
- type Client
- func (c *Client) Authorized() bool
- func (c *Client) GetFileStatus(id string) (*FileStatus, error)
- func (c *Client) GetURL(fileID, freeDownloadKey, captchaChallenge, captchaResponse, urlReferrer string) (string, error)
- func (c *Client) Login(username, password, challenge, response string) (string, error)
- func (c *Client) LoginWithChallenge(challenge, response string)
- func (c *Client) RequestRecaptcha() (*RequestRecaptchaResponse, error)
- func (c *Client) Token() *Token
- func (c *Client) UpdateAuthorization(username string, password string)
- type Error
- type FileStatus
- type GetFileStatusRequest
- type GetFileStatusResponse
- type GetURLRequest
- type GetURLResponse
- type LoginRequest
- type LoginResponse
- type RequestRecaptchaResponse
- type Response
- type Token
- type VideoInfo
Constants ¶
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 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 ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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) Authorized ¶
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) LoginWithChallenge ¶ added in v0.3.0
func (*Client) RequestRecaptcha ¶
func (c *Client) RequestRecaptcha() (*RequestRecaptchaResponse, error)
RequestRecaptcha calls the requestRecaptcha endpoint and returns the reCaptcha challenge and link
func (*Client) UpdateAuthorization ¶
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 FileStatus ¶
type FileStatus struct { ID string `json:"id"` Name string `json:"name"` IsAvailable bool `json:"is_available"` IsFolder bool `json:"is_folder"` DateCreated time.Time `json:"date_created"` Size int `json:"size"` 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 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