1 | import * as Config from '@oclif/config';
|
2 | import { CLIError } from '@oclif/errors';
|
3 | import { HTTP, HTTPError, HTTPRequestOptions } from 'http-call';
|
4 | import { Login } from './login';
|
5 | import { Mutex } from './mutex';
|
6 | export declare namespace APIClient {
|
7 | interface Options extends HTTPRequestOptions {
|
8 | retryAuth?: boolean;
|
9 | }
|
10 | }
|
11 | export interface IOptions {
|
12 | required?: boolean;
|
13 | preauth?: boolean;
|
14 | }
|
15 | export interface IHerokuAPIErrorOptions {
|
16 | resource?: string;
|
17 | app?: {
|
18 | id: string;
|
19 | name: string;
|
20 | };
|
21 | id?: string;
|
22 | message?: string;
|
23 | url?: string;
|
24 | }
|
25 | export declare class HerokuAPIError extends CLIError {
|
26 | http: HTTPError;
|
27 | body: IHerokuAPIErrorOptions;
|
28 | constructor(httpError: HTTPError);
|
29 | }
|
30 | export declare class APIClient {
|
31 | protected config: Config.IConfig;
|
32 | options: IOptions;
|
33 | preauthPromises: {
|
34 | [k: string]: Promise<HTTP<any>>;
|
35 | };
|
36 | authPromise?: Promise<HTTP<any>>;
|
37 | http: typeof HTTP;
|
38 | private readonly _login;
|
39 | private _twoFactorMutex;
|
40 | private _auth?;
|
41 | constructor(config: Config.IConfig, options?: IOptions);
|
42 | get twoFactorMutex(): Mutex<string>;
|
43 | get auth(): string | undefined;
|
44 | set auth(token: string | undefined);
|
45 | twoFactorPrompt(): Promise<string>;
|
46 | preauth(app: string, factor: string): Promise<HTTP<unknown>>;
|
47 | get<T>(url: string, options?: APIClient.Options): Promise<HTTP<T>>;
|
48 | post<T>(url: string, options?: APIClient.Options): Promise<HTTP<T>>;
|
49 | put<T>(url: string, options?: APIClient.Options): Promise<HTTP<T>>;
|
50 | patch<T>(url: string, options?: APIClient.Options): Promise<HTTP<T>>;
|
51 | delete<T>(url: string, options?: APIClient.Options): Promise<HTTP<T>>;
|
52 | stream(url: string, options?: APIClient.Options): Promise<HTTP<unknown>>;
|
53 | request<T>(url: string, options?: APIClient.Options): Promise<HTTP<T>>;
|
54 | login(opts?: Login.Options): Promise<void>;
|
55 | logout(): Promise<void>;
|
56 | get defaults(): typeof HTTP.defaults;
|
57 | }
|