Skip to content

Commit

Permalink
refactor: migrate second batch of sources to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
vinayteki95 committed Feb 17, 2025
1 parent 25a00f4 commit 6bfbac4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
7 changes: 3 additions & 4 deletions src/sources/monday/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ function processChallengeEvent(event) {
// to Monday to verify the webhook url.
// Ref: https://developer.monday.com/api-reference/docs/webhooks-1#how-to-verify-a-webhook-url
function process(payload) {
if (isChallengeEvent(payload)) {
return processChallengeEvent(payload);
}
const event = getBodyFromV2SpecPayload(payload);
const response = processNormalEvent(event);
const response = isChallengeEvent(event)
? processChallengeEvent(event)
: processNormalEvent(event);
return removeUndefinedAndNullValues(response);
}

Expand Down
18 changes: 18 additions & 0 deletions test/apitests/data_scenarios/source/v2/response_to_caller.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"input": [
{
"request": {
"body": "{\"challenge\": \"some_key\"}"
}
}
],
"output": [
{
"outputToSource": {
"body": "eyJjaGFsbGVuZ2UiOiJzb21lX2tleSJ9",
"contentType": "application/json"
},
"statusCode": 200
}
]
}
4 changes: 2 additions & 2 deletions test/apitests/service.api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,9 @@ describe('Destination api tests', () => {

describe('Source api tests', () => {
test('(shopify) success source transform (monday)', async () => {
const data = getDataFromPath('./data_scenarios/source/v0/response_to_caller.json');
const data = getDataFromPath('./data_scenarios/source/v2/response_to_caller.json');
const response = await request(server)
.post('/v0/sources/monday')
.post('/v2/sources/monday')
.set('Accept', 'application/json')
.send(data.input);
expect(response.status).toEqual(200);
Expand Down

0 comments on commit 6bfbac4

Please sign in to comment.