Skip to content

Commit 67808c0

Browse files
Automatically update Java SDK
1 parent d06673b commit 67808c0

File tree

5 files changed

+68
-68
lines changed

5 files changed

+68
-68
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.24</version>
11+
<version>1.0.25</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.1608");}});
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.1637");}});
3232
this.headerSuppliers = headerSuppliers;
3333
this.httpClient = httpClient;
3434
this.timeout = timeout;

src/main/java/so/trophy/resources/leaderboards/LeaderboardsClient.java

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@
2626
import okhttp3.Response;
2727
import okhttp3.ResponseBody;
2828
import so.trophy.resources.leaderboards.requests.LeaderboardsGetRequest;
29-
import so.trophy.resources.leaderboards.requests.UsersLeaderboardsRequest;
3029
import so.trophy.types.ErrorBody;
3130
import so.trophy.types.LeaderboardResponse;
3231
import so.trophy.types.LeaderboardResponseWithRankings;
33-
import so.trophy.types.UserLeaderboardResponse;
3432

3533
public class LeaderboardsClient {
3634
protected final ClientOptions clientOptions;
@@ -153,65 +151,4 @@ public LeaderboardResponseWithRankings get(String key, LeaderboardsGetRequest re
153151
throw new TrophyApiException("Network error executing HTTP request", e);
154152
}
155153
}
156-
157-
/**
158-
* Get a user's rank, value, and history for a specific leaderboard.
159-
*/
160-
public UserLeaderboardResponse usersLeaderboards(String userId, String key) {
161-
return usersLeaderboards(userId,key,UsersLeaderboardsRequest.builder().build());
162-
}
163-
164-
/**
165-
* Get a user's rank, value, and history for a specific leaderboard.
166-
*/
167-
public UserLeaderboardResponse usersLeaderboards(String userId, String key,
168-
UsersLeaderboardsRequest request) {
169-
return usersLeaderboards(userId,key,request,null);
170-
}
171-
172-
/**
173-
* Get a user's rank, value, and history for a specific leaderboard.
174-
*/
175-
public UserLeaderboardResponse usersLeaderboards(String userId, String key,
176-
UsersLeaderboardsRequest request, RequestOptions requestOptions) {
177-
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder()
178-
179-
.addPathSegments("users")
180-
.addPathSegment(userId)
181-
.addPathSegments("leaderboards")
182-
.addPathSegment(key);if (request.getRun().isPresent()) {
183-
httpUrl.addQueryParameter("run", request.getRun().get());
184-
}
185-
Request.Builder _requestBuilder = new Request.Builder()
186-
.url(httpUrl.build())
187-
.method("GET", null)
188-
.headers(Headers.of(clientOptions.headers(requestOptions)))
189-
.addHeader("Content-Type", "application/json").addHeader("Accept", "application/json");
190-
Request okhttpRequest = _requestBuilder.build();
191-
OkHttpClient client = clientOptions.httpClient();
192-
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
193-
client = clientOptions.httpClientWithTimeout(requestOptions);
194-
}
195-
try (Response response = client.newCall(okhttpRequest).execute()) {
196-
ResponseBody responseBody = response.body();
197-
if (response.isSuccessful()) {
198-
return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UserLeaderboardResponse.class);
199-
}
200-
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
201-
try {
202-
switch (response.code()) {
203-
case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorBody.class));
204-
case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorBody.class));
205-
case 422:throw new UnprocessableEntityError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorBody.class));
206-
}
207-
}
208-
catch (JsonProcessingException ignored) {
209-
// unable to map error response, throwing generic error
210-
}
211-
throw new TrophyApiApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class));
212-
}
213-
catch (IOException e) {
214-
throw new TrophyApiException("Network error executing HTTP request", e);
215-
}
216-
}
217-
}
154+
}

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

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import okhttp3.Response;
3030
import okhttp3.ResponseBody;
3131
import so.trophy.resources.users.requests.UsersAchievementsRequest;
32+
import so.trophy.resources.users.requests.UsersLeaderboardsRequest;
3233
import so.trophy.resources.users.requests.UsersMetricEventSummaryRequest;
3334
import so.trophy.resources.users.requests.UsersPointsEventSummaryRequest;
3435
import so.trophy.resources.users.requests.UsersPointsRequest;
@@ -43,6 +44,7 @@
4344
import so.trophy.types.UpdatedUser;
4445
import so.trophy.types.UpsertedUser;
4546
import so.trophy.types.User;
47+
import so.trophy.types.UserLeaderboardResponse;
4648

4749
public class UsersClient {
4850
protected final ClientOptions clientOptions;
@@ -677,4 +679,65 @@ public List<UsersPointsEventSummaryResponseItem> pointsEventSummary(String id, S
677679
throw new TrophyApiException("Network error executing HTTP request", e);
678680
}
679681
}
680-
}
682+
683+
/**
684+
* Get a user's rank, value, and history for a specific leaderboard.
685+
*/
686+
public UserLeaderboardResponse leaderboards(String id, String key) {
687+
return leaderboards(id,key,UsersLeaderboardsRequest.builder().build());
688+
}
689+
690+
/**
691+
* Get a user's rank, value, and history for a specific leaderboard.
692+
*/
693+
public UserLeaderboardResponse leaderboards(String id, String key,
694+
UsersLeaderboardsRequest request) {
695+
return leaderboards(id,key,request,null);
696+
}
697+
698+
/**
699+
* Get a user's rank, value, and history for a specific leaderboard.
700+
*/
701+
public UserLeaderboardResponse leaderboards(String id, String key,
702+
UsersLeaderboardsRequest request, RequestOptions requestOptions) {
703+
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()).newBuilder()
704+
705+
.addPathSegments("users")
706+
.addPathSegment(id)
707+
.addPathSegments("leaderboards")
708+
.addPathSegment(key);if (request.getRun().isPresent()) {
709+
httpUrl.addQueryParameter("run", request.getRun().get());
710+
}
711+
Request.Builder _requestBuilder = new Request.Builder()
712+
.url(httpUrl.build())
713+
.method("GET", null)
714+
.headers(Headers.of(clientOptions.headers(requestOptions)))
715+
.addHeader("Content-Type", "application/json").addHeader("Accept", "application/json");
716+
Request okhttpRequest = _requestBuilder.build();
717+
OkHttpClient client = clientOptions.httpClient();
718+
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
719+
client = clientOptions.httpClientWithTimeout(requestOptions);
720+
}
721+
try (Response response = client.newCall(okhttpRequest).execute()) {
722+
ResponseBody responseBody = response.body();
723+
if (response.isSuccessful()) {
724+
return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), UserLeaderboardResponse.class);
725+
}
726+
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
727+
try {
728+
switch (response.code()) {
729+
case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorBody.class));
730+
case 404:throw new NotFoundError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorBody.class));
731+
case 422:throw new UnprocessableEntityError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorBody.class));
732+
}
733+
}
734+
catch (JsonProcessingException ignored) {
735+
// unable to map error response, throwing generic error
736+
}
737+
throw new TrophyApiApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class));
738+
}
739+
catch (IOException e) {
740+
throw new TrophyApiException("Network error executing HTTP request", e);
741+
}
742+
}
743+
}

src/main/java/so/trophy/resources/leaderboards/requests/UsersLeaderboardsRequest.java renamed to src/main/java/so/trophy/resources/users/requests/UsersLeaderboardsRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package so.trophy.resources.leaderboards.requests;
1+
package so.trophy.resources.users.requests;
22

33
/**
44
* This file was auto-generated by Fern from our API Definition.

0 commit comments

Comments
 (0)