Skip to content

Commit b0558c5

Browse files
Automatically update Java SDK
1 parent 63b4bf3 commit b0558c5

10 files changed

Lines changed: 511 additions & 3 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.24.0</version>
11+
<version>1.25.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/.fern/metadata.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"enable-forward-compatible-enums": false,
77
"retry-status-codes": "legacy"
88
},
9-
"originGitCommit": "a26ab659060cc5cbecdc6795eb97b136e2694cdd",
9+
"originGitCommit": "19712978734e8ed2f50ee8914cc8ff1f3a01c459",
1010
"originGitCommitIsDirty": false,
1111
"invokedBy": "ci",
1212
"ciProvider": "github"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ private ClientOptions(Environment environment, Map<String, String> headers,
3535
this.environment = environment;
3636
this.headers = new HashMap<>();
3737
this.headers.putAll(headers);
38-
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.7441");}});
38+
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.7518");}});
3939
this.headerSuppliers = headerSuppliers;
4040
this.httpClient = httpClient;
4141
this.timeout = timeout;

‎src/main/java/so/trophy/src/main/java/resources/admin/AdminClient.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import so.trophy.resources.admin.achievements.AchievementsClient;
1212
import so.trophy.resources.admin.applicationapikeys.ApplicationApiKeysClient;
1313
import so.trophy.resources.admin.attributes.AttributesClient;
14+
import so.trophy.resources.admin.environments.EnvironmentsClient;
1415
import so.trophy.resources.admin.leaderboards.LeaderboardsClient;
1516
import so.trophy.resources.admin.metrics.MetricsClient;
1617
import so.trophy.resources.admin.points.PointsClient;
@@ -35,6 +36,8 @@ public class AdminClient {
3536

3637
protected final Supplier<ApplicationApiKeysClient> applicationApiKeysClient;
3738

39+
protected final Supplier<EnvironmentsClient> environmentsClient;
40+
3841
protected final Supplier<TenantsClient> tenantsClient;
3942

4043
protected final Supplier<PointsClient> pointsClient;
@@ -48,6 +51,7 @@ public AdminClient(ClientOptions clientOptions) {
4851
this.streaksClient = Suppliers.memoize(() -> new StreaksClient(clientOptions));
4952
this.settingsClient = Suppliers.memoize(() -> new SettingsClient(clientOptions));
5053
this.applicationApiKeysClient = Suppliers.memoize(() -> new ApplicationApiKeysClient(clientOptions));
54+
this.environmentsClient = Suppliers.memoize(() -> new EnvironmentsClient(clientOptions));
5155
this.tenantsClient = Suppliers.memoize(() -> new TenantsClient(clientOptions));
5256
this.pointsClient = Suppliers.memoize(() -> new PointsClient(clientOptions));
5357
}
@@ -80,6 +84,10 @@ public ApplicationApiKeysClient applicationApiKeys() {
8084
return this.applicationApiKeysClient.get();
8185
}
8286

87+
public EnvironmentsClient environments() {
88+
return this.environmentsClient.get();
89+
}
90+
8391
public TenantsClient tenants() {
8492
return this.tenantsClient.get();
8593
}

‎src/main/java/so/trophy/src/main/java/resources/admin/AsyncAdminClient.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import so.trophy.resources.admin.achievements.AsyncAchievementsClient;
1212
import so.trophy.resources.admin.applicationapikeys.AsyncApplicationApiKeysClient;
1313
import so.trophy.resources.admin.attributes.AsyncAttributesClient;
14+
import so.trophy.resources.admin.environments.AsyncEnvironmentsClient;
1415
import so.trophy.resources.admin.leaderboards.AsyncLeaderboardsClient;
1516
import so.trophy.resources.admin.metrics.AsyncMetricsClient;
1617
import so.trophy.resources.admin.points.AsyncPointsClient;
@@ -35,6 +36,8 @@ public class AsyncAdminClient {
3536

3637
protected final Supplier<AsyncApplicationApiKeysClient> applicationApiKeysClient;
3738

39+
protected final Supplier<AsyncEnvironmentsClient> environmentsClient;
40+
3841
protected final Supplier<AsyncTenantsClient> tenantsClient;
3942

4043
protected final Supplier<AsyncPointsClient> pointsClient;
@@ -48,6 +51,7 @@ public AsyncAdminClient(ClientOptions clientOptions) {
4851
this.streaksClient = Suppliers.memoize(() -> new AsyncStreaksClient(clientOptions));
4952
this.settingsClient = Suppliers.memoize(() -> new AsyncSettingsClient(clientOptions));
5053
this.applicationApiKeysClient = Suppliers.memoize(() -> new AsyncApplicationApiKeysClient(clientOptions));
54+
this.environmentsClient = Suppliers.memoize(() -> new AsyncEnvironmentsClient(clientOptions));
5155
this.tenantsClient = Suppliers.memoize(() -> new AsyncTenantsClient(clientOptions));
5256
this.pointsClient = Suppliers.memoize(() -> new AsyncPointsClient(clientOptions));
5357
}
@@ -80,6 +84,10 @@ public AsyncApplicationApiKeysClient applicationApiKeys() {
8084
return this.applicationApiKeysClient.get();
8185
}
8286

87+
public AsyncEnvironmentsClient environments() {
88+
return this.environmentsClient.get();
89+
}
90+
8391
public AsyncTenantsClient tenants() {
8492
return this.tenantsClient.get();
8593
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package so.trophy.src.main.java.resources.admin.environments;
2+
3+
/**
4+
* This file was auto-generated by Fern from our API Definition.
5+
*/
6+
7+
8+
import so.trophy.core.ClientOptions;
9+
import so.trophy.core.RequestOptions;
10+
import java.util.List;
11+
import java.util.concurrent.CompletableFuture;
12+
import so.trophy.types.AdminEnvironment;
13+
14+
public class AsyncEnvironmentsClient {
15+
protected final ClientOptions clientOptions;
16+
17+
private final AsyncRawEnvironmentsClient rawClient;
18+
19+
public AsyncEnvironmentsClient(ClientOptions clientOptions) {
20+
this.clientOptions = clientOptions;
21+
this.rawClient = new AsyncRawEnvironmentsClient(clientOptions);
22+
}
23+
24+
/**
25+
* Get responses with HTTP metadata like headers
26+
*/
27+
public AsyncRawEnvironmentsClient withRawResponse() {
28+
return this.rawClient;
29+
}
30+
31+
/**
32+
* List active environments.
33+
*/
34+
public CompletableFuture<List<AdminEnvironment>> list() {
35+
return this.rawClient.list().thenApply(response -> response.body());
36+
}
37+
38+
/**
39+
* List active environments.
40+
*/
41+
public CompletableFuture<List<AdminEnvironment>> list(RequestOptions requestOptions) {
42+
return this.rawClient.list(requestOptions).thenApply(response -> response.body());
43+
}
44+
}
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
package so.trophy.src.main.java.resources.admin.environments;
2+
3+
/**
4+
* This file was auto-generated by Fern from our API Definition.
5+
*/
6+
7+
8+
import com.fasterxml.jackson.core.JsonProcessingException;
9+
import com.fasterxml.jackson.core.type.TypeReference;
10+
import so.trophy.core.ClientOptions;
11+
import so.trophy.core.ObjectMappers;
12+
import so.trophy.core.RequestOptions;
13+
import so.trophy.core.RetryInterceptor;
14+
import so.trophy.core.TrophyApiApiException;
15+
import so.trophy.core.TrophyApiException;
16+
import so.trophy.core.TrophyApiHttpResponse;
17+
import so.trophy.errors.UnauthorizedError;
18+
import so.trophy.errors.UnprocessableEntityError;
19+
import java.io.IOException;
20+
import java.lang.Object;
21+
import java.lang.Override;
22+
import java.lang.String;
23+
import java.util.List;
24+
import java.util.concurrent.CompletableFuture;
25+
import okhttp3.Call;
26+
import okhttp3.Callback;
27+
import okhttp3.Headers;
28+
import okhttp3.HttpUrl;
29+
import okhttp3.OkHttpClient;
30+
import okhttp3.Request;
31+
import okhttp3.Response;
32+
import okhttp3.ResponseBody;
33+
import org.jetbrains.annotations.NotNull;
34+
import so.trophy.types.AdminEnvironment;
35+
36+
public class AsyncRawEnvironmentsClient {
37+
protected final ClientOptions clientOptions;
38+
39+
public AsyncRawEnvironmentsClient(ClientOptions clientOptions) {
40+
this.clientOptions = clientOptions;
41+
}
42+
43+
/**
44+
* List active environments.
45+
*/
46+
public CompletableFuture<TrophyApiHttpResponse<List<AdminEnvironment>>> list() {
47+
return list(null);
48+
}
49+
50+
/**
51+
* List active environments.
52+
*/
53+
public CompletableFuture<TrophyApiHttpResponse<List<AdminEnvironment>>> list(
54+
RequestOptions requestOptions) {
55+
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getAdminURL()).newBuilder()
56+
57+
.addPathSegments("environments");if (requestOptions != null) {
58+
requestOptions.getQueryParameters().forEach((_key, _value) -> {
59+
httpUrl.addQueryParameter(_key, _value);
60+
} );
61+
}
62+
Request okhttpRequest = new Request.Builder()
63+
.url(httpUrl.build())
64+
.method("GET", null)
65+
.headers(Headers.of(clientOptions.headers(requestOptions)))
66+
.addHeader("Accept", "application/json")
67+
.build();
68+
OkHttpClient client = clientOptions.httpClient();
69+
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
70+
client = clientOptions.httpClientWithTimeout(requestOptions);
71+
}
72+
if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) {
73+
okhttpRequest = okhttpRequest.newBuilder().tag(RetryInterceptor.MaxRetriesOverride.class, new RetryInterceptor.MaxRetriesOverride(requestOptions.getMaxRetries().get())).build();
74+
}
75+
CompletableFuture<TrophyApiHttpResponse<List<AdminEnvironment>>> future = new CompletableFuture<>();
76+
client.newCall(okhttpRequest).enqueue(new Callback() {
77+
@Override
78+
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
79+
try (ResponseBody responseBody = response.body()) {
80+
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
81+
if (response.isSuccessful()) {
82+
future.complete(new TrophyApiHttpResponse<>(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, new TypeReference<List<AdminEnvironment>>() {}), response));
83+
return;
84+
}
85+
try {
86+
switch (response.code()) {
87+
case 401:future.completeExceptionally(new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response));
88+
return;
89+
case 422:future.completeExceptionally(new UnprocessableEntityError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response));
90+
return;
91+
}
92+
}
93+
catch (JsonProcessingException ignored) {
94+
// unable to map error response, throwing generic error
95+
}
96+
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
97+
future.completeExceptionally(new TrophyApiApiException("Error with status code " + response.code(), response.code(), errorBody, response));
98+
return;
99+
}
100+
catch (IOException e) {
101+
future.completeExceptionally(new TrophyApiException("Network error executing HTTP request", e));
102+
}
103+
}
104+
105+
@Override
106+
public void onFailure(@NotNull Call call, @NotNull IOException e) {
107+
future.completeExceptionally(new TrophyApiException("Network error executing HTTP request", e));
108+
}
109+
});
110+
return future;
111+
}
112+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package so.trophy.src.main.java.resources.admin.environments;
2+
3+
/**
4+
* This file was auto-generated by Fern from our API Definition.
5+
*/
6+
7+
8+
import so.trophy.core.ClientOptions;
9+
import so.trophy.core.RequestOptions;
10+
import java.util.List;
11+
import so.trophy.types.AdminEnvironment;
12+
13+
public class EnvironmentsClient {
14+
protected final ClientOptions clientOptions;
15+
16+
private final RawEnvironmentsClient rawClient;
17+
18+
public EnvironmentsClient(ClientOptions clientOptions) {
19+
this.clientOptions = clientOptions;
20+
this.rawClient = new RawEnvironmentsClient(clientOptions);
21+
}
22+
23+
/**
24+
* Get responses with HTTP metadata like headers
25+
*/
26+
public RawEnvironmentsClient withRawResponse() {
27+
return this.rawClient;
28+
}
29+
30+
/**
31+
* List active environments.
32+
*/
33+
public List<AdminEnvironment> list() {
34+
return this.rawClient.list().body();
35+
}
36+
37+
/**
38+
* List active environments.
39+
*/
40+
public List<AdminEnvironment> list(RequestOptions requestOptions) {
41+
return this.rawClient.list(requestOptions).body();
42+
}
43+
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
package so.trophy.src.main.java.resources.admin.environments;
2+
3+
/**
4+
* This file was auto-generated by Fern from our API Definition.
5+
*/
6+
7+
8+
import com.fasterxml.jackson.core.JsonProcessingException;
9+
import com.fasterxml.jackson.core.type.TypeReference;
10+
import so.trophy.core.ClientOptions;
11+
import so.trophy.core.ObjectMappers;
12+
import so.trophy.core.RequestOptions;
13+
import so.trophy.core.RetryInterceptor;
14+
import so.trophy.core.TrophyApiApiException;
15+
import so.trophy.core.TrophyApiException;
16+
import so.trophy.core.TrophyApiHttpResponse;
17+
import so.trophy.errors.UnauthorizedError;
18+
import so.trophy.errors.UnprocessableEntityError;
19+
import java.io.IOException;
20+
import java.lang.Object;
21+
import java.lang.String;
22+
import java.util.List;
23+
import okhttp3.Headers;
24+
import okhttp3.HttpUrl;
25+
import okhttp3.OkHttpClient;
26+
import okhttp3.Request;
27+
import okhttp3.Response;
28+
import okhttp3.ResponseBody;
29+
import so.trophy.types.AdminEnvironment;
30+
31+
public class RawEnvironmentsClient {
32+
protected final ClientOptions clientOptions;
33+
34+
public RawEnvironmentsClient(ClientOptions clientOptions) {
35+
this.clientOptions = clientOptions;
36+
}
37+
38+
/**
39+
* List active environments.
40+
*/
41+
public TrophyApiHttpResponse<List<AdminEnvironment>> list() {
42+
return list(null);
43+
}
44+
45+
/**
46+
* List active environments.
47+
*/
48+
public TrophyApiHttpResponse<List<AdminEnvironment>> list(RequestOptions requestOptions) {
49+
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getAdminURL()).newBuilder()
50+
51+
.addPathSegments("environments");if (requestOptions != null) {
52+
requestOptions.getQueryParameters().forEach((_key, _value) -> {
53+
httpUrl.addQueryParameter(_key, _value);
54+
} );
55+
}
56+
Request okhttpRequest = new Request.Builder()
57+
.url(httpUrl.build())
58+
.method("GET", null)
59+
.headers(Headers.of(clientOptions.headers(requestOptions)))
60+
.addHeader("Accept", "application/json")
61+
.build();
62+
OkHttpClient client = clientOptions.httpClient();
63+
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
64+
client = clientOptions.httpClientWithTimeout(requestOptions);
65+
}
66+
if (requestOptions != null && requestOptions.getMaxRetries().isPresent()) {
67+
okhttpRequest = okhttpRequest.newBuilder().tag(RetryInterceptor.MaxRetriesOverride.class, new RetryInterceptor.MaxRetriesOverride(requestOptions.getMaxRetries().get())).build();
68+
}
69+
try (Response response = client.newCall(okhttpRequest).execute()) {
70+
ResponseBody responseBody = response.body();
71+
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
72+
if (response.isSuccessful()) {
73+
return new TrophyApiHttpResponse<>(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, new TypeReference<List<AdminEnvironment>>() {}), response);
74+
}
75+
try {
76+
switch (response.code()) {
77+
case 401:throw new UnauthorizedError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
78+
case 422:throw new UnprocessableEntityError(ObjectMappers.JSON_MAPPER.readValue(responseBodyString, Object.class), response);
79+
}
80+
}
81+
catch (JsonProcessingException ignored) {
82+
// unable to map error response, throwing generic error
83+
}
84+
Object errorBody = ObjectMappers.parseErrorBody(responseBodyString);
85+
throw new TrophyApiApiException("Error with status code " + response.code(), response.code(), errorBody, response);
86+
}
87+
catch (IOException e) {
88+
throw new TrophyApiException("Network error executing HTTP request", e);
89+
}
90+
}
91+
}

0 commit comments

Comments
 (0)