api

package
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2023 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAccountLimited

func IsAccountLimited(err error) bool

IsAccountLimited returns whether the error is caused by space not enough or rate limit...

func IsSpaceNotEnoughErr

func IsSpaceNotEnoughErr(err error) bool

IsSpaceNotEnoughErr returns whether the error is caused by space not enough.

func IsTaskDailyCreateLimitErr added in v0.1.4

func IsTaskDailyCreateLimitErr(err error) bool

IsTaskDailyCreateLimitErr returns whether the error is caused by task daily create limit.

func IsTaskRunNumsLimitErr added in v0.1.4

func IsTaskRunNumsLimitErr(err error) bool

IsTaskRunNumsLimitErr returns whether the error is caused by task run nums limit.

Types

type API

type API struct {
	*hosts.Dependencies
	// contains filtered or unexported fields
}

API PikPak server api.

func New

func New(q *query.Query, d *hosts.Dependencies) *API

New returns server api instance.

func (api *API) CreateFilesFromLink(ctx context.Context, master, worker, link string) (file *model.File, err error)

CreateFilesFromLink create files from link.

func (*API) CreateShare

func (api *API) CreateShare(ctx context.Context, master string, worker string, fileID string) (sharedLink string, err error)

CreateShare create a sharing link by files.

func (*API) DeleteFilesByIDs

func (api *API) DeleteFilesByIDs(ctx context.Context, worker string, fileIDs []string) error

func (*API) DeleteShare

func (api *API) DeleteShare(ctx context.Context, worker string, shareIDs []string) error

DeleteShare create a sharing link by files.

func (*API) DeleteShareByFileIDs

func (api *API) DeleteShareByFileIDs(ctx context.Context, worker string, fileIDs []string) error

DeleteShareByFileIDs deletes host shared links by original links.

func (*API) GetCommissions added in v0.1.3

func (api *API) GetCommissions(ctx context.Context, userID string) (*GetCommissionsResponse, error)

GetCommissions get commissions from server.

func (*API) GetFileByOriginalLinkHash

func (api *API) GetFileByOriginalLinkHash(ctx context.Context, master string, worker string, originalLinkHash string) (*model.File, error)

GetFileByOriginalLinkHash get file by original link. only one of master or worker is required.

func (*API) GetPremiumExpiration

func (api *API) GetPremiumExpiration(ctx context.Context, worker string) (*time.Time, error)

GetPremiumExpiration get the premium expiration for the worker account.

func (*API) GetShareStatus

func (api *API) GetShareStatus(ctx context.Context, sharedLink string) (status share.State, worker string, err error)

GetShareStatus returns the statuses of the shared link.

func (*API) GetStatistics

func (api *API) GetStatistics(ctx context.Context, sharedLink string) (*share.Statistics, error)

GetStatistics returns the statistics of each shared links.

func (*API) GetStorageSize

func (api *API) GetStorageSize(ctx context.Context, worker string) (used, limit int64, err error)

GetStorageSize returns the used and limit size of the worker.

func (*API) InviteSubAccount added in v0.1.2

func (api *API) InviteSubAccount(ctx context.Context, masterUserID string, workerEmail string) error

InviteSubAccount invite sub-account by email.

func (*API) JoinReferral added in v0.1.2

func (api *API) JoinReferral(ctx context.Context, userID string) error

JoinReferral join https://mypikpak.com/referral/

func (*API) SignUp

func (api *API) SignUp(ctx context.Context, email string, timeout time.Duration) (user *UserInfo, err error)

SignUp sign up a new account by email.

func (*API) TriggerRunningFile added in v0.1.5

func (api *API) TriggerRunningFile(file *model.File)

TriggerRunningFile try to update the status of the running or pending files.

func (*API) UpdateFilesStatus

func (api *API) UpdateFilesStatus(ctx context.Context, workerUserID string, files []*model.File, updateRunningTasks ...bool) (err error)

UpdateFilesStatus update files status. All files must belong to the same worker.

func (*API) UpdateWorkerPremium

func (api *API) UpdateWorkerPremium(ctx context.Context, worker *model.WorkerAccount) error

UpdateWorkerPremium updates the worker's premium expiration and also storage info.

func (*API) UpdateWorkerStorage

func (api *API) UpdateWorkerStorage(ctx context.Context, worker string) error

UpdateWorkerStorage updates the worker's storage info from server.

func (*API) VerifyInviteSubAccountToken added in v0.1.2

func (api *API) VerifyInviteSubAccountToken(ctx context.Context, token string) error

VerifyInviteSubAccountToken invite sub-account by email.

type GetCommissionsResponse added in v0.1.3

type GetCommissionsResponse struct {
	Total     float64 `json:"total"`
	Pending   float64 `json:"pending"`
	Available float64 `json:"available"`
}

GetCommissionsResponse is the response of the GetCommissions API.

type JSON

type JSON map[string]any

JSON alias of string map.

type RespErr

type RespErr struct {
	ErrorKey         string `json:"error"`
	ErrorCode        int    `json:"error_code"`
	ErrorDescription string `json:"error_description"`
}

RespErr server response error struct.

func (*RespErr) Error

func (e *RespErr) Error() error

Error check error and implement error interface..

type UserInfo

type UserInfo struct {
	UserID       string `json:"user_id"`
	Password     string `json:"password"`
	Email        string `json:"email"`
	AccessToken  string `json:"access_token"`
	ExpiresIn    int64  `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
}

UserInfo is the info of a user.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL