File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -2187,7 +2187,7 @@ export async function createAshbyWebhookSubscription(
21872187 throw new Error ( 'Trigger ID is required to create Ashby webhook.' )
21882188 }
21892189
2190- const webhookTypeMap : Record < string , string | undefined > = {
2190+ const webhookTypeMap : Record < string , string > = {
21912191 ashby_application_submit : 'applicationSubmit' ,
21922192 ashby_candidate_stage_change : 'candidateStageChange' ,
21932193 ashby_candidate_hire : 'candidateHire' ,
@@ -2197,6 +2197,10 @@ export async function createAshbyWebhookSubscription(
21972197 }
21982198
21992199 const webhookType = webhookTypeMap [ triggerId ]
2200+ if ( ! webhookType ) {
2201+ throw new Error ( `Unknown Ashby triggerId: ${ triggerId } . Add it to webhookTypeMap.` )
2202+ }
2203+
22002204 const notificationUrl = `${ getBaseUrl ( ) } /api/webhooks/trigger/${ path } `
22012205 const authString = Buffer . from ( `${ apiKey } :` ) . toString ( 'base64' )
22022206
@@ -2208,10 +2212,7 @@ export async function createAshbyWebhookSubscription(
22082212
22092213 const requestBody : Record < string , unknown > = {
22102214 requestUrl : notificationUrl ,
2211- }
2212-
2213- if ( webhookType ) {
2214- requestBody . webhookType = webhookType
2215+ webhookType,
22152216 }
22162217
22172218 const ashbyResponse = await fetch ( 'https://api.ashbyhq.com/webhook.create' , {
You can’t perform that action at this time.
0 commit comments