| 
									
										
										
										
											2015-06-12 21:50:19 -07:00
										 |  |  | import {CONST_EXPR, CONST, isPresent} from 'angular2/src/facade/lang'; | 
					
						
							| 
									
										
										
										
											2015-04-28 23:07:55 -07:00
										 |  |  | import {Headers} from './headers'; | 
					
						
							|  |  |  | import {URLSearchParams} from './url_search_params'; | 
					
						
							|  |  |  | import {RequestModesOpts, RequestMethods, RequestCacheOpts, RequestCredentialsOpts} from './enums'; | 
					
						
							|  |  |  | import {RequestOptions} from './interfaces'; | 
					
						
							|  |  |  | import {Injectable} from 'angular2/di'; | 
					
						
							| 
									
										
										
										
											2015-06-12 21:50:19 -07:00
										 |  |  | import {ListWrapper, StringMapWrapper} from 'angular2/src/facade/collection'; | 
					
						
							| 
									
										
										
										
											2015-04-28 23:07:55 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-12 21:50:19 -07:00
										 |  |  | export class RequestOptionsClass { | 
					
						
							|  |  |  |   method: RequestMethods = RequestMethods.GET; | 
					
						
							| 
									
										
										
										
											2015-04-28 23:07:55 -07:00
										 |  |  |   headers: Headers; | 
					
						
							|  |  |  |   body: URLSearchParams | FormData | string; | 
					
						
							| 
									
										
										
										
											2015-06-12 21:50:19 -07:00
										 |  |  |   mode: RequestModesOpts = RequestModesOpts.Cors; | 
					
						
							| 
									
										
										
										
											2015-04-28 23:07:55 -07:00
										 |  |  |   credentials: RequestCredentialsOpts; | 
					
						
							|  |  |  |   cache: RequestCacheOpts; | 
					
						
							| 
									
										
										
										
											2015-06-12 21:50:19 -07:00
										 |  |  |   constructor({method, headers, body, mode, credentials, | 
					
						
							|  |  |  |                cache}: RequestOptions = {method: RequestMethods.GET, mode: RequestModesOpts.Cors}) { | 
					
						
							|  |  |  |     this.method = method; | 
					
						
							|  |  |  |     this.headers = headers; | 
					
						
							|  |  |  |     this.body = body; | 
					
						
							|  |  |  |     this.mode = mode; | 
					
						
							|  |  |  |     this.credentials = credentials; | 
					
						
							|  |  |  |     this.cache = cache; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-04-28 23:07:55 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-12 21:50:19 -07:00
										 |  |  |   merge(opts: RequestOptions = {}): RequestOptionsClass { | 
					
						
							|  |  |  |     return new RequestOptionsClass(StringMapWrapper.merge(this, opts)); | 
					
						
							| 
									
										
										
										
											2015-04-28 23:07:55 -07:00
										 |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2015-06-12 21:50:19 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | @Injectable() | 
					
						
							|  |  |  | export class BaseRequestOptions extends RequestOptionsClass { | 
					
						
							|  |  |  |   constructor() { super(); } | 
					
						
							|  |  |  | } |