Skip to content

Commit 0f60a52

Browse files
author
Chris Wilson
committed
Working on sample code for webhook event parsing. It is a work in progress.
1 parent d99d1f8 commit 0f60a52

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

apps/sparkpost-samples-app/src/main/java/com/sparkpost/samples/webhooks/WebhookDecoderSample.java

+8-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import org.json.JSONArray;
1010
import org.json.JSONObject;
1111

12-
import com.google.gson.Gson;
1312
import com.sparkpost.model.webhook.event.AbstractWebhookEvent;
1413
import com.sparkpost.model.webhook.event.BounceEvent;
1514
import com.sparkpost.model.webhook.event.ClickEvent;
@@ -32,11 +31,14 @@
3231
import com.sparkpost.model.webhook.event.SpamComplaintEvent;
3332
import com.sparkpost.sdk.samples.helpers.SparkPostBaseApp;
3433

34+
/**
35+
* NOTE: Webhook events are experimental code and are subject to change.
36+
*/
3537
@SuppressWarnings("rawtypes")
3638
public class WebhookDecoderSample extends SparkPostBaseApp {
3739

3840
private final static Map<String, Class> classMap;
39-
private static final Gson GSON = new Gson();
41+
//private static final Gson GSON = new Gson();
4042

4143
public WebhookDecoderSample() {
4244

@@ -49,10 +51,10 @@ public static void main(String[] args) {
4951

5052
List<AbstractWebhookEvent> events = decoder.decodeEvents(json);
5153

52-
System.out.println("Found " + events.size() + " events.");
54+
System.out.println("Found " + events.size() + " events:");
5355

5456
for (AbstractWebhookEvent event : events) {
55-
System.out.println("\t " + event.getType());
57+
System.out.println("\t " + event.getType() + " - " + event.getClass().getSimpleName());
5658
}
5759

5860
}
@@ -86,9 +88,8 @@ public List<AbstractWebhookEvent> decodeEvents(String json) {
8688
continue;
8789
}
8890

89-
@SuppressWarnings("unchecked")
90-
AbstractWebhookEvent eventObj = GSON.fromJson(eventData.toString(), c);
91-
webhookEvents.add(eventObj);
91+
//AbstractWebhookEvent eventObj = GSON.fromJson(eventData.toString(), c);
92+
//webhookEvents.add(eventObj);
9293

9394
}
9495

0 commit comments

Comments
 (0)