Skip to content

Commit

Permalink
prettier api
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak committed Apr 30, 2024
1 parent f95f066 commit b24435c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
1 change: 1 addition & 0 deletions api.planx.uk/modules/send/s3/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe(`uploading an application to S3`, () => {
{
integrations: {
powerAutomateWebhookURL: "test.azure.com/whatever",
powerAutomateAPIKey: "secret",
},
},
],
Expand Down
33 changes: 18 additions & 15 deletions api.planx.uk/modules/send/s3/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ export async function sendToS3(
const { sessionId } = payload;

// Fetch integration credentials for this team
const { powerAutomateWebhookURL, powerAutomateAPIKey } = await $api.team.getIntegrations({
slug: localAuthority,
encryptionKey: process.env.ENCRYPTION_KEY!,
env,
});
const { powerAutomateWebhookURL, powerAutomateAPIKey } =
await $api.team.getIntegrations({
slug: localAuthority,
encryptionKey: process.env.ENCRYPTION_KEY!,
env,
});

if (!powerAutomateWebhookURL || !powerAutomateAPIKey) {
return next({
Expand All @@ -49,28 +50,30 @@ export async function sendToS3(
);

// Send a notification with the file URL to the Power Automate webook
let webhookResponseStatus: number | undefined;
let webhookResponseStatus: number | undefined;
await axios({
method: "POST",
url: powerAutomateWebhookURL,
adapter: "http",
headers: {
"Content-Type": "application/json",
"apiKey": powerAutomateAPIKey,
apiKey: powerAutomateAPIKey,
},
data: {
message: "New submission from PlanX",
environment: env,
file: fileUrl,
},
}).then((res) => {
// TODO Create & update audit table entry here
webhookResponseStatus = res.status;
}).catch((error) => {
throw new Error(
`Failed to send submission notification to ${localAuthority}'s Power Automate Webhook (${sessionId}): ${error}`,
);
});
})
.then((res) => {
// TODO Create & update audit table entry here
webhookResponseStatus = res.status;
})
.catch((error) => {
throw new Error(
`Failed to send submission notification to ${localAuthority}'s Power Automate Webhook (${sessionId}): ${error}`,
);
});

// Mark session as submitted so that reminder and expiry emails are not triggered
markSessionAsSubmitted(sessionId);
Expand Down

0 comments on commit b24435c

Please sign in to comment.