@egodigital/egoose
Version:
Helper classes and functions for Node.js 10 or later.
50 lines • 2.06 kB
JavaScript
;
/**
* This file is part of the @egodigital/egoose distribution.
* Copyright (c) e.GO Digital GmbH, Aachen, Germany (https://www.e-go-digital.com/)
*
* @egodigital/egoose is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, version 3.
*
* @egodigital/egoose is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
Object.defineProperty(exports, "__esModule", { value: true });
const _ = require("lodash");
const http_1 = require("../http");
const index_1 = require("../index");
/**
* Sends an app feedback to a service.
*
* @param {SendAppFeedbackOptions} opts The options for sending the feedback.
*
* @return {Promise<HttpResponse>} The promise with the HTTP response.
*/
function sendAppFeedback(opts) {
const BODY = {
"a": index_1.toStringSafe(opts.app).trim(),
"ct": index_1.normalizeString(opts.contentType),
"e": index_1.normalizeString(opts.email),
"m": index_1.toStringSafe(opts.message),
"r": index_1.normalizeString(opts.recipientMail),
"u": index_1.toStringSafe(opts.username).trim(),
"us": _.isNil(opts.useSlack) ?
'' : (opts.useSlack ? '1' : '0'),
};
return http_1.POST(index_1.toStringSafe(process.env.FEEDBACK_SERVICE_URL).trim(), {
headers: {
'Content-Type': 'application/json; charset=utf-8',
'x-ego': index_1.toStringSafe(process.env.FEEDBACK_SERVICE_KEY).trim(),
},
body: Buffer.from(JSON.stringify(BODY), 'utf8'),
doNotNormalizeHeaders: false,
});
}
exports.sendAppFeedback = sendAppFeedback;
//# sourceMappingURL=feedback.js.map