1 | /**
|
2 | * @author Juan David Correa
|
3 | */
|
4 | import { Observable } from 'rxjs/internal/Observable';
|
5 | import 'reflect-metadata';
|
6 | /**
|
7 | *
|
8 | */
|
9 | export interface HttpInterceptor {
|
10 | intercep: (req: Request_) => Request_;
|
11 | }
|
12 | /**
|
13 | *
|
14 | */
|
15 | export declare type Handler = (...request: any[]) => HttpRequestException;
|
16 | /**
|
17 | *
|
18 | */
|
19 | export declare class Http {
|
20 | private static interceptors;
|
21 | /**
|
22 | *
|
23 | * @param {T} interceptor
|
24 | */
|
25 | static addInterceptor<T extends {
|
26 | new (): HttpInterceptor;
|
27 | }>(interceptor: T): void;
|
28 | /**
|
29 | *
|
30 | * @param {string | Partial<ConfigHttp>} config
|
31 | * @returns {(target) => void}
|
32 | */
|
33 | static client(config: string | Partial<ConfigHttp>): (target: any) => void;
|
34 | /**
|
35 | *
|
36 | * @param {string} url
|
37 | * @param {Function} component
|
38 | * @param {number} statusCodeOk
|
39 | * @returns {Function}
|
40 | */
|
41 | static get(url: string, component: Function, statusCodeOk?: number): Function;
|
42 | /**
|
43 | *
|
44 | * @param {string} url
|
45 | * @param {Function} component
|
46 | * @param {number} statusCodeOk
|
47 | * @returns {Function}
|
48 | */
|
49 | static post(url: string, component: Function, statusCodeOk?: number): Function;
|
50 | /**
|
51 | *
|
52 | * @param {string} url
|
53 | * @param {Function} component
|
54 | * @param {number} statusCodeOk
|
55 | * @returns {Function}
|
56 | */
|
57 | static put(url: string, component: Function, statusCodeOk?: number): Function;
|
58 | /**
|
59 | *
|
60 | * @param {string} url
|
61 | * @param {Function} component
|
62 | * @param {number} statusCodeOk
|
63 | * @returns {Function}
|
64 | */
|
65 | static patch(url: string, component: Function, statusCodeOk?: number): Function;
|
66 | /**
|
67 | *
|
68 | * @param {string} url
|
69 | * @param {Function} component
|
70 | * @param {number} statusCodeOk
|
71 | * @returns {Function}
|
72 | */
|
73 | static delete(url: string, component: Function, statusCodeOk?: number): Function;
|
74 | /**
|
75 | * @param {string} method
|
76 | * @param {string} url
|
77 | * @param {Function} component
|
78 | * @param {number} statusCodeOk
|
79 | * @returns {(target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>) => void}
|
80 | */
|
81 | private static request;
|
82 | /**
|
83 | *
|
84 | * @param value
|
85 | * @param {Handler} exceptionHandler
|
86 | * @param statusCodeOk
|
87 | * @returns {any}
|
88 | */
|
89 | private static mapBodyAndControlError;
|
90 | /**
|
91 | *
|
92 | * @param {string} param
|
93 | * @returns {Function}
|
94 | */
|
95 | static pathParam(param?: string): Function;
|
96 | /**
|
97 | *
|
98 | * @param {string} param_
|
99 | * @returns {Function}
|
100 | */
|
101 | static query(param_?: string): Function;
|
102 | /**
|
103 | *
|
104 | * @param {Object} target
|
105 | * @param {string | symbol} propertyKey
|
106 | * @param {number} parameterIndex
|
107 | */
|
108 | static body(target: Object, propertyKey: string | symbol, parameterIndex: number): void;
|
109 | /**
|
110 | *
|
111 | * @param {boolean} enable
|
112 | * @returns {Function}
|
113 | */
|
114 | static pathParamProperty(enable?: boolean): Function;
|
115 | /**
|
116 | *
|
117 | * @param {Function} mapper
|
118 | * @returns {Function}
|
119 | */
|
120 | static mapper(mapper: Function): Function;
|
121 | /**
|
122 | *
|
123 | * @param {{[p: string]: T}} headers
|
124 | * @returns {Function}
|
125 | */
|
126 | static headers<T extends any>(headers: {
|
127 | [key: string]: T;
|
128 | }): Function;
|
129 | /**
|
130 | *
|
131 | * @param {(request: Request_) => Request_} before_
|
132 | * @returns {(target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>) => void}
|
133 | */
|
134 | static before(before_: (request: Request_) => Request_): (target: Object, propertyKey: string) => void;
|
135 | /**
|
136 | *
|
137 | * @param {Handler} handler
|
138 | * @returns {(target: Object, propertyKey: string, descriptor: TypedPropertyDescriptor<any>) => void}
|
139 | */
|
140 | static handlerError(handler: Handler): (target: Object, propertyKey: string) => void;
|
141 | }
|
142 | /**
|
143 | *
|
144 | */
|
145 | export declare class HttpRequestException {
|
146 | error: string;
|
147 | statusCode: number;
|
148 | message: string;
|
149 | constructor(error: string, statusCode: number, message: string);
|
150 | }
|
151 | /**
|
152 | *
|
153 | */
|
154 | declare class Headers {
|
155 | /**
|
156 | *
|
157 | * @type {Map<any, any>}
|
158 | */
|
159 | private headers;
|
160 | constructor();
|
161 | /**
|
162 | *
|
163 | * @param {string} key
|
164 | * boolean}
{ |
165 | */
|
166 | has(key: string): boolean;
|
167 | /**
|
168 | *
|
169 | * @param {string} key
|
170 | * @param header
|
171 | * @returns {this}
|
172 | */
|
173 | set(key: string, header: any): this;
|
174 | /**
|
175 | *
|
176 | * @returns {any}
|
177 | */
|
178 | getHeaders(): any;
|
179 | }
|
180 | /**
|
181 | *
|
182 | */
|
183 | export declare type HttpObservable<t> = Observable<t> & void;
|
184 | /**
|
185 | *
|
186 | */
|
187 | interface ConfigHttp {
|
188 | url: string;
|
189 | headers: {
|
190 | [key: string]: any;
|
191 | };
|
192 | }
|
193 | /**
|
194 | *
|
195 | */
|
196 | export interface Request_ {
|
197 | readonly method: string;
|
198 | body: any;
|
199 | readonly headers: Headers;
|
200 | readonly url: string;
|
201 | }
|
202 | export {};
|