1414import com .fasterxml .jackson .annotation .Nulls ;
1515import com .fasterxml .jackson .databind .annotation .JsonDeserialize ;
1616import so .trophy .core .ObjectMappers ;
17+ import java .lang .Boolean ;
1718import java .lang .Object ;
1819import java .lang .String ;
1920import java .util .HashMap ;
@@ -40,19 +41,25 @@ public final class EventResponse {
4041
4142 private final Optional <Map <String , MetricEventPointsResponse >> points ;
4243
44+ private final Optional <String > idempotencyKey ;
45+
46+ private final Optional <Boolean > idempotentReplayed ;
47+
4348 private final Map <String , Object > additionalProperties ;
4449
4550 private EventResponse (String eventId , String metricId , double total ,
4651 Optional <List <CompletedAchievementResponse >> achievements ,
4752 Optional <MetricEventStreakResponse > currentStreak ,
48- Optional <Map <String , MetricEventPointsResponse >> points ,
49- Map <String , Object > additionalProperties ) {
53+ Optional <Map <String , MetricEventPointsResponse >> points , Optional < String > idempotencyKey ,
54+ Optional < Boolean > idempotentReplayed , Map <String , Object > additionalProperties ) {
5055 this .eventId = eventId ;
5156 this .metricId = metricId ;
5257 this .total = total ;
5358 this .achievements = achievements ;
5459 this .currentStreak = currentStreak ;
5560 this .points = points ;
61+ this .idempotencyKey = idempotencyKey ;
62+ this .idempotentReplayed = idempotentReplayed ;
5663 this .additionalProperties = additionalProperties ;
5764 }
5865
@@ -104,6 +111,22 @@ public Optional<Map<String, MetricEventPointsResponse>> getPoints() {
104111 return points ;
105112 }
106113
114+ /**
115+ * @return The idempotency key used for the event, if one was provided.
116+ */
117+ @ JsonProperty ("idempotencyKey" )
118+ public Optional <String > getIdempotencyKey () {
119+ return idempotencyKey ;
120+ }
121+
122+ /**
123+ * @return Whether the event was replayed due to idempotency.
124+ */
125+ @ JsonProperty ("idempotentReplayed" )
126+ public Optional <Boolean > getIdempotentReplayed () {
127+ return idempotentReplayed ;
128+ }
129+
107130 @ java .lang .Override
108131 public boolean equals (Object other ) {
109132 if (this == other ) return true ;
@@ -116,12 +139,12 @@ public Map<String, Object> getAdditionalProperties() {
116139 }
117140
118141 private boolean equalTo (EventResponse other ) {
119- return eventId .equals (other .eventId ) && metricId .equals (other .metricId ) && total == other .total && achievements .equals (other .achievements ) && currentStreak .equals (other .currentStreak ) && points .equals (other .points );
142+ return eventId .equals (other .eventId ) && metricId .equals (other .metricId ) && total == other .total && achievements .equals (other .achievements ) && currentStreak .equals (other .currentStreak ) && points .equals (other .points ) && idempotencyKey . equals ( other . idempotencyKey ) && idempotentReplayed . equals ( other . idempotentReplayed ) ;
120143 }
121144
122145 @ java .lang .Override
123146 public int hashCode () {
124- return Objects .hash (this .eventId , this .metricId , this .total , this .achievements , this .currentStreak , this .points );
147+ return Objects .hash (this .eventId , this .metricId , this .total , this .achievements , this .currentStreak , this .points , this . idempotencyKey , this . idempotentReplayed );
125148 }
126149
127150 @ java .lang .Override
@@ -161,6 +184,14 @@ public interface _FinalStage {
161184 _FinalStage points (Optional <Map <String , MetricEventPointsResponse >> points );
162185
163186 _FinalStage points (Map <String , MetricEventPointsResponse > points );
187+
188+ _FinalStage idempotencyKey (Optional <String > idempotencyKey );
189+
190+ _FinalStage idempotencyKey (String idempotencyKey );
191+
192+ _FinalStage idempotentReplayed (Optional <Boolean > idempotentReplayed );
193+
194+ _FinalStage idempotentReplayed (Boolean idempotentReplayed );
164195 }
165196
166197 @ JsonIgnoreProperties (
@@ -173,6 +204,10 @@ public static final class Builder implements EventIdStage, MetricIdStage, TotalS
173204
174205 private double total ;
175206
207+ private Optional <Boolean > idempotentReplayed = Optional .empty ();
208+
209+ private Optional <String > idempotencyKey = Optional .empty ();
210+
176211 private Optional <Map <String , MetricEventPointsResponse >> points = Optional .empty ();
177212
178213 private Optional <MetricEventStreakResponse > currentStreak = Optional .empty ();
@@ -193,6 +228,8 @@ public Builder from(EventResponse other) {
193228 achievements (other .getAchievements ());
194229 currentStreak (other .getCurrentStreak ());
195230 points (other .getPoints ());
231+ idempotencyKey (other .getIdempotencyKey ());
232+ idempotentReplayed (other .getIdempotentReplayed ());
196233 return this ;
197234 }
198235
@@ -229,6 +266,46 @@ public _FinalStage total(double total) {
229266 return this ;
230267 }
231268
269+ /**
270+ * <p>Whether the event was replayed due to idempotency.</p>
271+ * @return Reference to {@code this} so that method calls can be chained together.
272+ */
273+ @ java .lang .Override
274+ public _FinalStage idempotentReplayed (Boolean idempotentReplayed ) {
275+ this .idempotentReplayed = Optional .ofNullable (idempotentReplayed );
276+ return this ;
277+ }
278+
279+ @ java .lang .Override
280+ @ JsonSetter (
281+ value = "idempotentReplayed" ,
282+ nulls = Nulls .SKIP
283+ )
284+ public _FinalStage idempotentReplayed (Optional <Boolean > idempotentReplayed ) {
285+ this .idempotentReplayed = idempotentReplayed ;
286+ return this ;
287+ }
288+
289+ /**
290+ * <p>The idempotency key used for the event, if one was provided.</p>
291+ * @return Reference to {@code this} so that method calls can be chained together.
292+ */
293+ @ java .lang .Override
294+ public _FinalStage idempotencyKey (String idempotencyKey ) {
295+ this .idempotencyKey = Optional .ofNullable (idempotencyKey );
296+ return this ;
297+ }
298+
299+ @ java .lang .Override
300+ @ JsonSetter (
301+ value = "idempotencyKey" ,
302+ nulls = Nulls .SKIP
303+ )
304+ public _FinalStage idempotencyKey (Optional <String > idempotencyKey ) {
305+ this .idempotencyKey = idempotencyKey ;
306+ return this ;
307+ }
308+
232309 /**
233310 * <p>A map of points systems by key that were affected by this event.</p>
234311 * @return Reference to {@code this} so that method calls can be chained together.
@@ -291,7 +368,7 @@ public _FinalStage achievements(Optional<List<CompletedAchievementResponse>> ach
291368
292369 @ java .lang .Override
293370 public EventResponse build () {
294- return new EventResponse (eventId , metricId , total , achievements , currentStreak , points , additionalProperties );
371+ return new EventResponse (eventId , metricId , total , achievements , currentStreak , points , idempotencyKey , idempotentReplayed , additionalProperties );
295372 }
296373 }
297374}
0 commit comments