2828 builder = MetricsEventRequest .Builder .class
2929)
3030public final class MetricsEventRequest {
31+ private final Optional <String > idempotencyKey ;
32+
3133 private final UpsertedUser user ;
3234
3335 private final double value ;
@@ -36,14 +38,23 @@ public final class MetricsEventRequest {
3638
3739 private final Map <String , Object > additionalProperties ;
3840
39- private MetricsEventRequest (UpsertedUser user , double value ,
41+ private MetricsEventRequest (Optional < String > idempotencyKey , UpsertedUser user , double value ,
4042 Optional <Map <String , String >> attributes , Map <String , Object > additionalProperties ) {
43+ this .idempotencyKey = idempotencyKey ;
4144 this .user = user ;
4245 this .value = value ;
4346 this .attributes = attributes ;
4447 this .additionalProperties = additionalProperties ;
4548 }
4649
50+ /**
51+ * @return The idempotency key for the event.
52+ */
53+ @ JsonProperty ("Idempotency-Key" )
54+ public Optional <String > getIdempotencyKey () {
55+ return idempotencyKey ;
56+ }
57+
4758 /**
4859 * @return The user that triggered the event.
4960 */
@@ -80,12 +91,12 @@ public Map<String, Object> getAdditionalProperties() {
8091 }
8192
8293 private boolean equalTo (MetricsEventRequest other ) {
83- return user .equals (other .user ) && value == other .value && attributes .equals (other .attributes );
94+ return idempotencyKey . equals ( other . idempotencyKey ) && user .equals (other .user ) && value == other .value && attributes .equals (other .attributes );
8495 }
8596
8697 @ java .lang .Override
8798 public int hashCode () {
88- return Objects .hash (this .user , this .value , this .attributes );
99+ return Objects .hash (this .idempotencyKey , this . user , this .value , this .attributes );
89100 }
90101
91102 @ java .lang .Override
@@ -110,6 +121,10 @@ public interface ValueStage {
110121 public interface _FinalStage {
111122 MetricsEventRequest build ();
112123
124+ _FinalStage idempotencyKey (Optional <String > idempotencyKey );
125+
126+ _FinalStage idempotencyKey (String idempotencyKey );
127+
113128 _FinalStage attributes (Optional <Map <String , String >> attributes );
114129
115130 _FinalStage attributes (Map <String , String > attributes );
@@ -125,6 +140,8 @@ public static final class Builder implements UserStage, ValueStage, _FinalStage
125140
126141 private Optional <Map <String , String >> attributes = Optional .empty ();
127142
143+ private Optional <String > idempotencyKey = Optional .empty ();
144+
128145 @ JsonAnySetter
129146 private Map <String , Object > additionalProperties = new HashMap <>();
130147
@@ -133,6 +150,7 @@ private Builder() {
133150
134151 @ java .lang .Override
135152 public Builder from (MetricsEventRequest other ) {
153+ idempotencyKey (other .getIdempotencyKey ());
136154 user (other .getUser ());
137155 value (other .getValue ());
138156 attributes (other .getAttributes ());
@@ -181,9 +199,29 @@ public _FinalStage attributes(Optional<Map<String, String>> attributes) {
181199 return this ;
182200 }
183201
202+ /**
203+ * <p>The idempotency key for the event.</p>
204+ * @return Reference to {@code this} so that method calls can be chained together.
205+ */
206+ @ java .lang .Override
207+ public _FinalStage idempotencyKey (String idempotencyKey ) {
208+ this .idempotencyKey = Optional .ofNullable (idempotencyKey );
209+ return this ;
210+ }
211+
212+ @ java .lang .Override
213+ @ JsonSetter (
214+ value = "Idempotency-Key" ,
215+ nulls = Nulls .SKIP
216+ )
217+ public _FinalStage idempotencyKey (Optional <String > idempotencyKey ) {
218+ this .idempotencyKey = idempotencyKey ;
219+ return this ;
220+ }
221+
184222 @ java .lang .Override
185223 public MetricsEventRequest build () {
186- return new MetricsEventRequest (user , value , attributes , additionalProperties );
224+ return new MetricsEventRequest (idempotencyKey , user , value , attributes , additionalProperties );
187225 }
188226 }
189227}
0 commit comments