Skip to content

Commit cd7d0ea

Browse files
SDK regeneration (#328)
Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
1 parent 616a571 commit cd7d0ea

File tree

10 files changed

+254
-426
lines changed

10 files changed

+254
-426
lines changed

src/main/java/com/intercom/api/resources/companies/AsyncCompaniesClient.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
import com.intercom.api.resources.companies.requests.RetrieveCompanyRequest;
1818
import com.intercom.api.resources.companies.requests.ScrollCompaniesRequest;
1919
import com.intercom.api.resources.companies.requests.UpdateCompanyRequest;
20+
import com.intercom.api.resources.companies.types.CompaniesRetrieveResponse;
2021
import com.intercom.api.resources.companies.types.Company;
2122
import com.intercom.api.types.CompanyAttachedContacts;
2223
import com.intercom.api.types.CompanyAttachedSegments;
23-
import com.intercom.api.types.CompanyList;
2424
import com.intercom.api.types.DeletedCompanyObject;
2525
import java.util.concurrent.CompletableFuture;
2626

@@ -49,7 +49,7 @@ public AsyncRawCompaniesClient withRawResponse() {
4949
* <p><code>https://api.intercom.io/companies?tag_id={tag_id}</code></p>
5050
* <p><code>https://api.intercom.io/companies?segment_id={segment_id}</code></p>
5151
*/
52-
public CompletableFuture<CompanyList> retrieve() {
52+
public CompletableFuture<CompaniesRetrieveResponse> retrieve() {
5353
return this.rawClient.retrieve().thenApply(response -> response.body());
5454
}
5555

@@ -61,7 +61,7 @@ public CompletableFuture<CompanyList> retrieve() {
6161
* <p><code>https://api.intercom.io/companies?tag_id={tag_id}</code></p>
6262
* <p><code>https://api.intercom.io/companies?segment_id={segment_id}</code></p>
6363
*/
64-
public CompletableFuture<CompanyList> retrieve(RetrieveCompanyRequest request) {
64+
public CompletableFuture<CompaniesRetrieveResponse> retrieve(RetrieveCompanyRequest request) {
6565
return this.rawClient.retrieve(request).thenApply(response -> response.body());
6666
}
6767

@@ -73,7 +73,8 @@ public CompletableFuture<CompanyList> retrieve(RetrieveCompanyRequest request) {
7373
* <p><code>https://api.intercom.io/companies?tag_id={tag_id}</code></p>
7474
* <p><code>https://api.intercom.io/companies?segment_id={segment_id}</code></p>
7575
*/
76-
public CompletableFuture<CompanyList> retrieve(RetrieveCompanyRequest request, RequestOptions requestOptions) {
76+
public CompletableFuture<CompaniesRetrieveResponse> retrieve(
77+
RetrieveCompanyRequest request, RequestOptions requestOptions) {
7778
return this.rawClient.retrieve(request, requestOptions).thenApply(response -> response.body());
7879
}
7980

src/main/java/com/intercom/api/resources/companies/AsyncRawCompaniesClient.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.intercom.api.resources.companies.requests.RetrieveCompanyRequest;
2828
import com.intercom.api.resources.companies.requests.ScrollCompaniesRequest;
2929
import com.intercom.api.resources.companies.requests.UpdateCompanyRequest;
30+
import com.intercom.api.resources.companies.types.CompaniesRetrieveResponse;
3031
import com.intercom.api.resources.companies.types.Company;
3132
import com.intercom.api.types.CompanyAttachedContacts;
3233
import com.intercom.api.types.CompanyAttachedSegments;
@@ -65,7 +66,7 @@ public AsyncRawCompaniesClient(ClientOptions clientOptions) {
6566
* <p><code>https://api.intercom.io/companies?tag_id={tag_id}</code></p>
6667
* <p><code>https://api.intercom.io/companies?segment_id={segment_id}</code></p>
6768
*/
68-
public CompletableFuture<IntercomHttpResponse<CompanyList>> retrieve() {
69+
public CompletableFuture<IntercomHttpResponse<CompaniesRetrieveResponse>> retrieve() {
6970
return retrieve(RetrieveCompanyRequest.builder().build());
7071
}
7172

@@ -77,7 +78,7 @@ public CompletableFuture<IntercomHttpResponse<CompanyList>> retrieve() {
7778
* <p><code>https://api.intercom.io/companies?tag_id={tag_id}</code></p>
7879
* <p><code>https://api.intercom.io/companies?segment_id={segment_id}</code></p>
7980
*/
80-
public CompletableFuture<IntercomHttpResponse<CompanyList>> retrieve(RetrieveCompanyRequest request) {
81+
public CompletableFuture<IntercomHttpResponse<CompaniesRetrieveResponse>> retrieve(RetrieveCompanyRequest request) {
8182
return retrieve(request, null);
8283
}
8384

@@ -89,7 +90,7 @@ public CompletableFuture<IntercomHttpResponse<CompanyList>> retrieve(RetrieveCom
8990
* <p><code>https://api.intercom.io/companies?tag_id={tag_id}</code></p>
9091
* <p><code>https://api.intercom.io/companies?segment_id={segment_id}</code></p>
9192
*/
92-
public CompletableFuture<IntercomHttpResponse<CompanyList>> retrieve(
93+
public CompletableFuture<IntercomHttpResponse<CompaniesRetrieveResponse>> retrieve(
9394
RetrieveCompanyRequest request, RequestOptions requestOptions) {
9495
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
9596
.newBuilder()
@@ -129,14 +130,15 @@ public CompletableFuture<IntercomHttpResponse<CompanyList>> retrieve(
129130
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
130131
client = clientOptions.httpClientWithTimeout(requestOptions);
131132
}
132-
CompletableFuture<IntercomHttpResponse<CompanyList>> future = new CompletableFuture<>();
133+
CompletableFuture<IntercomHttpResponse<CompaniesRetrieveResponse>> future = new CompletableFuture<>();
133134
client.newCall(okhttpRequest).enqueue(new Callback() {
134135
@Override
135136
public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
136137
try (ResponseBody responseBody = response.body()) {
137138
if (response.isSuccessful()) {
138139
future.complete(new IntercomHttpResponse<>(
139-
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompanyList.class),
140+
ObjectMappers.JSON_MAPPER.readValue(
141+
responseBody.string(), CompaniesRetrieveResponse.class),
140142
response));
141143
return;
142144
}

src/main/java/com/intercom/api/resources/companies/CompaniesClient.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
import com.intercom.api.resources.companies.requests.RetrieveCompanyRequest;
1818
import com.intercom.api.resources.companies.requests.ScrollCompaniesRequest;
1919
import com.intercom.api.resources.companies.requests.UpdateCompanyRequest;
20+
import com.intercom.api.resources.companies.types.CompaniesRetrieveResponse;
2021
import com.intercom.api.resources.companies.types.Company;
2122
import com.intercom.api.types.CompanyAttachedContacts;
2223
import com.intercom.api.types.CompanyAttachedSegments;
23-
import com.intercom.api.types.CompanyList;
2424
import com.intercom.api.types.DeletedCompanyObject;
2525

2626
public class CompaniesClient {
@@ -48,7 +48,7 @@ public RawCompaniesClient withRawResponse() {
4848
* <p><code>https://api.intercom.io/companies?tag_id={tag_id}</code></p>
4949
* <p><code>https://api.intercom.io/companies?segment_id={segment_id}</code></p>
5050
*/
51-
public CompanyList retrieve() {
51+
public CompaniesRetrieveResponse retrieve() {
5252
return this.rawClient.retrieve().body();
5353
}
5454

@@ -60,7 +60,7 @@ public CompanyList retrieve() {
6060
* <p><code>https://api.intercom.io/companies?tag_id={tag_id}</code></p>
6161
* <p><code>https://api.intercom.io/companies?segment_id={segment_id}</code></p>
6262
*/
63-
public CompanyList retrieve(RetrieveCompanyRequest request) {
63+
public CompaniesRetrieveResponse retrieve(RetrieveCompanyRequest request) {
6464
return this.rawClient.retrieve(request).body();
6565
}
6666

@@ -72,7 +72,7 @@ public CompanyList retrieve(RetrieveCompanyRequest request) {
7272
* <p><code>https://api.intercom.io/companies?tag_id={tag_id}</code></p>
7373
* <p><code>https://api.intercom.io/companies?segment_id={segment_id}</code></p>
7474
*/
75-
public CompanyList retrieve(RetrieveCompanyRequest request, RequestOptions requestOptions) {
75+
public CompaniesRetrieveResponse retrieve(RetrieveCompanyRequest request, RequestOptions requestOptions) {
7676
return this.rawClient.retrieve(request, requestOptions).body();
7777
}
7878

src/main/java/com/intercom/api/resources/companies/RawCompaniesClient.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.intercom.api.resources.companies.requests.RetrieveCompanyRequest;
2828
import com.intercom.api.resources.companies.requests.ScrollCompaniesRequest;
2929
import com.intercom.api.resources.companies.requests.UpdateCompanyRequest;
30+
import com.intercom.api.resources.companies.types.CompaniesRetrieveResponse;
3031
import com.intercom.api.resources.companies.types.Company;
3132
import com.intercom.api.types.CompanyAttachedContacts;
3233
import com.intercom.api.types.CompanyAttachedSegments;
@@ -60,7 +61,7 @@ public RawCompaniesClient(ClientOptions clientOptions) {
6061
* <p><code>https://api.intercom.io/companies?tag_id={tag_id}</code></p>
6162
* <p><code>https://api.intercom.io/companies?segment_id={segment_id}</code></p>
6263
*/
63-
public IntercomHttpResponse<CompanyList> retrieve() {
64+
public IntercomHttpResponse<CompaniesRetrieveResponse> retrieve() {
6465
return retrieve(RetrieveCompanyRequest.builder().build());
6566
}
6667

@@ -72,7 +73,7 @@ public IntercomHttpResponse<CompanyList> retrieve() {
7273
* <p><code>https://api.intercom.io/companies?tag_id={tag_id}</code></p>
7374
* <p><code>https://api.intercom.io/companies?segment_id={segment_id}</code></p>
7475
*/
75-
public IntercomHttpResponse<CompanyList> retrieve(RetrieveCompanyRequest request) {
76+
public IntercomHttpResponse<CompaniesRetrieveResponse> retrieve(RetrieveCompanyRequest request) {
7677
return retrieve(request, null);
7778
}
7879

@@ -84,7 +85,8 @@ public IntercomHttpResponse<CompanyList> retrieve(RetrieveCompanyRequest request
8485
* <p><code>https://api.intercom.io/companies?tag_id={tag_id}</code></p>
8586
* <p><code>https://api.intercom.io/companies?segment_id={segment_id}</code></p>
8687
*/
87-
public IntercomHttpResponse<CompanyList> retrieve(RetrieveCompanyRequest request, RequestOptions requestOptions) {
88+
public IntercomHttpResponse<CompaniesRetrieveResponse> retrieve(
89+
RetrieveCompanyRequest request, RequestOptions requestOptions) {
8890
HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
8991
.newBuilder()
9092
.addPathSegments("companies");
@@ -127,7 +129,8 @@ public IntercomHttpResponse<CompanyList> retrieve(RetrieveCompanyRequest request
127129
ResponseBody responseBody = response.body();
128130
if (response.isSuccessful()) {
129131
return new IntercomHttpResponse<>(
130-
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompanyList.class), response);
132+
ObjectMappers.JSON_MAPPER.readValue(responseBody.string(), CompaniesRetrieveResponse.class),
133+
response);
131134
}
132135
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
133136
try {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
/**
2+
* This file was auto-generated by Fern from our API Definition.
3+
*/
4+
package com.intercom.api.resources.companies.types;
5+
6+
import com.fasterxml.jackson.annotation.JsonCreator;
7+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
8+
import com.fasterxml.jackson.annotation.JsonProperty;
9+
import com.fasterxml.jackson.annotation.JsonSubTypes;
10+
import com.fasterxml.jackson.annotation.JsonTypeInfo;
11+
import com.fasterxml.jackson.annotation.JsonTypeName;
12+
import com.fasterxml.jackson.annotation.JsonUnwrapped;
13+
import com.fasterxml.jackson.annotation.JsonValue;
14+
import com.intercom.api.types.CompanyList;
15+
import java.util.Objects;
16+
import java.util.Optional;
17+
18+
public final class CompaniesRetrieveResponse {
19+
private final Value value;
20+
21+
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
22+
private CompaniesRetrieveResponse(Value value) {
23+
this.value = value;
24+
}
25+
26+
public <T> T visit(Visitor<T> visitor) {
27+
return value.visit(visitor);
28+
}
29+
30+
public static CompaniesRetrieveResponse company(Company value) {
31+
return new CompaniesRetrieveResponse(new CompanyValue(value));
32+
}
33+
34+
public static CompaniesRetrieveResponse list(CompanyList value) {
35+
return new CompaniesRetrieveResponse(new ListValue(value));
36+
}
37+
38+
public boolean isCompany() {
39+
return value instanceof CompanyValue;
40+
}
41+
42+
public boolean isList() {
43+
return value instanceof ListValue;
44+
}
45+
46+
public boolean _isUnknown() {
47+
return value instanceof _UnknownValue;
48+
}
49+
50+
public Optional<Company> getCompany() {
51+
if (isCompany()) {
52+
return Optional.of(((CompanyValue) value).value);
53+
}
54+
return Optional.empty();
55+
}
56+
57+
public Optional<CompanyList> getList() {
58+
if (isList()) {
59+
return Optional.of(((ListValue) value).value);
60+
}
61+
return Optional.empty();
62+
}
63+
64+
public Optional<Object> _getUnknown() {
65+
if (_isUnknown()) {
66+
return Optional.of(((_UnknownValue) value).value);
67+
}
68+
return Optional.empty();
69+
}
70+
71+
@JsonValue
72+
private Value getValue() {
73+
return this.value;
74+
}
75+
76+
public interface Visitor<T> {
77+
T visitCompany(Company company);
78+
79+
T visitList(CompanyList list);
80+
81+
T _visitUnknown(Object unknownType);
82+
}
83+
84+
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", visible = true, defaultImpl = _UnknownValue.class)
85+
@JsonSubTypes({@JsonSubTypes.Type(CompanyValue.class), @JsonSubTypes.Type(ListValue.class)})
86+
@JsonIgnoreProperties(ignoreUnknown = true)
87+
private interface Value {
88+
<T> T visit(Visitor<T> visitor);
89+
}
90+
91+
@JsonTypeName("company")
92+
@JsonIgnoreProperties("type")
93+
private static final class CompanyValue implements Value {
94+
@JsonUnwrapped
95+
private Company value;
96+
97+
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
98+
private CompanyValue() {}
99+
100+
private CompanyValue(Company value) {
101+
this.value = value;
102+
}
103+
104+
@java.lang.Override
105+
public <T> T visit(Visitor<T> visitor) {
106+
return visitor.visitCompany(value);
107+
}
108+
109+
@java.lang.Override
110+
public boolean equals(Object other) {
111+
if (this == other) return true;
112+
return other instanceof CompanyValue && equalTo((CompanyValue) other);
113+
}
114+
115+
private boolean equalTo(CompanyValue other) {
116+
return value.equals(other.value);
117+
}
118+
119+
@java.lang.Override
120+
public int hashCode() {
121+
return Objects.hash(this.value);
122+
}
123+
124+
@java.lang.Override
125+
public String toString() {
126+
return "CompaniesRetrieveResponse{" + "value: " + value + "}";
127+
}
128+
}
129+
130+
@JsonTypeName("list")
131+
@JsonIgnoreProperties("type")
132+
private static final class ListValue implements Value {
133+
@JsonUnwrapped
134+
private CompanyList value;
135+
136+
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
137+
private ListValue() {}
138+
139+
private ListValue(CompanyList value) {
140+
this.value = value;
141+
}
142+
143+
@java.lang.Override
144+
public <T> T visit(Visitor<T> visitor) {
145+
return visitor.visitList(value);
146+
}
147+
148+
@java.lang.Override
149+
public boolean equals(Object other) {
150+
if (this == other) return true;
151+
return other instanceof ListValue && equalTo((ListValue) other);
152+
}
153+
154+
private boolean equalTo(ListValue other) {
155+
return value.equals(other.value);
156+
}
157+
158+
@java.lang.Override
159+
public int hashCode() {
160+
return Objects.hash(this.value);
161+
}
162+
163+
@java.lang.Override
164+
public String toString() {
165+
return "CompaniesRetrieveResponse{" + "value: " + value + "}";
166+
}
167+
}
168+
169+
@JsonIgnoreProperties("type")
170+
private static final class _UnknownValue implements Value {
171+
private String type;
172+
173+
@JsonValue
174+
private Object value;
175+
176+
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
177+
private _UnknownValue(@JsonProperty("value") Object value) {}
178+
179+
@java.lang.Override
180+
public <T> T visit(Visitor<T> visitor) {
181+
return visitor._visitUnknown(value);
182+
}
183+
184+
@java.lang.Override
185+
public boolean equals(Object other) {
186+
if (this == other) return true;
187+
return other instanceof _UnknownValue && equalTo((_UnknownValue) other);
188+
}
189+
190+
private boolean equalTo(_UnknownValue other) {
191+
return type.equals(other.type) && value.equals(other.value);
192+
}
193+
194+
@java.lang.Override
195+
public int hashCode() {
196+
return Objects.hash(this.type, this.value);
197+
}
198+
199+
@java.lang.Override
200+
public String toString() {
201+
return "CompaniesRetrieveResponse{" + "type: " + type + ", value: " + value + "}";
202+
}
203+
}
204+
}

0 commit comments

Comments
 (0)