interface_sdk-js/api/@system.request.d.ts
2021-06-02 02:21:32 +08:00

67 lines
1.8 KiB
TypeScript
Executable File

/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export interface UploadResponse {
code: number;
data: string;
headers: Object;
}
export interface DownloadResponse {
token: string;
}
export interface OnDownloadCompleteResponse {
uri: string;
}
export interface RequestFile {
filename?: string;
name?: string;
uri: string;
type?: string;
}
export interface RequestData {
name: string;
value: string;
}
export interface UploadRequestOptions {
url: string;
data?: Array<RequestData>;
files: Array<RequestFile>;
header?: Object;
method?: string;
success?: (data: UploadResponse) => void;
fail?: (data: any, code: number) => void;
complete?: () => void;
}
export interface DownloadRequestOptions {
url: string;
filename?: string;
header?: string;
description?: string;
success?: (data: DownloadResponse) => void;
fail?: (data: any, code: number) => void;
complete?: () => void;
}
export interface OnDownloadCompleteOptions {
token: string;
success?: (data: OnDownloadCompleteResponse) => void;
fail?: (data: any, code: number) => void;
complete?: () => void;
}
export default class Request {
static upload(options: UploadRequestOptions): void;
static download(options: DownloadRequestOptions): void;
static onDownloadComplete(options: OnDownloadCompleteOptions): void;
}