2 * Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 var services = angular.module('App.Services', [ 'App.Config' ]);
19 services.factory('restAPISvc', [
22 function($http, appContext) {
24 svc.getRestAPI = function(path, cb) {
27 url : appContext + path,
29 'Content-Type' : "application/json",
30 'Accept' : "application/json"
34 if (response.status == 200) {
37 /* eslint-disable no-console */
38 console.log("Get REST API error: "
39 + response.statusText);
40 /* eslint-enable no-console */
45 /* eslint-disable no-console */
46 console.log("Get REST API error: "
48 /* eslint-enable no-console */
52 svc.postRestAPI = function(path, json, cb) {
55 url : appContext + path,
57 'Content-Type' : "application/json",
58 'Accept' : "application/json"
63 if (response.status == 200
64 || response.status == 201) {
67 /* eslint-disable no-console */
68 console.log("Post REST API error: "
69 + response.statusText);
70 /* eslint-enable no-console */
75 /* eslint-disable no-console */
76 console.log("Post REST API error: "
78 /* eslint-enable no-console */
82 svc.deleteRestAPI = function(path, json) {
85 url : appContext + path,
87 'Content-Type' : "application/json",
88 'Accept' : "application/json"
93 if (response.status !== 200) {
94 /* eslint-disable no-console */
95 console.log("Delete REST API error: "
96 + response.statusText);
97 /* eslint-enable no-console */
101 /* eslint-disable no-console */
102 console.log("Delete REST API error: "
104 /* eslint-enable no-console */