Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.3.0"
".": "0.4.0"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 17
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-56b0f699c5437d9e5326626d35dfc972c17d01f12cb416c7f4854c8ea6d0e95e.yml
openapi_spec_hash: 158f405c1880706266d83e6ff16b9d2f
config_hash: ab495a165f0919b37cbf9efbd0f0e6ef
configured_endpoints: 12
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cas-parser%2Fcas-parser-6a9d3b677dcfb856dc571865c34b3fe401e4d7f0d799edfc743acb9a55800bd0.yml
openapi_spec_hash: 037703a6c741e4310fda3f57c22fa51e
config_hash: 41c337f5cda03b13880617490f82bad0
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Changelog

## 0.4.0 (2026-02-21)

Full Changelog: [v0.3.0...v0.4.0](https://github.com/CASParser/cas-parser-java/compare/v0.3.0...v0.4.0)

### Features

* **api:** api update ([8d2cb43](https://github.com/CASParser/cas-parser-java/commit/8d2cb43b11b1923624fdc32f7433115f5b20cf37))
* **client:** add connection pooling option ([3ad0fbc](https://github.com/CASParser/cas-parser-java/commit/3ad0fbcafa782f6f7dfcead9d4c4646aedd4e681))


### Chores

* **internal:** make `OkHttp` constructor internal ([1939ec1](https://github.com/CASParser/cas-parser-java/commit/1939ec1346feeb7a1ea45db385d6f8b7f8daacf6))
* **internal:** remove mock server code ([0bdc28f](https://github.com/CASParser/cas-parser-java/commit/0bdc28fc1a9ae2e735d2c40d9cf86c1dc00461ae))
* **internal:** update `TestServerExtension` comment ([ff77ead](https://github.com/CASParser/cas-parser-java/commit/ff77ead512a0b13377c61c0e92cc478586e7a67e))
* update mock server docs ([e7286da](https://github.com/CASParser/cas-parser-java/commit/e7286da78e71c2750514686fb39e2b1a0b5140af))

## 0.3.0 (2026-02-14)

Full Changelog: [v0.2.1...v0.3.0](https://github.com/CASParser/cas-parser-java/compare/v0.2.1...v0.3.0)
Expand Down
99 changes: 59 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<!-- x-release-please-start-version -->

[![Maven Central](https://img.shields.io/maven-central/v/com.cas_parser.api/cas-parser-java)](https://central.sonatype.com/artifact/com.cas_parser.api/cas-parser-java/0.3.0)
[![javadoc](https://javadoc.io/badge2/com.cas_parser.api/cas-parser-java/0.3.0/javadoc.svg)](https://javadoc.io/doc/com.cas_parser.api/cas-parser-java/0.3.0)
[![Maven Central](https://img.shields.io/maven-central/v/com.cas_parser.api/cas-parser-java)](https://central.sonatype.com/artifact/com.cas_parser.api/cas-parser-java/0.4.0)
[![javadoc](https://javadoc.io/badge2/com.cas_parser.api/cas-parser-java/0.4.0/javadoc.svg)](https://javadoc.io/doc/com.cas_parser.api/cas-parser-java/0.4.0)

<!-- x-release-please-end -->

Expand All @@ -22,7 +22,7 @@ Use the Cas Parser MCP Server to enable AI assistants to interact with this API,

<!-- x-release-please-start-version -->

The REST API documentation can be found on [docs.casparser.in](https://docs.casparser.in). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.cas_parser.api/cas-parser-java/0.3.0).
The REST API documentation can be found on [docs.casparser.in](https://docs.casparser.in). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.cas_parser.api/cas-parser-java/0.4.0).

<!-- x-release-please-end -->

Expand All @@ -33,7 +33,7 @@ The REST API documentation can be found on [docs.casparser.in](https://docs.casp
### Gradle

```kotlin
implementation("com.cas_parser.api:cas-parser-java:0.3.0")
implementation("com.cas_parser.api:cas-parser-java:0.4.0")
```

### Maven
Expand All @@ -42,7 +42,7 @@ implementation("com.cas_parser.api:cas-parser-java:0.3.0")
<dependency>
<groupId>com.cas_parser.api</groupId>
<artifactId>cas-parser-java</artifactId>
<version>0.3.0</version>
<version>0.4.0</version>
</dependency>
```

Expand All @@ -57,14 +57,14 @@ This library requires Java 8 or later.
```java
import com.cas_parser.api.client.CasParserClient;
import com.cas_parser.api.client.okhttp.CasParserOkHttpClient;
import com.cas_parser.api.models.credits.CreditCheckParams;
import com.cas_parser.api.models.credits.CreditCheckResponse;
import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams;
import com.cas_parser.api.models.camskfintech.UnifiedResponse;

// Configures using the `casparser.apiKey` and `casparser.baseUrl` system properties
// Or configures using the `CAS_PARSER_API_KEY` and `CAS_PARSER_BASE_URL` environment variables
CasParserClient client = CasParserOkHttpClient.fromEnv();

CreditCheckResponse response = client.credits().check();
UnifiedResponse unifiedResponse = client.camsKfintech().parse();
```

## Client configuration
Expand Down Expand Up @@ -137,7 +137,7 @@ The `withOptions()` method does not affect the original client or service.

To send a request to the Cas Parser API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.

For example, `client.credits().check(...)` should be called with an instance of `CreditCheckParams`, and it will return an instance of `CreditCheckResponse`.
For example, `client.camsKfintech().parse(...)` should be called with an instance of `CamsKfintechParseParams`, and it will return an instance of `UnifiedResponse`.

## Immutability

Expand All @@ -154,31 +154,31 @@ The default client is synchronous. To switch to asynchronous execution, call the
```java
import com.cas_parser.api.client.CasParserClient;
import com.cas_parser.api.client.okhttp.CasParserOkHttpClient;
import com.cas_parser.api.models.credits.CreditCheckParams;
import com.cas_parser.api.models.credits.CreditCheckResponse;
import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams;
import com.cas_parser.api.models.camskfintech.UnifiedResponse;
import java.util.concurrent.CompletableFuture;

// Configures using the `casparser.apiKey` and `casparser.baseUrl` system properties
// Or configures using the `CAS_PARSER_API_KEY` and `CAS_PARSER_BASE_URL` environment variables
CasParserClient client = CasParserOkHttpClient.fromEnv();

CompletableFuture<CreditCheckResponse> response = client.async().credits().check();
CompletableFuture<UnifiedResponse> unifiedResponse = client.async().camsKfintech().parse();
```

Or create an asynchronous client from the beginning:

```java
import com.cas_parser.api.client.CasParserClientAsync;
import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync;
import com.cas_parser.api.models.credits.CreditCheckParams;
import com.cas_parser.api.models.credits.CreditCheckResponse;
import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams;
import com.cas_parser.api.models.camskfintech.UnifiedResponse;
import java.util.concurrent.CompletableFuture;

// Configures using the `casparser.apiKey` and `casparser.baseUrl` system properties
// Or configures using the `CAS_PARSER_API_KEY` and `CAS_PARSER_BASE_URL` environment variables
CasParserClientAsync client = CasParserOkHttpClientAsync.fromEnv();

CompletableFuture<CreditCheckResponse> response = client.credits().check();
CompletableFuture<UnifiedResponse> unifiedResponse = client.camsKfintech().parse();
```

The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.
Expand All @@ -192,21 +192,21 @@ To access this data, prefix any HTTP method call on a client or service with `wi
```java
import com.cas_parser.api.core.http.Headers;
import com.cas_parser.api.core.http.HttpResponseFor;
import com.cas_parser.api.models.credits.CreditCheckParams;
import com.cas_parser.api.models.credits.CreditCheckResponse;
import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams;
import com.cas_parser.api.models.camskfintech.UnifiedResponse;

HttpResponseFor<CreditCheckResponse> response = client.credits().withRawResponse().check();
HttpResponseFor<UnifiedResponse> unifiedResponse = client.camsKfintech().withRawResponse().parse();

int statusCode = response.statusCode();
Headers headers = response.headers();
int statusCode = unifiedResponse.statusCode();
Headers headers = unifiedResponse.headers();
```

You can still deserialize the response into an instance of a Java class if needed:

```java
import com.cas_parser.api.models.credits.CreditCheckResponse;
import com.cas_parser.api.models.camskfintech.UnifiedResponse;

CreditCheckResponse parsedResponse = response.parse();
UnifiedResponse parsedUnifiedResponse = unifiedResponse.parse();
```

## Error handling
Expand Down Expand Up @@ -304,9 +304,9 @@ Requests time out after 1 minute by default.
To set a custom timeout, configure the method call using the `timeout` method:

```java
import com.cas_parser.api.models.credits.CreditCheckResponse;
import com.cas_parser.api.models.camskfintech.UnifiedResponse;

CreditCheckResponse response = client.credits().check(RequestOptions.builder().timeout(Duration.ofSeconds(30)).build());
UnifiedResponse unifiedResponse = client.camsKfintech().parse(RequestOptions.builder().timeout(Duration.ofSeconds(30)).build());
```

Or configure the default for all method calls at the client level:
Expand Down Expand Up @@ -342,6 +342,25 @@ CasParserClient client = CasParserOkHttpClient.builder()
.build();
```

### Connection pooling

To customize the underlying OkHttp connection pool, configure the client using the `maxIdleConnections` and `keepAliveDuration` methods:

```java
import com.cas_parser.api.client.CasParserClient;
import com.cas_parser.api.client.okhttp.CasParserOkHttpClient;
import java.time.Duration;

CasParserClient client = CasParserOkHttpClient.builder()
.fromEnv()
// If `maxIdleConnections` is set, then `keepAliveDuration` must be set, and vice versa.
.maxIdleConnections(10)
.keepAliveDuration(Duration.ofMinutes(2))
.build();
```

If both options are unset, OkHttp's default connection pool settings are used.

### HTTPS

> [!NOTE]
Expand Down Expand Up @@ -424,9 +443,9 @@ To set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQu

```java
import com.cas_parser.api.core.JsonValue;
import com.cas_parser.api.models.credits.CreditCheckParams;
import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams;

CreditCheckParams params = CreditCheckParams.builder()
CamsKfintechParseParams params = CamsKfintechParseParams.builder()
.putAdditionalHeader("Secret-Header", "42")
.putAdditionalQueryParam("secret_query_param", "42")
.putAdditionalBodyProperty("secretProperty", JsonValue.from("42"))
Expand All @@ -438,9 +457,9 @@ These can be accessed on the built object later using the `_additionalHeaders()`
To set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](cas-parser-java-core/src/main/kotlin/com/cas_parser/api/core/Values.kt) object to its setter:

```java
import com.cas_parser.api.models.credits.CreditCheckParams;
import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams;

CreditCheckParams params = CreditCheckParams.builder().build();
CamsKfintechParseParams params = CamsKfintechParseParams.builder().build();
```

The most straightforward way to create a [`JsonValue`](cas-parser-java-core/src/main/kotlin/com/cas_parser/api/core/Values.kt) is using its `from(...)` method:
Expand Down Expand Up @@ -488,10 +507,10 @@ To forcibly omit a required parameter or property, pass [`JsonMissing`](cas-pars

```java
import com.cas_parser.api.core.JsonMissing;
import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams;
import com.cas_parser.api.models.cdsl.fetch.FetchRequestOtpParams;
import com.cas_parser.api.models.credits.CreditCheckParams;

CreditCheckParams params = FetchRequestOtpParams.builder()
CamsKfintechParseParams params = FetchRequestOtpParams.builder()
.dob("1990-01-15")
.pan("ABCDE1234F")
.boId(JsonMissing.of())
Expand All @@ -506,7 +525,7 @@ To access undocumented response properties, call the `_additionalProperties()` m
import com.cas_parser.api.core.JsonValue;
import java.util.Map;

Map<String, JsonValue> additionalProperties = client.credits().check(params)._additionalProperties();
Map<String, JsonValue> additionalProperties = client.camsKfintech().parse(params)._additionalProperties();
JsonValue secretPropertyValue = additionalProperties.get("secretProperty");

String result = secretPropertyValue.accept(new JsonValue.Visitor<>() {
Expand Down Expand Up @@ -536,19 +555,19 @@ To access a property's raw JSON value, which may be undocumented, call its `_` p
import com.cas_parser.api.core.JsonField;
import java.util.Optional;

JsonField<Object> field = client.credits().check(params)._field();
JsonField<String> password = client.camsKfintech().parse(params)._password();

if (field.isMissing()) {
if (password.isMissing()) {
// The property is absent from the JSON response
} else if (field.isNull()) {
} else if (password.isNull()) {
// The property was set to literal null
} else {
// Check if value was provided as a string
// Other methods include `asNumber()`, `asBoolean()`, etc.
Optional<String> jsonString = field.asString();
Optional<String> jsonString = password.asString();

// Try to deserialize into a custom type
MyClass myObject = field.asUnknown().orElseThrow().convert(MyClass.class);
MyClass myObject = password.asUnknown().orElseThrow().convert(MyClass.class);
}
```

Expand All @@ -561,17 +580,17 @@ By default, the SDK will not throw an exception in this case. It will throw [`Ca
If you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:

```java
import com.cas_parser.api.models.credits.CreditCheckResponse;
import com.cas_parser.api.models.camskfintech.UnifiedResponse;

CreditCheckResponse response = client.credits().check(params).validate();
UnifiedResponse unifiedResponse = client.camsKfintech().parse(params).validate();
```

Or configure the method call to validate the response using the `responseValidation` method:

```java
import com.cas_parser.api.models.credits.CreditCheckResponse;
import com.cas_parser.api.models.camskfintech.UnifiedResponse;

CreditCheckResponse response = client.credits().check(RequestOptions.builder().responseValidation(true).build());
UnifiedResponse unifiedResponse = client.camsKfintech().parse(RequestOptions.builder().responseValidation(true).build());
```

Or configure the default for all method calls at the client level:
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repositories {

allprojects {
group = "com.cas_parser.api"
version = "0.3.0" // x-release-please-version
version = "0.4.0" // x-release-please-version
}

subprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class CasParserOkHttpClient private constructor() {
private var clientOptions: ClientOptions.Builder = ClientOptions.builder()
private var dispatcherExecutorService: ExecutorService? = null
private var proxy: Proxy? = null
private var maxIdleConnections: Int? = null
private var keepAliveDuration: Duration? = null
private var sslSocketFactory: SSLSocketFactory? = null
private var trustManager: X509TrustManager? = null
private var hostnameVerifier: HostnameVerifier? = null
Expand Down Expand Up @@ -75,6 +77,46 @@ class CasParserOkHttpClient private constructor() {
/** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */
fun proxy(proxy: Optional<Proxy>) = proxy(proxy.getOrNull())

/**
* The maximum number of idle connections kept by the underlying OkHttp connection pool.
*
* If this is set, then [keepAliveDuration] must also be set.
*
* If unset, then OkHttp's default is used.
*/
fun maxIdleConnections(maxIdleConnections: Int?) = apply {
this.maxIdleConnections = maxIdleConnections
}

/**
* Alias for [Builder.maxIdleConnections].
*
* This unboxed primitive overload exists for backwards compatibility.
*/
fun maxIdleConnections(maxIdleConnections: Int) =
maxIdleConnections(maxIdleConnections as Int?)

/**
* Alias for calling [Builder.maxIdleConnections] with `maxIdleConnections.orElse(null)`.
*/
fun maxIdleConnections(maxIdleConnections: Optional<Int>) =
maxIdleConnections(maxIdleConnections.getOrNull())

/**
* The keep-alive duration for idle connections in the underlying OkHttp connection pool.
*
* If this is set, then [maxIdleConnections] must also be set.
*
* If unset, then OkHttp's default is used.
*/
fun keepAliveDuration(keepAliveDuration: Duration?) = apply {
this.keepAliveDuration = keepAliveDuration
}

/** Alias for calling [Builder.keepAliveDuration] with `keepAliveDuration.orElse(null)`. */
fun keepAliveDuration(keepAliveDuration: Optional<Duration>) =
keepAliveDuration(keepAliveDuration.getOrNull())

/**
* The socket factory used to secure HTTPS connections.
*
Expand Down Expand Up @@ -328,6 +370,8 @@ class CasParserOkHttpClient private constructor() {
OkHttpClient.builder()
.timeout(clientOptions.timeout())
.proxy(proxy)
.maxIdleConnections(maxIdleConnections)
.keepAliveDuration(keepAliveDuration)
.dispatcherExecutorService(dispatcherExecutorService)
.sslSocketFactory(sslSocketFactory)
.trustManager(trustManager)
Expand Down
Loading
Loading