1 /* Copyright (c) 2019 AT&T Intellectual Property. #
\r
3 # Licensed under the Apache License, Version 2.0 (the "License"); #
\r
4 # you may not use this file except in compliance with the License. #
\r
5 # You may obtain a copy of the License at #
\r
7 # http://www.apache.org/licenses/LICENSE-2.0 #
\r
9 # Unless required by applicable law or agreed to in writing, software #
\r
10 # distributed under the License is distributed on an "AS IS" BASIS, #
\r
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
\r
12 # See the License for the specific language governing permissions and #
\r
13 # limitations under the License. #
\r
14 ##############################################################################*/
\r
17 const axios = require('axios');
\r
18 const { parseString, Builder } = require('xml2js');
\r
19 const pickleRick = require('pickle-rick');
\r
20 const Response = require('http-response-object');
\r
21 const request = require('request');
\r
22 const util = require('../../../lib/otf-util');
\r
24 /* eslint-disable no-unused-vars */
\r
26 constructor (options) {
\r
27 this.options = options || {};
\r
30 async find (params) {
\r
34 // Check process definition key to see if unique
\r
35 async get (id, params) {
\r
36 // return await axios.get(this.options.app.get('camundaApi').url + 'otf/tcu/process-instance-completion-check/v1/' + id,
\r
39 // Authorization: 'Basic ' +
\r
40 // util.base64Encode(
\r
41 // this.options.app.get('serviceApi').aafId + ':' +
\r
42 // this.options.app.get('serviceApi').aafPassword)
\r
45 // .then(result => {
\r
46 // return new Response(200, {}, result.data);
\r
49 // console.log(err);
\r
53 url: this.options.app.get('camundaApi').url + 'otf/tcu/process-instance-completion-check/v1/' + id,
\r
55 'Authorization': 'Basic ' + util.base64Encode(this.options.app.get('serviceApi').aafId + ':' + this.options.app.get('serviceApi').aafPassword),
\r
56 'Content-Type': "application/json"
\r
58 rejectUnauthorized: false
\r
61 return await new Promise((resolve, reject) => {
\r
62 request.get(options, (err, res, body) => {
\r
66 if(res && res.body){
\r
67 res.body = JSON.parse(res.body);
\r
82 async create (data, params) {
\r
83 if (Array.isArray(data)) {
\r
84 return Promise.all(data.map(current => this.create(current, params)));
\r
88 async update (id, data, params) {
\r
92 async patch (id, data, params) {
\r
96 async remove (id, params) {
\r
100 async parseAndUpload (data, params, method) {
\r
105 module.exports = function (options) {
\r
106 return new Service(options);
\r
109 module.exports.Service = Service;
\r