1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | declare module 'request-promise' {
|
7 | import request = require('request');
|
8 | import http = require('http');
|
9 | import errors = require('request-promise/errors');
|
10 | import promise = require('bluebird');
|
11 |
|
12 | namespace requestPromise {
|
13 | interface RequestPromise extends request.Request {
|
14 | then<TResult>(onfulfilled?: (value: any) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => TResult | PromiseLike<TResult>): Promise<TResult>;
|
15 | then<TResult>(onfulfilled?: (value: any) => TResult | PromiseLike<TResult>, onrejected?: (reason: any) => void): Promise<TResult>;
|
16 | catch(onrejected?: (reason: any) => any | PromiseLike<any>): Promise<any>;
|
17 | catch(onrejected?: (reason: any) => void): Promise<any>;
|
18 | catch(type: errors.RequestErrorConstructor, onrejected?: (reason: errors.RequestError) => void): Promise<any>;
|
19 | catch(type: errors.StatusCodeErrorConstructor, onrejected?: (reason: errors.StatusCodeError) => void): Promise<any>;
|
20 | catch(type: errors.TransformErrorConstructor, onrejected?: (reason: errors.TransformError) => void): Promise<any>;
|
21 | finally<TResult>(handler: () => PromiseLike<TResult>): Promise<any>;
|
22 | finally<TResult>(handler: () => TResult): Promise<any>;
|
23 | promise(): Promise<any>;
|
24 | }
|
25 |
|
26 | interface RequestPromiseOptions extends request.CoreOptions {
|
27 | simple?: boolean;
|
28 | transform?: (body: any, response: http.IncomingMessage, resolveWithFullResponse?: boolean) => any;
|
29 | resolveWithFullResponse?: boolean;
|
30 | }
|
31 |
|
32 | export type OptionsWithUri = request.UriOptions & RequestPromiseOptions;
|
33 | export type OptionsWithUrl = request.UrlOptions & RequestPromiseOptions;
|
34 | export type Options = OptionsWithUri | OptionsWithUrl;
|
35 | }
|
36 |
|
37 | var requestPromise: request.RequestAPI<requestPromise.RequestPromise, requestPromise.RequestPromiseOptions, request.RequiredUriUrl>;
|
38 | export = requestPromise;
|
39 | }
|
40 | declare module 'request-promise/errors' {
|
41 | import rp = require('request-promise');
|
42 | import http = require('http');
|
43 |
|
44 | export interface RequestError extends Error {
|
45 | cause: any;
|
46 | error: any;
|
47 | options: rp.Options;
|
48 | response: http.IncomingMessage;
|
49 | }
|
50 | export interface RequestErrorConstructor {
|
51 | new (cause: any, options: rp.Options, response: http.IncomingMessage): RequestError;
|
52 | (cause: any, options: rp.Options, response: http.IncomingMessage): RequestError;
|
53 | prototype: RequestError;
|
54 | }
|
55 | export const RequestError: RequestErrorConstructor;
|
56 |
|
57 | export interface StatusCodeError extends Error {
|
58 | statusCode: number;
|
59 | error: any;
|
60 | options: rp.Options;
|
61 | response: http.IncomingMessage;
|
62 | }
|
63 | export interface StatusCodeErrorConstructor extends Error {
|
64 | new (statusCode: number, body: any, options: rp.Options, response: http.IncomingMessage): StatusCodeError;
|
65 | (statusCode: number, body: any, options: rp.Options, response: http.IncomingMessage): StatusCodeError;
|
66 | prototype: StatusCodeError;
|
67 | }
|
68 | export const StatusCodeError: StatusCodeErrorConstructor;
|
69 |
|
70 | export interface TransformError extends Error {
|
71 | cause: any;
|
72 | error: any;
|
73 | options: rp.Options;
|
74 | response: http.IncomingMessage;
|
75 | }
|
76 | export interface TransformErrorConstructor extends Error {
|
77 | new (cause: any, options: rp.Options, response: http.IncomingMessage): TransformError;
|
78 | (cause: any, options: rp.Options, response: http.IncomingMessage): TransformError;
|
79 | prototype: TransformError;
|
80 | }
|
81 | export const TransformError: TransformErrorConstructor;
|
82 | }
|