|
| 1 | +import { Http, Headers as AngularHeaders } from 'angular2/http'; |
| 2 | +export interface IRequest { |
| 3 | + url: string; |
| 4 | + headers: AngularHeaders; |
| 5 | + body?: Object; |
| 6 | +} |
| 7 | +export interface IResponse { |
| 8 | +} |
| 9 | +/** |
| 10 | +* Angular 2 RESTClient class. |
| 11 | +* |
| 12 | +* @class RESTClient |
| 13 | +* @constructor |
| 14 | +*/ |
| 15 | +export declare class RESTClient { |
| 16 | + protected http: Http; |
| 17 | + constructor(http: Http); |
| 18 | + protected getBaseUrl(): string; |
| 19 | + protected getDefaultHeaders(): Object; |
| 20 | + /** |
| 21 | + * Request Interceptor |
| 22 | + * |
| 23 | + * @method requestInterceptor |
| 24 | + * @param {IRequest} req - request object |
| 25 | + */ |
| 26 | + protected requestInterceptor(req: IRequest): void; |
| 27 | + /** |
| 28 | + * Response Interceptor |
| 29 | + * NOT IMPLEMENTED YET! |
| 30 | + * |
| 31 | + * @method responseInterceptor |
| 32 | + * @param {IResponse} resp - response object |
| 33 | + */ |
| 34 | + protected responseInterceptor(resp: IResponse): void; |
| 35 | +} |
| 36 | +/** |
| 37 | + * Set the base URL of REST resource |
| 38 | + * @param {String} url - base URL |
| 39 | + */ |
| 40 | +export declare function BaseUrl(url: string): <TFunction extends Function>(Target: TFunction) => TFunction; |
| 41 | +/** |
| 42 | + * Set default headers for every method of the RESTClient |
| 43 | + * @param {Object} headers - deafult headers in a key-value pair |
| 44 | + */ |
| 45 | +export declare function DefaultHeaders(headers: any): <TFunction extends Function>(Target: TFunction) => TFunction; |
| 46 | +/** |
| 47 | + * Path variable of a method's url, type: string |
| 48 | + * @param {string} key - path key to bind value |
| 49 | + */ |
| 50 | +export declare var Path: (key: string) => (target: RESTClient, propertyKey: string | symbol, parameterIndex: number) => void; |
| 51 | +/** |
| 52 | + * Query value of a method's url, type: string |
| 53 | + * @param {string} key - query key to bind value |
| 54 | + */ |
| 55 | +export declare var Query: (key: string) => (target: RESTClient, propertyKey: string | symbol, parameterIndex: number) => void; |
| 56 | +/** |
| 57 | + * Body of a REST method, type: key-value pair object |
| 58 | + * Only one body per method! |
| 59 | + */ |
| 60 | +export declare var Body: (target: RESTClient, propertyKey: string | symbol, parameterIndex: number) => void; |
| 61 | +/** |
| 62 | + * Custom header of a REST method, type: string |
| 63 | + * @param {string} key - header key to bind value |
| 64 | + */ |
| 65 | +export declare var Header: (key: string) => (target: RESTClient, propertyKey: string | symbol, parameterIndex: number) => void; |
| 66 | +/** |
| 67 | + * Set custom headers for a REST method |
| 68 | + * @param {Object} headersDef - custom headers in a key-value pair |
| 69 | + */ |
| 70 | +export declare function Headers(headersDef: any): (target: RESTClient, propertyKey: string, descriptor: any) => any; |
| 71 | +/** |
| 72 | + * GET method |
| 73 | + * @param {string} url - resource url of the method |
| 74 | + */ |
| 75 | +export declare var GET: (url: string) => (target: RESTClient, propertyKey: string, descriptor: any) => any; |
| 76 | +/** |
| 77 | + * POST method |
| 78 | + * @param {string} url - resource url of the method |
| 79 | + */ |
| 80 | +export declare var POST: (url: string) => (target: RESTClient, propertyKey: string, descriptor: any) => any; |
| 81 | +/** |
| 82 | + * PUT method |
| 83 | + * @param {string} url - resource url of the method |
| 84 | + */ |
| 85 | +export declare var PUT: (url: string) => (target: RESTClient, propertyKey: string, descriptor: any) => any; |
| 86 | +/** |
| 87 | + * DELETE method |
| 88 | + * @param {string} url - resource url of the method |
| 89 | + */ |
| 90 | +export declare var DELETE: (url: string) => (target: RESTClient, propertyKey: string, descriptor: any) => any; |
0 commit comments