-
Notifications
You must be signed in to change notification settings - Fork 31
Working with webhooks
Igor Balos edited this page Dec 14, 2017
·
6 revisions
Postmark Java library allows you to easily retrieve Postmark webhooks and convert these to objects you can use within your code.
In order to do that, we are going to share a simple example how to retrieve webhooks.
To retrieve webhooks, you can use HttpClient within Postmark Java library.
HttpClient client = new HttpClient(new MultivaluedHashMap<>());
HttpClient.ClientResponse response = client.execute(HttpClient.REQUEST_TYPES.GET, "http://webhooks-example.com");Once you retrieved the content, all you need is to convert that response to appropriate object.
Retrieve Bounce webhook:
BounceWebhook bounceWebhook = dataHandler.fromJson(response.getMessage(), BounceWebhook.class);Retrieve Delivery webhook:
DeliveryWebhook deliveryWebhook = dataHandler.fromJson(response.getMessage(), DeliveryWebhook.class);Retrieve Open webhook:
OpenWebhook openWebhook = dataHandler.fromJson(response.getMessage(), OpenWebhook.class);Retrieve Click webhook:
ClickWebhook clickWebhook = dataHandler.fromJson(response.getMessage(), ClickWebhook.class);For additional information about the capabilities of the Postmark API, see Postmark Developers Documentation.