Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

Commit

Permalink
use ApiKey for auth
Browse files Browse the repository at this point in the history
  • Loading branch information
mamadou committed Nov 9, 2021
1 parent 4e80096 commit 359f782
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
11 changes: 4 additions & 7 deletions lib/Adaptor.js
Expand Up @@ -180,7 +180,7 @@ function submitXls(formData, params) {
applicationName,
hostUrl,
username,
password
apiKey
} = state.configuration;
const json = (0, _languageCommon.expandReferences)(formData)(state);
const {
Expand All @@ -201,7 +201,7 @@ function submitXls(formData, params) {

const buffer = _xlsx.default.write(workbook, {
type: 'buffer',
bookType: 'xlsx'
bookType: 'xls'
}); // xlsx.writeFile(workbook, 'out.xls'); // If needing to write to filesystem


Expand All @@ -217,11 +217,8 @@ function submitXls(formData, params) {
return _languageCommon.http.post({
url,
data,
auth: {
username,
password
},
headers: { ...data.getHeaders()
headers: { ...data.getHeaders(),
Authorization: `ApiKey ${username}:${apiKey}`
}
})(state).then(response => {
return { ...state,
Expand Down
11 changes: 3 additions & 8 deletions src/Adaptor.js
Expand Up @@ -83,12 +83,7 @@ function clientPost({ url, body, username, password }) {
*/
export function submitXls(formData, params) {
return state => {
const {
applicationName,
hostUrl,
username,
password,
} = state.configuration;
const { applicationName, hostUrl, username, apiKey } = state.configuration;

const json = expandReferences(formData)(state);
const { case_type, search_field, create_new_cases } = params;
Expand All @@ -105,7 +100,7 @@ export function submitXls(formData, params) {
xlsx.utils.book_append_sheet(workbook, worksheet, ws_name);

// Generate buffer
const buffer = xlsx.write(workbook, { type: 'buffer', bookType: 'xlsx' });
const buffer = xlsx.write(workbook, { type: 'buffer', bookType: 'xls' });
// xlsx.writeFile(workbook, 'out.xls'); // If needing to write to filesystem

const data = new FormData();
Expand All @@ -121,9 +116,9 @@ export function submitXls(formData, params) {
.post({
url,
data,
auth: { username, password },
headers: {
...data.getHeaders(),
Authorization: `ApiKey ${username}:${apiKey}`,
},
})(state)
.then(response => {
Expand Down

0 comments on commit 359f782

Please sign in to comment.