UNPKG

2.11 kBTypeScriptView Raw
1/// <reference types="node" />
2import { JSONObject, JSONValue } from '@expo/json-file';
3import FormData from 'form-data';
4import { ParsedUrlQueryInput } from 'querystring';
5export declare class ApiV2Error extends Error {
6 readonly name = "ApiV2Error";
7 code: string;
8 details?: JSONValue;
9 serverStack?: string;
10 metadata?: object;
11 readonly _isApiError = true;
12 constructor(message: string, code?: string);
13}
14declare type RequestOptions = {
15 httpMethod: 'get' | 'post' | 'put' | 'patch' | 'delete';
16 queryParameters?: QueryParameters;
17 body?: JSONObject;
18 timeout?: number;
19};
20declare type UploadOptions = {
21 headers: any;
22 data: any;
23};
24declare type QueryParameters = ParsedUrlQueryInput;
25declare type APIV2ClientOptions = {
26 sessionSecret?: string;
27 accessToken?: string;
28};
29export default class ApiV2Client {
30 static exponentClient: string;
31 sessionSecret: string | null;
32 accessToken: string | null;
33 static clientForUser(user?: APIV2ClientOptions | null): ApiV2Client;
34 static setClientName(name: string): void;
35 constructor(options?: APIV2ClientOptions);
36 getAsync(methodName: string, args?: QueryParameters, extraOptions?: Partial<RequestOptions>, returnEntireResponse?: boolean): Promise<any>;
37 postAsync(methodName: string, data?: JSONObject, extraOptions?: Partial<RequestOptions>, returnEntireResponse?: boolean): Promise<any>;
38 putAsync(methodName: string, data: JSONObject, extraOptions?: Partial<RequestOptions>, returnEntireResponse?: boolean): Promise<any>;
39 patchAsync(methodName: string, data: JSONObject, extraOptions?: Partial<RequestOptions>, returnEntireResponse?: boolean): Promise<any>;
40 deleteAsync(methodName: string, args?: QueryParameters, extraOptions?: Partial<RequestOptions>, returnEntireResponse?: boolean): Promise<any>;
41 uploadFormDataAsync(methodName: string, formData: FormData): Promise<any>;
42 _requestAsync(methodName: string, options: RequestOptions, extraRequestOptions?: Partial<RequestOptions>, returnEntireResponse?: boolean, uploadOptions?: UploadOptions): Promise<any>;
43}
44export {};