Skip to content

Commit 3560f9d

Browse files
Automatically update Java SDK
1 parent aedec34 commit 3560f9d

12 files changed

Lines changed: 444 additions & 22 deletions

‎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.12.0</version>
11+
<version>1.13.0</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
@@ -30,7 +30,7 @@ private ClientOptions(Environment environment, Map<String, String> headers,
3030
this.environment = environment;
3131
this.headers = new HashMap<>();
3232
this.headers.putAll(headers);
33-
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.3892");}});
33+
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.3999");}});
3434
this.headerSuppliers = headerSuppliers;
3535
this.httpClient = httpClient;
3636
this.timeout = timeout;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package so.trophy.errors;
2+
3+
/**
4+
* This file was auto-generated by Fern from our API Definition.
5+
*/
6+
7+
8+
import so.trophy.core.TrophyApiApiException;
9+
import okhttp3.Response;
10+
import so.trophy.types.ErrorBody;
11+
12+
public final class ForbiddenError extends TrophyApiApiException {
13+
/**
14+
* The body of the response that triggered the exception.
15+
*/
16+
private final ErrorBody body;
17+
18+
public ForbiddenError(ErrorBody body) {
19+
super("ForbiddenError", 403, body);
20+
this.body = body;
21+
}
22+
23+
public ForbiddenError(ErrorBody body, Response rawResponse) {
24+
super("ForbiddenError", 403, body, rawResponse);
25+
this.body = body;
26+
}
27+
28+
/**
29+
* @return the body
30+
*/
31+
@java.lang.Override
32+
public ErrorBody body() {
33+
return this.body;
34+
}
35+
}

‎src/main/java/so/trophy/resources/users/AsyncRawUsersClient.java‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import so.trophy.core.TrophyApiException;
1717
import so.trophy.core.TrophyApiHttpResponse;
1818
import so.trophy.errors.BadRequestError;
19+
import so.trophy.errors.ForbiddenError;
1920
import so.trophy.errors.NotFoundError;
2021
import so.trophy.errors.UnauthorizedError;
2122
import so.trophy.errors.UnprocessableEntityError;
@@ -437,23 +438,23 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
437438
}
438439

439440
/**
440-
* Update a user's notification preferences.
441+
* Update a user's notification and streak preferences. Streak preferences require streak customization to be enabled in your Trophy dashboard settings.
441442
*/
442443
public CompletableFuture<TrophyApiHttpResponse<UserPreferencesResponse>> updatePreferences(
443444
String id) {
444445
return updatePreferences(id,UpdateUserPreferencesRequest.builder().build());
445446
}
446447

447448
/**
448-
* Update a user's notification preferences.
449+
* Update a user's notification and streak preferences. Streak preferences require streak customization to be enabled in your Trophy dashboard settings.
449450
*/
450451
public CompletableFuture<TrophyApiHttpResponse<UserPreferencesResponse>> updatePreferences(
451452
String id, UpdateUserPreferencesRequest request) {
452453
return updatePreferences(id,request,null);
453454
}
454455

455456
/**
456-
* Update a user's notification preferences.
457+
* Update a user's notification and streak preferences. Streak preferences require streak customization to be enabled in your Trophy dashboard settings.
457458
*/
458459
public CompletableFuture<TrophyApiHttpResponse<UserPreferencesResponse>> updatePreferences(
459460
String id, UpdateUserPreferencesRequest request, RequestOptions requestOptions) {
@@ -495,6 +496,8 @@ public void onResponse(@NotNull Call call, @NotNull Response response) throws IO
495496
switch (response.code()) {
496497
case 401:future.completeExceptionally(new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorBody.class), response));
497498
return;
499+
case 403:future.completeExceptionally(new ForbiddenError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorBody.class), response));
500+
return;
498501
case 404:future.completeExceptionally(new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorBody.class), response));
499502
return;
500503
case 422:future.completeExceptionally(new UnprocessableEntityError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorBody.class), response));

‎src/main/java/so/trophy/resources/users/AsyncUsersClient.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,22 +137,22 @@ public CompletableFuture<UserPreferencesResponse> getPreferences(String id,
137137
}
138138

139139
/**
140-
* Update a user's notification preferences.
140+
* Update a user's notification and streak preferences. Streak preferences require streak customization to be enabled in your Trophy dashboard settings.
141141
*/
142142
public CompletableFuture<UserPreferencesResponse> updatePreferences(String id) {
143143
return this.rawClient.updatePreferences(id).thenApply(response -> response.body());
144144
}
145145

146146
/**
147-
* Update a user's notification preferences.
147+
* Update a user's notification and streak preferences. Streak preferences require streak customization to be enabled in your Trophy dashboard settings.
148148
*/
149149
public CompletableFuture<UserPreferencesResponse> updatePreferences(String id,
150150
UpdateUserPreferencesRequest request) {
151151
return this.rawClient.updatePreferences(id, request).thenApply(response -> response.body());
152152
}
153153

154154
/**
155-
* Update a user's notification preferences.
155+
* Update a user's notification and streak preferences. Streak preferences require streak customization to be enabled in your Trophy dashboard settings.
156156
*/
157157
public CompletableFuture<UserPreferencesResponse> updatePreferences(String id,
158158
UpdateUserPreferencesRequest request, RequestOptions requestOptions) {

‎src/main/java/so/trophy/resources/users/RawUsersClient.java‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import so.trophy.core.TrophyApiException;
1717
import so.trophy.core.TrophyApiHttpResponse;
1818
import so.trophy.errors.BadRequestError;
19+
import so.trophy.errors.ForbiddenError;
1920
import so.trophy.errors.NotFoundError;
2021
import so.trophy.errors.UnauthorizedError;
2122
import so.trophy.errors.UnprocessableEntityError;
@@ -348,22 +349,22 @@ public TrophyApiHttpResponse<UserPreferencesResponse> getPreferences(String id,
348349
}
349350

350351
/**
351-
* Update a user's notification preferences.
352+
* Update a user's notification and streak preferences. Streak preferences require streak customization to be enabled in your Trophy dashboard settings.
352353
*/
353354
public TrophyApiHttpResponse<UserPreferencesResponse> updatePreferences(String id) {
354355
return updatePreferences(id,UpdateUserPreferencesRequest.builder().build());
355356
}
356357

357358
/**
358-
* Update a user's notification preferences.
359+
* Update a user's notification and streak preferences. Streak preferences require streak customization to be enabled in your Trophy dashboard settings.
359360
*/
360361
public TrophyApiHttpResponse<UserPreferencesResponse> updatePreferences(String id,
361362
UpdateUserPreferencesRequest request) {
362363
return updatePreferences(id,request,null);
363364
}
364365

365366
/**
366-
* Update a user's notification preferences.
367+
* Update a user's notification and streak preferences. Streak preferences require streak customization to be enabled in your Trophy dashboard settings.
367368
*/
368369
public TrophyApiHttpResponse<UserPreferencesResponse> updatePreferences(String id,
369370
UpdateUserPreferencesRequest request, RequestOptions requestOptions) {
@@ -400,6 +401,7 @@ public TrophyApiHttpResponse<UserPreferencesResponse> updatePreferences(String i
400401
try {
401402
switch (response.code()) {
402403
case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorBody.class), response);
404+
case 403:throw new ForbiddenError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorBody.class), response);
403405
case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorBody.class), response);
404406
case 422:throw new UnprocessableEntityError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorBody.class), response);
405407
}

‎src/main/java/so/trophy/resources/users/UsersClient.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,22 +133,22 @@ public UserPreferencesResponse getPreferences(String id, RequestOptions requestO
133133
}
134134

135135
/**
136-
* Update a user's notification preferences.
136+
* Update a user's notification and streak preferences. Streak preferences require streak customization to be enabled in your Trophy dashboard settings.
137137
*/
138138
public UserPreferencesResponse updatePreferences(String id) {
139139
return this.rawClient.updatePreferences(id).body();
140140
}
141141

142142
/**
143-
* Update a user's notification preferences.
143+
* Update a user's notification and streak preferences. Streak preferences require streak customization to be enabled in your Trophy dashboard settings.
144144
*/
145145
public UserPreferencesResponse updatePreferences(String id,
146146
UpdateUserPreferencesRequest request) {
147147
return this.rawClient.updatePreferences(id, request).body();
148148
}
149149

150150
/**
151-
* Update a user's notification preferences.
151+
* Update a user's notification and streak preferences. Streak preferences require streak customization to be enabled in your Trophy dashboard settings.
152152
*/
153153
public UserPreferencesResponse updatePreferences(String id, UpdateUserPreferencesRequest request,
154154
RequestOptions requestOptions) {

‎src/main/java/so/trophy/resources/users/requests/UpdateUserPreferencesRequest.java‎

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.Objects;
2222
import java.util.Optional;
2323
import so.trophy.types.NotificationPreferences;
24+
import so.trophy.types.StreakPreferences;
2425

2526
@JsonInclude(JsonInclude.Include.NON_ABSENT)
2627
@JsonDeserialize(
@@ -29,11 +30,14 @@
2930
public final class UpdateUserPreferencesRequest {
3031
private final Optional<NotificationPreferences> notifications;
3132

33+
private final Optional<StreakPreferences> streak;
34+
3235
private final Map<String, Object> additionalProperties;
3336

3437
private UpdateUserPreferencesRequest(Optional<NotificationPreferences> notifications,
35-
Map<String, Object> additionalProperties) {
38+
Optional<StreakPreferences> streak, Map<String, Object> additionalProperties) {
3639
this.notifications = notifications;
40+
this.streak = streak;
3741
this.additionalProperties = additionalProperties;
3842
}
3943

@@ -42,6 +46,11 @@ public Optional<NotificationPreferences> getNotifications() {
4246
return notifications;
4347
}
4448

49+
@JsonProperty("streak")
50+
public Optional<StreakPreferences> getStreak() {
51+
return streak;
52+
}
53+
4554
@java.lang.Override
4655
public boolean equals(Object other) {
4756
if (this == other) return true;
@@ -54,12 +63,12 @@ public Map<String, Object> getAdditionalProperties() {
5463
}
5564

5665
private boolean equalTo(UpdateUserPreferencesRequest other) {
57-
return notifications.equals(other.notifications);
66+
return notifications.equals(other.notifications) && streak.equals(other.streak);
5867
}
5968

6069
@java.lang.Override
6170
public int hashCode() {
62-
return Objects.hash(this.notifications);
71+
return Objects.hash(this.notifications, this.streak);
6372
}
6473

6574
@java.lang.Override
@@ -77,6 +86,8 @@ public static Builder builder() {
7786
public static final class Builder {
7887
private Optional<NotificationPreferences> notifications = Optional.empty();
7988

89+
private Optional<StreakPreferences> streak = Optional.empty();
90+
8091
@JsonAnySetter
8192
private Map<String, Object> additionalProperties = new HashMap<>();
8293

@@ -85,6 +96,7 @@ private Builder() {
8596

8697
public Builder from(UpdateUserPreferencesRequest other) {
8798
notifications(other.getNotifications());
99+
streak(other.getStreak());
88100
return this;
89101
}
90102

@@ -102,8 +114,22 @@ public Builder notifications(NotificationPreferences notifications) {
102114
return this;
103115
}
104116

117+
@JsonSetter(
118+
value = "streak",
119+
nulls = Nulls.SKIP
120+
)
121+
public Builder streak(Optional<StreakPreferences> streak) {
122+
this.streak = streak;
123+
return this;
124+
}
125+
126+
public Builder streak(StreakPreferences streak) {
127+
this.streak = Optional.ofNullable(streak);
128+
return this;
129+
}
130+
105131
public UpdateUserPreferencesRequest build() {
106-
return new UpdateUserPreferencesRequest(notifications, additionalProperties);
132+
return new UpdateUserPreferencesRequest(notifications, streak, additionalProperties);
107133
}
108134
}
109135
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package so.trophy.types;
2+
3+
/**
4+
* This file was auto-generated by Fern from our API Definition.
5+
*/
6+
7+
8+
import com.fasterxml.jackson.annotation.JsonValue;
9+
import java.lang.String;
10+
11+
public enum StreakEvaluationModePreference {
12+
OR("OR"),
13+
14+
AND("AND");
15+
16+
private final String value;
17+
18+
StreakEvaluationModePreference(String value) {
19+
this.value = value;
20+
}
21+
22+
@JsonValue
23+
@java.lang.Override
24+
public String toString() {
25+
return this.value;
26+
}
27+
}

0 commit comments

Comments
 (0)