Skip to content

Commit d45769c

Browse files
committed
Release 0.5.0
1 parent 8074f15 commit d45769c

File tree

392 files changed

+14124
-3988
lines changed

Some content is hidden

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

392 files changed

+14124
-3988
lines changed

build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ java {
4444

4545
group = 'dev.vapi'
4646

47-
version = '0.4.0'
47+
version = '0.5.0'
4848

4949
jar {
5050
dependsOn(":generatePomFileForMavenPublication")
@@ -71,7 +71,7 @@ publishing {
7171
maven(MavenPublication) {
7272
groupId = 'dev.vapi'
7373
artifactId = 'server-sdk'
74-
version = '0.4.0'
74+
version = '0.5.0'
7575
from components.java
7676
pom {
7777
licenses {

gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

src/main/java/com/vapi/api/Vapi.java

+24
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
import com.vapi.api.resources.logs.LogsClient;
1515
import com.vapi.api.resources.phonenumbers.PhoneNumbersClient;
1616
import com.vapi.api.resources.squads.SquadsClient;
17+
import com.vapi.api.resources.testsuiteruns.TestSuiteRunsClient;
18+
import com.vapi.api.resources.testsuites.TestSuitesClient;
19+
import com.vapi.api.resources.testsuitetests.TestSuiteTestsClient;
1720
import com.vapi.api.resources.tools.ToolsClient;
1821
import java.util.function.Supplier;
1922

@@ -40,6 +43,12 @@ public class Vapi {
4043

4144
protected final Supplier<LogsClient> logsClient;
4245

46+
protected final Supplier<TestSuitesClient> testSuitesClient;
47+
48+
protected final Supplier<TestSuiteTestsClient> testSuiteTestsClient;
49+
50+
protected final Supplier<TestSuiteRunsClient> testSuiteRunsClient;
51+
4352
public Vapi(ClientOptions clientOptions) {
4453
this.clientOptions = clientOptions;
4554
this.callsClient = Suppliers.memoize(() -> new CallsClient(clientOptions));
@@ -52,6 +61,9 @@ public Vapi(ClientOptions clientOptions) {
5261
this.filesClient = Suppliers.memoize(() -> new FilesClient(clientOptions));
5362
this.analyticsClient = Suppliers.memoize(() -> new AnalyticsClient(clientOptions));
5463
this.logsClient = Suppliers.memoize(() -> new LogsClient(clientOptions));
64+
this.testSuitesClient = Suppliers.memoize(() -> new TestSuitesClient(clientOptions));
65+
this.testSuiteTestsClient = Suppliers.memoize(() -> new TestSuiteTestsClient(clientOptions));
66+
this.testSuiteRunsClient = Suppliers.memoize(() -> new TestSuiteRunsClient(clientOptions));
5567
}
5668

5769
public CallsClient calls() {
@@ -94,6 +106,18 @@ public LogsClient logs() {
94106
return this.logsClient.get();
95107
}
96108

109+
public TestSuitesClient testSuites() {
110+
return this.testSuitesClient.get();
111+
}
112+
113+
public TestSuiteTestsClient testSuiteTests() {
114+
return this.testSuiteTestsClient.get();
115+
}
116+
117+
public TestSuiteRunsClient testSuiteRuns() {
118+
return this.testSuiteRunsClient.get();
119+
}
120+
97121
public static VapiBuilder builder() {
98122
return new VapiBuilder();
99123
}

src/main/java/com/vapi/api/VapiBuilder.java

+12
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import com.vapi.api.core.ClientOptions;
77
import com.vapi.api.core.Environment;
8+
import okhttp3.OkHttpClient;
89

910
public final class VapiBuilder {
1011
private ClientOptions.Builder clientOptionsBuilder = ClientOptions.builder();
@@ -39,7 +40,18 @@ public VapiBuilder timeout(int timeout) {
3940
return this;
4041
}
4142

43+
/**
44+
* Sets the underlying OkHttp client
45+
*/
46+
public VapiBuilder httpClient(OkHttpClient httpClient) {
47+
this.clientOptionsBuilder.httpClient(httpClient);
48+
return this;
49+
}
50+
4251
public Vapi build() {
52+
if (token == null) {
53+
throw new RuntimeException("Please provide token");
54+
}
4355
this.clientOptionsBuilder.addHeader("Authorization", "Bearer " + this.token);
4456
clientOptionsBuilder.environment(this.environment);
4557
return new Vapi(clientOptionsBuilder.build());

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

+13-6
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,10 @@ private ClientOptions(
3131
this.headers.putAll(headers);
3232
this.headers.putAll(new HashMap<String, String>() {
3333
{
34+
put("User-Agent", "dev.vapi:server-sdk/0.5.0");
3435
put("X-Fern-Language", "JAVA");
3536
put("X-Fern-SDK-Name", "com.vapi.fern:api-sdk");
36-
put("X-Fern-SDK-Version", "0.4.0");
37+
put("X-Fern-SDK-Version", "0.5.0");
3738
}
3839
});
3940
this.headerSuppliers = headerSuppliers;
@@ -86,6 +87,11 @@ public static final class Builder {
8687

8788
private int timeout = 60;
8889

90+
private OkHttpClient httpClient = new OkHttpClient.Builder()
91+
.addInterceptor(new RetryInterceptor(3))
92+
.callTimeout(this.timeout, TimeUnit.SECONDS)
93+
.build();
94+
8995
public Builder environment(Environment environment) {
9096
this.environment = environment;
9197
return this;
@@ -109,12 +115,13 @@ public Builder timeout(int timeout) {
109115
return this;
110116
}
111117

118+
public Builder httpClient(OkHttpClient httpClient) {
119+
this.httpClient = httpClient;
120+
return this;
121+
}
122+
112123
public ClientOptions build() {
113-
OkHttpClient okhttpClient = new OkHttpClient.Builder()
114-
.addInterceptor(new RetryInterceptor(3))
115-
.callTimeout(this.timeout, TimeUnit.SECONDS)
116-
.build();
117-
return new ClientOptions(environment, headers, headerSuppliers, okhttpClient, this.timeout);
124+
return new ClientOptions(environment, headers, headerSuppliers, httpClient, this.timeout);
118125
}
119126
}
120127
}

src/main/java/com/vapi/api/core/RequestOptions.java

+32-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.util.Map;
88
import java.util.Optional;
99
import java.util.concurrent.TimeUnit;
10+
import java.util.function.Supplier;
1011

1112
public final class RequestOptions {
1213
private final String token;
@@ -15,10 +16,21 @@ public final class RequestOptions {
1516

1617
private final TimeUnit timeoutTimeUnit;
1718

18-
private RequestOptions(String token, Optional<Integer> timeout, TimeUnit timeoutTimeUnit) {
19+
private final Map<String, String> headers;
20+
21+
private final Map<String, Supplier<String>> headerSuppliers;
22+
23+
private RequestOptions(
24+
String token,
25+
Optional<Integer> timeout,
26+
TimeUnit timeoutTimeUnit,
27+
Map<String, String> headers,
28+
Map<String, Supplier<String>> headerSuppliers) {
1929
this.token = token;
2030
this.timeout = timeout;
2131
this.timeoutTimeUnit = timeoutTimeUnit;
32+
this.headers = headers;
33+
this.headerSuppliers = headerSuppliers;
2234
}
2335

2436
public Optional<Integer> getTimeout() {
@@ -34,6 +46,10 @@ public Map<String, String> getHeaders() {
3446
if (this.token != null) {
3547
headers.put("Authorization", "Bearer " + this.token);
3648
}
49+
headers.putAll(this.headers);
50+
this.headerSuppliers.forEach((key, supplier) -> {
51+
headers.put(key, supplier.get());
52+
});
3753
return headers;
3854
}
3955

@@ -48,6 +64,10 @@ public static final class Builder {
4864

4965
private TimeUnit timeoutTimeUnit = TimeUnit.SECONDS;
5066

67+
private final Map<String, String> headers = new HashMap<>();
68+
69+
private final Map<String, Supplier<String>> headerSuppliers = new HashMap<>();
70+
5171
public Builder token(String token) {
5272
this.token = token;
5373
return this;
@@ -64,8 +84,18 @@ public Builder timeout(Integer timeout, TimeUnit timeoutTimeUnit) {
6484
return this;
6585
}
6686

87+
public Builder addHeader(String key, String value) {
88+
this.headers.put(key, value);
89+
return this;
90+
}
91+
92+
public Builder addHeader(String key, Supplier<String> value) {
93+
this.headerSuppliers.put(key, value);
94+
return this;
95+
}
96+
6797
public RequestOptions build() {
68-
return new RequestOptions(token, timeout, timeoutTimeUnit);
98+
return new RequestOptions(token, timeout, timeoutTimeUnit, headers, headerSuppliers);
6999
}
70100
}
71101
}

src/main/java/com/vapi/api/core/Stream.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import java.util.Scanner;
1010

1111
/**
12-
* The {@code Stream} class implmenets {@link Iterable} to provide a simple mechanism for reading and parsing
12+
* The {@code Stream} class implements {@link Iterable} to provide a simple mechanism for reading and parsing
1313
* objects of a given type from data streamed via a {@link Reader} using a specified delimiter.
1414
* <p>
1515
* {@code Stream} assumes that data is being pushed to the provided {@link Reader} asynchronously and utilizes a
@@ -23,7 +23,7 @@ public final class Stream<T> implements Iterable<T> {
2323
*/
2424
private final Class<T> valueType;
2525
/**
26-
* The {@link Scanner} used for reading from the input stream and blocking when neede during iteration.
26+
* The {@link Scanner} used for reading from the input stream and blocking when needed during iteration.
2727
*/
2828
private final Scanner scanner;
2929

src/main/java/com/vapi/api/resources/analytics/AnalyticsClient.java

+21-5
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@
33
*/
44
package com.vapi.api.resources.analytics;
55

6+
import com.fasterxml.jackson.core.JsonProcessingException;
7+
import com.fasterxml.jackson.core.type.TypeReference;
68
import com.vapi.api.core.ClientOptions;
9+
import com.vapi.api.core.MediaTypes;
710
import com.vapi.api.core.ObjectMappers;
811
import com.vapi.api.core.RequestOptions;
912
import com.vapi.api.core.VapiApiException;
1013
import com.vapi.api.core.VapiException;
14+
import com.vapi.api.resources.analytics.requests.AnalyticsQueryDto;
15+
import com.vapi.api.types.AnalyticsQueryResult;
1116
import java.io.IOException;
17+
import java.util.List;
1218
import okhttp3.Headers;
1319
import okhttp3.HttpUrl;
1420
import okhttp3.OkHttpClient;
@@ -24,19 +30,28 @@ public AnalyticsClient(ClientOptions clientOptions) {
2430
this.clientOptions = clientOptions;
2531
}
2632

27-
public void get() {
28-
get(null);
33+
public List<AnalyticsQueryResult> get(AnalyticsQueryDto request) {
34+
return get(request, null);
2935
}
3036

31-
public void get(RequestOptions requestOptions) {
37+
public List<AnalyticsQueryResult> get(AnalyticsQueryDto request, RequestOptions requestOptions) {
3238
HttpUrl httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl())
3339
.newBuilder()
3440
.addPathSegments("analytics")
3541
.build();
42+
RequestBody body;
43+
try {
44+
body = RequestBody.create(
45+
ObjectMappers.JSON_MAPPER.writeValueAsBytes(request), MediaTypes.APPLICATION_JSON);
46+
} catch (JsonProcessingException e) {
47+
throw new VapiException("Failed to serialize request", e);
48+
}
3649
Request okhttpRequest = new Request.Builder()
3750
.url(httpUrl)
38-
.method("POST", RequestBody.create("", null))
51+
.method("POST", body)
3952
.headers(Headers.of(clientOptions.headers(requestOptions)))
53+
.addHeader("Content-Type", "application/json")
54+
.addHeader("Accept", "application/json")
4055
.build();
4156
OkHttpClient client = clientOptions.httpClient();
4257
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
@@ -45,7 +60,8 @@ public void get(RequestOptions requestOptions) {
4560
try (Response response = client.newCall(okhttpRequest).execute()) {
4661
ResponseBody responseBody = response.body();
4762
if (response.isSuccessful()) {
48-
return;
63+
return ObjectMappers.JSON_MAPPER.readValue(
64+
responseBody.string(), new TypeReference<List<AnalyticsQueryResult>>() {});
4965
}
5066
String responseBodyString = responseBody != null ? responseBody.string() : "{}";
5167
throw new VapiApiException(

src/main/java/com/vapi/api/types/AnalyticsQueryDto.java renamed to src/main/java/com/vapi/api/resources/analytics/requests/AnalyticsQueryDto.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* This file was auto-generated by Fern from our API Definition.
33
*/
4-
package com.vapi.api.types;
4+
package com.vapi.api.resources.analytics.requests;
55

66
import com.fasterxml.jackson.annotation.JsonAnyGetter;
77
import com.fasterxml.jackson.annotation.JsonAnySetter;
@@ -12,6 +12,7 @@
1212
import com.fasterxml.jackson.annotation.Nulls;
1313
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
1414
import com.vapi.api.core.ObjectMappers;
15+
import com.vapi.api.types.AnalyticsQuery;
1516
import java.util.ArrayList;
1617
import java.util.HashMap;
1718
import java.util.List;

src/main/java/com/vapi/api/resources/assistants/AssistantsClient.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ public List<Assistant> list(AssistantsListRequest request, RequestOptions reques
8383
.url(httpUrl.build())
8484
.method("GET", null)
8585
.headers(Headers.of(clientOptions.headers(requestOptions)))
86-
.addHeader("Content-Type", "application/json");
86+
.addHeader("Content-Type", "application/json")
87+
.addHeader("Accept", "application/json");
8788
Request okhttpRequest = _requestBuilder.build();
8889
OkHttpClient client = clientOptions.httpClient();
8990
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
@@ -130,6 +131,7 @@ public Assistant create(CreateAssistantDto request, RequestOptions requestOption
130131
.method("POST", body)
131132
.headers(Headers.of(clientOptions.headers(requestOptions)))
132133
.addHeader("Content-Type", "application/json")
134+
.addHeader("Accept", "application/json")
133135
.build();
134136
OkHttpClient client = clientOptions.httpClient();
135137
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
@@ -165,6 +167,7 @@ public Assistant get(String id, RequestOptions requestOptions) {
165167
.method("GET", null)
166168
.headers(Headers.of(clientOptions.headers(requestOptions)))
167169
.addHeader("Content-Type", "application/json")
170+
.addHeader("Accept", "application/json")
168171
.build();
169172
OkHttpClient client = clientOptions.httpClient();
170173
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
@@ -200,6 +203,7 @@ public Assistant delete(String id, RequestOptions requestOptions) {
200203
.method("DELETE", null)
201204
.headers(Headers.of(clientOptions.headers(requestOptions)))
202205
.addHeader("Content-Type", "application/json")
206+
.addHeader("Accept", "application/json")
203207
.build();
204208
OkHttpClient client = clientOptions.httpClient();
205209
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {
@@ -220,6 +224,10 @@ public Assistant delete(String id, RequestOptions requestOptions) {
220224
}
221225
}
222226

227+
public Assistant update(String id) {
228+
return update(id, UpdateAssistantDto.builder().build());
229+
}
230+
223231
public Assistant update(String id, UpdateAssistantDto request) {
224232
return update(id, request, null);
225233
}
@@ -242,6 +250,7 @@ public Assistant update(String id, UpdateAssistantDto request, RequestOptions re
242250
.method("PATCH", body)
243251
.headers(Headers.of(clientOptions.headers(requestOptions)))
244252
.addHeader("Content-Type", "application/json")
253+
.addHeader("Accept", "application/json")
245254
.build();
246255
OkHttpClient client = clientOptions.httpClient();
247256
if (requestOptions != null && requestOptions.getTimeout().isPresent()) {

0 commit comments

Comments
 (0)