UNPKG

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