File tree Expand file tree Collapse file tree 5 files changed +859
-733
lines changed Expand file tree Collapse file tree 5 files changed +859
-733
lines changed Original file line number Diff line number Diff line change @@ -310,3 +310,54 @@ export async function deleteWebhookConfig(props: {
310310 status : "success" ,
311311 } ;
312312}
313+
314+ type TestDestinationUrlResponse =
315+ | {
316+ result : {
317+ httpStatusCode : number ;
318+ httpResponseBody : string ;
319+ } ;
320+ status : "success" ;
321+ }
322+ | {
323+ body : string ;
324+ reason : string ;
325+ status : "error" ;
326+ } ;
327+
328+ export async function testDestinationUrl ( props : {
329+ teamIdOrSlug : string ;
330+ projectIdOrSlug : string ;
331+ destinationUrl : string ;
332+ } ) : Promise < TestDestinationUrlResponse > {
333+ const authToken = await getAuthToken ( ) ;
334+
335+ if ( ! authToken ) {
336+ return {
337+ body : "Authentication required" ,
338+ reason : "no_auth_token" ,
339+ status : "error" ,
340+ } ;
341+ }
342+
343+ const resp = await fetch (
344+ `${ NEXT_PUBLIC_THIRDWEB_API_HOST } /v1/teams/${ props . teamIdOrSlug } /projects/${ props . projectIdOrSlug } /webhook-configs/test-destination-url` ,
345+ {
346+ body : JSON . stringify ( { destinationUrl : props . destinationUrl } ) ,
347+ headers : {
348+ Authorization : `Bearer ${ authToken } ` ,
349+ "Content-Type" : "application/json" ,
350+ } ,
351+ method : "POST" ,
352+ } ,
353+ ) ;
354+ console . log ( "[DEBUG] resp:" , resp ) ;
355+ if ( ! resp . ok ) {
356+ return {
357+ body : await resp . text ( ) ,
358+ reason : "unknown" ,
359+ status : "error" ,
360+ } ;
361+ }
362+ return await resp . json ( ) ;
363+ }
You can’t perform that action at this time.
0 commit comments