mailgun-java icon indicating copy to clipboard operation
mailgun-java copied to clipboard

Add WebHook event models

Open sebastianblesgen opened this issue 1 year ago • 0 comments

If I try to implement a webhook, I don't find the models for the body of the POST performed by Mailgun.

EventItem can be used but it's just part of the bod. There is also the signature part. Both are wrapped in a model.

This is what I did in Kotlin with Spring Boot (Java is similar)

   @PostMapping("/events")
    fun eventHook(@RequestBody event: Event) {
        val correlationId = event.eventData.message.headers.messageId
        val timestamp = event.signature.timestamp
        // ....
    }

    data class Event(
        val signature: Signature,
        @JsonProperty("event-data")
        val eventData: EventItem
    )

    data class Signature(
        val token: String,
        val timestamp: String,
        val signature: String
    )

sebastianblesgen avatar Jun 28 '24 12:06 sebastianblesgen