--- /dev/null
+/* Copyright (c) 2019 AT&T Intellectual Property. #\r
+# #\r
+# Licensed under the Apache License, Version 2.0 (the "License"); #\r
+# you may not use this file except in compliance with the License. #\r
+# You may obtain a copy of the License at #\r
+# #\r
+# http://www.apache.org/licenses/LICENSE-2.0 #\r
+# #\r
+# Unless required by applicable law or agreed to in writing, software #\r
+# distributed under the License is distributed on an "AS IS" BASIS, #\r
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #\r
+# See the License for the specific language governing permissions and #\r
+# limitations under the License. #\r
+##############################################################################*/\r
+\r
+\r
+const config = require('../config/default.json');\r
+const btoa = require('btoa');\r
+\r
+module.exports.parser = function (response) {\r
+ var jsonObject = {\r
+ data: [],\r
+ status: ''\r
+ };\r
+\r
+ if (response.result) {\r
+ // loop through musics rusults and make it into an array\r
+ for (var key in response.result) {\r
+ if (response.result.hasOwnProperty(key)) {\r
+ jsonObject.data.push(response.result[key]);\r
+ }\r
+ }\r
+ }\r
+\r
+ // set store status in new reponse\r
+ jsonObject.status = response.status;\r
+\r
+ return jsonObject;\r
+};\r
+\r
+module.exports.stringifyParams = function (params) {\r
+ var string = '';\r
+ var count = 0;\r
+\r
+ for (var key in params.query) {\r
+ if (params.query.hasOwnProperty(key) && key[0] != '$') {\r
+ if (count > 0) {\r
+ string += '&&';\r
+ }\r
+ string += key + '=' + params.query[key];\r
+ count++;\r
+ }\r
+ }\r
+\r
+ return string;\r
+};\r
+\r
+module.exports.musicHeaders = {\r
+ 'Content-Type': 'application/json',\r
+ 'ns': config.music.ns,\r
+ 'X-minorVersion': config.music['X-minorVersion'],\r
+ 'X-patchVersion': config.music['X-patchVersion'],\r
+ 'Authorization': 'Basic ' + btoa(config.music.username + ':' + config.music.password)\r
+};\r
+\r
+module.exports.musicUrl = config.music.url;\r