Skip to content

Commit 454297e

Browse files
author
Chris Wilson
committed
Working on unit tests for web hook events.
1 parent d64078e commit 454297e

23 files changed

+815
-41
lines changed

apps/sparkpost-documentor-app/src/main/java/com/sparkpost/documentor/GenerateWebhookEventPojos.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,21 +64,26 @@ public String renderEventClass(JSONObject eventInfo) {
6464
builder.append("import java.util.List;\n");
6565
builder.append("import java.util.Map;\n");
6666
builder.append("import com.yepher.jsondoc.annotations.Description;\n");
67-
67+
builder.append("import com.google.gson.annotations.SerializedName;\n");
68+
builder.append("import com.sparkpost.model.Base;\n");
6869
builder.append("import lombok.Data;\n");
6970
builder.append("import lombok.EqualsAndHashCode;\n");
7071

7172
builder.append("\n\n/**\n").append(eventInfo.optString("description").trim()).append("\n*/\n\n");
7273
builder.append("@Data\n");
73-
builder.append("@EqualsAndHashCode()\n");
74-
builder.append("public class " + convertToCamelCase(eventInfo.getString("display_name"), true) + "Event {\n\n");
74+
builder.append("@EqualsAndHashCode(callSuper = true)\n");
75+
builder.append("public class " + convertToCamelCase(eventInfo.getString("display_name"), true) + "Event extends Base {\n\n");
7576

7677
JSONObject fields = eventInfo.getJSONObject("event");
7778
Set<String> fieldNames = fields.keySet();
7879

7980
for (String fieldName : fieldNames) {
8081
JSONObject field = fields.getJSONObject(fieldName);
8182

83+
if (fieldName.contains("_")) {
84+
builder.append("\t@SerializedName(\"" + fieldName + "\")\n");
85+
}
86+
8287
//@Description(
8388
// value = "A suppression list - or exclusion list, as it is sometimes called - stores a recipient's opt-out preferences.",
8489
// sample = {"Array of SuppressionListEntrys"})

libs/sparkpost-lib/src/main/java/com/sparkpost/model/webhook/event/BounceEvent.java

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import java.util.List;
44
import java.util.Map;
55

6+
import com.google.gson.annotations.SerializedName;
7+
import com.sparkpost.model.Base;
68
import com.yepher.jsondoc.annotations.Description;
79

810
import lombok.Data;
@@ -14,24 +16,27 @@
1416
*/
1517

1618
@Data
17-
@EqualsAndHashCode()
18-
public class BounceEvent {
19+
@EqualsAndHashCode(callSuper = true)
20+
public class BounceEvent extends Base {
1921

2022
@Description(
2123
value = "Canonicalized text of the response returned by the remote server due to a failed delivery attempt",
2224
sample = "MAIL REFUSED - IP (a.b.c.d) is in black list")
2325
private String reason;
2426

27+
@SerializedName("sms_src_npi")
2528
@Description(
2629
value = "Source numbering plan identification",
2730
sample = "E164")
2831
private String smsSrcNpi;
2932

33+
@SerializedName("template_version")
3034
@Description(
3135
value = "Version of the template used to construct this message",
3236
sample = "1")
3337
private String templateVersion;
3438

39+
@SerializedName("friendly_from")
3540
@Description(
3641
value = "Friendly sender or \"From\" header in the original email",
3742
sample = "sender@example.com")
@@ -42,11 +47,13 @@ public class BounceEvent {
4247
sample = "Summer deals are here!")
4348
private String subject;
4449

50+
@SerializedName("ip_pool")
4551
@Description(
4652
value = "IP pool through which this message was sent",
4753
sample = "Example-Ip-Pool")
4854
private String ipPool;
4955

56+
@SerializedName("rcpt_tags")
5057
@Description(
5158
value = "Tags applied to the message which generated this event",
5259
sample = "[\"male\",\"US\"]")
@@ -57,51 +64,61 @@ public class BounceEvent {
5764
sample = "bounce")
5865
private String type;
5966

67+
@SerializedName("num_retries")
6068
@Description(
6169
value = "Number of failed attempts before this message was successfully delivered; when the first attempt succeeds, zero",
6270
sample = "2")
6371
private String numRetries;
6472

73+
@SerializedName("sms_dst_npi")
6574
@Description(
6675
value = "Destination numbering plan identification",
6776
sample = "E164")
6877
private String smsDstNpi;
6978

79+
@SerializedName("bounce_class")
7080
@Description(
7181
value = "Classification code for a given message (see [Bounce Classification Codes](https://support.sparkpost.com/customer/portal/articles/1929896))",
7282
sample = "1")
7383
private String bounceClass;
7484

85+
@SerializedName("raw_rcpt_to")
7586
@Description(
7687
value = "Actual recipient address used on this message's SMTP envelope",
7788
sample = "Recipient@example.com")
7889
private String rawRcptTo;
7990

91+
@SerializedName("sms_src")
8092
@Description(
8193
value = "SMS source address",
8294
sample = "1234")
8395
private String smsSrc;
8496

97+
@SerializedName("msg_from")
8598
@Description(
8699
value = "Sender address used on this message's SMTP envelope",
87100
sample = "sender@example.com")
88101
private String msgFrom;
89102

103+
@SerializedName("rcpt_to")
90104
@Description(
91105
value = "Lowercase version of recipient address used on this message's SMTP envelope",
92106
sample = "recipient@example.com")
93107
private String rcptTo;
94108

109+
@SerializedName("subaccount_id")
95110
@Description(
96111
value = "Unique subaccount identifier.",
97112
sample = "101")
98113
private String subaccountId;
99114

115+
@SerializedName("transmission_id")
100116
@Description(
101117
value = "Transmission which originated this message",
102118
sample = "65832150921904138")
103119
private String transmissionId;
104120

121+
@SerializedName("campaign_id")
105122
@Description(
106123
value = "Campaign of which this message was a part",
107124
sample = "Example Campaign Name")
@@ -112,91 +129,109 @@ public class BounceEvent {
112129
sample = "1454442600")
113130
private String timestamp;
114131

132+
@SerializedName("sms_coding")
115133
@Description(
116134
value = "Data encoding used in the SMS message",
117135
sample = "ASCII")
118136
private String smsCoding;
119137

138+
@SerializedName("rcpt_meta")
120139
@Description(
121140
value = "Metadata describing the message recipient",
122141
sample = "{\"customKey\":\"customValue\"}")
123142
private Map<String, String> rcptMeta;
124143

144+
@SerializedName("message_id")
125145
@Description(
126146
value = "SparkPost-cluster-wide unique identifier for this message",
127147
sample = "000443ee14578172be22")
128148
private String messageId;
129149

150+
@SerializedName("ip_address")
130151
@Description(
131152
value = "IP address of the host to which SparkPost delivered this message; in engagement events, the IP address of the host where the HTTP request originated",
132153
sample = "127.0.0.1")
133154
private String ipAddress;
134155

156+
@SerializedName("rcpt_type")
135157
@Description(
136158
value = "Indicates that a recipient address appeared in the Cc or Bcc header or the archive JSON array",
137159
sample = "cc")
138160
private String rcptType;
139161

162+
@SerializedName("sms_dst")
140163
@Description(
141164
value = "SMS destination address",
142165
sample = "7876712656")
143166
private String smsDst;
144167

168+
@SerializedName("event_id")
145169
@Description(
146170
value = "Unique event identifier",
147171
sample = "92356927693813856")
148172
private String eventId;
149173

174+
@SerializedName("routing_domain")
150175
@Description(
151176
value = "Domain receiving this message",
152177
sample = "example.com")
153178
private String routingDomain;
154179

180+
@SerializedName("sending_ip")
155181
@Description(
156182
value = "IP address through which this message was sent",
157183
sample = "127.0.0.1")
158184
private String sendingIp;
159185

186+
@SerializedName("sms_src_ton")
160187
@Description(
161188
value = "Type of number for the source address",
162189
sample = "Unknown")
163190
private String smsSrcTon;
164191

192+
@SerializedName("device_token")
165193
@Description(
166194
value = "Token of the device / application targeted by this PUSH notification message. Applies only when delv_method is gcm or apn.",
167195
sample = "45c19189783f867973f6e6a5cca60061ffe4fa77c547150563a1192fa9847f8a")
168196
private String deviceToken;
169197

198+
@SerializedName("raw_reason")
170199
@Description(
171200
value = "Unmodified, exact response returned by the remote server due to a failed delivery attempt",
172201
sample = "MAIL REFUSED - IP (17.99.99.99) is in black list")
173202
private String rawReason;
174203

204+
@SerializedName("sms_dst_ton")
175205
@Description(
176206
value = "Type of number for the destination address",
177207
sample = "International")
178208
private String smsDstTon;
179209

210+
@SerializedName("error_code")
180211
@Description(
181212
value = "Error code by which the remote server described a failed delivery attempt",
182213
sample = "554")
183214
private String errorCode;
184215

216+
@SerializedName("template_id")
185217
@Description(
186218
value = "Slug of the template used to construct this message",
187219
sample = "templ-1234")
188220
private String templateId;
189221

222+
@SerializedName("delv_method")
190223
@Description(
191224
value = "Protocol by which SparkPost delivered this message",
192225
sample = "esmtp")
193226
private String delvMethod;
194227

228+
@SerializedName("customer_id")
195229
@Description(
196230
value = "SparkPost-customer identifier through which this message was sent",
197231
sample = "1")
198232
private String customerId;
199233

234+
@SerializedName("msg_size")
200235
@Description(
201236
value = "Message's size in bytes",
202237
sample = "1337")

0 commit comments

Comments
 (0)