Skip to content

Commit c5ca30d

Browse files
Automatically update Java SDK
1 parent 818eb02 commit c5ca30d

25 files changed

+2097
-276
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<!-- General project information -->
99
<groupId>so.trophy</groupId>
1010
<artifactId>trophy-java</artifactId>
11-
<version>1.0.16</version>
11+
<version>1.0.17</version>
1212
<packaging>jar</packaging>
1313
<name>Trophy</name>
1414
<description>Java client library for the Trophy API</description>

src/main/java/so/trophy/core/ClientOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ private ClientOptions(Environment environment, Map<String, String> headers,
2828
this.environment = environment;
2929
this.headers = new HashMap<>();
3030
this.headers.putAll(headers);
31-
this.headers.putAll(new HashMap<String,String>() {{put("X-Fern-Language", "JAVA");put("X-Fern-SDK-Name", "com.trophy.fern:api-sdk");put("X-Fern-SDK-Version", "0.0.1286");}});
31+
this.headers.putAll(new HashMap<String,String>() {{put("X-Fern-Language", "JAVA");put("X-Fern-SDK-Name", "com.trophy.fern:api-sdk");put("X-Fern-SDK-Version", "0.0.1391");}});
3232
this.headerSuppliers = headerSuppliers;
3333
this.httpClient = httpClient;
3434
this.timeout = timeout;

src/main/java/so/trophy/resources/achievements/AchievementsClient.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ public List<AchievementWithStatsResponse> all(RequestOptions requestOptions) {
7474
try {
7575
switch (response.code()) {
7676
case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorBody.class));
77-
case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorBody.class));
7877
case 422:throw new UnprocessableEntityError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorBody.class));
7978
}
8079
}

src/main/java/so/trophy/resources/achievements/requests/AchievementsCompleteRequest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@
1919
import java.util.Map;
2020
import java.util.Objects;
2121
import org.jetbrains.annotations.NotNull;
22-
import so.trophy.types.UpdatedUser;
22+
import so.trophy.types.UpsertedUser;
2323

2424
@JsonInclude(JsonInclude.Include.NON_ABSENT)
2525
@JsonDeserialize(
2626
builder = AchievementsCompleteRequest.Builder.class
2727
)
2828
public final class AchievementsCompleteRequest {
29-
private final UpdatedUser user;
29+
private final UpsertedUser user;
3030

3131
private final Map<String, Object> additionalProperties;
3232

33-
private AchievementsCompleteRequest(UpdatedUser user, Map<String, Object> additionalProperties) {
33+
private AchievementsCompleteRequest(UpsertedUser user, Map<String, Object> additionalProperties) {
3434
this.user = user;
3535
this.additionalProperties = additionalProperties;
3636
}
@@ -39,7 +39,7 @@ private AchievementsCompleteRequest(UpdatedUser user, Map<String, Object> additi
3939
* @return The user that completed the achievement.
4040
*/
4141
@JsonProperty("user")
42-
public UpdatedUser getUser() {
42+
public UpsertedUser getUser() {
4343
return user;
4444
}
4545

@@ -73,7 +73,7 @@ public static UserStage builder() {
7373
}
7474

7575
public interface UserStage {
76-
_FinalStage user(@NotNull UpdatedUser user);
76+
_FinalStage user(@NotNull UpsertedUser user);
7777

7878
Builder from(AchievementsCompleteRequest other);
7979
}
@@ -86,7 +86,7 @@ public interface _FinalStage {
8686
ignoreUnknown = true
8787
)
8888
public static final class Builder implements UserStage, _FinalStage {
89-
private UpdatedUser user;
89+
private UpsertedUser user;
9090

9191
@JsonAnySetter
9292
private Map<String, Object> additionalProperties = new HashMap<>();
@@ -106,7 +106,7 @@ public Builder from(AchievementsCompleteRequest other) {
106106
*/
107107
@java.lang.Override
108108
@JsonSetter("user")
109-
public _FinalStage user(@NotNull UpdatedUser user) {
109+
public _FinalStage user(@NotNull UpsertedUser user) {
110110
this.user = Objects.requireNonNull(user, "user must not be null");
111111
return this;
112112
}

src/main/java/so/trophy/resources/metrics/requests/MetricsEventRequest.java

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
import com.fasterxml.jackson.annotation.JsonInclude;
1212
import com.fasterxml.jackson.annotation.JsonProperty;
1313
import com.fasterxml.jackson.annotation.JsonSetter;
14+
import com.fasterxml.jackson.annotation.Nulls;
1415
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
1516
import so.trophy.core.ObjectMappers;
1617
import java.lang.Object;
1718
import java.lang.String;
1819
import java.util.HashMap;
1920
import java.util.Map;
2021
import java.util.Objects;
22+
import java.util.Optional;
2123
import org.jetbrains.annotations.NotNull;
2224
import so.trophy.types.UpsertedUser;
2325

@@ -30,12 +32,15 @@ public final class MetricsEventRequest {
3032

3133
private final double value;
3234

35+
private final Optional<Map<String, String>> attributes;
36+
3337
private final Map<String, Object> additionalProperties;
3438

3539
private MetricsEventRequest(UpsertedUser user, double value,
36-
Map<String, Object> additionalProperties) {
40+
Optional<Map<String, String>> attributes, Map<String, Object> additionalProperties) {
3741
this.user = user;
3842
this.value = value;
43+
this.attributes = attributes;
3944
this.additionalProperties = additionalProperties;
4045
}
4146

@@ -55,6 +60,14 @@ public double getValue() {
5560
return value;
5661
}
5762

63+
/**
64+
* @return Event attributes as key-value pairs. Keys must match existing event attributes set up in the Trophy dashboard.
65+
*/
66+
@JsonProperty("attributes")
67+
public Optional<Map<String, String>> getAttributes() {
68+
return attributes;
69+
}
70+
5871
@java.lang.Override
5972
public boolean equals(Object other) {
6073
if (this == other) return true;
@@ -67,12 +80,12 @@ public Map<String, Object> getAdditionalProperties() {
6780
}
6881

6982
private boolean equalTo(MetricsEventRequest other) {
70-
return user.equals(other.user) && value == other.value;
83+
return user.equals(other.user) && value == other.value && attributes.equals(other.attributes);
7184
}
7285

7386
@java.lang.Override
7487
public int hashCode() {
75-
return Objects.hash(this.user, this.value);
88+
return Objects.hash(this.user, this.value, this.attributes);
7689
}
7790

7891
@java.lang.Override
@@ -96,6 +109,10 @@ public interface ValueStage {
96109

97110
public interface _FinalStage {
98111
MetricsEventRequest build();
112+
113+
_FinalStage attributes(Optional<Map<String, String>> attributes);
114+
115+
_FinalStage attributes(Map<String, String> attributes);
99116
}
100117

101118
@JsonIgnoreProperties(
@@ -106,6 +123,8 @@ public static final class Builder implements UserStage, ValueStage, _FinalStage
106123

107124
private double value;
108125

126+
private Optional<Map<String, String>> attributes = Optional.empty();
127+
109128
@JsonAnySetter
110129
private Map<String, Object> additionalProperties = new HashMap<>();
111130

@@ -116,6 +135,7 @@ private Builder() {
116135
public Builder from(MetricsEventRequest other) {
117136
user(other.getUser());
118137
value(other.getValue());
138+
attributes(other.getAttributes());
119139
return this;
120140
}
121141

@@ -141,9 +161,29 @@ public _FinalStage value(double value) {
141161
return this;
142162
}
143163

164+
/**
165+
* <p>Event attributes as key-value pairs. Keys must match existing event attributes set up in the Trophy dashboard.</p>
166+
* @return Reference to {@code this} so that method calls can be chained together.
167+
*/
168+
@java.lang.Override
169+
public _FinalStage attributes(Map<String, String> attributes) {
170+
this.attributes = Optional.ofNullable(attributes);
171+
return this;
172+
}
173+
174+
@java.lang.Override
175+
@JsonSetter(
176+
value = "attributes",
177+
nulls = Nulls.SKIP
178+
)
179+
public _FinalStage attributes(Optional<Map<String, String>> attributes) {
180+
this.attributes = attributes;
181+
return this;
182+
}
183+
144184
@java.lang.Override
145185
public MetricsEventRequest build() {
146-
return new MetricsEventRequest(user, value, additionalProperties);
186+
return new MetricsEventRequest(user, value, attributes, additionalProperties);
147187
}
148188
}
149189
}

0 commit comments

Comments
 (0)