Package ai.extend.wrapper.webhooks
Class VerifyAndParseResult
- java.lang.Object
-
- ai.extend.wrapper.webhooks.VerifyAndParseResult
-
- All Implemented Interfaces:
RawWebhookEvent
public class VerifyAndParseResult extends java.lang.Object implements RawWebhookEvent
Result of verifying and parsing a webhook event.This class provides type-safe access to the parsed webhook event, which can be either a normal typed event or a signed URL event.
Usage
VerifyAndParseResult result = webhooks.verifyAndParseWithOptions(body, headers, secret, options); if (result.isSignedUrlEvent()) { WebhookEventWithSignedUrl signedEvent = result.getSignedUrlEvent(); WebhookEvent fullEvent = webhooks.fetchSignedPayload(signedEvent); } else { WebhookEvent event = result.getEvent(); event.visit(new WebhookEvent.Visitor<Void>() { ... }); }
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description WebhookEventgetEvent()Returns the parsed webhook event.java.lang.StringgetEventId()Returns the event ID from either event type.java.lang.StringgetEventType()Returns the event type from either event type.WebhookEventWithSignedUrlgetSignedUrlEvent()Returns the signed URL event.booleanisSignedUrlEvent()Returns true if this is a signed URL event.static VerifyAndParseResultofEvent(WebhookEvent event, java.lang.String eventId, java.lang.String eventType)Creates a result for a normal webhook event.static VerifyAndParseResultofSignedUrlEvent(WebhookEventWithSignedUrl signedUrlEvent)Creates a result for a signed URL webhook event.java.lang.StringtoString()
-
-
-
Method Detail
-
ofEvent
public static VerifyAndParseResult ofEvent(WebhookEvent event, java.lang.String eventId, java.lang.String eventType)
Creates a result for a normal webhook event.
-
ofSignedUrlEvent
public static VerifyAndParseResult ofSignedUrlEvent(WebhookEventWithSignedUrl signedUrlEvent)
Creates a result for a signed URL webhook event.
-
isSignedUrlEvent
public boolean isSignedUrlEvent()
Returns true if this is a signed URL event.- Specified by:
isSignedUrlEventin interfaceRawWebhookEvent
-
getEvent
public WebhookEvent getEvent()
Returns the parsed webhook event.- Specified by:
getEventin interfaceRawWebhookEvent- Returns:
- The typed webhook event
- Throws:
java.lang.IllegalStateException- if this is a signed URL event
-
getSignedUrlEvent
public WebhookEventWithSignedUrl getSignedUrlEvent()
Returns the signed URL event.- Specified by:
getSignedUrlEventin interfaceRawWebhookEvent- Returns:
- The signed URL event
- Throws:
java.lang.IllegalStateException- if this is not a signed URL event
-
getEventId
public java.lang.String getEventId()
Returns the event ID from either event type.- Specified by:
getEventIdin interfaceRawWebhookEvent
-
getEventType
public java.lang.String getEventType()
Returns the event type from either event type.- Specified by:
getEventTypein interfaceRawWebhookEvent
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-