emailengine-client
Version:
A TypeScript client for the EmailEngine API
38 lines • 1.44 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.setupAxiosRequestConfig = void 0;
const ParameterTypeDecorator_1 = require("../decorators/ParameterTypeDecorator");
function setupAxiosRequestConfig(options) {
let axiosReqConfig = {};
let tempParams = Object.assign({}, options);
for (let key in tempParams) {
switch ((0, ParameterTypeDecorator_1.getParameterType)(options, key)) {
case 'header':
if (!axiosReqConfig.headers)
axiosReqConfig.headers = {};
axiosReqConfig.headers[key] = options[key];
delete tempParams[key];
break;
case 'query':
if (!axiosReqConfig.params)
axiosReqConfig.params = {};
axiosReqConfig.params[key] = options[key];
delete tempParams[key];
break;
case 'path':
// Remove from tempParams and skip
delete tempParams[key];
break;
case 'body':
// Remove from tempParams and skip
//axiosReqConfig.data = options[key];
delete tempParams[key];
break;
default:
break;
}
}
return axiosReqConfig;
}
exports.setupAxiosRequestConfig = setupAxiosRequestConfig;
//# sourceMappingURL=helpers.js.map