Skip to content

Commit 4a7e2df

Browse files
Fix Async Passthrough polling object type (#60)
Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Co-authored-by: Rohan Konnur <[email protected]>
1 parent bcf823d commit 4a7e2df

File tree

14 files changed

+608
-26
lines changed

14 files changed

+608
-26
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ publishing {
4646
maven(MavenPublication) {
4747
groupId = 'dev.merge'
4848
artifactId = 'merge-java-client'
49-
version = '1.0.16'
49+
version = '1.0.17'
5050
from components.java
5151
pom {
5252
scm {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ private ClientOptions(
3030
{
3131
put("X-Fern-Language", "JAVA");
3232
put("X-Fern-SDK-Name", "com.merge.fern:api-sdk");
33-
put("X-Fern-SDK-Version", "1.0.16");
33+
put("X-Fern-SDK-Version", "1.0.17");
3434
}
3535
});
3636
this.headerSuppliers = headerSuppliers;

src/main/java/com/merge/api/resources/accounting/asyncpassthrough/AsyncPassthroughClient.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
import com.merge.api.core.MergeException;
1111
import com.merge.api.core.ObjectMappers;
1212
import com.merge.api.core.RequestOptions;
13+
import com.merge.api.resources.accounting.asyncpassthrough.types.AsyncPassthroughRetrieveResponse;
1314
import com.merge.api.resources.accounting.types.AsyncPassthroughReciept;
1415
import com.merge.api.resources.accounting.types.DataPassthroughRequest;
15-
import com.merge.api.resources.accounting.types.RemoteResponse;
1616
import java.io.IOException;
1717
import okhttp3.Headers;
1818
import okhttp3.HttpUrl;
@@ -79,14 +79,14 @@ public AsyncPassthroughReciept create(DataPassthroughRequest request, RequestOpt
7979
/**
8080
* Retrieves data from earlier async-passthrough POST request
8181
*/
82-
public RemoteResponse retrieve(String asyncPassthroughReceiptId) {
82+
public AsyncPassthroughRetrieveResponse retrieve(String asyncPassthroughReceiptId) {
8383
return retrieve(asyncPassthroughReceiptId, null);
8484
}
8585

8686
/**
8787
* Retrieves data from earlier async-passthrough POST request
8888
*/
89-
public RemoteResponse retrieve(String asyncPassthroughReceiptId, RequestOptions requestOptions) {
89+
public AsyncPassthroughRetrieveResponse retrieve(String asyncPassthroughReceiptId, RequestOptions requestOptions) {
9090
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
9191
.newBuilder()
9292
.addPathSegments("accounting/v1/async-passthrough")
@@ -105,7 +105,8 @@ public RemoteResponse retrieve(String asyncPassthroughReceiptId, RequestOptions
105105
try (Response response = client.newCall(okhttpRequest).execute()) {
106106
ResponseBody responseBody = response.body();
107107
if (response.isSuccessful()) {
108-
return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteResponse.class);
108+
return ObjectMappers.JSON_MAPPER.readValue(
109+
responseBody.string(), AsyncPassthroughRetrieveResponse.class);
109110
}
110111
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
111112
throw new ApiError(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/**
2+
* This file was auto-generated by Fern from our API Definition.
3+
*/
4+
package com.merge.api.resources.accounting.asyncpassthrough.types;
5+
6+
import com.fasterxml.jackson.annotation.JsonValue;
7+
import com.fasterxml.jackson.core.JsonParseException;
8+
import com.fasterxml.jackson.core.JsonParser;
9+
import com.fasterxml.jackson.databind.DeserializationContext;
10+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
11+
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
12+
import com.merge.api.core.ObjectMappers;
13+
import com.merge.api.resources.accounting.types.RemoteResponse;
14+
import java.io.IOException;
15+
import java.util.Objects;
16+
17+
@JsonDeserialize(using = AsyncPassthroughRetrieveResponse.Deserializer.class)
18+
public final class AsyncPassthroughRetrieveResponse {
19+
private final Object value;
20+
21+
private final int type;
22+
23+
private AsyncPassthroughRetrieveResponse(Object value, int type) {
24+
this.value = value;
25+
this.type = type;
26+
}
27+
28+
@JsonValue
29+
public Object get() {
30+
return this.value;
31+
}
32+
33+
public <T> T visit(Visitor<T> visitor) {
34+
if (this.type == 0) {
35+
return visitor.visit((RemoteResponse) this.value);
36+
} else if (this.type == 1) {
37+
return visitor.visit((String) this.value);
38+
}
39+
throw new IllegalStateException("Failed to visit value. This should never happen.");
40+
}
41+
42+
@java.lang.Override
43+
public boolean equals(Object other) {
44+
if (this == other) return true;
45+
return other instanceof AsyncPassthroughRetrieveResponse && equalTo((AsyncPassthroughRetrieveResponse) other);
46+
}
47+
48+
private boolean equalTo(AsyncPassthroughRetrieveResponse other) {
49+
return value.equals(other.value);
50+
}
51+
52+
@java.lang.Override
53+
public int hashCode() {
54+
return Objects.hash(this.value);
55+
}
56+
57+
@java.lang.Override
58+
public String toString() {
59+
return this.value.toString();
60+
}
61+
62+
public static AsyncPassthroughRetrieveResponse of(RemoteResponse value) {
63+
return new AsyncPassthroughRetrieveResponse(value, 0);
64+
}
65+
66+
public static AsyncPassthroughRetrieveResponse of(String value) {
67+
return new AsyncPassthroughRetrieveResponse(value, 1);
68+
}
69+
70+
public interface Visitor<T> {
71+
T visit(RemoteResponse value);
72+
73+
T visit(String value);
74+
}
75+
76+
static final class Deserializer extends StdDeserializer<AsyncPassthroughRetrieveResponse> {
77+
Deserializer() {
78+
super(AsyncPassthroughRetrieveResponse.class);
79+
}
80+
81+
@java.lang.Override
82+
public AsyncPassthroughRetrieveResponse deserialize(JsonParser p, DeserializationContext ctxt)
83+
throws IOException {
84+
Object value = p.readValueAs(Object.class);
85+
try {
86+
return of(ObjectMappers.JSON_MAPPER.convertValue(value, RemoteResponse.class));
87+
} catch (IllegalArgumentException e) {
88+
}
89+
try {
90+
return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class));
91+
} catch (IllegalArgumentException e) {
92+
}
93+
throw new JsonParseException(p, "Failed to deserialize");
94+
}
95+
}
96+
}

src/main/java/com/merge/api/resources/ats/asyncpassthrough/AsyncPassthroughClient.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
import com.merge.api.core.MergeException;
1111
import com.merge.api.core.ObjectMappers;
1212
import com.merge.api.core.RequestOptions;
13+
import com.merge.api.resources.ats.asyncpassthrough.types.AsyncPassthroughRetrieveResponse;
1314
import com.merge.api.resources.ats.types.AsyncPassthroughReciept;
1415
import com.merge.api.resources.ats.types.DataPassthroughRequest;
15-
import com.merge.api.resources.ats.types.RemoteResponse;
1616
import java.io.IOException;
1717
import okhttp3.Headers;
1818
import okhttp3.HttpUrl;
@@ -79,14 +79,14 @@ public AsyncPassthroughReciept create(DataPassthroughRequest request, RequestOpt
7979
/**
8080
* Retrieves data from earlier async-passthrough POST request
8181
*/
82-
public RemoteResponse retrieve(String asyncPassthroughReceiptId) {
82+
public AsyncPassthroughRetrieveResponse retrieve(String asyncPassthroughReceiptId) {
8383
return retrieve(asyncPassthroughReceiptId, null);
8484
}
8585

8686
/**
8787
* Retrieves data from earlier async-passthrough POST request
8888
*/
89-
public RemoteResponse retrieve(String asyncPassthroughReceiptId, RequestOptions requestOptions) {
89+
public AsyncPassthroughRetrieveResponse retrieve(String asyncPassthroughReceiptId, RequestOptions requestOptions) {
9090
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
9191
.newBuilder()
9292
.addPathSegments("ats/v1/async-passthrough")
@@ -105,7 +105,8 @@ public RemoteResponse retrieve(String asyncPassthroughReceiptId, RequestOptions
105105
try (Response response = client.newCall(okhttpRequest).execute()) {
106106
ResponseBody responseBody = response.body();
107107
if (response.isSuccessful()) {
108-
return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteResponse.class);
108+
return ObjectMappers.JSON_MAPPER.readValue(
109+
responseBody.string(), AsyncPassthroughRetrieveResponse.class);
109110
}
110111
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
111112
throw new ApiError(
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/**
2+
* This file was auto-generated by Fern from our API Definition.
3+
*/
4+
package com.merge.api.resources.ats.asyncpassthrough.types;
5+
6+
import com.fasterxml.jackson.annotation.JsonValue;
7+
import com.fasterxml.jackson.core.JsonParseException;
8+
import com.fasterxml.jackson.core.JsonParser;
9+
import com.fasterxml.jackson.databind.DeserializationContext;
10+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
11+
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
12+
import com.merge.api.core.ObjectMappers;
13+
import com.merge.api.resources.ats.types.RemoteResponse;
14+
import java.io.IOException;
15+
import java.util.Objects;
16+
17+
@JsonDeserialize(using = AsyncPassthroughRetrieveResponse.Deserializer.class)
18+
public final class AsyncPassthroughRetrieveResponse {
19+
private final Object value;
20+
21+
private final int type;
22+
23+
private AsyncPassthroughRetrieveResponse(Object value, int type) {
24+
this.value = value;
25+
this.type = type;
26+
}
27+
28+
@JsonValue
29+
public Object get() {
30+
return this.value;
31+
}
32+
33+
public <T> T visit(Visitor<T> visitor) {
34+
if (this.type == 0) {
35+
return visitor.visit((RemoteResponse) this.value);
36+
} else if (this.type == 1) {
37+
return visitor.visit((String) this.value);
38+
}
39+
throw new IllegalStateException("Failed to visit value. This should never happen.");
40+
}
41+
42+
@java.lang.Override
43+
public boolean equals(Object other) {
44+
if (this == other) return true;
45+
return other instanceof AsyncPassthroughRetrieveResponse && equalTo((AsyncPassthroughRetrieveResponse) other);
46+
}
47+
48+
private boolean equalTo(AsyncPassthroughRetrieveResponse other) {
49+
return value.equals(other.value);
50+
}
51+
52+
@java.lang.Override
53+
public int hashCode() {
54+
return Objects.hash(this.value);
55+
}
56+
57+
@java.lang.Override
58+
public String toString() {
59+
return this.value.toString();
60+
}
61+
62+
public static AsyncPassthroughRetrieveResponse of(RemoteResponse value) {
63+
return new AsyncPassthroughRetrieveResponse(value, 0);
64+
}
65+
66+
public static AsyncPassthroughRetrieveResponse of(String value) {
67+
return new AsyncPassthroughRetrieveResponse(value, 1);
68+
}
69+
70+
public interface Visitor<T> {
71+
T visit(RemoteResponse value);
72+
73+
T visit(String value);
74+
}
75+
76+
static final class Deserializer extends StdDeserializer<AsyncPassthroughRetrieveResponse> {
77+
Deserializer() {
78+
super(AsyncPassthroughRetrieveResponse.class);
79+
}
80+
81+
@java.lang.Override
82+
public AsyncPassthroughRetrieveResponse deserialize(JsonParser p, DeserializationContext ctxt)
83+
throws IOException {
84+
Object value = p.readValueAs(Object.class);
85+
try {
86+
return of(ObjectMappers.JSON_MAPPER.convertValue(value, RemoteResponse.class));
87+
} catch (IllegalArgumentException e) {
88+
}
89+
try {
90+
return of(ObjectMappers.JSON_MAPPER.convertValue(value, String.class));
91+
} catch (IllegalArgumentException e) {
92+
}
93+
throw new JsonParseException(p, "Failed to deserialize");
94+
}
95+
}
96+
}

src/main/java/com/merge/api/resources/crm/asyncpassthrough/AsyncPassthroughClient.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
import com.merge.api.core.MergeException;
1111
import com.merge.api.core.ObjectMappers;
1212
import com.merge.api.core.RequestOptions;
13+
import com.merge.api.resources.crm.asyncpassthrough.types.AsyncPassthroughRetrieveResponse;
1314
import com.merge.api.resources.crm.types.AsyncPassthroughReciept;
1415
import com.merge.api.resources.crm.types.DataPassthroughRequest;
15-
import com.merge.api.resources.crm.types.RemoteResponse;
1616
import java.io.IOException;
1717
import okhttp3.Headers;
1818
import okhttp3.HttpUrl;
@@ -79,14 +79,14 @@ public AsyncPassthroughReciept create(DataPassthroughRequest request, RequestOpt
7979
/**
8080
* Retrieves data from earlier async-passthrough POST request
8181
*/
82-
public RemoteResponse retrieve(String asyncPassthroughReceiptId) {
82+
public AsyncPassthroughRetrieveResponse retrieve(String asyncPassthroughReceiptId) {
8383
return retrieve(asyncPassthroughReceiptId, null);
8484
}
8585

8686
/**
8787
* Retrieves data from earlier async-passthrough POST request
8888
*/
89-
public RemoteResponse retrieve(String asyncPassthroughReceiptId, RequestOptions requestOptions) {
89+
public AsyncPassthroughRetrieveResponse retrieve(String asyncPassthroughReceiptId, RequestOptions requestOptions) {
9090
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
9191
.newBuilder()
9292
.addPathSegments("crm/v1/async-passthrough")
@@ -105,7 +105,8 @@ public RemoteResponse retrieve(String asyncPassthroughReceiptId, RequestOptions
105105
try (Response response = client.newCall(okhttpRequest).execute()) {
106106
ResponseBody responseBody = response.body();
107107
if (response.isSuccessful()) {
108-
return ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), RemoteResponse.class);
108+
return ObjectMappers.JSON_MAPPER.readValue(
109+
responseBody.string(), AsyncPassthroughRetrieveResponse.class);
109110
}
110111
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
111112
throw new ApiError(

0 commit comments

Comments
 (0)