blob: 35c504758f3f4602568dfc7c74965bf2fb8ebcbd [file] [log] [blame]
Skip Wonnell2c977e22018-03-01 08:30:15 -06001/*
2============LICENSE_START==========================================
3===================================================================
4Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
5===================================================================
6
7Unless otherwise specified, all software contained herein is licensed
8under the Apache License, Version 2.0 (the License);
9you may not use this software except in compliance with the License.
10You may obtain a copy of the License at
11
12 http://www.apache.org/licenses/LICENSE-2.0
13
14Unless required by applicable law or agreed to in writing, software
15distributed under the License is distributed on an "AS IS" BASIS,
16WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17See the License for the specific language governing permissions and
18limitations under the License.
19
20ECOMP is a trademark and service mark of AT&T Intellectual Property.
21============LICENSE_END============================================
22*/
23import { observable } from 'rxjs/symbol/observable';
24import 'rxjs/add/operator/map';
25import 'rxjs/add/operator/toPromise';
26import { Injectable } from '@angular/core';
27import { Http, Response, Headers, RequestOptions } from '@angular/http';
28
29@Injectable()
30export class HttpUtilService {
31 headers: Headers;
32 options: RequestOptions
33 constructor (private http: Http) {
34 this.headers = new Headers({ 'Content-Type': 'application/json' }); // ... Set content type to JSON
35 // this.options = new RequestOptions({headers: this.headers}); //
36 }
37
38 get(req) {
39
40 return this
41 .http
42 .get(req.url, this.options)
43 .map((res: Response) => res.json())
44 }
45
46 post(req) {
47
48 this.headers.append('Authorization', 'Basic ' + btoa('m97292@appc.att.com:enc:Ai8KDxN7EANwATsV'));
49 this.options = new RequestOptions({ headers: this.headers });
50
51 return this
52 .http
53 .post(req.url, req.data, this.options)
54 .map((res: Response) => res.json())
55 }
56
57}