Skip to content

Commit aedec34

Browse files
Automatically update Java SDK
1 parent 7cd2d4f commit aedec34

10 files changed

Lines changed: 59 additions & 605 deletions

File tree

‎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.11.0</version>
11+
<version>1.12.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.3815");}});
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");}});
3434
this.headerSuppliers = headerSuppliers;
3535
this.httpClient = httpClient;
3636
this.timeout = timeout;

‎src/main/java/so/trophy/resources/streaks/AsyncRawStreaksClient.java‎

Lines changed: 1 addition & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,8 @@
3232
import okhttp3.ResponseBody;
3333
import org.jetbrains.annotations.NotNull;
3434
import so.trophy.resources.streaks.requests.StreaksListRequest;
35-
import so.trophy.resources.streaks.requests.StreaksRankingsRequest;
3635
import so.trophy.types.BulkStreakResponseItem;
3736
import so.trophy.types.ErrorBody;
38-
import so.trophy.types.StreakRankingUser;
3937

4038
public class AsyncRawStreaksClient {
4139
protected final ClientOptions clientOptions;
@@ -115,79 +113,4 @@ public void onFailure(@NotNull Call call, @NotNull IOException e) {
115113
});
116114
return future;
117115
}
118-
119-
/**
120-
* Get the top users by streak length (active or longest).
121-
*/
122-
public CompletableFuture<TrophyApiHttpResponse<List<StreakRankingUser>>> rankings() {
123-
return rankings(StreaksRankingsRequest.builder().build());
124-
}
125-
126-
/**
127-
* Get the top users by streak length (active or longest).
128-
*/
129-
public CompletableFuture<TrophyApiHttpResponse<List<StreakRankingUser>>> rankings(
130-
StreaksRankingsRequest request) {
131-
return rankings(request,null);
132-
}
133-
134-
/**
135-
* Get the top users by streak length (active or longest).
136-
*/
137-
public CompletableFuture<TrophyApiHttpResponse<List<StreakRankingUser>>> rankings(
138-
StreaksRankingsRequest request, RequestOptions requestOptions) {
139-
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getApiURL()).newBuilder()
140-
141-
.addPathSegments("streaks/rankings");if (request.getLimit().isPresent()) {
142-
QueryStringMapper.addQueryParameter(httpUrl, "limit", request.getLimit().get(), false);
143-
}
144-
if (request.getType().isPresent()) {
145-
QueryStringMapper.addQueryParameter(httpUrl, "type", request.getType().get(), false);
146-
}
147-
Request.Builder _requestBuilder = new Request.Builder()
148-
.url(httpUrl.build())
149-
.method("GET", null)
150-
.headers(Headers.of(clientOptions.headers(requestOptions)))
151-
.addHeader("Accept", "application/json");
152-
Request okhttpRequest = _requestBuilder.build();
153-
OkHttpClient client = clientOptions.httpClient();
154-
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
155-
client = clientOptions.httpClientWithTimeout(requestOptions);
156-
}
157-
CompletableFuture<TrophyApiHttpResponse<List<StreakRankingUser>>> future = new CompletableFuture<>();
158-
client.newCall(okhttpRequest).enqueue(new Callback() {
159-
@Override
160-
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
161-
try (ResponseBody responseBody = response.body()) {
162-
if (response.isSuccessful()) {
163-
future.complete(new TrophyApiHttpResponse<>(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), new TypeReference<List<StreakRankingUser>>() {}), response));
164-
return;
165-
}
166-
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
167-
try {
168-
switch (response.code()) {
169-
case 401:future.completeExceptionally(new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorBody.class), response));
170-
return;
171-
case 422:future.completeExceptionally(new UnprocessableEntityError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorBody.class), response));
172-
return;
173-
}
174-
}
175-
catch (JsonProcessingException ignored) {
176-
// unable to map error response, throwing generic error
177-
}
178-
future.completeExceptionally(new TrophyApiApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response));
179-
return;
180-
}
181-
catch (IOException e) {
182-
future.completeExceptionally(new TrophyApiException("Network error executing HTTP request", e));
183-
}
184-
}
185-
186-
@Override
187-
public void onFailure(@NotNull Call call, @NotNull IOException e) {
188-
future.completeExceptionally(new TrophyApiException("Network error executing HTTP request", e));
189-
}
190-
});
191-
return future;
192-
}
193-
}
116+
}

‎src/main/java/so/trophy/resources/streaks/AsyncStreaksClient.java‎

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
import java.util.List;
1111
import java.util.concurrent.CompletableFuture;
1212
import so.trophy.resources.streaks.requests.StreaksListRequest;
13-
import so.trophy.resources.streaks.requests.StreaksRankingsRequest;
1413
import so.trophy.types.BulkStreakResponseItem;
15-
import so.trophy.types.StreakRankingUser;
1614

1715
public class AsyncStreaksClient {
1816
protected final ClientOptions clientOptions;
@@ -52,26 +50,4 @@ public CompletableFuture<List<BulkStreakResponseItem>> list(StreaksListRequest r
5250
RequestOptions requestOptions) {
5351
return this.rawClient.list(request, requestOptions).thenApply(response -> response.body());
5452
}
55-
56-
/**
57-
* Get the top users by streak length (active or longest).
58-
*/
59-
public CompletableFuture<List<StreakRankingUser>> rankings() {
60-
return this.rawClient.rankings().thenApply(response -> response.body());
61-
}
62-
63-
/**
64-
* Get the top users by streak length (active or longest).
65-
*/
66-
public CompletableFuture<List<StreakRankingUser>> rankings(StreaksRankingsRequest request) {
67-
return this.rawClient.rankings(request).thenApply(response -> response.body());
68-
}
69-
70-
/**
71-
* Get the top users by streak length (active or longest).
72-
*/
73-
public CompletableFuture<List<StreakRankingUser>> rankings(StreaksRankingsRequest request,
74-
RequestOptions requestOptions) {
75-
return this.rawClient.rankings(request, requestOptions).thenApply(response -> response.body());
76-
}
7753
}

‎src/main/java/so/trophy/resources/streaks/RawStreaksClient.java‎

Lines changed: 1 addition & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@
2727
import okhttp3.Response;
2828
import okhttp3.ResponseBody;
2929
import so.trophy.resources.streaks.requests.StreaksListRequest;
30-
import so.trophy.resources.streaks.requests.StreaksRankingsRequest;
3130
import so.trophy.types.BulkStreakResponseItem;
3231
import so.trophy.types.ErrorBody;
33-
import so.trophy.types.StreakRankingUser;
3432

3533
public class RawStreaksClient {
3634
protected final ClientOptions clientOptions;
@@ -94,63 +92,4 @@ public TrophyApiHttpResponse<List<BulkStreakResponseItem>> list(StreaksListReque
9492
throw new TrophyApiException("Network error executing HTTP request", e);
9593
}
9694
}
97-
98-
/**
99-
* Get the top users by streak length (active or longest).
100-
*/
101-
public TrophyApiHttpResponse<List<StreakRankingUser>> rankings() {
102-
return rankings(StreaksRankingsRequest.builder().build());
103-
}
104-
105-
/**
106-
* Get the top users by streak length (active or longest).
107-
*/
108-
public TrophyApiHttpResponse<List<StreakRankingUser>> rankings(StreaksRankingsRequest request) {
109-
return rankings(request,null);
110-
}
111-
112-
/**
113-
* Get the top users by streak length (active or longest).
114-
*/
115-
public TrophyApiHttpResponse<List<StreakRankingUser>> rankings(StreaksRankingsRequest request,
116-
RequestOptions requestOptions) {
117-
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getApiURL()).newBuilder()
118-
119-
.addPathSegments("streaks/rankings");if (request.getLimit().isPresent()) {
120-
QueryStringMapper.addQueryParameter(httpUrl, "limit", request.getLimit().get(), false);
121-
}
122-
if (request.getType().isPresent()) {
123-
QueryStringMapper.addQueryParameter(httpUrl, "type", request.getType().get(), false);
124-
}
125-
Request.Builder _requestBuilder = new Request.Builder()
126-
.url(httpUrl.build())
127-
.method("GET", null)
128-
.headers(Headers.of(clientOptions.headers(requestOptions)))
129-
.addHeader("Accept", "application/json");
130-
Request okhttpRequest = _requestBuilder.build();
131-
OkHttpClient client = clientOptions.httpClient();
132-
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
133-
client = clientOptions.httpClientWithTimeout(requestOptions);
134-
}
135-
try (Response response = client.newCall(okhttpRequest).execute()) {
136-
ResponseBody responseBody = response.body();
137-
if (response.isSuccessful()) {
138-
return new TrophyApiHttpResponse<>(ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), new TypeReference<List<StreakRankingUser>>() {}), response);
139-
}
140-
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
141-
try {
142-
switch (response.code()) {
143-
case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorBody.class), response);
144-
case 422:throw new UnprocessableEntityError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, ErrorBody.class), response);
145-
}
146-
}
147-
catch (JsonProcessingException ignored) {
148-
// unable to map error response, throwing generic error
149-
}
150-
throw new TrophyApiApiException("Error with status code " + response.code(), response.code(), ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
151-
}
152-
catch (IOException e) {
153-
throw new TrophyApiException("Network error executing HTTP request", e);
154-
}
155-
}
156-
}
95+
}

‎src/main/java/so/trophy/resources/streaks/StreaksClient.java‎

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
import so.trophy.core.RequestOptions;
1010
import java.util.List;
1111
import so.trophy.resources.streaks.requests.StreaksListRequest;
12-
import so.trophy.resources.streaks.requests.StreaksRankingsRequest;
1312
import so.trophy.types.BulkStreakResponseItem;
14-
import so.trophy.types.StreakRankingUser;
1513

1614
public class StreaksClient {
1715
protected final ClientOptions clientOptions;
@@ -51,26 +49,4 @@ public List<BulkStreakResponseItem> list(StreaksListRequest request,
5149
RequestOptions requestOptions) {
5250
return this.rawClient.list(request, requestOptions).body();
5351
}
54-
55-
/**
56-
* Get the top users by streak length (active or longest).
57-
*/
58-
public List<StreakRankingUser> rankings() {
59-
return this.rawClient.rankings().body();
60-
}
61-
62-
/**
63-
* Get the top users by streak length (active or longest).
64-
*/
65-
public List<StreakRankingUser> rankings(StreaksRankingsRequest request) {
66-
return this.rawClient.rankings(request).body();
67-
}
68-
69-
/**
70-
* Get the top users by streak length (active or longest).
71-
*/
72-
public List<StreakRankingUser> rankings(StreaksRankingsRequest request,
73-
RequestOptions requestOptions) {
74-
return this.rawClient.rankings(request, requestOptions).body();
75-
}
7652
}

0 commit comments

Comments
 (0)