open-115-sdk
Version:
115生活开放SDK接口封装
119 lines (118 loc) • 3.92 kB
TypeScript
export interface Open115Config {
baseURL?: string;
token?: string;
clientId: string;
}
export declare class Open115Error extends Error {
constructor(message: string);
}
export declare class Open115SDK {
private client;
private token?;
private clientId;
private codeVerifier?;
constructor(config: Open115Config);
/**
* 设置认证token
* @param token
*/
setToken(token: string): void;
/**
* 获取设备码和二维码内容
* 使用接口返回的 data.qrcode 作为二维码的内容,在第三方客户端展示二维码,用于给115客户端扫码授权。
*/
authDeviceCode(): Promise<ApiAuthDeviceCodeResponse>;
/**
* 轮询二维码状态
* 此为长轮询接口。注意:当二维码状态没有更新时,此接口不会立即响应,直到接口超时或者二维码状态有更新。
* @param uid 二维码ID/设备码,从 authDeviceCode 方法 data.uid 获取
* @param time 校验参数,从 authDeviceCode 方法 data.time 获取
* @param sign 校验签名,从 authDeviceCode 方法 data.sign 获取
*/
loginScanQrCodeStatus(uid: string, time: number, sign: string): Promise<ApiQrCodeStatusResponse>;
/**
* 用设备码换取 access_token
* @param uid 二维码ID/设备码
*/
authDeviceCodeToToken(uid: string): Promise<ApiAccessTokenResponse>;
/**
* 刷新 access_token
* 请勿频繁刷新,否则列入频控。
* @param refresh_token 二维码ID/设备码
*/
authRefreshToken(refresh_token: string): Promise<ApiAccessTokenResponse>;
/**
* 获取用户空间和vip信息
*/
userInfo(): Promise<ApiUserInfoResponse>;
/**
* 创建目录
* @param body
*/
folderAdd(body: ApiFolderAddRequestBody): Promise<ApiFolderAddResponse>;
/**
* 获取目录信息
* @param fileId
*/
folderGetInfo(fileId: string): Promise<ApiFolderGetInfoResponse>;
/**
* 获取文件列表
* @param params
*/
files(params: ApiUFileFilesRequestQuery): Promise<ApiUFileFilesResponse>;
/**
* 根据文件名搜索文件(夹)
* @param params
*/
fileSearch(params: ApiUFileSearchRequestQuery): Promise<ApiUFileSearchResponse>;
/**
* 批量复制文件
* @param body
*/
fileCopy(body: ApiUFileCopyRequestBody): Promise<BaseResponse<any[]>>;
/**
* 批量移动文件
* @param body
*/
fileMove(body: ApiUFileMoveRequestBody): Promise<BaseResponse<any[]>>;
/**
* 根据文件提取码取文件下载地址
* @param pick_code 文件提取码
*/
fileDownUrl(pick_code: string): Promise<ApiUFileDownUrlResponse>;
/**
* 批量更新文件名、星标文件
* @param body
*/
fileUpdate(body: ApiUFileUpdateRequestBody): Promise<ApiUFileUpdateResponse>;
/**
* 删除文件
* @param body
*/
fileDelete(body: ApiUFileDeleteRequestBody): Promise<ApiUFileDeleteResponse>;
/**
* 回收站列表
* @param offset 数据显示偏移量
* @param limit 单页记录数,int,默认30,最大200
*/
rbList(offset?: number, limit?: number): Promise<ApiRbListResponse>;
/**
* 还原回收站文件(夹)
* @param tld 需要还原的ID,可多个
*/
rbRevert(tld: string | string[]): Promise<ApiRbReverseResponse>;
/**
* 还原回收站文件(夹)
* @param tld 需要还原的ID,可多个
*/
rbDel(tld: string | string[]): Promise<BaseResponse<string[]>>;
/**
* 获取开放平台产品列表扫描跳转链接地址
* @param openDevice 设备号
* @param defaultProductId 默认产品ID
*/
vipQrUrl(openDevice: string, defaultProductId?: string): Promise<BaseResponse<{
qrcode_url: string;
}>>;
}
export default Open115SDK;