Skip to content

Commit 1cc00d9

Browse files
committed
Release 0.1.4
1 parent 827eb40 commit 1cc00d9

File tree

232 files changed

+2357
-1844
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

232 files changed

+2357
-1844
lines changed

.github/workflows/ci.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,24 @@ jobs:
2020
- name: Compile
2121
run: ./gradlew compileJava
2222

23-
publish:
23+
test:
2424
needs: [ compile ]
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout repo
28+
uses: actions/checkout@v3
29+
30+
- name: Set up Java
31+
id: setup-jre
32+
uses: actions/setup-java@v1
33+
with:
34+
java-version: "11"
35+
architecture: x64
36+
37+
- name: Test
38+
run: ./gradlew test
39+
publish:
40+
needs: [ compile, test ]
2541
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
2642
runs-on: ubuntu-latest
2743

build.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ dependencies {
1616
api 'com.fasterxml.jackson.core:jackson-databind:2.13.0'
1717
api 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.12.3'
1818
api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.3'
19+
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
20+
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
1921
}
2022

2123
spotless {
@@ -29,12 +31,16 @@ java {
2931
withJavadocJar()
3032
}
3133

34+
test {
35+
useJUnitPlatform()
36+
}
37+
3238
publishing {
3339
publications {
3440
maven(MavenPublication) {
3541
groupId = 'io.github.seamapi'
3642
artifactId = 'java'
37-
version = '0.1.3'
43+
version = '0.1.4'
3844
from components.java
3945
}
4046
}

sample-app/src/main/java/sample/App.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* This file was auto-generated by Fern from our API Definition.
3+
*/
4+
15
package sample;
26

37
import java.lang.String;

src/main/java/com/seam/api/SeamApiClient.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* This file was auto-generated by Fern from our API Definition.
3+
*/
14
package com.seam.api;
25

36
import com.seam.api.core.ClientOptions;

src/main/java/com/seam/api/SeamApiClientBuilder.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* This file was auto-generated by Fern from our API Definition.
3+
*/
14
package com.seam.api;
25

36
import com.seam.api.core.ClientOptions;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* This file was auto-generated by Fern from our API Definition.
3+
*/
4+
package com.seam.api.core;
5+
6+
public final class ApiError extends RuntimeException {
7+
private final int statusCode;
8+
9+
private final Object body;
10+
11+
public ApiError(int statusCode, Object body) {
12+
this.statusCode = statusCode;
13+
this.body = body;
14+
}
15+
16+
public int statusCode() {
17+
return this.statusCode;
18+
}
19+
20+
public Object body() {
21+
return this.body;
22+
}
23+
24+
@Override
25+
public String toString() {
26+
return "ApiError{" + "statusCode: " + statusCode + ", body: " + body + "}";
27+
}
28+
}

src/main/java/com/seam/api/core/ClientOptions.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* This file was auto-generated by Fern from our API Definition.
3+
*/
14
package com.seam.api.core;
25

36
import java.util.HashMap;
@@ -23,7 +26,7 @@ private ClientOptions(
2326
this.headers = new HashMap<>();
2427
this.headers.putAll(headers);
2528
this.headers.putAll(Map.of(
26-
"X-Fern-SDK-Name", "com.seam.fern:api-sdk", "X-Fern-SDK-Version", "0.1.3", "X-Fern-Language", "JAVA"));
29+
"X-Fern-SDK-Name", "com.seam.fern:api-sdk", "X-Fern-SDK-Version", "0.1.4", "X-Fern-Language", "JAVA"));
2730
this.headerSuppliers = headerSuppliers;
2831
this.httpClient = httpClient;
2932
;
@@ -75,7 +78,10 @@ public Builder addHeader(String key, Supplier<String> value) {
7578
}
7679

7780
public ClientOptions build() {
78-
return new ClientOptions(environment, headers, headerSuppliers, new OkHttpClient());
81+
OkHttpClient okhttpClient = new OkHttpClient.Builder()
82+
.addInterceptor(new RetryInterceptor(3))
83+
.build();
84+
return new ClientOptions(environment, headers, headerSuppliers, okhttpClient);
7985
}
8086
}
8187
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* This file was auto-generated by Fern from our API Definition.
3+
*/
4+
package com.seam.api.core;
5+
6+
import com.fasterxml.jackson.core.JsonParser;
7+
import com.fasterxml.jackson.core.JsonToken;
8+
import com.fasterxml.jackson.databind.DeserializationContext;
9+
import com.fasterxml.jackson.databind.JsonDeserializer;
10+
import com.fasterxml.jackson.databind.module.SimpleModule;
11+
import java.io.IOException;
12+
import java.time.Instant;
13+
import java.time.LocalDateTime;
14+
import java.time.OffsetDateTime;
15+
import java.time.ZoneOffset;
16+
import java.time.format.DateTimeFormatter;
17+
import java.time.temporal.TemporalAccessor;
18+
import java.time.temporal.TemporalQueries;
19+
20+
/**
21+
* Custom deserializer that handles converting ISO8601 dates into {@link OffsetDateTime} objects.
22+
*/
23+
class DateTimeDeserializer extends JsonDeserializer<OffsetDateTime> {
24+
private static final SimpleModule MODULE;
25+
26+
static {
27+
MODULE = new SimpleModule().addDeserializer(OffsetDateTime.class, new DateTimeDeserializer());
28+
}
29+
30+
/**
31+
* Gets a module wrapping this deserializer as an adapter for the Jackson ObjectMapper.
32+
*
33+
* @return A {@link SimpleModule} to be plugged onto Jackson ObjectMapper.
34+
*/
35+
public static SimpleModule getModule() {
36+
return MODULE;
37+
}
38+
39+
@Override
40+
public OffsetDateTime deserialize(JsonParser parser, DeserializationContext context) throws IOException {
41+
JsonToken token = parser.currentToken();
42+
if (token == JsonToken.VALUE_NUMBER_INT) {
43+
return OffsetDateTime.ofInstant(Instant.ofEpochSecond(parser.getValueAsLong()), ZoneOffset.UTC);
44+
} else {
45+
TemporalAccessor temporal = DateTimeFormatter.ISO_DATE_TIME.parseBest(
46+
parser.getValueAsString(), OffsetDateTime::from, LocalDateTime::from);
47+
48+
if (temporal.query(TemporalQueries.offset()) == null) {
49+
return LocalDateTime.from(temporal).atOffset(ZoneOffset.UTC);
50+
} else {
51+
return OffsetDateTime.from(temporal);
52+
}
53+
}
54+
}
55+
}

src/main/java/com/seam/api/core/Environment.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* This file was auto-generated by Fern from our API Definition.
3+
*/
14
package com.seam.api.core;
25

36
public final class Environment {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,36 @@
1+
/**
2+
* This file was auto-generated by Fern from our API Definition.
3+
*/
14
package com.seam.api.core;
25

6+
import com.fasterxml.jackson.annotation.JsonInclude;
37
import com.fasterxml.jackson.databind.DeserializationFeature;
48
import com.fasterxml.jackson.databind.ObjectMapper;
9+
import com.fasterxml.jackson.databind.SerializationFeature;
510
import com.fasterxml.jackson.databind.json.JsonMapper;
611
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
712
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
13+
import java.io.IOException;
814

915
public final class ObjectMappers {
1016
public static final ObjectMapper JSON_MAPPER = JsonMapper.builder()
1117
.addModule(new Jdk8Module())
1218
.addModule(new JavaTimeModule())
19+
.addModule(DateTimeDeserializer.getModule())
1320
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
21+
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
1422
.build();
1523

1624
private ObjectMappers() {}
25+
26+
public static String stringify(Object o) {
27+
try {
28+
return JSON_MAPPER
29+
.setSerializationInclusion(JsonInclude.Include.ALWAYS)
30+
.writerWithDefaultPrettyPrinter()
31+
.writeValueAsString(o);
32+
} catch (IOException e) {
33+
return o.getClass().getName() + "@" + Integer.toHexString(o.hashCode());
34+
}
35+
}
1736
}

0 commit comments

Comments
 (0)