Class 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 Detail

      • ofEvent

        public static VerifyAndParseResult ofEvent​(WebhookEvent event,
                                                   java.lang.String eventId,
                                                   java.lang.String eventType)
        Creates a result for a normal webhook event.
      • isSignedUrlEvent

        public boolean isSignedUrlEvent()
        Returns true if this is a signed URL event.
        Specified by:
        isSignedUrlEvent in interface RawWebhookEvent
      • getEvent

        public WebhookEvent getEvent()
        Returns the parsed webhook event.
        Specified by:
        getEvent in interface RawWebhookEvent
        Returns:
        The typed webhook event
        Throws:
        java.lang.IllegalStateException - if this is a signed URL event
      • getEventId

        public java.lang.String getEventId()
        Returns the event ID from either event type.
        Specified by:
        getEventId in interface RawWebhookEvent
      • getEventType

        public java.lang.String getEventType()
        Returns the event type from either event type.
        Specified by:
        getEventType in interface RawWebhookEvent
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object