bot18
Version:
A high-frequency cryptocurrency trading bot by Zenbot creator @carlos8f
166 lines (135 loc) • 6.63 kB
TypeScript
// Type definitions for got 7.1
// Project: https://github.com/sindresorhus/got#readme
// Definitions by: BendingBender <https://github.com/BendingBender>
// Linus Unnebäck <https://github.com/LinusU>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="node"/>
import { Url } from 'url';
import * as http from 'http';
import * as nodeStream from 'stream';
export = got;
declare class RequestError extends StdError {
name: 'RequestError';
}
declare class ReadError extends StdError {
name: 'ReadError';
}
declare class ParseError extends StdError {
name: 'ParseError';
statusCode: number;
statusMessage: string;
}
declare class HTTPError extends StdError {
name: 'HTTPError';
statusCode: number;
statusMessage: string;
headers: http.IncomingHttpHeaders;
}
declare class MaxRedirectsError extends StdError {
name: 'MaxRedirectsError';
statusCode: number;
statusMessage: string;
redirectUrls: string[];
}
declare class UnsupportedProtocolError extends StdError {
name: 'UnsupportedProtocolError';
}
declare class StdError extends Error {
code?: string;
host?: string;
hostname?: string;
method?: string;
path?: string;
protocol?: string;
url?: string;
response?: any;
}
declare const got: got.GotFn &
Record<'get' | 'post' | 'put' | 'patch' | 'head' | 'delete', got.GotFn> &
{
stream: got.GotStreamFn & Record<'get' | 'post' | 'put' | 'patch' | 'head' | 'delete', got.GotStreamFn>
RequestError: typeof RequestError
ReadError: typeof ReadError
ParseError: typeof ParseError
HTTPError: typeof HTTPError
MaxRedirectsError: typeof MaxRedirectsError
UnsupportedProtocolError: typeof UnsupportedProtocolError
};
declare namespace got {
interface GotFn {
(url: GotUrl): GotPromise<string>;
(url: GotUrl, options: GotJSONOptions): GotPromise<any>;
(url: GotUrl, options: GotFormOptions<string>): GotPromise<string>;
(url: GotUrl, options: GotFormOptions<null>): GotPromise<Buffer>;
(url: GotUrl, options: GotBodyOptions<string>): GotPromise<string>;
(url: GotUrl, options: GotBodyOptions<null>): GotPromise<Buffer>;
}
type GotStreamFn = (url: GotUrl, options?: GotOptions<string | null>) => GotEmitter & nodeStream.Duplex;
type GotUrl = string | http.RequestOptions | Url;
interface GotBodyOptions<E extends string | null> extends GotOptions<E> {
body?: string | Buffer | nodeStream.Readable;
}
interface GotJSONOptions extends GotOptions<string | null> {
body?: object;
form?: boolean;
json: true;
}
interface GotFormOptions<E extends string | null> extends GotOptions<E> {
body?: {[key: string]: any};
form: true;
json?: boolean;
}
interface TimoutRequestOptions extends http.RequestOptions {
timeout?: any;
}
interface GotOptions<E extends string | null> extends TimoutRequestOptions {
encoding?: E;
query?: string | object;
timeout?: number | TimeoutOptions;
retries?: number | RetryFunction;
followRedirect?: boolean;
decompress?: boolean;
useElectronNet?: boolean;
}
interface TimeoutOptions {
connect?: number;
socket?: number;
request?: number;
}
type RetryFunction = (retry: number, error: any) => number;
interface Response<B extends Buffer | string | object> extends http.IncomingMessage {
body: B;
url: string;
requestUrl: string;
redirectUrls?: string[];
}
type GotPromise<B extends Buffer | string | object> = Promise<Response<B>> & { cancel(): void };
interface GotEmitter {
addListener(event: 'request', listener: (req: http.ClientRequest) => void): this;
addListener(event: 'response', listener: (res: http.IncomingMessage) => void): this;
addListener(event: 'redirect', listener: (res: http.IncomingMessage, nextOptions: GotOptions<string | null> & Url) => void): this;
addListener(event: 'error', listener: (error: GotError, body?: any, res?: http.IncomingMessage) => void): this;
on(event: 'request', listener: (req: http.ClientRequest) => void): this;
on(event: 'response', listener: (res: http.IncomingMessage) => void): this;
on(event: 'redirect', listener: (res: http.IncomingMessage, nextOptions: GotOptions<string | null> & Url) => void): this;
on(event: 'error', listener: (error: GotError, body?: any, res?: http.IncomingMessage) => void): this;
once(event: 'request', listener: (req: http.ClientRequest) => void): this;
once(event: 'response', listener: (res: http.IncomingMessage) => void): this;
once(event: 'redirect', listener: (res: http.IncomingMessage, nextOptions: GotOptions<string | null> & Url) => void): this;
once(event: 'error', listener: (error: GotError, body?: any, res?: http.IncomingMessage) => void): this;
prependListener(event: 'request', listener: (req: http.ClientRequest) => void): this;
prependListener(event: 'response', listener: (res: http.IncomingMessage) => void): this;
prependListener(event: 'redirect', listener: (res: http.IncomingMessage, nextOptions: GotOptions<string | null> & Url) => void): this;
prependListener(event: 'error', listener: (error: GotError, body?: any, res?: http.IncomingMessage) => void): this;
prependOnceListener(event: 'request', listener: (req: http.ClientRequest) => void): this;
prependOnceListener(event: 'response', listener: (res: http.IncomingMessage) => void): this;
prependOnceListener(event: 'redirect', listener: (res: http.IncomingMessage, nextOptions: GotOptions<string | null> & Url) => void): this;
prependOnceListener(event: 'error', listener: (error: GotError, body?: any, res?: http.IncomingMessage) => void): this;
removeListener(event: 'request', listener: (req: http.ClientRequest) => void): this;
removeListener(event: 'response', listener: (res: http.IncomingMessage) => void): this;
removeListener(event: 'redirect', listener: (res: http.IncomingMessage, nextOptions: GotOptions<string | null> & Url) => void): this;
removeListener(event: 'error', listener: (error: GotError, body?: any, res?: http.IncomingMessage) => void): this;
}
type GotError = RequestError | ReadError | ParseError | HTTPError | MaxRedirectsError | UnsupportedProtocolError;
}