Skip to content

Commit

Permalink
Merge pull request #63 from vtfk/test
Browse files Browse the repository at this point in the history
Test
  • Loading branch information
robinElli authored Feb 23, 2023
2 parents e892b3a + 6ba5a09 commit f871485
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
19 changes: 19 additions & 0 deletions func-getBrreg/function.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get"
],
"route": "brreg/{id}"
},
{
"type": "http",
"direction": "out",
"name": "$return"
}
]
}
21 changes: 21 additions & 0 deletions func-getBrreg/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const { azfHandleResponse, azfHandleError } = require('@vtfk/responsehandlers');
const axios = require('axios');

module.exports = async function (context, req) {
try {
// Authentication / Authorization
await require('../sharedcode/auth/auth').auth(req);

// Get ID from request
const id = context.bindingData.id
if(!id) throw new HTTPError(400, 'No dispatch id was provided');

// Make the request
const response = await axios.get(`https://data.brreg.no/enhetsregisteret/api/enheter/${id}`);

// Return the brreg info
return await azfHandleResponse(response.data, context, req)
} catch (err) {
return await azfHandleError(err, context, req)
}
}
2 changes: 1 addition & 1 deletion func-getreadydispatches/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module.exports = async function (context, req) {

// Check if the dispatch has passed the registration threshold
let registrationThreshold = dayjs(dispatch.approvedTimestamp).set('hour', 23).set('minute', 59).set('second', 59).set('millisecond', 0);
let delaySendUntil = dayjs().add(1, 'day').set('hour', 11).set('minute', 0).set('second', 0).set('millisecond', 0);
let delaySendUntil = dayjs().set('hour', 11).set('minute', 0).set('second', 0).set('millisecond', 0);
if(!config.BYPASS_REGISTRATION_THRESHOLD) {
if(dayjs(new Date()).isBefore(registrationThreshold)) continue;
}
Expand Down

0 comments on commit f871485

Please sign in to comment.