diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 3d2ac0b..10f3091 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0" + ".": "0.2.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 2c90fa6..4d62cd0 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 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: cb5d75abef6264b5d86448caf7295afa +config_hash: 1af2e938c93ea4ec25fc633469072c43 diff --git a/CHANGELOG.md b/CHANGELOG.md index c68f82c..d4e9764 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## 0.2.0 (2026-02-14) + +Full Changelog: [v0.1.0...v0.2.0](https://github.com/CASParser/cas-parser-java/compare/v0.1.0...v0.2.0) + +### Features + +* **api:** manual updates ([b21f22f](https://github.com/CASParser/cas-parser-java/commit/b21f22fdb7949e53222c362d41cdde390036a7d7)) + + +### Chores + +* configure new SDK language ([2e9b4a1](https://github.com/CASParser/cas-parser-java/commit/2e9b4a178af20b81ed25065a309581afad0689da)) +* update SDK settings ([27c0e10](https://github.com/CASParser/cas-parser-java/commit/27c0e107ff02b981b34b1740d977ce4d99f3c771)) + ## 0.1.0 (2026-02-14) Full Changelog: [v0.0.4...v0.1.0](https://github.com/CASParser/cas-parser-java/compare/v0.0.4...v0.1.0) diff --git a/README.md b/README.md index dc0b1dc..3d0bf3f 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,12 @@ -[![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.1.0) -[![javadoc](https://javadoc.io/badge2/com.cas_parser.api/cas-parser-java/0.1.0/javadoc.svg)](https://javadoc.io/doc/com.cas_parser.api/cas-parser-java/0.1.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.2.0) +[![javadoc](https://javadoc.io/badge2/com.cas_parser.api/cas-parser-java/0.2.0/javadoc.svg)](https://javadoc.io/doc/com.cas_parser.api/cas-parser-java/0.2.0) -The Cas Parser Java SDK provides convenient access to the [Cas Parser REST API](https://docs.casparser.in/reference) from applications written in Java. +The Cas Parser Java SDK provides convenient access to the Cas Parser REST API from applications written in Java. It is generated with [Stainless](https://www.stainless.com/). @@ -15,14 +15,14 @@ It is generated with [Stainless](https://www.stainless.com/). Use the Cas Parser MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application. -[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=cas-parser-node-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsImNhcy1wYXJzZXItbm9kZS1tY3AiXSwiZW52Ijp7IkNBU19QQVJTRVJfQVBJX0tFWSI6Ik15IEFQSSBLZXkifX0) -[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22cas-parser-node-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22cas-parser-node-mcp%22%5D%2C%22env%22%3A%7B%22CAS_PARSER_API_KEY%22%3A%22My%20API%20Key%22%7D%7D) +[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=cas-parser-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsImNhcy1wYXJzZXItbWNwIl0sImVudiI6eyJDQVNfUEFSU0VSX0FQSV9LRVkiOiJNeSBBUEkgS2V5In19) +[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22cas-parser-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22cas-parser-mcp%22%5D%2C%22env%22%3A%7B%22CAS_PARSER_API_KEY%22%3A%22My%20API%20Key%22%7D%7D) > Note: You may need to set environment variables in your MCP client. -The REST API documentation can be found on [docs.casparser.in](https://docs.casparser.in/reference). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.cas_parser.api/cas-parser-java/0.1.0). +Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.cas_parser.api/cas-parser-java/0.2.0). @@ -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.1.0") +implementation("com.cas_parser.api:cas-parser-java:0.2.0") ``` ### Maven @@ -42,7 +42,7 @@ implementation("com.cas_parser.api:cas-parser-java:0.1.0") com.cas_parser.api cas-parser-java - 0.1.0 + 0.2.0 ``` @@ -57,18 +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.casparser.CasParserSmartParseParams; -import com.cas_parser.api.models.casparser.UnifiedResponse; +import com.cas_parser.api.models.credits.CreditCheckParams; +import com.cas_parser.api.models.credits.CreditCheckResponse; // 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(); -CasParserSmartParseParams params = CasParserSmartParseParams.builder() - .password("ABCDF") - .pdfUrl("https://your-cas-pdf-url-here.com") - .build(); -UnifiedResponse unifiedResponse = client.casParser().smartParse(params); +CreditCheckResponse response = client.credits().check(); ``` ## Client configuration @@ -141,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.casParser().smartParse(...)` should be called with an instance of `CasParserSmartParseParams`, and it will return an instance of `UnifiedResponse`. +For example, `client.credits().check(...)` should be called with an instance of `CreditCheckParams`, and it will return an instance of `CreditCheckResponse`. ## Immutability @@ -158,19 +154,15 @@ 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.casparser.CasParserSmartParseParams; -import com.cas_parser.api.models.casparser.UnifiedResponse; +import com.cas_parser.api.models.credits.CreditCheckParams; +import com.cas_parser.api.models.credits.CreditCheckResponse; 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(); -CasParserSmartParseParams params = CasParserSmartParseParams.builder() - .password("ABCDF") - .pdfUrl("https://your-cas-pdf-url-here.com") - .build(); -CompletableFuture unifiedResponse = client.async().casParser().smartParse(params); +CompletableFuture response = client.async().credits().check(); ``` Or create an asynchronous client from the beginning: @@ -178,19 +170,15 @@ 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.casparser.CasParserSmartParseParams; -import com.cas_parser.api.models.casparser.UnifiedResponse; +import com.cas_parser.api.models.credits.CreditCheckParams; +import com.cas_parser.api.models.credits.CreditCheckResponse; 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(); -CasParserSmartParseParams params = CasParserSmartParseParams.builder() - .password("ABCDF") - .pdfUrl("https://your-cas-pdf-url-here.com") - .build(); -CompletableFuture unifiedResponse = client.casParser().smartParse(params); +CompletableFuture response = client.credits().check(); ``` The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s. @@ -204,25 +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.casparser.CasParserSmartParseParams; -import com.cas_parser.api.models.casparser.UnifiedResponse; +import com.cas_parser.api.models.credits.CreditCheckParams; +import com.cas_parser.api.models.credits.CreditCheckResponse; -CasParserSmartParseParams params = CasParserSmartParseParams.builder() - .password("ABCDF") - .pdfUrl("https://you-cas-pdf-url-here.com") - .build(); -HttpResponseFor unifiedResponse = client.casParser().withRawResponse().smartParse(params); +HttpResponseFor response = client.credits().withRawResponse().check(); -int statusCode = unifiedResponse.statusCode(); -Headers headers = unifiedResponse.headers(); +int statusCode = response.statusCode(); +Headers headers = response.headers(); ``` You can still deserialize the response into an instance of a Java class if needed: ```java -import com.cas_parser.api.models.casparser.UnifiedResponse; +import com.cas_parser.api.models.credits.CreditCheckResponse; -UnifiedResponse parsedUnifiedResponse = unifiedResponse.parse(); +CreditCheckResponse parsedResponse = response.parse(); ``` ## Error handling @@ -320,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.casparser.UnifiedResponse; +import com.cas_parser.api.models.credits.CreditCheckResponse; -UnifiedResponse unifiedResponse = client.casParser().smartParse(RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()); +CreditCheckResponse response = client.credits().check(RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()); ``` Or configure the default for all method calls at the client level: @@ -379,6 +363,21 @@ CasParserClient client = CasParserOkHttpClient.builder() .build(); ``` +### Environments + +The SDK sends requests to the production by default. To send requests to a different environment, configure the client like so: + +```java +import com.cas_parser.api.client.CasParserClient; +import com.cas_parser.api.client.okhttp.CasParserOkHttpClient; + +CasParserClient client = CasParserOkHttpClient.builder() + .fromEnv() + // Other options include `environment2` + .environment1() + .build(); +``` + ### Custom HTTP client The SDK consists of three artifacts: @@ -425,9 +424,9 @@ To set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQu ```java import com.cas_parser.api.core.JsonValue; -import com.cas_parser.api.models.casparser.CasParserSmartParseParams; +import com.cas_parser.api.models.credits.CreditCheckParams; -CasParserSmartParseParams params = CasParserSmartParseParams.builder() +CreditCheckParams params = CreditCheckParams.builder() .putAdditionalHeader("Secret-Header", "42") .putAdditionalQueryParam("secret_query_param", "42") .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) @@ -439,13 +438,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.core.JsonValue; -import com.cas_parser.api.models.casparser.CasParserSmartParseParams; +import com.cas_parser.api.models.credits.CreditCheckParams; -CasParserSmartParseParams params = CasParserSmartParseParams.builder() - .password(JsonValue.from(42)) - .pdfUrl("https://your-cas-pdf-url-here.com") - .build(); +CreditCheckParams params = CreditCheckParams.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: @@ -487,6 +482,22 @@ JsonValue complexValue = JsonValue.from(Map.of( )); ``` +Normally a `Builder` class's `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset. + +To forcibly omit a required parameter or property, pass [`JsonMissing`](cas-parser-java-core/src/main/kotlin/com/cas_parser/api/core/Values.kt): + +```java +import com.cas_parser.api.core.JsonMissing; +import com.cas_parser.api.models.cdsl.fetch.FetchRequestOtpParams; +import com.cas_parser.api.models.credits.CreditCheckParams; + +CreditCheckParams params = FetchRequestOtpParams.builder() + .dob("1990-01-15") + .pan("ABCDE1234F") + .boId(JsonMissing.of()) + .build(); +``` + ### Response properties To access undocumented response properties, call the `_additionalProperties()` method: @@ -495,7 +506,7 @@ To access undocumented response properties, call the `_additionalProperties()` m import com.cas_parser.api.core.JsonValue; import java.util.Map; -Map additionalProperties = client.casParser().smartParse(params)._additionalProperties(); +Map additionalProperties = client.credits().check(params)._additionalProperties(); JsonValue secretPropertyValue = additionalProperties.get("secretProperty"); String result = secretPropertyValue.accept(new JsonValue.Visitor<>() { @@ -525,19 +536,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 password = client.casParser().smartParse(params)._password(); +JsonField field = client.credits().check(params)._field(); -if (password.isMissing()) { +if (field.isMissing()) { // The property is absent from the JSON response -} else if (password.isNull()) { +} else if (field.isNull()) { // The property was set to literal null } else { // Check if value was provided as a string // Other methods include `asNumber()`, `asBoolean()`, etc. - Optional jsonString = password.asString(); + Optional jsonString = field.asString(); // Try to deserialize into a custom type - MyClass myObject = password.asUnknown().orElseThrow().convert(MyClass.class); + MyClass myObject = field.asUnknown().orElseThrow().convert(MyClass.class); } ``` @@ -550,17 +561,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.casparser.UnifiedResponse; +import com.cas_parser.api.models.credits.CreditCheckResponse; -UnifiedResponse unifiedResponse = client.casParser().smartParse(params).validate(); +CreditCheckResponse response = client.credits().check(params).validate(); ``` Or configure the method call to validate the response using the `responseValidation` method: ```java -import com.cas_parser.api.models.casparser.UnifiedResponse; +import com.cas_parser.api.models.credits.CreditCheckResponse; -UnifiedResponse unifiedResponse = client.casParser().smartParse(RequestOptions.builder().responseValidation(true).build()); +CreditCheckResponse response = client.credits().check(RequestOptions.builder().responseValidation(true).build()); ``` Or configure the default for all method calls at the client level: diff --git a/build.gradle.kts b/build.gradle.kts index 30b3cae..55b241b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ repositories { allprojects { group = "com.cas_parser.api" - version = "0.1.0" // x-release-please-version + version = "0.2.0" // x-release-please-version } subprojects { diff --git a/buildSrc/src/main/kotlin/cas-parser.publish.gradle.kts b/buildSrc/src/main/kotlin/cas-parser.publish.gradle.kts index 26aec10..56f585c 100644 --- a/buildSrc/src/main/kotlin/cas-parser.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/cas-parser.publish.gradle.kts @@ -11,7 +11,7 @@ configure { pom { name.set("CAS Parser - Track Portfolios from CDSL, NSDL, CAMS, KFintech") description.set("API for parsing and analyzing CAS (Consolidated Account Statement) PDF files\nfrom NSDL, CDSL, and CAMS/KFintech, with a unified response format") - url.set("https://docs.casparser.in/reference") + url.set("https://www.github.com/CASParser/cas-parser-java") licenses { license { diff --git a/cas-parser-java-client-okhttp/src/main/kotlin/com/cas_parser/api/client/okhttp/CasParserOkHttpClient.kt b/cas-parser-java-client-okhttp/src/main/kotlin/com/cas_parser/api/client/okhttp/CasParserOkHttpClient.kt index 93a7aeb..dc713f6 100644 --- a/cas-parser-java-client-okhttp/src/main/kotlin/com/cas_parser/api/client/okhttp/CasParserOkHttpClient.kt +++ b/cas-parser-java-client-okhttp/src/main/kotlin/com/cas_parser/api/client/okhttp/CasParserOkHttpClient.kt @@ -166,12 +166,22 @@ class CasParserOkHttpClient private constructor() { * The base URL to use for every request. * * Defaults to the production environment: `https://portfolio-parser.api.casparser.in`. + * + * The following other environments, with dedicated builder methods, are available: + * - environment_1: `https://client-apis.casparser.in` + * - environment_2: `http://localhost:5000` */ fun baseUrl(baseUrl: String?) = apply { clientOptions.baseUrl(baseUrl) } /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) + /** Sets [baseUrl] to `https://client-apis.casparser.in`. */ + fun environment1() = apply { clientOptions.environment1() } + + /** Sets [baseUrl] to `http://localhost:5000`. */ + fun environment2() = apply { clientOptions.environment2() } + /** * Whether to call `validate` on every response before returning it. * diff --git a/cas-parser-java-client-okhttp/src/main/kotlin/com/cas_parser/api/client/okhttp/CasParserOkHttpClientAsync.kt b/cas-parser-java-client-okhttp/src/main/kotlin/com/cas_parser/api/client/okhttp/CasParserOkHttpClientAsync.kt index f4858a0..5d4beab 100644 --- a/cas-parser-java-client-okhttp/src/main/kotlin/com/cas_parser/api/client/okhttp/CasParserOkHttpClientAsync.kt +++ b/cas-parser-java-client-okhttp/src/main/kotlin/com/cas_parser/api/client/okhttp/CasParserOkHttpClientAsync.kt @@ -166,12 +166,22 @@ class CasParserOkHttpClientAsync private constructor() { * The base URL to use for every request. * * Defaults to the production environment: `https://portfolio-parser.api.casparser.in`. + * + * The following other environments, with dedicated builder methods, are available: + * - environment_1: `https://client-apis.casparser.in` + * - environment_2: `http://localhost:5000` */ fun baseUrl(baseUrl: String?) = apply { clientOptions.baseUrl(baseUrl) } /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) + /** Sets [baseUrl] to `https://client-apis.casparser.in`. */ + fun environment1() = apply { clientOptions.environment1() } + + /** Sets [baseUrl] to `http://localhost:5000`. */ + fun environment2() = apply { clientOptions.environment2() } + /** * Whether to call `validate` on every response before returning it. * diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClient.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClient.kt index 6a2e9fb..87a671b 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClient.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClient.kt @@ -3,8 +3,17 @@ package com.cas_parser.api.client import com.cas_parser.api.core.ClientOptions -import com.cas_parser.api.services.blocking.CasGeneratorService -import com.cas_parser.api.services.blocking.CasParserService +import com.cas_parser.api.services.blocking.AccessTokenService +import com.cas_parser.api.services.blocking.CamsKfintechService +import com.cas_parser.api.services.blocking.CdslService +import com.cas_parser.api.services.blocking.ContractNoteService +import com.cas_parser.api.services.blocking.CreditService +import com.cas_parser.api.services.blocking.InboxService +import com.cas_parser.api.services.blocking.KfintechService +import com.cas_parser.api.services.blocking.LogService +import com.cas_parser.api.services.blocking.NsdlService +import com.cas_parser.api.services.blocking.SmartService +import com.cas_parser.api.services.blocking.VerifyTokenService import java.util.function.Consumer /** @@ -43,9 +52,27 @@ interface CasParserClient { */ fun withOptions(modifier: Consumer): CasParserClient - fun casParser(): CasParserService + fun credits(): CreditService - fun casGenerator(): CasGeneratorService + fun logs(): LogService + + fun accessToken(): AccessTokenService + + fun verifyToken(): VerifyTokenService + + fun camsKfintech(): CamsKfintechService + + fun cdsl(): CdslService + + fun contractNote(): ContractNoteService + + fun inbox(): InboxService + + fun kfintech(): KfintechService + + fun nsdl(): NsdlService + + fun smart(): SmartService /** * Closes this client, relinquishing any underlying resources. @@ -70,8 +97,26 @@ interface CasParserClient { */ fun withOptions(modifier: Consumer): CasParserClient.WithRawResponse - fun casParser(): CasParserService.WithRawResponse + fun credits(): CreditService.WithRawResponse + + fun logs(): LogService.WithRawResponse + + fun accessToken(): AccessTokenService.WithRawResponse + + fun verifyToken(): VerifyTokenService.WithRawResponse + + fun camsKfintech(): CamsKfintechService.WithRawResponse + + fun cdsl(): CdslService.WithRawResponse + + fun contractNote(): ContractNoteService.WithRawResponse + + fun inbox(): InboxService.WithRawResponse + + fun kfintech(): KfintechService.WithRawResponse + + fun nsdl(): NsdlService.WithRawResponse - fun casGenerator(): CasGeneratorService.WithRawResponse + fun smart(): SmartService.WithRawResponse } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClientAsync.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClientAsync.kt index 24e7f4e..22f6ad3 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClientAsync.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClientAsync.kt @@ -3,8 +3,17 @@ package com.cas_parser.api.client import com.cas_parser.api.core.ClientOptions -import com.cas_parser.api.services.async.CasGeneratorServiceAsync -import com.cas_parser.api.services.async.CasParserServiceAsync +import com.cas_parser.api.services.async.AccessTokenServiceAsync +import com.cas_parser.api.services.async.CamsKfintechServiceAsync +import com.cas_parser.api.services.async.CdslServiceAsync +import com.cas_parser.api.services.async.ContractNoteServiceAsync +import com.cas_parser.api.services.async.CreditServiceAsync +import com.cas_parser.api.services.async.InboxServiceAsync +import com.cas_parser.api.services.async.KfintechServiceAsync +import com.cas_parser.api.services.async.LogServiceAsync +import com.cas_parser.api.services.async.NsdlServiceAsync +import com.cas_parser.api.services.async.SmartServiceAsync +import com.cas_parser.api.services.async.VerifyTokenServiceAsync import java.util.function.Consumer /** @@ -43,9 +52,27 @@ interface CasParserClientAsync { */ fun withOptions(modifier: Consumer): CasParserClientAsync - fun casParser(): CasParserServiceAsync + fun credits(): CreditServiceAsync - fun casGenerator(): CasGeneratorServiceAsync + fun logs(): LogServiceAsync + + fun accessToken(): AccessTokenServiceAsync + + fun verifyToken(): VerifyTokenServiceAsync + + fun camsKfintech(): CamsKfintechServiceAsync + + fun cdsl(): CdslServiceAsync + + fun contractNote(): ContractNoteServiceAsync + + fun inbox(): InboxServiceAsync + + fun kfintech(): KfintechServiceAsync + + fun nsdl(): NsdlServiceAsync + + fun smart(): SmartServiceAsync /** * Closes this client, relinquishing any underlying resources. @@ -74,8 +101,26 @@ interface CasParserClientAsync { modifier: Consumer ): CasParserClientAsync.WithRawResponse - fun casParser(): CasParserServiceAsync.WithRawResponse + fun credits(): CreditServiceAsync.WithRawResponse + + fun logs(): LogServiceAsync.WithRawResponse + + fun accessToken(): AccessTokenServiceAsync.WithRawResponse + + fun verifyToken(): VerifyTokenServiceAsync.WithRawResponse + + fun camsKfintech(): CamsKfintechServiceAsync.WithRawResponse + + fun cdsl(): CdslServiceAsync.WithRawResponse + + fun contractNote(): ContractNoteServiceAsync.WithRawResponse + + fun inbox(): InboxServiceAsync.WithRawResponse + + fun kfintech(): KfintechServiceAsync.WithRawResponse + + fun nsdl(): NsdlServiceAsync.WithRawResponse - fun casGenerator(): CasGeneratorServiceAsync.WithRawResponse + fun smart(): SmartServiceAsync.WithRawResponse } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClientAsyncImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClientAsyncImpl.kt index d8b0b67..5f28136 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClientAsyncImpl.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClientAsyncImpl.kt @@ -4,10 +4,28 @@ package com.cas_parser.api.client import com.cas_parser.api.core.ClientOptions import com.cas_parser.api.core.getPackageVersion -import com.cas_parser.api.services.async.CasGeneratorServiceAsync -import com.cas_parser.api.services.async.CasGeneratorServiceAsyncImpl -import com.cas_parser.api.services.async.CasParserServiceAsync -import com.cas_parser.api.services.async.CasParserServiceAsyncImpl +import com.cas_parser.api.services.async.AccessTokenServiceAsync +import com.cas_parser.api.services.async.AccessTokenServiceAsyncImpl +import com.cas_parser.api.services.async.CamsKfintechServiceAsync +import com.cas_parser.api.services.async.CamsKfintechServiceAsyncImpl +import com.cas_parser.api.services.async.CdslServiceAsync +import com.cas_parser.api.services.async.CdslServiceAsyncImpl +import com.cas_parser.api.services.async.ContractNoteServiceAsync +import com.cas_parser.api.services.async.ContractNoteServiceAsyncImpl +import com.cas_parser.api.services.async.CreditServiceAsync +import com.cas_parser.api.services.async.CreditServiceAsyncImpl +import com.cas_parser.api.services.async.InboxServiceAsync +import com.cas_parser.api.services.async.InboxServiceAsyncImpl +import com.cas_parser.api.services.async.KfintechServiceAsync +import com.cas_parser.api.services.async.KfintechServiceAsyncImpl +import com.cas_parser.api.services.async.LogServiceAsync +import com.cas_parser.api.services.async.LogServiceAsyncImpl +import com.cas_parser.api.services.async.NsdlServiceAsync +import com.cas_parser.api.services.async.NsdlServiceAsyncImpl +import com.cas_parser.api.services.async.SmartServiceAsync +import com.cas_parser.api.services.async.SmartServiceAsyncImpl +import com.cas_parser.api.services.async.VerifyTokenServiceAsync +import com.cas_parser.api.services.async.VerifyTokenServiceAsyncImpl import java.util.function.Consumer class CasParserClientAsyncImpl(private val clientOptions: ClientOptions) : CasParserClientAsync { @@ -27,12 +45,42 @@ class CasParserClientAsyncImpl(private val clientOptions: ClientOptions) : CasPa WithRawResponseImpl(clientOptions) } - private val casParser: CasParserServiceAsync by lazy { - CasParserServiceAsyncImpl(clientOptionsWithUserAgent) + private val credits: CreditServiceAsync by lazy { + CreditServiceAsyncImpl(clientOptionsWithUserAgent) } - private val casGenerator: CasGeneratorServiceAsync by lazy { - CasGeneratorServiceAsyncImpl(clientOptionsWithUserAgent) + private val logs: LogServiceAsync by lazy { LogServiceAsyncImpl(clientOptionsWithUserAgent) } + + private val accessToken: AccessTokenServiceAsync by lazy { + AccessTokenServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val verifyToken: VerifyTokenServiceAsync by lazy { + VerifyTokenServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val camsKfintech: CamsKfintechServiceAsync by lazy { + CamsKfintechServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val cdsl: CdslServiceAsync by lazy { CdslServiceAsyncImpl(clientOptionsWithUserAgent) } + + private val contractNote: ContractNoteServiceAsync by lazy { + ContractNoteServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val inbox: InboxServiceAsync by lazy { + InboxServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val kfintech: KfintechServiceAsync by lazy { + KfintechServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val nsdl: NsdlServiceAsync by lazy { NsdlServiceAsyncImpl(clientOptionsWithUserAgent) } + + private val smart: SmartServiceAsync by lazy { + SmartServiceAsyncImpl(clientOptionsWithUserAgent) } override fun sync(): CasParserClient = sync @@ -42,21 +90,75 @@ class CasParserClientAsyncImpl(private val clientOptions: ClientOptions) : CasPa override fun withOptions(modifier: Consumer): CasParserClientAsync = CasParserClientAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun casParser(): CasParserServiceAsync = casParser + override fun credits(): CreditServiceAsync = credits + + override fun logs(): LogServiceAsync = logs + + override fun accessToken(): AccessTokenServiceAsync = accessToken + + override fun verifyToken(): VerifyTokenServiceAsync = verifyToken + + override fun camsKfintech(): CamsKfintechServiceAsync = camsKfintech + + override fun cdsl(): CdslServiceAsync = cdsl - override fun casGenerator(): CasGeneratorServiceAsync = casGenerator + override fun contractNote(): ContractNoteServiceAsync = contractNote + + override fun inbox(): InboxServiceAsync = inbox + + override fun kfintech(): KfintechServiceAsync = kfintech + + override fun nsdl(): NsdlServiceAsync = nsdl + + override fun smart(): SmartServiceAsync = smart override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CasParserClientAsync.WithRawResponse { - private val casParser: CasParserServiceAsync.WithRawResponse by lazy { - CasParserServiceAsyncImpl.WithRawResponseImpl(clientOptions) + private val credits: CreditServiceAsync.WithRawResponse by lazy { + CreditServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val logs: LogServiceAsync.WithRawResponse by lazy { + LogServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val casGenerator: CasGeneratorServiceAsync.WithRawResponse by lazy { - CasGeneratorServiceAsyncImpl.WithRawResponseImpl(clientOptions) + private val accessToken: AccessTokenServiceAsync.WithRawResponse by lazy { + AccessTokenServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val verifyToken: VerifyTokenServiceAsync.WithRawResponse by lazy { + VerifyTokenServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val camsKfintech: CamsKfintechServiceAsync.WithRawResponse by lazy { + CamsKfintechServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val cdsl: CdslServiceAsync.WithRawResponse by lazy { + CdslServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val contractNote: ContractNoteServiceAsync.WithRawResponse by lazy { + ContractNoteServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val inbox: InboxServiceAsync.WithRawResponse by lazy { + InboxServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val kfintech: KfintechServiceAsync.WithRawResponse by lazy { + KfintechServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val nsdl: NsdlServiceAsync.WithRawResponse by lazy { + NsdlServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val smart: SmartServiceAsync.WithRawResponse by lazy { + SmartServiceAsyncImpl.WithRawResponseImpl(clientOptions) } override fun withOptions( @@ -66,8 +168,26 @@ class CasParserClientAsyncImpl(private val clientOptions: ClientOptions) : CasPa clientOptions.toBuilder().apply(modifier::accept).build() ) - override fun casParser(): CasParserServiceAsync.WithRawResponse = casParser + override fun credits(): CreditServiceAsync.WithRawResponse = credits + + override fun logs(): LogServiceAsync.WithRawResponse = logs + + override fun accessToken(): AccessTokenServiceAsync.WithRawResponse = accessToken + + override fun verifyToken(): VerifyTokenServiceAsync.WithRawResponse = verifyToken + + override fun camsKfintech(): CamsKfintechServiceAsync.WithRawResponse = camsKfintech + + override fun cdsl(): CdslServiceAsync.WithRawResponse = cdsl + + override fun contractNote(): ContractNoteServiceAsync.WithRawResponse = contractNote + + override fun inbox(): InboxServiceAsync.WithRawResponse = inbox + + override fun kfintech(): KfintechServiceAsync.WithRawResponse = kfintech + + override fun nsdl(): NsdlServiceAsync.WithRawResponse = nsdl - override fun casGenerator(): CasGeneratorServiceAsync.WithRawResponse = casGenerator + override fun smart(): SmartServiceAsync.WithRawResponse = smart } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClientImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClientImpl.kt index fe0f962..f4b18e8 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClientImpl.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/client/CasParserClientImpl.kt @@ -4,10 +4,28 @@ package com.cas_parser.api.client import com.cas_parser.api.core.ClientOptions import com.cas_parser.api.core.getPackageVersion -import com.cas_parser.api.services.blocking.CasGeneratorService -import com.cas_parser.api.services.blocking.CasGeneratorServiceImpl -import com.cas_parser.api.services.blocking.CasParserService -import com.cas_parser.api.services.blocking.CasParserServiceImpl +import com.cas_parser.api.services.blocking.AccessTokenService +import com.cas_parser.api.services.blocking.AccessTokenServiceImpl +import com.cas_parser.api.services.blocking.CamsKfintechService +import com.cas_parser.api.services.blocking.CamsKfintechServiceImpl +import com.cas_parser.api.services.blocking.CdslService +import com.cas_parser.api.services.blocking.CdslServiceImpl +import com.cas_parser.api.services.blocking.ContractNoteService +import com.cas_parser.api.services.blocking.ContractNoteServiceImpl +import com.cas_parser.api.services.blocking.CreditService +import com.cas_parser.api.services.blocking.CreditServiceImpl +import com.cas_parser.api.services.blocking.InboxService +import com.cas_parser.api.services.blocking.InboxServiceImpl +import com.cas_parser.api.services.blocking.KfintechService +import com.cas_parser.api.services.blocking.KfintechServiceImpl +import com.cas_parser.api.services.blocking.LogService +import com.cas_parser.api.services.blocking.LogServiceImpl +import com.cas_parser.api.services.blocking.NsdlService +import com.cas_parser.api.services.blocking.NsdlServiceImpl +import com.cas_parser.api.services.blocking.SmartService +import com.cas_parser.api.services.blocking.SmartServiceImpl +import com.cas_parser.api.services.blocking.VerifyTokenService +import com.cas_parser.api.services.blocking.VerifyTokenServiceImpl import java.util.function.Consumer class CasParserClientImpl(private val clientOptions: ClientOptions) : CasParserClient { @@ -27,14 +45,38 @@ class CasParserClientImpl(private val clientOptions: ClientOptions) : CasParserC WithRawResponseImpl(clientOptions) } - private val casParser: CasParserService by lazy { - CasParserServiceImpl(clientOptionsWithUserAgent) + private val credits: CreditService by lazy { CreditServiceImpl(clientOptionsWithUserAgent) } + + private val logs: LogService by lazy { LogServiceImpl(clientOptionsWithUserAgent) } + + private val accessToken: AccessTokenService by lazy { + AccessTokenServiceImpl(clientOptionsWithUserAgent) + } + + private val verifyToken: VerifyTokenService by lazy { + VerifyTokenServiceImpl(clientOptionsWithUserAgent) + } + + private val camsKfintech: CamsKfintechService by lazy { + CamsKfintechServiceImpl(clientOptionsWithUserAgent) } - private val casGenerator: CasGeneratorService by lazy { - CasGeneratorServiceImpl(clientOptionsWithUserAgent) + private val cdsl: CdslService by lazy { CdslServiceImpl(clientOptionsWithUserAgent) } + + private val contractNote: ContractNoteService by lazy { + ContractNoteServiceImpl(clientOptionsWithUserAgent) + } + + private val inbox: InboxService by lazy { InboxServiceImpl(clientOptionsWithUserAgent) } + + private val kfintech: KfintechService by lazy { + KfintechServiceImpl(clientOptionsWithUserAgent) } + private val nsdl: NsdlService by lazy { NsdlServiceImpl(clientOptionsWithUserAgent) } + + private val smart: SmartService by lazy { SmartServiceImpl(clientOptionsWithUserAgent) } + override fun async(): CasParserClientAsync = async override fun withRawResponse(): CasParserClient.WithRawResponse = withRawResponse @@ -42,21 +84,75 @@ class CasParserClientImpl(private val clientOptions: ClientOptions) : CasParserC override fun withOptions(modifier: Consumer): CasParserClient = CasParserClientImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun casParser(): CasParserService = casParser + override fun credits(): CreditService = credits - override fun casGenerator(): CasGeneratorService = casGenerator + override fun logs(): LogService = logs + + override fun accessToken(): AccessTokenService = accessToken + + override fun verifyToken(): VerifyTokenService = verifyToken + + override fun camsKfintech(): CamsKfintechService = camsKfintech + + override fun cdsl(): CdslService = cdsl + + override fun contractNote(): ContractNoteService = contractNote + + override fun inbox(): InboxService = inbox + + override fun kfintech(): KfintechService = kfintech + + override fun nsdl(): NsdlService = nsdl + + override fun smart(): SmartService = smart override fun close() = clientOptions.close() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : CasParserClient.WithRawResponse { - private val casParser: CasParserService.WithRawResponse by lazy { - CasParserServiceImpl.WithRawResponseImpl(clientOptions) + private val credits: CreditService.WithRawResponse by lazy { + CreditServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val logs: LogService.WithRawResponse by lazy { + LogServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val accessToken: AccessTokenService.WithRawResponse by lazy { + AccessTokenServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val verifyToken: VerifyTokenService.WithRawResponse by lazy { + VerifyTokenServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val camsKfintech: CamsKfintechService.WithRawResponse by lazy { + CamsKfintechServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val cdsl: CdslService.WithRawResponse by lazy { + CdslServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val contractNote: ContractNoteService.WithRawResponse by lazy { + ContractNoteServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val inbox: InboxService.WithRawResponse by lazy { + InboxServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val kfintech: KfintechService.WithRawResponse by lazy { + KfintechServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val nsdl: NsdlService.WithRawResponse by lazy { + NsdlServiceImpl.WithRawResponseImpl(clientOptions) } - private val casGenerator: CasGeneratorService.WithRawResponse by lazy { - CasGeneratorServiceImpl.WithRawResponseImpl(clientOptions) + private val smart: SmartService.WithRawResponse by lazy { + SmartServiceImpl.WithRawResponseImpl(clientOptions) } override fun withOptions( @@ -66,8 +162,26 @@ class CasParserClientImpl(private val clientOptions: ClientOptions) : CasParserC clientOptions.toBuilder().apply(modifier::accept).build() ) - override fun casParser(): CasParserService.WithRawResponse = casParser + override fun credits(): CreditService.WithRawResponse = credits + + override fun logs(): LogService.WithRawResponse = logs + + override fun accessToken(): AccessTokenService.WithRawResponse = accessToken + + override fun verifyToken(): VerifyTokenService.WithRawResponse = verifyToken + + override fun camsKfintech(): CamsKfintechService.WithRawResponse = camsKfintech + + override fun cdsl(): CdslService.WithRawResponse = cdsl + + override fun contractNote(): ContractNoteService.WithRawResponse = contractNote + + override fun inbox(): InboxService.WithRawResponse = inbox + + override fun kfintech(): KfintechService.WithRawResponse = kfintech + + override fun nsdl(): NsdlService.WithRawResponse = nsdl - override fun casGenerator(): CasGeneratorService.WithRawResponse = casGenerator + override fun smart(): SmartService.WithRawResponse = smart } } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/core/ClientOptions.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/core/ClientOptions.kt index 1db211b..e3e4eaf 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/core/ClientOptions.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/core/ClientOptions.kt @@ -107,6 +107,10 @@ private constructor( * The base URL to use for every request. * * Defaults to the production environment: `https://portfolio-parser.api.casparser.in`. + * + * The following other environments, with dedicated builder methods, are available: + * - environment_1: `https://client-apis.casparser.in` + * - environment_2: `http://localhost:5000` */ fun baseUrl(): String = baseUrl ?: PRODUCTION_URL @@ -116,6 +120,10 @@ private constructor( const val PRODUCTION_URL = "https://portfolio-parser.api.casparser.in" + const val ENVIRONMENT_1_URL = "https://client-apis.casparser.in" + + const val ENVIRONMENT_2_URL = "http://localhost:5000" + /** * Returns a mutable builder for constructing an instance of [ClientOptions]. * @@ -221,12 +229,22 @@ private constructor( * The base URL to use for every request. * * Defaults to the production environment: `https://portfolio-parser.api.casparser.in`. + * + * The following other environments, with dedicated builder methods, are available: + * - environment_1: `https://client-apis.casparser.in` + * - environment_2: `http://localhost:5000` */ fun baseUrl(baseUrl: String?) = apply { this.baseUrl = baseUrl } /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) + /** Sets [baseUrl] to `https://client-apis.casparser.in`. */ + fun environment1() = baseUrl(ENVIRONMENT_1_URL) + + /** Sets [baseUrl] to `http://localhost:5000`. */ + fun environment2() = baseUrl(ENVIRONMENT_2_URL) + /** * Whether to call `validate` on every response before returning it. * diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateParams.kt new file mode 100644 index 0000000..676dc4d --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateParams.kt @@ -0,0 +1,410 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.accesstoken + +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.Params +import com.cas_parser.api.core.http.Headers +import com.cas_parser.api.core.http.QueryParams +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** + * Generate a short-lived access token from your API key. + * + * **Use this endpoint from your backend** to create tokens that can be safely passed to + * frontend/SDK. + * + * Access tokens: + * - Are prefixed with `at_` for easy identification + * - Valid for up to 60 minutes + * - Can be used in place of API keys on all v4 endpoints + * - Cannot be used to generate other access tokens + */ +class AccessTokenCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Token validity in minutes (max 60) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expiryMinutes(): Optional = body.expiryMinutes() + + /** + * Returns the raw JSON value of [expiryMinutes]. + * + * Unlike [expiryMinutes], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _expiryMinutes(): JsonField = body._expiryMinutes() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): AccessTokenCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [AccessTokenCreateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccessTokenCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(accessTokenCreateParams: AccessTokenCreateParams) = apply { + body = accessTokenCreateParams.body.toBuilder() + additionalHeaders = accessTokenCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = accessTokenCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [expiryMinutes] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Token validity in minutes (max 60) */ + fun expiryMinutes(expiryMinutes: Long) = apply { body.expiryMinutes(expiryMinutes) } + + /** + * Sets [Builder.expiryMinutes] to an arbitrary JSON value. + * + * You should usually call [Builder.expiryMinutes] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun expiryMinutes(expiryMinutes: JsonField) = apply { + body.expiryMinutes(expiryMinutes) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [AccessTokenCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AccessTokenCreateParams = + AccessTokenCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val expiryMinutes: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("expiry_minutes") + @ExcludeMissing + expiryMinutes: JsonField = JsonMissing.of() + ) : this(expiryMinutes, mutableMapOf()) + + /** + * Token validity in minutes (max 60) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun expiryMinutes(): Optional = expiryMinutes.getOptional("expiry_minutes") + + /** + * Returns the raw JSON value of [expiryMinutes]. + * + * Unlike [expiryMinutes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("expiry_minutes") + @ExcludeMissing + fun _expiryMinutes(): JsonField = expiryMinutes + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var expiryMinutes: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + expiryMinutes = body.expiryMinutes + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** Token validity in minutes (max 60) */ + fun expiryMinutes(expiryMinutes: Long) = expiryMinutes(JsonField.of(expiryMinutes)) + + /** + * Sets [Builder.expiryMinutes] to an arbitrary JSON value. + * + * You should usually call [Builder.expiryMinutes] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expiryMinutes(expiryMinutes: JsonField) = apply { + this.expiryMinutes = expiryMinutes + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(expiryMinutes, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + expiryMinutes() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (if (expiryMinutes.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + expiryMinutes == other.expiryMinutes && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(expiryMinutes, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{expiryMinutes=$expiryMinutes, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AccessTokenCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "AccessTokenCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateResponse.kt new file mode 100644 index 0000000..a23d37b --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateResponse.kt @@ -0,0 +1,239 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.accesstoken + +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional + +class AccessTokenCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val accessToken: JsonField, + private val expiresIn: JsonField, + private val tokenType: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("access_token") + @ExcludeMissing + accessToken: JsonField = JsonMissing.of(), + @JsonProperty("expires_in") @ExcludeMissing expiresIn: JsonField = JsonMissing.of(), + @JsonProperty("token_type") @ExcludeMissing tokenType: JsonField = JsonMissing.of(), + ) : this(accessToken, expiresIn, tokenType, mutableMapOf()) + + /** + * The at_ prefixed access token + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun accessToken(): Optional = accessToken.getOptional("access_token") + + /** + * Token validity in seconds + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expiresIn(): Optional = expiresIn.getOptional("expires_in") + + /** + * Always "api_key" - token is a drop-in replacement for x-api-key header + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun tokenType(): Optional = tokenType.getOptional("token_type") + + /** + * Returns the raw JSON value of [accessToken]. + * + * Unlike [accessToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("access_token") + @ExcludeMissing + fun _accessToken(): JsonField = accessToken + + /** + * Returns the raw JSON value of [expiresIn]. + * + * Unlike [expiresIn], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expires_in") @ExcludeMissing fun _expiresIn(): JsonField = expiresIn + + /** + * Returns the raw JSON value of [tokenType]. + * + * Unlike [tokenType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token_type") @ExcludeMissing fun _tokenType(): JsonField = tokenType + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [AccessTokenCreateResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AccessTokenCreateResponse]. */ + class Builder internal constructor() { + + private var accessToken: JsonField = JsonMissing.of() + private var expiresIn: JsonField = JsonMissing.of() + private var tokenType: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(accessTokenCreateResponse: AccessTokenCreateResponse) = apply { + accessToken = accessTokenCreateResponse.accessToken + expiresIn = accessTokenCreateResponse.expiresIn + tokenType = accessTokenCreateResponse.tokenType + additionalProperties = accessTokenCreateResponse.additionalProperties.toMutableMap() + } + + /** The at_ prefixed access token */ + fun accessToken(accessToken: String) = accessToken(JsonField.of(accessToken)) + + /** + * Sets [Builder.accessToken] to an arbitrary JSON value. + * + * You should usually call [Builder.accessToken] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun accessToken(accessToken: JsonField) = apply { this.accessToken = accessToken } + + /** Token validity in seconds */ + fun expiresIn(expiresIn: Long) = expiresIn(JsonField.of(expiresIn)) + + /** + * Sets [Builder.expiresIn] to an arbitrary JSON value. + * + * You should usually call [Builder.expiresIn] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun expiresIn(expiresIn: JsonField) = apply { this.expiresIn = expiresIn } + + /** Always "api_key" - token is a drop-in replacement for x-api-key header */ + fun tokenType(tokenType: String) = tokenType(JsonField.of(tokenType)) + + /** + * Sets [Builder.tokenType] to an arbitrary JSON value. + * + * You should usually call [Builder.tokenType] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tokenType(tokenType: JsonField) = apply { this.tokenType = tokenType } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AccessTokenCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AccessTokenCreateResponse = + AccessTokenCreateResponse( + accessToken, + expiresIn, + tokenType, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AccessTokenCreateResponse = apply { + if (validated) { + return@apply + } + + accessToken() + expiresIn() + tokenType() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (accessToken.asKnown().isPresent) 1 else 0) + + (if (expiresIn.asKnown().isPresent) 1 else 0) + + (if (tokenType.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AccessTokenCreateResponse && + accessToken == other.accessToken && + expiresIn == other.expiresIn && + tokenType == other.tokenType && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(accessToken, expiresIn, tokenType, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AccessTokenCreateResponse{accessToken=$accessToken, expiresIn=$expiresIn, tokenType=$tokenType, additionalProperties=$additionalProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/casparser/CasParserCamsKfintechParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/camskfintech/CamsKfintechParseParams.kt similarity index 94% rename from cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/casparser/CasParserCamsKfintechParams.kt rename to cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/camskfintech/CamsKfintechParseParams.kt index 131d1dd..2b503a6 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/casparser/CasParserCamsKfintechParams.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/camskfintech/CamsKfintechParseParams.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.cas_parser.api.models.casparser +package com.cas_parser.api.models.camskfintech import com.cas_parser.api.core.ExcludeMissing import com.cas_parser.api.core.JsonValue @@ -22,7 +22,7 @@ import java.util.Optional * and returns data in a unified format. Use this endpoint when you know the PDF is from CAMS or * KFintech. */ -class CasParserCamsKfintechParams +class CamsKfintechParseParams private constructor( private val body: Body, private val additionalHeaders: Headers, @@ -86,15 +86,13 @@ private constructor( companion object { - @JvmStatic fun none(): CasParserCamsKfintechParams = builder().build() + @JvmStatic fun none(): CamsKfintechParseParams = builder().build() - /** - * Returns a mutable builder for constructing an instance of [CasParserCamsKfintechParams]. - */ + /** Returns a mutable builder for constructing an instance of [CamsKfintechParseParams]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [CasParserCamsKfintechParams]. */ + /** A builder for [CamsKfintechParseParams]. */ class Builder internal constructor() { private var body: Body.Builder = Body.builder() @@ -102,10 +100,10 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(casParserCamsKfintechParams: CasParserCamsKfintechParams) = apply { - body = casParserCamsKfintechParams.body.toBuilder() - additionalHeaders = casParserCamsKfintechParams.additionalHeaders.toBuilder() - additionalQueryParams = casParserCamsKfintechParams.additionalQueryParams.toBuilder() + internal fun from(camsKfintechParseParams: CamsKfintechParseParams) = apply { + body = camsKfintechParseParams.body.toBuilder() + additionalHeaders = camsKfintechParseParams.additionalHeaders.toBuilder() + additionalQueryParams = camsKfintechParseParams.additionalQueryParams.toBuilder() } /** @@ -270,12 +268,12 @@ private constructor( } /** - * Returns an immutable instance of [CasParserCamsKfintechParams]. + * Returns an immutable instance of [CamsKfintechParseParams]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): CasParserCamsKfintechParams = - CasParserCamsKfintechParams( + fun build(): CamsKfintechParseParams = + CamsKfintechParseParams( body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -492,7 +490,7 @@ private constructor( return true } - return other is CasParserCamsKfintechParams && + return other is CamsKfintechParseParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams @@ -501,5 +499,5 @@ private constructor( override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = - "CasParserCamsKfintechParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "CamsKfintechParseParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/camskfintech/LinkedHolder.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/camskfintech/LinkedHolder.kt new file mode 100644 index 0000000..9aa025d --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/camskfintech/LinkedHolder.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.camskfintech + +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional + +class LinkedHolder +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val name: JsonField, + private val pan: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("pan") @ExcludeMissing pan: JsonField = JsonMissing.of(), + ) : this(name, pan, mutableMapOf()) + + /** + * Name of the account holder + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * PAN of the account holder + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun pan(): Optional = pan.getOptional("pan") + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [pan]. + * + * Unlike [pan], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pan") @ExcludeMissing fun _pan(): JsonField = pan + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [LinkedHolder]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LinkedHolder]. */ + class Builder internal constructor() { + + private var name: JsonField = JsonMissing.of() + private var pan: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(linkedHolder: LinkedHolder) = apply { + name = linkedHolder.name + pan = linkedHolder.pan + additionalProperties = linkedHolder.additionalProperties.toMutableMap() + } + + /** Name of the account holder */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** PAN of the account holder */ + fun pan(pan: String) = pan(JsonField.of(pan)) + + /** + * Sets [Builder.pan] to an arbitrary JSON value. + * + * You should usually call [Builder.pan] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun pan(pan: JsonField) = apply { this.pan = pan } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LinkedHolder]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LinkedHolder = LinkedHolder(name, pan, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): LinkedHolder = apply { + if (validated) { + return@apply + } + + name() + pan() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (name.asKnown().isPresent) 1 else 0) + (if (pan.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LinkedHolder && + name == other.name && + pan == other.pan && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(name, pan, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LinkedHolder{name=$name, pan=$pan, additionalProperties=$additionalProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/camskfintech/Transaction.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/camskfintech/Transaction.kt new file mode 100644 index 0000000..64c2700 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/camskfintech/Transaction.kt @@ -0,0 +1,1129 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.camskfintech + +import com.cas_parser.api.core.Enum +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.time.LocalDate +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Unified transaction schema for all holding types (MF folios, equities, bonds, etc.) */ +class Transaction +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val additionalInfo: JsonField, + private val amount: JsonField, + private val balance: JsonField, + private val date: JsonField, + private val description: JsonField, + private val dividendRate: JsonField, + private val nav: JsonField, + private val type: JsonField, + private val units: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("additional_info") + @ExcludeMissing + additionalInfo: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("balance") @ExcludeMissing balance: JsonField = JsonMissing.of(), + @JsonProperty("date") @ExcludeMissing date: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("dividend_rate") + @ExcludeMissing + dividendRate: JsonField = JsonMissing.of(), + @JsonProperty("nav") @ExcludeMissing nav: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("units") @ExcludeMissing units: JsonField = JsonMissing.of(), + ) : this( + additionalInfo, + amount, + balance, + date, + description, + dividendRate, + nav, + type, + units, + mutableMapOf(), + ) + + /** + * Additional transaction-specific fields that vary by source + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun additionalInfo(): Optional = additionalInfo.getOptional("additional_info") + + /** + * Transaction amount in currency (computed from units × price/NAV) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * Balance units after transaction + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun balance(): Optional = balance.getOptional("balance") + + /** + * Transaction date (YYYY-MM-DD) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun date(): Optional = date.getOptional("date") + + /** + * Transaction description/particulars + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * Dividend rate (for DIVIDEND_PAYOUT transactions) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dividendRate(): Optional = dividendRate.getOptional("dividend_rate") + + /** + * NAV/price per unit on transaction date + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun nav(): Optional = nav.getOptional("nav") + + /** + * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, SWITCH_IN, + * SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, DIVIDEND_REINVEST, + * SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, REVERSAL, UNKNOWN. + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Number of units involved in transaction + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun units(): Optional = units.getOptional("units") + + /** + * Returns the raw JSON value of [additionalInfo]. + * + * Unlike [additionalInfo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("additional_info") + @ExcludeMissing + fun _additionalInfo(): JsonField = additionalInfo + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [balance]. + * + * Unlike [balance], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("balance") @ExcludeMissing fun _balance(): JsonField = balance + + /** + * Returns the raw JSON value of [date]. + * + * Unlike [date], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("date") @ExcludeMissing fun _date(): JsonField = date + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [dividendRate]. + * + * Unlike [dividendRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dividend_rate") + @ExcludeMissing + fun _dividendRate(): JsonField = dividendRate + + /** + * Returns the raw JSON value of [nav]. + * + * Unlike [nav], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("nav") @ExcludeMissing fun _nav(): JsonField = nav + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [units]. + * + * Unlike [units], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("units") @ExcludeMissing fun _units(): JsonField = units + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Transaction]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Transaction]. */ + class Builder internal constructor() { + + private var additionalInfo: JsonField = JsonMissing.of() + private var amount: JsonField = JsonMissing.of() + private var balance: JsonField = JsonMissing.of() + private var date: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var dividendRate: JsonField = JsonMissing.of() + private var nav: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var units: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(transaction: Transaction) = apply { + additionalInfo = transaction.additionalInfo + amount = transaction.amount + balance = transaction.balance + date = transaction.date + description = transaction.description + dividendRate = transaction.dividendRate + nav = transaction.nav + type = transaction.type + units = transaction.units + additionalProperties = transaction.additionalProperties.toMutableMap() + } + + /** Additional transaction-specific fields that vary by source */ + fun additionalInfo(additionalInfo: AdditionalInfo) = + additionalInfo(JsonField.of(additionalInfo)) + + /** + * Sets [Builder.additionalInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.additionalInfo] with a well-typed [AdditionalInfo] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun additionalInfo(additionalInfo: JsonField) = apply { + this.additionalInfo = additionalInfo + } + + /** Transaction amount in currency (computed from units × price/NAV) */ + fun amount(amount: Float?) = amount(JsonField.ofNullable(amount)) + + /** + * Alias for [Builder.amount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun amount(amount: Float) = amount(amount as Float?) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Float] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** Balance units after transaction */ + fun balance(balance: Float) = balance(JsonField.of(balance)) + + /** + * Sets [Builder.balance] to an arbitrary JSON value. + * + * You should usually call [Builder.balance] with a well-typed [Float] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun balance(balance: JsonField) = apply { this.balance = balance } + + /** Transaction date (YYYY-MM-DD) */ + fun date(date: LocalDate) = date(JsonField.of(date)) + + /** + * Sets [Builder.date] to an arbitrary JSON value. + * + * You should usually call [Builder.date] with a well-typed [LocalDate] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun date(date: JsonField) = apply { this.date = date } + + /** Transaction description/particulars */ + fun description(description: String) = description(JsonField.of(description)) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { this.description = description } + + /** Dividend rate (for DIVIDEND_PAYOUT transactions) */ + fun dividendRate(dividendRate: Float?) = dividendRate(JsonField.ofNullable(dividendRate)) + + /** + * Alias for [Builder.dividendRate]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun dividendRate(dividendRate: Float) = dividendRate(dividendRate as Float?) + + /** Alias for calling [Builder.dividendRate] with `dividendRate.orElse(null)`. */ + fun dividendRate(dividendRate: Optional) = dividendRate(dividendRate.getOrNull()) + + /** + * Sets [Builder.dividendRate] to an arbitrary JSON value. + * + * You should usually call [Builder.dividendRate] with a well-typed [Float] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dividendRate(dividendRate: JsonField) = apply { + this.dividendRate = dividendRate + } + + /** NAV/price per unit on transaction date */ + fun nav(nav: Float?) = nav(JsonField.ofNullable(nav)) + + /** + * Alias for [Builder.nav]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun nav(nav: Float) = nav(nav as Float?) + + /** Alias for calling [Builder.nav] with `nav.orElse(null)`. */ + fun nav(nav: Optional) = nav(nav.getOrNull()) + + /** + * Sets [Builder.nav] to an arbitrary JSON value. + * + * You should usually call [Builder.nav] with a well-typed [Float] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun nav(nav: JsonField) = apply { this.nav = nav } + + /** + * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, SWITCH_IN, + * SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, DIVIDEND_REINVEST, + * SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, REVERSAL, UNKNOWN. + */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** Number of units involved in transaction */ + fun units(units: Float) = units(JsonField.of(units)) + + /** + * Sets [Builder.units] to an arbitrary JSON value. + * + * You should usually call [Builder.units] with a well-typed [Float] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun units(units: JsonField) = apply { this.units = units } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Transaction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Transaction = + Transaction( + additionalInfo, + amount, + balance, + date, + description, + dividendRate, + nav, + type, + units, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Transaction = apply { + if (validated) { + return@apply + } + + additionalInfo().ifPresent { it.validate() } + amount() + balance() + date() + description() + dividendRate() + nav() + type().ifPresent { it.validate() } + units() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (additionalInfo.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (if (balance.asKnown().isPresent) 1 else 0) + + (if (date.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (dividendRate.asKnown().isPresent) 1 else 0) + + (if (nav.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (units.asKnown().isPresent) 1 else 0) + + /** Additional transaction-specific fields that vary by source */ + class AdditionalInfo + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val capitalWithdrawal: JsonField, + private val credit: JsonField, + private val debit: JsonField, + private val incomeDistribution: JsonField, + private val orderNo: JsonField, + private val price: JsonField, + private val stampDuty: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("capital_withdrawal") + @ExcludeMissing + capitalWithdrawal: JsonField = JsonMissing.of(), + @JsonProperty("credit") @ExcludeMissing credit: JsonField = JsonMissing.of(), + @JsonProperty("debit") @ExcludeMissing debit: JsonField = JsonMissing.of(), + @JsonProperty("income_distribution") + @ExcludeMissing + incomeDistribution: JsonField = JsonMissing.of(), + @JsonProperty("order_no") @ExcludeMissing orderNo: JsonField = JsonMissing.of(), + @JsonProperty("price") @ExcludeMissing price: JsonField = JsonMissing.of(), + @JsonProperty("stamp_duty") + @ExcludeMissing + stampDuty: JsonField = JsonMissing.of(), + ) : this( + capitalWithdrawal, + credit, + debit, + incomeDistribution, + orderNo, + price, + stampDuty, + mutableMapOf(), + ) + + /** + * Capital withdrawal amount (CDSL MF transactions) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun capitalWithdrawal(): Optional = + capitalWithdrawal.getOptional("capital_withdrawal") + + /** + * Units credited (demat transactions) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun credit(): Optional = credit.getOptional("credit") + + /** + * Units debited (demat transactions) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun debit(): Optional = debit.getOptional("debit") + + /** + * Income distribution amount (CDSL MF transactions) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun incomeDistribution(): Optional = + incomeDistribution.getOptional("income_distribution") + + /** + * Order/transaction reference number (demat transactions) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun orderNo(): Optional = orderNo.getOptional("order_no") + + /** + * Price per unit (NSDL/CDSL MF transactions) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun price(): Optional = price.getOptional("price") + + /** + * Stamp duty charged + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun stampDuty(): Optional = stampDuty.getOptional("stamp_duty") + + /** + * Returns the raw JSON value of [capitalWithdrawal]. + * + * Unlike [capitalWithdrawal], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("capital_withdrawal") + @ExcludeMissing + fun _capitalWithdrawal(): JsonField = capitalWithdrawal + + /** + * Returns the raw JSON value of [credit]. + * + * Unlike [credit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credit") @ExcludeMissing fun _credit(): JsonField = credit + + /** + * Returns the raw JSON value of [debit]. + * + * Unlike [debit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("debit") @ExcludeMissing fun _debit(): JsonField = debit + + /** + * Returns the raw JSON value of [incomeDistribution]. + * + * Unlike [incomeDistribution], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("income_distribution") + @ExcludeMissing + fun _incomeDistribution(): JsonField = incomeDistribution + + /** + * Returns the raw JSON value of [orderNo]. + * + * Unlike [orderNo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("order_no") @ExcludeMissing fun _orderNo(): JsonField = orderNo + + /** + * Returns the raw JSON value of [price]. + * + * Unlike [price], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + + /** + * Returns the raw JSON value of [stampDuty]. + * + * Unlike [stampDuty], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("stamp_duty") @ExcludeMissing fun _stampDuty(): JsonField = stampDuty + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [AdditionalInfo]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AdditionalInfo]. */ + class Builder internal constructor() { + + private var capitalWithdrawal: JsonField = JsonMissing.of() + private var credit: JsonField = JsonMissing.of() + private var debit: JsonField = JsonMissing.of() + private var incomeDistribution: JsonField = JsonMissing.of() + private var orderNo: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var stampDuty: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(additionalInfo: AdditionalInfo) = apply { + capitalWithdrawal = additionalInfo.capitalWithdrawal + credit = additionalInfo.credit + debit = additionalInfo.debit + incomeDistribution = additionalInfo.incomeDistribution + orderNo = additionalInfo.orderNo + price = additionalInfo.price + stampDuty = additionalInfo.stampDuty + additionalProperties = additionalInfo.additionalProperties.toMutableMap() + } + + /** Capital withdrawal amount (CDSL MF transactions) */ + fun capitalWithdrawal(capitalWithdrawal: Float) = + capitalWithdrawal(JsonField.of(capitalWithdrawal)) + + /** + * Sets [Builder.capitalWithdrawal] to an arbitrary JSON value. + * + * You should usually call [Builder.capitalWithdrawal] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun capitalWithdrawal(capitalWithdrawal: JsonField) = apply { + this.capitalWithdrawal = capitalWithdrawal + } + + /** Units credited (demat transactions) */ + fun credit(credit: Float) = credit(JsonField.of(credit)) + + /** + * Sets [Builder.credit] to an arbitrary JSON value. + * + * You should usually call [Builder.credit] with a well-typed [Float] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun credit(credit: JsonField) = apply { this.credit = credit } + + /** Units debited (demat transactions) */ + fun debit(debit: Float) = debit(JsonField.of(debit)) + + /** + * Sets [Builder.debit] to an arbitrary JSON value. + * + * You should usually call [Builder.debit] with a well-typed [Float] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun debit(debit: JsonField) = apply { this.debit = debit } + + /** Income distribution amount (CDSL MF transactions) */ + fun incomeDistribution(incomeDistribution: Float) = + incomeDistribution(JsonField.of(incomeDistribution)) + + /** + * Sets [Builder.incomeDistribution] to an arbitrary JSON value. + * + * You should usually call [Builder.incomeDistribution] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun incomeDistribution(incomeDistribution: JsonField) = apply { + this.incomeDistribution = incomeDistribution + } + + /** Order/transaction reference number (demat transactions) */ + fun orderNo(orderNo: String) = orderNo(JsonField.of(orderNo)) + + /** + * Sets [Builder.orderNo] to an arbitrary JSON value. + * + * You should usually call [Builder.orderNo] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun orderNo(orderNo: JsonField) = apply { this.orderNo = orderNo } + + /** Price per unit (NSDL/CDSL MF transactions) */ + fun price(price: Float) = price(JsonField.of(price)) + + /** + * Sets [Builder.price] to an arbitrary JSON value. + * + * You should usually call [Builder.price] with a well-typed [Float] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun price(price: JsonField) = apply { this.price = price } + + /** Stamp duty charged */ + fun stampDuty(stampDuty: Float) = stampDuty(JsonField.of(stampDuty)) + + /** + * Sets [Builder.stampDuty] to an arbitrary JSON value. + * + * You should usually call [Builder.stampDuty] with a well-typed [Float] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun stampDuty(stampDuty: JsonField) = apply { this.stampDuty = stampDuty } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [AdditionalInfo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): AdditionalInfo = + AdditionalInfo( + capitalWithdrawal, + credit, + debit, + incomeDistribution, + orderNo, + price, + stampDuty, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): AdditionalInfo = apply { + if (validated) { + return@apply + } + + capitalWithdrawal() + credit() + debit() + incomeDistribution() + orderNo() + price() + stampDuty() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (capitalWithdrawal.asKnown().isPresent) 1 else 0) + + (if (credit.asKnown().isPresent) 1 else 0) + + (if (debit.asKnown().isPresent) 1 else 0) + + (if (incomeDistribution.asKnown().isPresent) 1 else 0) + + (if (orderNo.asKnown().isPresent) 1 else 0) + + (if (price.asKnown().isPresent) 1 else 0) + + (if (stampDuty.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AdditionalInfo && + capitalWithdrawal == other.capitalWithdrawal && + credit == other.credit && + debit == other.debit && + incomeDistribution == other.incomeDistribution && + orderNo == other.orderNo && + price == other.price && + stampDuty == other.stampDuty && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + capitalWithdrawal, + credit, + debit, + incomeDistribution, + orderNo, + price, + stampDuty, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AdditionalInfo{capitalWithdrawal=$capitalWithdrawal, credit=$credit, debit=$debit, incomeDistribution=$incomeDistribution, orderNo=$orderNo, price=$price, stampDuty=$stampDuty, additionalProperties=$additionalProperties}" + } + + /** + * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, SWITCH_IN, + * SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, DIVIDEND_REINVEST, + * SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, REVERSAL, UNKNOWN. + */ + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PURCHASE = of("PURCHASE") + + @JvmField val PURCHASE_SIP = of("PURCHASE_SIP") + + @JvmField val REDEMPTION = of("REDEMPTION") + + @JvmField val SWITCH_IN = of("SWITCH_IN") + + @JvmField val SWITCH_IN_MERGER = of("SWITCH_IN_MERGER") + + @JvmField val SWITCH_OUT = of("SWITCH_OUT") + + @JvmField val SWITCH_OUT_MERGER = of("SWITCH_OUT_MERGER") + + @JvmField val DIVIDEND_PAYOUT = of("DIVIDEND_PAYOUT") + + @JvmField val DIVIDEND_REINVEST = of("DIVIDEND_REINVEST") + + @JvmField val SEGREGATION = of("SEGREGATION") + + @JvmField val STAMP_DUTY_TAX = of("STAMP_DUTY_TAX") + + @JvmField val TDS_TAX = of("TDS_TAX") + + @JvmField val STT_TAX = of("STT_TAX") + + @JvmField val MISC = of("MISC") + + @JvmField val REVERSAL = of("REVERSAL") + + @JvmField val UNKNOWN = of("UNKNOWN") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + PURCHASE, + PURCHASE_SIP, + REDEMPTION, + SWITCH_IN, + SWITCH_IN_MERGER, + SWITCH_OUT, + SWITCH_OUT_MERGER, + DIVIDEND_PAYOUT, + DIVIDEND_REINVEST, + SEGREGATION, + STAMP_DUTY_TAX, + TDS_TAX, + STT_TAX, + MISC, + REVERSAL, + UNKNOWN, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PURCHASE, + PURCHASE_SIP, + REDEMPTION, + SWITCH_IN, + SWITCH_IN_MERGER, + SWITCH_OUT, + SWITCH_OUT_MERGER, + DIVIDEND_PAYOUT, + DIVIDEND_REINVEST, + SEGREGATION, + STAMP_DUTY_TAX, + TDS_TAX, + STT_TAX, + MISC, + REVERSAL, + UNKNOWN, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PURCHASE -> Value.PURCHASE + PURCHASE_SIP -> Value.PURCHASE_SIP + REDEMPTION -> Value.REDEMPTION + SWITCH_IN -> Value.SWITCH_IN + SWITCH_IN_MERGER -> Value.SWITCH_IN_MERGER + SWITCH_OUT -> Value.SWITCH_OUT + SWITCH_OUT_MERGER -> Value.SWITCH_OUT_MERGER + DIVIDEND_PAYOUT -> Value.DIVIDEND_PAYOUT + DIVIDEND_REINVEST -> Value.DIVIDEND_REINVEST + SEGREGATION -> Value.SEGREGATION + STAMP_DUTY_TAX -> Value.STAMP_DUTY_TAX + TDS_TAX -> Value.TDS_TAX + STT_TAX -> Value.STT_TAX + MISC -> Value.MISC + REVERSAL -> Value.REVERSAL + UNKNOWN -> Value.UNKNOWN + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CasParserInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PURCHASE -> Known.PURCHASE + PURCHASE_SIP -> Known.PURCHASE_SIP + REDEMPTION -> Known.REDEMPTION + SWITCH_IN -> Known.SWITCH_IN + SWITCH_IN_MERGER -> Known.SWITCH_IN_MERGER + SWITCH_OUT -> Known.SWITCH_OUT + SWITCH_OUT_MERGER -> Known.SWITCH_OUT_MERGER + DIVIDEND_PAYOUT -> Known.DIVIDEND_PAYOUT + DIVIDEND_REINVEST -> Known.DIVIDEND_REINVEST + SEGREGATION -> Known.SEGREGATION + STAMP_DUTY_TAX -> Known.STAMP_DUTY_TAX + TDS_TAX -> Known.TDS_TAX + STT_TAX -> Known.STT_TAX + MISC -> Known.MISC + REVERSAL -> Known.REVERSAL + UNKNOWN -> Known.UNKNOWN + else -> throw CasParserInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CasParserInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CasParserInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Transaction && + additionalInfo == other.additionalInfo && + amount == other.amount && + balance == other.balance && + date == other.date && + description == other.description && + dividendRate == other.dividendRate && + nav == other.nav && + type == other.type && + units == other.units && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + additionalInfo, + amount, + balance, + date, + description, + dividendRate, + nav, + type, + units, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Transaction{additionalInfo=$additionalInfo, amount=$amount, balance=$balance, date=$date, description=$description, dividendRate=$dividendRate, nav=$nav, type=$type, units=$units, additionalProperties=$additionalProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/casparser/UnifiedResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/camskfintech/UnifiedResponse.kt similarity index 54% rename from cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/casparser/UnifiedResponse.kt rename to cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/camskfintech/UnifiedResponse.kt index 40030b6..6a27c6f 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/casparser/UnifiedResponse.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/camskfintech/UnifiedResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.cas_parser.api.models.casparser +package com.cas_parser.api.models.camskfintech import com.cas_parser.api.core.Enum import com.cas_parser.api.core.ExcludeMissing @@ -2345,1211 +2345,615 @@ private constructor( "AdditionalInfo{closeUnits=$closeUnits, openUnits=$openUnits, additionalProperties=$additionalProperties}" } - /** - * Unified transaction schema for all holding types (MF folios, equities, bonds, - * etc.) - */ - class Transaction - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val additionalInfo: JsonField, - private val amount: JsonField, - private val balance: JsonField, - private val date: JsonField, - private val description: JsonField, - private val dividendRate: JsonField, - private val nav: JsonField, - private val type: JsonField, - private val units: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonCreator - private constructor( - @JsonProperty("additional_info") - @ExcludeMissing - additionalInfo: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("balance") - @ExcludeMissing - balance: JsonField = JsonMissing.of(), - @JsonProperty("date") - @ExcludeMissing - date: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("dividend_rate") - @ExcludeMissing - dividendRate: JsonField = JsonMissing.of(), - @JsonProperty("nav") - @ExcludeMissing - nav: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonField = JsonMissing.of(), - @JsonProperty("units") - @ExcludeMissing - units: JsonField = JsonMissing.of(), - ) : this( + return other is Aif && + additionalInfo == other.additionalInfo && + isin == other.isin && + name == other.name && + transactions == other.transactions && + units == other.units && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( additionalInfo, - amount, - balance, - date, - description, - dividendRate, - nav, - type, + isin, + name, + transactions, units, - mutableMapOf(), + value, + additionalProperties, ) + } - /** - * Additional transaction-specific fields that vary by source - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun additionalInfo(): Optional = - additionalInfo.getOptional("additional_info") - - /** - * Transaction amount in currency (computed from units × price/NAV) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * Balance units after transaction - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun balance(): Optional = balance.getOptional("balance") - - /** - * Transaction date (YYYY-MM-DD) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun date(): Optional = date.getOptional("date") - - /** - * Transaction description/particulars - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") - - /** - * Dividend rate (for DIVIDEND_PAYOUT transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun dividendRate(): Optional = dividendRate.getOptional("dividend_rate") - - /** - * NAV/price per unit on transaction date - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun nav(): Optional = nav.getOptional("nav") + override fun hashCode(): Int = hashCode - /** - * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, - * SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, - * DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, - * REVERSAL, UNKNOWN. - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") + override fun toString() = + "Aif{additionalInfo=$additionalInfo, isin=$isin, name=$name, transactions=$transactions, units=$units, value=$value, additionalProperties=$additionalProperties}" + } - /** - * Number of units involved in transaction - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun units(): Optional = units.getOptional("units") + class CorporateBond + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val additionalInfo: JsonField, + private val isin: JsonField, + private val name: JsonField, + private val transactions: JsonField>, + private val units: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [additionalInfo]. - * - * Unlike [additionalInfo], this method doesn't throw if the JSON field has an - * unexpected type. - */ + @JsonCreator + private constructor( @JsonProperty("additional_info") @ExcludeMissing - fun _additionalInfo(): JsonField = additionalInfo - - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** - * Returns the raw JSON value of [balance]. - * - * Unlike [balance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("balance") + additionalInfo: JsonField = JsonMissing.of(), + @JsonProperty("isin") @ExcludeMissing - fun _balance(): JsonField = balance - - /** - * Returns the raw JSON value of [date]. - * - * Unlike [date], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("date") @ExcludeMissing fun _date(): JsonField = date - - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("description") + isin: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing - fun _description(): JsonField = description - - /** - * Returns the raw JSON value of [dividendRate]. - * - * Unlike [dividendRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("dividend_rate") + name: JsonField = JsonMissing.of(), + @JsonProperty("transactions") @ExcludeMissing - fun _dividendRate(): JsonField = dividendRate - - /** - * Returns the raw JSON value of [nav]. - * - * Unlike [nav], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("nav") @ExcludeMissing fun _nav(): JsonField = nav - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [units]. - * - * Unlike [units], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("units") @ExcludeMissing fun _units(): JsonField = units - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter + transactions: JsonField> = JsonMissing.of(), + @JsonProperty("units") @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + units: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + ) : this(additionalInfo, isin, name, transactions, units, value, mutableMapOf()) - fun toBuilder() = Builder().from(this) + /** + * Additional information specific to the corporate bond + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun additionalInfo(): Optional = + additionalInfo.getOptional("additional_info") - companion object { + /** + * ISIN code of the corporate bond + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun isin(): Optional = isin.getOptional("isin") - /** - * Returns a mutable builder for constructing an instance of [Transaction]. - */ - @JvmStatic fun builder() = Builder() - } + /** + * Name of the corporate bond + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") - /** A builder for [Transaction]. */ - class Builder internal constructor() { + /** + * List of transactions for this holding (beta) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun transactions(): Optional> = + transactions.getOptional("transactions") - private var additionalInfo: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var balance: JsonField = JsonMissing.of() - private var date: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var dividendRate: JsonField = JsonMissing.of() - private var nav: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var units: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Number of units held + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun units(): Optional = units.getOptional("units") - @JvmSynthetic - internal fun from(transaction: Transaction) = apply { - additionalInfo = transaction.additionalInfo - amount = transaction.amount - balance = transaction.balance - date = transaction.date - description = transaction.description - dividendRate = transaction.dividendRate - nav = transaction.nav - type = transaction.type - units = transaction.units - additionalProperties = transaction.additionalProperties.toMutableMap() - } + /** + * Current market value of the holding + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun value(): Optional = value.getOptional("value") - /** Additional transaction-specific fields that vary by source */ - fun additionalInfo(additionalInfo: AdditionalInfo) = - additionalInfo(JsonField.of(additionalInfo)) + /** + * Returns the raw JSON value of [additionalInfo]. + * + * Unlike [additionalInfo], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("additional_info") + @ExcludeMissing + fun _additionalInfo(): JsonField = additionalInfo - /** - * Sets [Builder.additionalInfo] to an arbitrary JSON value. - * - * You should usually call [Builder.additionalInfo] with a well-typed - * [AdditionalInfo] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun additionalInfo(additionalInfo: JsonField) = apply { - this.additionalInfo = additionalInfo - } + /** + * Returns the raw JSON value of [isin]. + * + * Unlike [isin], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("isin") @ExcludeMissing fun _isin(): JsonField = isin - /** Transaction amount in currency (computed from units × price/NAV) */ - fun amount(amount: Float?) = amount(JsonField.ofNullable(amount)) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Alias for [Builder.amount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun amount(amount: Float) = amount(amount as Float?) - - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) - - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } + /** + * Returns the raw JSON value of [transactions]. + * + * Unlike [transactions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("transactions") + @ExcludeMissing + fun _transactions(): JsonField> = transactions - /** Balance units after transaction */ - fun balance(balance: Float) = balance(JsonField.of(balance)) + /** + * Returns the raw JSON value of [units]. + * + * Unlike [units], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("units") @ExcludeMissing fun _units(): JsonField = units - /** - * Sets [Builder.balance] to an arbitrary JSON value. - * - * You should usually call [Builder.balance] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun balance(balance: JsonField) = apply { this.balance = balance } + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - /** Transaction date (YYYY-MM-DD) */ - fun date(date: LocalDate) = date(JsonField.of(date)) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.date] to an arbitrary JSON value. - * - * You should usually call [Builder.date] with a well-typed [LocalDate] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun date(date: JsonField) = apply { this.date = date } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** Transaction description/particulars */ - fun description(description: String) = - description(JsonField.of(description)) + fun toBuilder() = Builder().from(this) - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun description(description: JsonField) = apply { - this.description = description - } + companion object { - /** Dividend rate (for DIVIDEND_PAYOUT transactions) */ - fun dividendRate(dividendRate: Float?) = - dividendRate(JsonField.ofNullable(dividendRate)) + /** + * Returns a mutable builder for constructing an instance of [CorporateBond]. + */ + @JvmStatic fun builder() = Builder() + } - /** - * Alias for [Builder.dividendRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun dividendRate(dividendRate: Float) = dividendRate(dividendRate as Float?) + /** A builder for [CorporateBond]. */ + class Builder internal constructor() { - /** - * Alias for calling [Builder.dividendRate] with - * `dividendRate.orElse(null)`. - */ - fun dividendRate(dividendRate: Optional) = - dividendRate(dividendRate.getOrNull()) + private var additionalInfo: JsonField = JsonMissing.of() + private var isin: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var transactions: JsonField>? = null + private var units: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Sets [Builder.dividendRate] to an arbitrary JSON value. - * - * You should usually call [Builder.dividendRate] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun dividendRate(dividendRate: JsonField) = apply { - this.dividendRate = dividendRate - } + @JvmSynthetic + internal fun from(corporateBond: CorporateBond) = apply { + additionalInfo = corporateBond.additionalInfo + isin = corporateBond.isin + name = corporateBond.name + transactions = corporateBond.transactions.map { it.toMutableList() } + units = corporateBond.units + value = corporateBond.value + additionalProperties = corporateBond.additionalProperties.toMutableMap() + } - /** NAV/price per unit on transaction date */ - fun nav(nav: Float?) = nav(JsonField.ofNullable(nav)) + /** Additional information specific to the corporate bond */ + fun additionalInfo(additionalInfo: AdditionalInfo) = + additionalInfo(JsonField.of(additionalInfo)) - /** - * Alias for [Builder.nav]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun nav(nav: Float) = nav(nav as Float?) + /** + * Sets [Builder.additionalInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.additionalInfo] with a well-typed + * [AdditionalInfo] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun additionalInfo(additionalInfo: JsonField) = apply { + this.additionalInfo = additionalInfo + } - /** Alias for calling [Builder.nav] with `nav.orElse(null)`. */ - fun nav(nav: Optional) = nav(nav.getOrNull()) + /** ISIN code of the corporate bond */ + fun isin(isin: String) = isin(JsonField.of(isin)) - /** - * Sets [Builder.nav] to an arbitrary JSON value. - * - * You should usually call [Builder.nav] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun nav(nav: JsonField) = apply { this.nav = nav } + /** + * Sets [Builder.isin] to an arbitrary JSON value. + * + * You should usually call [Builder.isin] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun isin(isin: JsonField) = apply { this.isin = isin } - /** - * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, - * SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, - * DIVIDEND_PAYOUT, DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, - * STT_TAX, MISC, REVERSAL, UNKNOWN. - */ - fun type(type: Type) = type(JsonField.of(type)) + /** Name of the corporate bond */ + fun name(name: String) = name(JsonField.of(name)) - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** Number of units involved in transaction */ - fun units(units: Float) = units(JsonField.of(units)) + /** List of transactions for this holding (beta) */ + fun transactions(transactions: List) = + transactions(JsonField.of(transactions)) - /** - * Sets [Builder.units] to an arbitrary JSON value. - * - * You should usually call [Builder.units] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun units(units: JsonField) = apply { this.units = units } + /** + * Sets [Builder.transactions] to an arbitrary JSON value. + * + * You should usually call [Builder.transactions] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun transactions(transactions: JsonField>) = apply { + this.transactions = transactions.map { it.toMutableList() } + } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + /** + * Adds a single [Transaction] to [transactions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTransaction(transaction: Transaction) = apply { + transactions = + (transactions ?: JsonField.of(mutableListOf())).also { + checkKnown("transactions", it).add(transaction) } + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** Number of units held */ + fun units(units: Float) = units(JsonField.of(units)) - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** + * Sets [Builder.units] to an arbitrary JSON value. + * + * You should usually call [Builder.units] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun units(units: JsonField) = apply { this.units = units } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** Current market value of the holding */ + fun value(value: Float) = value(JsonField.of(value)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } - /** - * Returns an immutable instance of [Transaction]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Transaction = - Transaction( - additionalInfo, - amount, - balance, - date, - description, - dividendRate, - nav, - type, - units, - additionalProperties.toMutableMap(), - ) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - private var validated: Boolean = false + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun validate(): Transaction = apply { - if (validated) { - return@apply + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - additionalInfo().ifPresent { it.validate() } - amount() - balance() - date() - description() - dividendRate() - nav() - type().ifPresent { it.validate() } - units() - validated = true + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an immutable instance of [CorporateBond]. * - * Used for best match union deserialization. + * Further updates to this [Builder] will not mutate the returned instance. */ - @JvmSynthetic - internal fun validity(): Int = - (additionalInfo.asKnown().getOrNull()?.validity() ?: 0) + - (if (amount.asKnown().isPresent) 1 else 0) + - (if (balance.asKnown().isPresent) 1 else 0) + - (if (date.asKnown().isPresent) 1 else 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (if (dividendRate.asKnown().isPresent) 1 else 0) + - (if (nav.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (units.asKnown().isPresent) 1 else 0) - - /** Additional transaction-specific fields that vary by source */ - class AdditionalInfo - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val capitalWithdrawal: JsonField, - private val credit: JsonField, - private val debit: JsonField, - private val incomeDistribution: JsonField, - private val orderNo: JsonField, - private val price: JsonField, - private val stampDuty: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("capital_withdrawal") - @ExcludeMissing - capitalWithdrawal: JsonField = JsonMissing.of(), - @JsonProperty("credit") - @ExcludeMissing - credit: JsonField = JsonMissing.of(), - @JsonProperty("debit") - @ExcludeMissing - debit: JsonField = JsonMissing.of(), - @JsonProperty("income_distribution") - @ExcludeMissing - incomeDistribution: JsonField = JsonMissing.of(), - @JsonProperty("order_no") - @ExcludeMissing - orderNo: JsonField = JsonMissing.of(), - @JsonProperty("price") - @ExcludeMissing - price: JsonField = JsonMissing.of(), - @JsonProperty("stamp_duty") - @ExcludeMissing - stampDuty: JsonField = JsonMissing.of(), - ) : this( - capitalWithdrawal, - credit, - debit, - incomeDistribution, - orderNo, - price, - stampDuty, - mutableMapOf(), + fun build(): CorporateBond = + CorporateBond( + additionalInfo, + isin, + name, + (transactions ?: JsonMissing.of()).map { it.toImmutable() }, + units, + value, + additionalProperties.toMutableMap(), ) + } - /** - * Capital withdrawal amount (CDSL MF transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun capitalWithdrawal(): Optional = - capitalWithdrawal.getOptional("capital_withdrawal") + private var validated: Boolean = false - /** - * Units credited (demat transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun credit(): Optional = credit.getOptional("credit") - - /** - * Units debited (demat transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun debit(): Optional = debit.getOptional("debit") + fun validate(): CorporateBond = apply { + if (validated) { + return@apply + } - /** - * Income distribution amount (CDSL MF transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun incomeDistribution(): Optional = - incomeDistribution.getOptional("income_distribution") + additionalInfo().ifPresent { it.validate() } + isin() + name() + transactions().ifPresent { it.forEach { it.validate() } } + units() + value() + validated = true + } - /** - * Order/transaction reference number (demat transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun orderNo(): Optional = orderNo.getOptional("order_no") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } - /** - * Price per unit (NSDL/CDSL MF transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun price(): Optional = price.getOptional("price") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (additionalInfo.asKnown().getOrNull()?.validity() ?: 0) + + (if (isin.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (transactions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (units.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) - /** - * Stamp duty charged - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun stampDuty(): Optional = stampDuty.getOptional("stamp_duty") + /** Additional information specific to the corporate bond */ + class AdditionalInfo + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val closeUnits: JsonField, + private val openUnits: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [capitalWithdrawal]. - * - * Unlike [capitalWithdrawal], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("capital_withdrawal") + @JsonCreator + private constructor( + @JsonProperty("close_units") @ExcludeMissing - fun _capitalWithdrawal(): JsonField = capitalWithdrawal + closeUnits: JsonField = JsonMissing.of(), + @JsonProperty("open_units") + @ExcludeMissing + openUnits: JsonField = JsonMissing.of(), + ) : this(closeUnits, openUnits, mutableMapOf()) + + /** + * Closing balance units for the statement period (beta) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun closeUnits(): Optional = closeUnits.getOptional("close_units") + + /** + * Opening balance units for the statement period (beta) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun openUnits(): Optional = openUnits.getOptional("open_units") + + /** + * Returns the raw JSON value of [closeUnits]. + * + * Unlike [closeUnits], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("close_units") + @ExcludeMissing + fun _closeUnits(): JsonField = closeUnits + + /** + * Returns the raw JSON value of [openUnits]. + * + * Unlike [openUnits], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("open_units") + @ExcludeMissing + fun _openUnits(): JsonField = openUnits + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { /** - * Returns the raw JSON value of [credit]. - * - * Unlike [credit], this method doesn't throw if the JSON field has an - * unexpected type. + * Returns a mutable builder for constructing an instance of + * [AdditionalInfo]. */ - @JsonProperty("credit") - @ExcludeMissing - fun _credit(): JsonField = credit + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AdditionalInfo]. */ + class Builder internal constructor() { + + private var closeUnits: JsonField = JsonMissing.of() + private var openUnits: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(additionalInfo: AdditionalInfo) = apply { + closeUnits = additionalInfo.closeUnits + openUnits = additionalInfo.openUnits + additionalProperties = + additionalInfo.additionalProperties.toMutableMap() + } + + /** Closing balance units for the statement period (beta) */ + fun closeUnits(closeUnits: Float?) = + closeUnits(JsonField.ofNullable(closeUnits)) /** - * Returns the raw JSON value of [debit]. + * Alias for [Builder.closeUnits]. * - * Unlike [debit], this method doesn't throw if the JSON field has an - * unexpected type. + * This unboxed primitive overload exists for backwards compatibility. */ - @JsonProperty("debit") - @ExcludeMissing - fun _debit(): JsonField = debit + fun closeUnits(closeUnits: Float) = closeUnits(closeUnits as Float?) /** - * Returns the raw JSON value of [incomeDistribution]. - * - * Unlike [incomeDistribution], this method doesn't throw if the JSON field - * has an unexpected type. + * Alias for calling [Builder.closeUnits] with `closeUnits.orElse(null)`. */ - @JsonProperty("income_distribution") - @ExcludeMissing - fun _incomeDistribution(): JsonField = incomeDistribution + fun closeUnits(closeUnits: Optional) = + closeUnits(closeUnits.getOrNull()) /** - * Returns the raw JSON value of [orderNo]. + * Sets [Builder.closeUnits] to an arbitrary JSON value. * - * Unlike [orderNo], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.closeUnits] with a well-typed [Float] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - @JsonProperty("order_no") - @ExcludeMissing - fun _orderNo(): JsonField = orderNo + fun closeUnits(closeUnits: JsonField) = apply { + this.closeUnits = closeUnits + } + + /** Opening balance units for the statement period (beta) */ + fun openUnits(openUnits: Float?) = + openUnits(JsonField.ofNullable(openUnits)) /** - * Returns the raw JSON value of [price]. + * Alias for [Builder.openUnits]. * - * Unlike [price], this method doesn't throw if the JSON field has an - * unexpected type. + * This unboxed primitive overload exists for backwards compatibility. */ - @JsonProperty("price") - @ExcludeMissing - fun _price(): JsonField = price + fun openUnits(openUnits: Float) = openUnits(openUnits as Float?) + + /** Alias for calling [Builder.openUnits] with `openUnits.orElse(null)`. */ + fun openUnits(openUnits: Optional) = openUnits(openUnits.getOrNull()) /** - * Returns the raw JSON value of [stampDuty]. + * Sets [Builder.openUnits] to an arbitrary JSON value. * - * Unlike [stampDuty], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.openUnits] with a well-typed [Float] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. */ - @JsonProperty("stamp_duty") - @ExcludeMissing - fun _stampDuty(): JsonField = stampDuty - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [AdditionalInfo]. - */ - @JvmStatic fun builder() = Builder() + fun openUnits(openUnits: JsonField) = apply { + this.openUnits = openUnits } - /** A builder for [AdditionalInfo]. */ - class Builder internal constructor() { - - private var capitalWithdrawal: JsonField = JsonMissing.of() - private var credit: JsonField = JsonMissing.of() - private var debit: JsonField = JsonMissing.of() - private var incomeDistribution: JsonField = JsonMissing.of() - private var orderNo: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var stampDuty: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(additionalInfo: AdditionalInfo) = apply { - capitalWithdrawal = additionalInfo.capitalWithdrawal - credit = additionalInfo.credit - debit = additionalInfo.debit - incomeDistribution = additionalInfo.incomeDistribution - orderNo = additionalInfo.orderNo - price = additionalInfo.price - stampDuty = additionalInfo.stampDuty - additionalProperties = - additionalInfo.additionalProperties.toMutableMap() - } - - /** Capital withdrawal amount (CDSL MF transactions) */ - fun capitalWithdrawal(capitalWithdrawal: Float) = - capitalWithdrawal(JsonField.of(capitalWithdrawal)) - - /** - * Sets [Builder.capitalWithdrawal] to an arbitrary JSON value. - * - * You should usually call [Builder.capitalWithdrawal] with a well-typed - * [Float] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun capitalWithdrawal(capitalWithdrawal: JsonField) = apply { - this.capitalWithdrawal = capitalWithdrawal - } - - /** Units credited (demat transactions) */ - fun credit(credit: Float) = credit(JsonField.of(credit)) - - /** - * Sets [Builder.credit] to an arbitrary JSON value. - * - * You should usually call [Builder.credit] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun credit(credit: JsonField) = apply { this.credit = credit } - - /** Units debited (demat transactions) */ - fun debit(debit: Float) = debit(JsonField.of(debit)) - - /** - * Sets [Builder.debit] to an arbitrary JSON value. - * - * You should usually call [Builder.debit] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun debit(debit: JsonField) = apply { this.debit = debit } - - /** Income distribution amount (CDSL MF transactions) */ - fun incomeDistribution(incomeDistribution: Float) = - incomeDistribution(JsonField.of(incomeDistribution)) - - /** - * Sets [Builder.incomeDistribution] to an arbitrary JSON value. - * - * You should usually call [Builder.incomeDistribution] with a - * well-typed [Float] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun incomeDistribution(incomeDistribution: JsonField) = apply { - this.incomeDistribution = incomeDistribution - } - - /** Order/transaction reference number (demat transactions) */ - fun orderNo(orderNo: String) = orderNo(JsonField.of(orderNo)) - - /** - * Sets [Builder.orderNo] to an arbitrary JSON value. - * - * You should usually call [Builder.orderNo] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun orderNo(orderNo: JsonField) = apply { - this.orderNo = orderNo - } - - /** Price per unit (NSDL/CDSL MF transactions) */ - fun price(price: Float) = price(JsonField.of(price)) - - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun price(price: JsonField) = apply { this.price = price } - - /** Stamp duty charged */ - fun stampDuty(stampDuty: Float) = stampDuty(JsonField.of(stampDuty)) - - /** - * Sets [Builder.stampDuty] to an arbitrary JSON value. - * - * You should usually call [Builder.stampDuty] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun stampDuty(stampDuty: JsonField) = apply { - this.stampDuty = stampDuty - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns an immutable instance of [AdditionalInfo]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): AdditionalInfo = - AdditionalInfo( - capitalWithdrawal, - credit, - debit, - incomeDistribution, - orderNo, - price, - stampDuty, - additionalProperties.toMutableMap(), - ) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - private var validated: Boolean = false - - fun validate(): AdditionalInfo = apply { - if (validated) { - return@apply - } + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } - capitalWithdrawal() - credit() - debit() - incomeDistribution() - orderNo() - price() - stampDuty() - validated = true + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns a score indicating how many valid values are contained in this - * object recursively. + * Returns an immutable instance of [AdditionalInfo]. * - * Used for best match union deserialization. + * Further updates to this [Builder] will not mutate the returned instance. */ - @JvmSynthetic - internal fun validity(): Int = - (if (capitalWithdrawal.asKnown().isPresent) 1 else 0) + - (if (credit.asKnown().isPresent) 1 else 0) + - (if (debit.asKnown().isPresent) 1 else 0) + - (if (incomeDistribution.asKnown().isPresent) 1 else 0) + - (if (orderNo.asKnown().isPresent) 1 else 0) + - (if (price.asKnown().isPresent) 1 else 0) + - (if (stampDuty.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun build(): AdditionalInfo = + AdditionalInfo( + closeUnits, + openUnits, + additionalProperties.toMutableMap(), + ) + } - return other is AdditionalInfo && - capitalWithdrawal == other.capitalWithdrawal && - credit == other.credit && - debit == other.debit && - incomeDistribution == other.incomeDistribution && - orderNo == other.orderNo && - price == other.price && - stampDuty == other.stampDuty && - additionalProperties == other.additionalProperties - } + private var validated: Boolean = false - private val hashCode: Int by lazy { - Objects.hash( - capitalWithdrawal, - credit, - debit, - incomeDistribution, - orderNo, - price, - stampDuty, - additionalProperties, - ) + fun validate(): AdditionalInfo = apply { + if (validated) { + return@apply } - override fun hashCode(): Int = hashCode - - override fun toString() = - "AdditionalInfo{capitalWithdrawal=$capitalWithdrawal, credit=$credit, debit=$debit, incomeDistribution=$incomeDistribution, orderNo=$orderNo, price=$price, stampDuty=$stampDuty, additionalProperties=$additionalProperties}" + closeUnits() + openUnits() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + /** - * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, - * SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, - * DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, - * REVERSAL, UNKNOWN. + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. */ - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PURCHASE = of("PURCHASE") - - @JvmField val PURCHASE_SIP = of("PURCHASE_SIP") - - @JvmField val REDEMPTION = of("REDEMPTION") - - @JvmField val SWITCH_IN = of("SWITCH_IN") - - @JvmField val SWITCH_IN_MERGER = of("SWITCH_IN_MERGER") - - @JvmField val SWITCH_OUT = of("SWITCH_OUT") - - @JvmField val SWITCH_OUT_MERGER = of("SWITCH_OUT_MERGER") - - @JvmField val DIVIDEND_PAYOUT = of("DIVIDEND_PAYOUT") - - @JvmField val DIVIDEND_REINVEST = of("DIVIDEND_REINVEST") - - @JvmField val SEGREGATION = of("SEGREGATION") - - @JvmField val STAMP_DUTY_TAX = of("STAMP_DUTY_TAX") - - @JvmField val TDS_TAX = of("TDS_TAX") - - @JvmField val STT_TAX = of("STT_TAX") - - @JvmField val MISC = of("MISC") - - @JvmField val REVERSAL = of("REVERSAL") - - @JvmField val UNKNOWN = of("UNKNOWN") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - PURCHASE, - PURCHASE_SIP, - REDEMPTION, - SWITCH_IN, - SWITCH_IN_MERGER, - SWITCH_OUT, - SWITCH_OUT_MERGER, - DIVIDEND_PAYOUT, - DIVIDEND_REINVEST, - SEGREGATION, - STAMP_DUTY_TAX, - TDS_TAX, - STT_TAX, - MISC, - REVERSAL, - UNKNOWN, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PURCHASE, - PURCHASE_SIP, - REDEMPTION, - SWITCH_IN, - SWITCH_IN_MERGER, - SWITCH_OUT, - SWITCH_OUT_MERGER, - DIVIDEND_PAYOUT, - DIVIDEND_REINVEST, - SEGREGATION, - STAMP_DUTY_TAX, - TDS_TAX, - STT_TAX, - MISC, - REVERSAL, - UNKNOWN, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PURCHASE -> Value.PURCHASE - PURCHASE_SIP -> Value.PURCHASE_SIP - REDEMPTION -> Value.REDEMPTION - SWITCH_IN -> Value.SWITCH_IN - SWITCH_IN_MERGER -> Value.SWITCH_IN_MERGER - SWITCH_OUT -> Value.SWITCH_OUT - SWITCH_OUT_MERGER -> Value.SWITCH_OUT_MERGER - DIVIDEND_PAYOUT -> Value.DIVIDEND_PAYOUT - DIVIDEND_REINVEST -> Value.DIVIDEND_REINVEST - SEGREGATION -> Value.SEGREGATION - STAMP_DUTY_TAX -> Value.STAMP_DUTY_TAX - TDS_TAX -> Value.TDS_TAX - STT_TAX -> Value.STT_TAX - MISC -> Value.MISC - REVERSAL -> Value.REVERSAL - UNKNOWN -> Value.UNKNOWN - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws CasParserInvalidDataException if this class instance's value is a - * not a known member. - */ - fun known(): Known = - when (this) { - PURCHASE -> Known.PURCHASE - PURCHASE_SIP -> Known.PURCHASE_SIP - REDEMPTION -> Known.REDEMPTION - SWITCH_IN -> Known.SWITCH_IN - SWITCH_IN_MERGER -> Known.SWITCH_IN_MERGER - SWITCH_OUT -> Known.SWITCH_OUT - SWITCH_OUT_MERGER -> Known.SWITCH_OUT_MERGER - DIVIDEND_PAYOUT -> Known.DIVIDEND_PAYOUT - DIVIDEND_REINVEST -> Known.DIVIDEND_REINVEST - SEGREGATION -> Known.SEGREGATION - STAMP_DUTY_TAX -> Known.STAMP_DUTY_TAX - TDS_TAX -> Known.TDS_TAX - STT_TAX -> Known.STT_TAX - MISC -> Known.MISC - REVERSAL -> Known.REVERSAL - UNKNOWN -> Known.UNKNOWN - else -> throw CasParserInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws CasParserInvalidDataException if this class instance's value does - * not have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CasParserInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + @JvmSynthetic + internal fun validity(): Int = + (if (closeUnits.asKnown().isPresent) 1 else 0) + + (if (openUnits.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Transaction && - additionalInfo == other.additionalInfo && - amount == other.amount && - balance == other.balance && - date == other.date && - description == other.description && - dividendRate == other.dividendRate && - nav == other.nav && - type == other.type && - units == other.units && + return other is AdditionalInfo && + closeUnits == other.closeUnits && + openUnits == other.openUnits && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - additionalInfo, - amount, - balance, - date, - description, - dividendRate, - nav, - type, - units, - additionalProperties, - ) + Objects.hash(closeUnits, openUnits, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Transaction{additionalInfo=$additionalInfo, amount=$amount, balance=$balance, date=$date, description=$description, dividendRate=$dividendRate, nav=$nav, type=$type, units=$units, additionalProperties=$additionalProperties}" + "AdditionalInfo{closeUnits=$closeUnits, openUnits=$openUnits, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -3557,7 +2961,7 @@ private constructor( return true } - return other is Aif && + return other is CorporateBond && additionalInfo == other.additionalInfo && isin == other.isin && name == other.name && @@ -3582,10 +2986,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Aif{additionalInfo=$additionalInfo, isin=$isin, name=$name, transactions=$transactions, units=$units, value=$value, additionalProperties=$additionalProperties}" + "CorporateBond{additionalInfo=$additionalInfo, isin=$isin, name=$name, transactions=$transactions, units=$units, value=$value, additionalProperties=$additionalProperties}" } - class CorporateBond + class DematMutualFund @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val additionalInfo: JsonField, @@ -3620,7 +3024,7 @@ private constructor( ) : this(additionalInfo, isin, name, transactions, units, value, mutableMapOf()) /** - * Additional information specific to the corporate bond + * Additional information specific to the mutual fund * * @throws CasParserInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -3629,7 +3033,7 @@ private constructor( additionalInfo.getOptional("additional_info") /** - * ISIN code of the corporate bond + * ISIN code of the mutual fund * * @throws CasParserInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -3637,7 +3041,7 @@ private constructor( fun isin(): Optional = isin.getOptional("isin") /** - * Name of the corporate bond + * Name of the mutual fund * * @throws CasParserInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -3736,12 +3140,12 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [CorporateBond]. + * Returns a mutable builder for constructing an instance of [DematMutualFund]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [CorporateBond]. */ + /** A builder for [DematMutualFund]. */ class Builder internal constructor() { private var additionalInfo: JsonField = JsonMissing.of() @@ -3753,17 +3157,17 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(corporateBond: CorporateBond) = apply { - additionalInfo = corporateBond.additionalInfo - isin = corporateBond.isin - name = corporateBond.name - transactions = corporateBond.transactions.map { it.toMutableList() } - units = corporateBond.units - value = corporateBond.value - additionalProperties = corporateBond.additionalProperties.toMutableMap() + internal fun from(dematMutualFund: DematMutualFund) = apply { + additionalInfo = dematMutualFund.additionalInfo + isin = dematMutualFund.isin + name = dematMutualFund.name + transactions = dematMutualFund.transactions.map { it.toMutableList() } + units = dematMutualFund.units + value = dematMutualFund.value + additionalProperties = dematMutualFund.additionalProperties.toMutableMap() } - /** Additional information specific to the corporate bond */ + /** Additional information specific to the mutual fund */ fun additionalInfo(additionalInfo: AdditionalInfo) = additionalInfo(JsonField.of(additionalInfo)) @@ -3778,7 +3182,7 @@ private constructor( this.additionalInfo = additionalInfo } - /** ISIN code of the corporate bond */ + /** ISIN code of the mutual fund */ fun isin(isin: String) = isin(JsonField.of(isin)) /** @@ -3790,7 +3194,7 @@ private constructor( */ fun isin(isin: JsonField) = apply { this.isin = isin } - /** Name of the corporate bond */ + /** Name of the mutual fund */ fun name(name: String) = name(JsonField.of(name)) /** @@ -3876,12 +3280,12 @@ private constructor( } /** - * Returns an immutable instance of [CorporateBond]. + * Returns an immutable instance of [DematMutualFund]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): CorporateBond = - CorporateBond( + fun build(): DematMutualFund = + DematMutualFund( additionalInfo, isin, name, @@ -3894,7 +3298,7 @@ private constructor( private var validated: Boolean = false - fun validate(): CorporateBond = apply { + fun validate(): DematMutualFund = apply { if (validated) { return@apply } @@ -3931,7 +3335,7 @@ private constructor( (if (units.asKnown().isPresent) 1 else 0) + (if (value.asKnown().isPresent) 1 else 0) - /** Additional information specific to the corporate bond */ + /** Additional information specific to the mutual fund */ class AdditionalInfo @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -4163,427 +3567,527 @@ private constructor( "AdditionalInfo{closeUnits=$closeUnits, openUnits=$openUnits, additionalProperties=$additionalProperties}" } - /** - * Unified transaction schema for all holding types (MF folios, equities, bonds, - * etc.) - */ - class Transaction - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val additionalInfo: JsonField, - private val amount: JsonField, - private val balance: JsonField, - private val date: JsonField, - private val description: JsonField, - private val dividendRate: JsonField, - private val nav: JsonField, - private val type: JsonField, - private val units: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonCreator - private constructor( - @JsonProperty("additional_info") - @ExcludeMissing - additionalInfo: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("balance") - @ExcludeMissing - balance: JsonField = JsonMissing.of(), - @JsonProperty("date") - @ExcludeMissing - date: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("dividend_rate") - @ExcludeMissing - dividendRate: JsonField = JsonMissing.of(), - @JsonProperty("nav") - @ExcludeMissing - nav: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonField = JsonMissing.of(), - @JsonProperty("units") - @ExcludeMissing - units: JsonField = JsonMissing.of(), - ) : this( + return other is DematMutualFund && + additionalInfo == other.additionalInfo && + isin == other.isin && + name == other.name && + transactions == other.transactions && + units == other.units && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( additionalInfo, - amount, - balance, - date, - description, - dividendRate, - nav, - type, + isin, + name, + transactions, units, - mutableMapOf(), + value, + additionalProperties, ) + } - /** - * Additional transaction-specific fields that vary by source - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun additionalInfo(): Optional = - additionalInfo.getOptional("additional_info") - - /** - * Transaction amount in currency (computed from units × price/NAV) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * Balance units after transaction - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun balance(): Optional = balance.getOptional("balance") - - /** - * Transaction date (YYYY-MM-DD) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun date(): Optional = date.getOptional("date") - - /** - * Transaction description/particulars - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") - - /** - * Dividend rate (for DIVIDEND_PAYOUT transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun dividendRate(): Optional = dividendRate.getOptional("dividend_rate") - - /** - * NAV/price per unit on transaction date - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun nav(): Optional = nav.getOptional("nav") + override fun hashCode(): Int = hashCode - /** - * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, - * SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, - * DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, - * REVERSAL, UNKNOWN. - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") + override fun toString() = + "DematMutualFund{additionalInfo=$additionalInfo, isin=$isin, name=$name, transactions=$transactions, units=$units, value=$value, additionalProperties=$additionalProperties}" + } - /** - * Number of units involved in transaction - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun units(): Optional = units.getOptional("units") + class Equity + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val additionalInfo: JsonField, + private val isin: JsonField, + private val name: JsonField, + private val transactions: JsonField>, + private val units: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [additionalInfo]. - * - * Unlike [additionalInfo], this method doesn't throw if the JSON field has an - * unexpected type. - */ + @JsonCreator + private constructor( @JsonProperty("additional_info") @ExcludeMissing - fun _additionalInfo(): JsonField = additionalInfo - - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** - * Returns the raw JSON value of [balance]. - * - * Unlike [balance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("balance") + additionalInfo: JsonField = JsonMissing.of(), + @JsonProperty("isin") @ExcludeMissing - fun _balance(): JsonField = balance - - /** - * Returns the raw JSON value of [date]. - * - * Unlike [date], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("date") @ExcludeMissing fun _date(): JsonField = date - - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("description") + isin: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing - fun _description(): JsonField = description - - /** - * Returns the raw JSON value of [dividendRate]. - * - * Unlike [dividendRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("dividend_rate") + name: JsonField = JsonMissing.of(), + @JsonProperty("transactions") + @ExcludeMissing + transactions: JsonField> = JsonMissing.of(), + @JsonProperty("units") + @ExcludeMissing + units: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing - fun _dividendRate(): JsonField = dividendRate + value: JsonField = JsonMissing.of(), + ) : this(additionalInfo, isin, name, transactions, units, value, mutableMapOf()) - /** - * Returns the raw JSON value of [nav]. - * - * Unlike [nav], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("nav") @ExcludeMissing fun _nav(): JsonField = nav + /** + * Additional information specific to the equity + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun additionalInfo(): Optional = + additionalInfo.getOptional("additional_info") - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + /** + * ISIN code of the equity + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun isin(): Optional = isin.getOptional("isin") - /** - * Returns the raw JSON value of [units]. - * - * Unlike [units], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("units") @ExcludeMissing fun _units(): JsonField = units + /** + * Name of the equity + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * List of transactions for this holding (beta) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun transactions(): Optional> = + transactions.getOptional("transactions") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Number of units held + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun units(): Optional = units.getOptional("units") - fun toBuilder() = Builder().from(this) + /** + * Current market value of the holding + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun value(): Optional = value.getOptional("value") - companion object { + /** + * Returns the raw JSON value of [additionalInfo]. + * + * Unlike [additionalInfo], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("additional_info") + @ExcludeMissing + fun _additionalInfo(): JsonField = additionalInfo - /** - * Returns a mutable builder for constructing an instance of [Transaction]. - */ - @JvmStatic fun builder() = Builder() - } + /** + * Returns the raw JSON value of [isin]. + * + * Unlike [isin], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("isin") @ExcludeMissing fun _isin(): JsonField = isin - /** A builder for [Transaction]. */ - class Builder internal constructor() { + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - private var additionalInfo: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var balance: JsonField = JsonMissing.of() - private var date: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var dividendRate: JsonField = JsonMissing.of() - private var nav: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var units: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + /** + * Returns the raw JSON value of [transactions]. + * + * Unlike [transactions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("transactions") + @ExcludeMissing + fun _transactions(): JsonField> = transactions - @JvmSynthetic - internal fun from(transaction: Transaction) = apply { - additionalInfo = transaction.additionalInfo - amount = transaction.amount - balance = transaction.balance - date = transaction.date - description = transaction.description - dividendRate = transaction.dividendRate - nav = transaction.nav - type = transaction.type - units = transaction.units - additionalProperties = transaction.additionalProperties.toMutableMap() - } + /** + * Returns the raw JSON value of [units]. + * + * Unlike [units], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("units") @ExcludeMissing fun _units(): JsonField = units - /** Additional transaction-specific fields that vary by source */ - fun additionalInfo(additionalInfo: AdditionalInfo) = - additionalInfo(JsonField.of(additionalInfo)) + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - /** - * Sets [Builder.additionalInfo] to an arbitrary JSON value. - * - * You should usually call [Builder.additionalInfo] with a well-typed - * [AdditionalInfo] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun additionalInfo(additionalInfo: JsonField) = apply { - this.additionalInfo = additionalInfo - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** Transaction amount in currency (computed from units × price/NAV) */ - fun amount(amount: Float?) = amount(JsonField.ofNullable(amount)) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Alias for [Builder.amount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun amount(amount: Float) = amount(amount as Float?) + fun toBuilder() = Builder().from(this) - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) + companion object { - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } + /** Returns a mutable builder for constructing an instance of [Equity]. */ + @JvmStatic fun builder() = Builder() + } - /** Balance units after transaction */ - fun balance(balance: Float) = balance(JsonField.of(balance)) + /** A builder for [Equity]. */ + class Builder internal constructor() { - /** - * Sets [Builder.balance] to an arbitrary JSON value. - * - * You should usually call [Builder.balance] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun balance(balance: JsonField) = apply { this.balance = balance } + private var additionalInfo: JsonField = JsonMissing.of() + private var isin: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var transactions: JsonField>? = null + private var units: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** Transaction date (YYYY-MM-DD) */ - fun date(date: LocalDate) = date(JsonField.of(date)) + @JvmSynthetic + internal fun from(equity: Equity) = apply { + additionalInfo = equity.additionalInfo + isin = equity.isin + name = equity.name + transactions = equity.transactions.map { it.toMutableList() } + units = equity.units + value = equity.value + additionalProperties = equity.additionalProperties.toMutableMap() + } - /** - * Sets [Builder.date] to an arbitrary JSON value. - * - * You should usually call [Builder.date] with a well-typed [LocalDate] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun date(date: JsonField) = apply { this.date = date } + /** Additional information specific to the equity */ + fun additionalInfo(additionalInfo: AdditionalInfo) = + additionalInfo(JsonField.of(additionalInfo)) - /** Transaction description/particulars */ - fun description(description: String) = - description(JsonField.of(description)) + /** + * Sets [Builder.additionalInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.additionalInfo] with a well-typed + * [AdditionalInfo] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun additionalInfo(additionalInfo: JsonField) = apply { + this.additionalInfo = additionalInfo + } - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun description(description: JsonField) = apply { - this.description = description - } + /** ISIN code of the equity */ + fun isin(isin: String) = isin(JsonField.of(isin)) - /** Dividend rate (for DIVIDEND_PAYOUT transactions) */ - fun dividendRate(dividendRate: Float?) = - dividendRate(JsonField.ofNullable(dividendRate)) + /** + * Sets [Builder.isin] to an arbitrary JSON value. + * + * You should usually call [Builder.isin] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun isin(isin: JsonField) = apply { this.isin = isin } - /** - * Alias for [Builder.dividendRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun dividendRate(dividendRate: Float) = dividendRate(dividendRate as Float?) + /** Name of the equity */ + fun name(name: String) = name(JsonField.of(name)) - /** - * Alias for calling [Builder.dividendRate] with - * `dividendRate.orElse(null)`. - */ - fun dividendRate(dividendRate: Optional) = - dividendRate(dividendRate.getOrNull()) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - /** - * Sets [Builder.dividendRate] to an arbitrary JSON value. - * - * You should usually call [Builder.dividendRate] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun dividendRate(dividendRate: JsonField) = apply { - this.dividendRate = dividendRate - } + /** List of transactions for this holding (beta) */ + fun transactions(transactions: List) = + transactions(JsonField.of(transactions)) - /** NAV/price per unit on transaction date */ - fun nav(nav: Float?) = nav(JsonField.ofNullable(nav)) + /** + * Sets [Builder.transactions] to an arbitrary JSON value. + * + * You should usually call [Builder.transactions] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun transactions(transactions: JsonField>) = apply { + this.transactions = transactions.map { it.toMutableList() } + } - /** - * Alias for [Builder.nav]. - * - * This unboxed primitive overload exists for backwards compatibility. + /** + * Adds a single [Transaction] to [transactions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTransaction(transaction: Transaction) = apply { + transactions = + (transactions ?: JsonField.of(mutableListOf())).also { + checkKnown("transactions", it).add(transaction) + } + } + + /** Number of units held */ + fun units(units: Float) = units(JsonField.of(units)) + + /** + * Sets [Builder.units] to an arbitrary JSON value. + * + * You should usually call [Builder.units] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun units(units: JsonField) = apply { this.units = units } + + /** Current market value of the holding */ + fun value(value: Float) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Equity]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Equity = + Equity( + additionalInfo, + isin, + name, + (transactions ?: JsonMissing.of()).map { it.toImmutable() }, + units, + value, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Equity = apply { + if (validated) { + return@apply + } + + additionalInfo().ifPresent { it.validate() } + isin() + name() + transactions().ifPresent { it.forEach { it.validate() } } + units() + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (additionalInfo.asKnown().getOrNull()?.validity() ?: 0) + + (if (isin.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (transactions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (units.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + + /** Additional information specific to the equity */ + class AdditionalInfo + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val closeUnits: JsonField, + private val openUnits: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("close_units") + @ExcludeMissing + closeUnits: JsonField = JsonMissing.of(), + @JsonProperty("open_units") + @ExcludeMissing + openUnits: JsonField = JsonMissing.of(), + ) : this(closeUnits, openUnits, mutableMapOf()) + + /** + * Closing balance units for the statement period (beta) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun closeUnits(): Optional = closeUnits.getOptional("close_units") + + /** + * Opening balance units for the statement period (beta) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun openUnits(): Optional = openUnits.getOptional("open_units") + + /** + * Returns the raw JSON value of [closeUnits]. + * + * Unlike [closeUnits], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("close_units") + @ExcludeMissing + fun _closeUnits(): JsonField = closeUnits + + /** + * Returns the raw JSON value of [openUnits]. + * + * Unlike [openUnits], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("open_units") + @ExcludeMissing + fun _openUnits(): JsonField = openUnits + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [AdditionalInfo]. */ - fun nav(nav: Float) = nav(nav as Float?) + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AdditionalInfo]. */ + class Builder internal constructor() { + + private var closeUnits: JsonField = JsonMissing.of() + private var openUnits: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(additionalInfo: AdditionalInfo) = apply { + closeUnits = additionalInfo.closeUnits + openUnits = additionalInfo.openUnits + additionalProperties = + additionalInfo.additionalProperties.toMutableMap() + } - /** Alias for calling [Builder.nav] with `nav.orElse(null)`. */ - fun nav(nav: Optional) = nav(nav.getOrNull()) + /** Closing balance units for the statement period (beta) */ + fun closeUnits(closeUnits: Float?) = + closeUnits(JsonField.ofNullable(closeUnits)) /** - * Sets [Builder.nav] to an arbitrary JSON value. + * Alias for [Builder.closeUnits]. * - * You should usually call [Builder.nav] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. + * This unboxed primitive overload exists for backwards compatibility. */ - fun nav(nav: JsonField) = apply { this.nav = nav } + fun closeUnits(closeUnits: Float) = closeUnits(closeUnits as Float?) /** - * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, - * SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, - * DIVIDEND_PAYOUT, DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, - * STT_TAX, MISC, REVERSAL, UNKNOWN. + * Alias for calling [Builder.closeUnits] with `closeUnits.orElse(null)`. */ - fun type(type: Type) = type(JsonField.of(type)) + fun closeUnits(closeUnits: Optional) = + closeUnits(closeUnits.getOrNull()) /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets [Builder.closeUnits] to an arbitrary JSON value. * - * You should usually call [Builder.type] with a well-typed [Type] value - * instead. This method is primarily for setting the field to an + * You should usually call [Builder.closeUnits] with a well-typed [Float] + * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun type(type: JsonField) = apply { this.type = type } + fun closeUnits(closeUnits: JsonField) = apply { + this.closeUnits = closeUnits + } + + /** Opening balance units for the statement period (beta) */ + fun openUnits(openUnits: Float?) = + openUnits(JsonField.ofNullable(openUnits)) + + /** + * Alias for [Builder.openUnits]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun openUnits(openUnits: Float) = openUnits(openUnits as Float?) - /** Number of units involved in transaction */ - fun units(units: Float) = units(JsonField.of(units)) + /** Alias for calling [Builder.openUnits] with `openUnits.orElse(null)`. */ + fun openUnits(openUnits: Optional) = openUnits(openUnits.getOrNull()) /** - * Sets [Builder.units] to an arbitrary JSON value. + * Sets [Builder.openUnits] to an arbitrary JSON value. * - * You should usually call [Builder.units] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an + * You should usually call [Builder.openUnits] with a well-typed [Float] + * value instead. This method is primarily for setting the field to an * undocumented or not yet supported value. */ - fun units(units: JsonField) = apply { this.units = units } + fun openUnits(openUnits: JsonField) = apply { + this.openUnits = openUnits + } fun additionalProperties(additionalProperties: Map) = apply { @@ -4608,41 +4112,27 @@ private constructor( } /** - * Returns an immutable instance of [Transaction]. + * Returns an immutable instance of [AdditionalInfo]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Transaction = - Transaction( - additionalInfo, - amount, - balance, - date, - description, - dividendRate, - nav, - type, - units, + fun build(): AdditionalInfo = + AdditionalInfo( + closeUnits, + openUnits, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): Transaction = apply { + fun validate(): AdditionalInfo = apply { if (validated) { return@apply } - additionalInfo().ifPresent { it.validate() } - amount() - balance() - date() - description() - dividendRate() - nav() - type().ifPresent { it.validate() } - units() + closeUnits() + openUnits() validated = true } @@ -4662,712 +4152,28 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (additionalInfo.asKnown().getOrNull()?.validity() ?: 0) + - (if (amount.asKnown().isPresent) 1 else 0) + - (if (balance.asKnown().isPresent) 1 else 0) + - (if (date.asKnown().isPresent) 1 else 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (if (dividendRate.asKnown().isPresent) 1 else 0) + - (if (nav.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (units.asKnown().isPresent) 1 else 0) - - /** Additional transaction-specific fields that vary by source */ - class AdditionalInfo - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val capitalWithdrawal: JsonField, - private val credit: JsonField, - private val debit: JsonField, - private val incomeDistribution: JsonField, - private val orderNo: JsonField, - private val price: JsonField, - private val stampDuty: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("capital_withdrawal") - @ExcludeMissing - capitalWithdrawal: JsonField = JsonMissing.of(), - @JsonProperty("credit") - @ExcludeMissing - credit: JsonField = JsonMissing.of(), - @JsonProperty("debit") - @ExcludeMissing - debit: JsonField = JsonMissing.of(), - @JsonProperty("income_distribution") - @ExcludeMissing - incomeDistribution: JsonField = JsonMissing.of(), - @JsonProperty("order_no") - @ExcludeMissing - orderNo: JsonField = JsonMissing.of(), - @JsonProperty("price") - @ExcludeMissing - price: JsonField = JsonMissing.of(), - @JsonProperty("stamp_duty") - @ExcludeMissing - stampDuty: JsonField = JsonMissing.of(), - ) : this( - capitalWithdrawal, - credit, - debit, - incomeDistribution, - orderNo, - price, - stampDuty, - mutableMapOf(), - ) - - /** - * Capital withdrawal amount (CDSL MF transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun capitalWithdrawal(): Optional = - capitalWithdrawal.getOptional("capital_withdrawal") - - /** - * Units credited (demat transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun credit(): Optional = credit.getOptional("credit") - - /** - * Units debited (demat transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun debit(): Optional = debit.getOptional("debit") - - /** - * Income distribution amount (CDSL MF transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun incomeDistribution(): Optional = - incomeDistribution.getOptional("income_distribution") - - /** - * Order/transaction reference number (demat transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun orderNo(): Optional = orderNo.getOptional("order_no") - - /** - * Price per unit (NSDL/CDSL MF transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun price(): Optional = price.getOptional("price") - - /** - * Stamp duty charged - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun stampDuty(): Optional = stampDuty.getOptional("stamp_duty") - - /** - * Returns the raw JSON value of [capitalWithdrawal]. - * - * Unlike [capitalWithdrawal], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("capital_withdrawal") - @ExcludeMissing - fun _capitalWithdrawal(): JsonField = capitalWithdrawal - - /** - * Returns the raw JSON value of [credit]. - * - * Unlike [credit], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("credit") - @ExcludeMissing - fun _credit(): JsonField = credit - - /** - * Returns the raw JSON value of [debit]. - * - * Unlike [debit], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("debit") - @ExcludeMissing - fun _debit(): JsonField = debit - - /** - * Returns the raw JSON value of [incomeDistribution]. - * - * Unlike [incomeDistribution], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("income_distribution") - @ExcludeMissing - fun _incomeDistribution(): JsonField = incomeDistribution - - /** - * Returns the raw JSON value of [orderNo]. - * - * Unlike [orderNo], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("order_no") - @ExcludeMissing - fun _orderNo(): JsonField = orderNo - - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("price") - @ExcludeMissing - fun _price(): JsonField = price - - /** - * Returns the raw JSON value of [stampDuty]. - * - * Unlike [stampDuty], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("stamp_duty") - @ExcludeMissing - fun _stampDuty(): JsonField = stampDuty - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [AdditionalInfo]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AdditionalInfo]. */ - class Builder internal constructor() { - - private var capitalWithdrawal: JsonField = JsonMissing.of() - private var credit: JsonField = JsonMissing.of() - private var debit: JsonField = JsonMissing.of() - private var incomeDistribution: JsonField = JsonMissing.of() - private var orderNo: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var stampDuty: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(additionalInfo: AdditionalInfo) = apply { - capitalWithdrawal = additionalInfo.capitalWithdrawal - credit = additionalInfo.credit - debit = additionalInfo.debit - incomeDistribution = additionalInfo.incomeDistribution - orderNo = additionalInfo.orderNo - price = additionalInfo.price - stampDuty = additionalInfo.stampDuty - additionalProperties = - additionalInfo.additionalProperties.toMutableMap() - } - - /** Capital withdrawal amount (CDSL MF transactions) */ - fun capitalWithdrawal(capitalWithdrawal: Float) = - capitalWithdrawal(JsonField.of(capitalWithdrawal)) - - /** - * Sets [Builder.capitalWithdrawal] to an arbitrary JSON value. - * - * You should usually call [Builder.capitalWithdrawal] with a well-typed - * [Float] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun capitalWithdrawal(capitalWithdrawal: JsonField) = apply { - this.capitalWithdrawal = capitalWithdrawal - } - - /** Units credited (demat transactions) */ - fun credit(credit: Float) = credit(JsonField.of(credit)) - - /** - * Sets [Builder.credit] to an arbitrary JSON value. - * - * You should usually call [Builder.credit] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun credit(credit: JsonField) = apply { this.credit = credit } - - /** Units debited (demat transactions) */ - fun debit(debit: Float) = debit(JsonField.of(debit)) - - /** - * Sets [Builder.debit] to an arbitrary JSON value. - * - * You should usually call [Builder.debit] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun debit(debit: JsonField) = apply { this.debit = debit } - - /** Income distribution amount (CDSL MF transactions) */ - fun incomeDistribution(incomeDistribution: Float) = - incomeDistribution(JsonField.of(incomeDistribution)) - - /** - * Sets [Builder.incomeDistribution] to an arbitrary JSON value. - * - * You should usually call [Builder.incomeDistribution] with a - * well-typed [Float] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun incomeDistribution(incomeDistribution: JsonField) = apply { - this.incomeDistribution = incomeDistribution - } - - /** Order/transaction reference number (demat transactions) */ - fun orderNo(orderNo: String) = orderNo(JsonField.of(orderNo)) - - /** - * Sets [Builder.orderNo] to an arbitrary JSON value. - * - * You should usually call [Builder.orderNo] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun orderNo(orderNo: JsonField) = apply { - this.orderNo = orderNo - } - - /** Price per unit (NSDL/CDSL MF transactions) */ - fun price(price: Float) = price(JsonField.of(price)) - - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun price(price: JsonField) = apply { this.price = price } - - /** Stamp duty charged */ - fun stampDuty(stampDuty: Float) = stampDuty(JsonField.of(stampDuty)) - - /** - * Sets [Builder.stampDuty] to an arbitrary JSON value. - * - * You should usually call [Builder.stampDuty] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun stampDuty(stampDuty: JsonField) = apply { - this.stampDuty = stampDuty - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AdditionalInfo]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): AdditionalInfo = - AdditionalInfo( - capitalWithdrawal, - credit, - debit, - incomeDistribution, - orderNo, - price, - stampDuty, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AdditionalInfo = apply { - if (validated) { - return@apply - } - - capitalWithdrawal() - credit() - debit() - incomeDistribution() - orderNo() - price() - stampDuty() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (capitalWithdrawal.asKnown().isPresent) 1 else 0) + - (if (credit.asKnown().isPresent) 1 else 0) + - (if (debit.asKnown().isPresent) 1 else 0) + - (if (incomeDistribution.asKnown().isPresent) 1 else 0) + - (if (orderNo.asKnown().isPresent) 1 else 0) + - (if (price.asKnown().isPresent) 1 else 0) + - (if (stampDuty.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AdditionalInfo && - capitalWithdrawal == other.capitalWithdrawal && - credit == other.credit && - debit == other.debit && - incomeDistribution == other.incomeDistribution && - orderNo == other.orderNo && - price == other.price && - stampDuty == other.stampDuty && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - capitalWithdrawal, - credit, - debit, - incomeDistribution, - orderNo, - price, - stampDuty, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AdditionalInfo{capitalWithdrawal=$capitalWithdrawal, credit=$credit, debit=$debit, incomeDistribution=$incomeDistribution, orderNo=$orderNo, price=$price, stampDuty=$stampDuty, additionalProperties=$additionalProperties}" - } - - /** - * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, - * SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, - * DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, - * REVERSAL, UNKNOWN. - */ - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PURCHASE = of("PURCHASE") - - @JvmField val PURCHASE_SIP = of("PURCHASE_SIP") - - @JvmField val REDEMPTION = of("REDEMPTION") - - @JvmField val SWITCH_IN = of("SWITCH_IN") - - @JvmField val SWITCH_IN_MERGER = of("SWITCH_IN_MERGER") - - @JvmField val SWITCH_OUT = of("SWITCH_OUT") - - @JvmField val SWITCH_OUT_MERGER = of("SWITCH_OUT_MERGER") - - @JvmField val DIVIDEND_PAYOUT = of("DIVIDEND_PAYOUT") - - @JvmField val DIVIDEND_REINVEST = of("DIVIDEND_REINVEST") - - @JvmField val SEGREGATION = of("SEGREGATION") - - @JvmField val STAMP_DUTY_TAX = of("STAMP_DUTY_TAX") - - @JvmField val TDS_TAX = of("TDS_TAX") - - @JvmField val STT_TAX = of("STT_TAX") - - @JvmField val MISC = of("MISC") - - @JvmField val REVERSAL = of("REVERSAL") - - @JvmField val UNKNOWN = of("UNKNOWN") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - PURCHASE, - PURCHASE_SIP, - REDEMPTION, - SWITCH_IN, - SWITCH_IN_MERGER, - SWITCH_OUT, - SWITCH_OUT_MERGER, - DIVIDEND_PAYOUT, - DIVIDEND_REINVEST, - SEGREGATION, - STAMP_DUTY_TAX, - TDS_TAX, - STT_TAX, - MISC, - REVERSAL, - UNKNOWN, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PURCHASE, - PURCHASE_SIP, - REDEMPTION, - SWITCH_IN, - SWITCH_IN_MERGER, - SWITCH_OUT, - SWITCH_OUT_MERGER, - DIVIDEND_PAYOUT, - DIVIDEND_REINVEST, - SEGREGATION, - STAMP_DUTY_TAX, - TDS_TAX, - STT_TAX, - MISC, - REVERSAL, - UNKNOWN, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PURCHASE -> Value.PURCHASE - PURCHASE_SIP -> Value.PURCHASE_SIP - REDEMPTION -> Value.REDEMPTION - SWITCH_IN -> Value.SWITCH_IN - SWITCH_IN_MERGER -> Value.SWITCH_IN_MERGER - SWITCH_OUT -> Value.SWITCH_OUT - SWITCH_OUT_MERGER -> Value.SWITCH_OUT_MERGER - DIVIDEND_PAYOUT -> Value.DIVIDEND_PAYOUT - DIVIDEND_REINVEST -> Value.DIVIDEND_REINVEST - SEGREGATION -> Value.SEGREGATION - STAMP_DUTY_TAX -> Value.STAMP_DUTY_TAX - TDS_TAX -> Value.TDS_TAX - STT_TAX -> Value.STT_TAX - MISC -> Value.MISC - REVERSAL -> Value.REVERSAL - UNKNOWN -> Value.UNKNOWN - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws CasParserInvalidDataException if this class instance's value is a - * not a known member. - */ - fun known(): Known = - when (this) { - PURCHASE -> Known.PURCHASE - PURCHASE_SIP -> Known.PURCHASE_SIP - REDEMPTION -> Known.REDEMPTION - SWITCH_IN -> Known.SWITCH_IN - SWITCH_IN_MERGER -> Known.SWITCH_IN_MERGER - SWITCH_OUT -> Known.SWITCH_OUT - SWITCH_OUT_MERGER -> Known.SWITCH_OUT_MERGER - DIVIDEND_PAYOUT -> Known.DIVIDEND_PAYOUT - DIVIDEND_REINVEST -> Known.DIVIDEND_REINVEST - SEGREGATION -> Known.SEGREGATION - STAMP_DUTY_TAX -> Known.STAMP_DUTY_TAX - TDS_TAX -> Known.TDS_TAX - STT_TAX -> Known.STT_TAX - MISC -> Known.MISC - REVERSAL -> Known.REVERSAL - UNKNOWN -> Known.UNKNOWN - else -> throw CasParserInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws CasParserInvalidDataException if this class instance's value does - * not have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CasParserInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } + (if (closeUnits.asKnown().isPresent) 1 else 0) + + (if (openUnits.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Transaction && - additionalInfo == other.additionalInfo && - amount == other.amount && - balance == other.balance && - date == other.date && - description == other.description && - dividendRate == other.dividendRate && - nav == other.nav && - type == other.type && - units == other.units && + return other is AdditionalInfo && + closeUnits == other.closeUnits && + openUnits == other.openUnits && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - additionalInfo, - amount, - balance, - date, - description, - dividendRate, - nav, - type, - units, - additionalProperties, - ) + Objects.hash(closeUnits, openUnits, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Transaction{additionalInfo=$additionalInfo, amount=$amount, balance=$balance, date=$date, description=$description, dividendRate=$dividendRate, nav=$nav, type=$type, units=$units, additionalProperties=$additionalProperties}" + "AdditionalInfo{closeUnits=$closeUnits, openUnits=$openUnits, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -5375,7 +4181,7 @@ private constructor( return true } - return other is CorporateBond && + return other is Equity && additionalInfo == other.additionalInfo && isin == other.isin && name == other.name && @@ -5400,10 +4206,10 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "CorporateBond{additionalInfo=$additionalInfo, isin=$isin, name=$name, transactions=$transactions, units=$units, value=$value, additionalProperties=$additionalProperties}" + "Equity{additionalInfo=$additionalInfo, isin=$isin, name=$name, transactions=$transactions, units=$units, value=$value, additionalProperties=$additionalProperties}" } - class DematMutualFund + class GovernmentSecurity @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val additionalInfo: JsonField, @@ -5438,7 +4244,7 @@ private constructor( ) : this(additionalInfo, isin, name, transactions, units, value, mutableMapOf()) /** - * Additional information specific to the mutual fund + * Additional information specific to the government security * * @throws CasParserInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -5447,7 +4253,7 @@ private constructor( additionalInfo.getOptional("additional_info") /** - * ISIN code of the mutual fund + * ISIN code of the government security * * @throws CasParserInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -5455,7 +4261,7 @@ private constructor( fun isin(): Optional = isin.getOptional("isin") /** - * Name of the mutual fund + * Name of the government security * * @throws CasParserInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -5554,12 +4360,13 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [DematMutualFund]. + * Returns a mutable builder for constructing an instance of + * [GovernmentSecurity]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [DematMutualFund]. */ + /** A builder for [GovernmentSecurity]. */ class Builder internal constructor() { private var additionalInfo: JsonField = JsonMissing.of() @@ -5571,17 +4378,18 @@ private constructor( private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(dematMutualFund: DematMutualFund) = apply { - additionalInfo = dematMutualFund.additionalInfo - isin = dematMutualFund.isin - name = dematMutualFund.name - transactions = dematMutualFund.transactions.map { it.toMutableList() } - units = dematMutualFund.units - value = dematMutualFund.value - additionalProperties = dematMutualFund.additionalProperties.toMutableMap() + internal fun from(governmentSecurity: GovernmentSecurity) = apply { + additionalInfo = governmentSecurity.additionalInfo + isin = governmentSecurity.isin + name = governmentSecurity.name + transactions = governmentSecurity.transactions.map { it.toMutableList() } + units = governmentSecurity.units + value = governmentSecurity.value + additionalProperties = + governmentSecurity.additionalProperties.toMutableMap() } - /** Additional information specific to the mutual fund */ + /** Additional information specific to the government security */ fun additionalInfo(additionalInfo: AdditionalInfo) = additionalInfo(JsonField.of(additionalInfo)) @@ -5596,7 +4404,7 @@ private constructor( this.additionalInfo = additionalInfo } - /** ISIN code of the mutual fund */ + /** ISIN code of the government security */ fun isin(isin: String) = isin(JsonField.of(isin)) /** @@ -5608,7 +4416,7 @@ private constructor( */ fun isin(isin: JsonField) = apply { this.isin = isin } - /** Name of the mutual fund */ + /** Name of the government security */ fun name(name: String) = name(JsonField.of(name)) /** @@ -5694,12 +4502,12 @@ private constructor( } /** - * Returns an immutable instance of [DematMutualFund]. + * Returns an immutable instance of [GovernmentSecurity]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): DematMutualFund = - DematMutualFund( + fun build(): GovernmentSecurity = + GovernmentSecurity( additionalInfo, isin, name, @@ -5712,7 +4520,7 @@ private constructor( private var validated: Boolean = false - fun validate(): DematMutualFund = apply { + fun validate(): GovernmentSecurity = apply { if (validated) { return@apply } @@ -5749,7 +4557,7 @@ private constructor( (if (units.asKnown().isPresent) 1 else 0) + (if (value.asKnown().isPresent) 1 else 0) - /** Additional information specific to the mutual fund */ + /** Additional information specific to the government security */ class AdditionalInfo @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -5981,7014 +4789,1027 @@ private constructor( "AdditionalInfo{closeUnits=$closeUnits, openUnits=$openUnits, additionalProperties=$additionalProperties}" } - /** - * Unified transaction schema for all holding types (MF folios, equities, bonds, - * etc.) - */ - class Transaction - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val additionalInfo: JsonField, - private val amount: JsonField, - private val balance: JsonField, - private val date: JsonField, - private val description: JsonField, - private val dividendRate: JsonField, - private val nav: JsonField, - private val type: JsonField, - private val units: JsonField, - private val additionalProperties: MutableMap, - ) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JsonCreator - private constructor( - @JsonProperty("additional_info") - @ExcludeMissing - additionalInfo: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("balance") - @ExcludeMissing - balance: JsonField = JsonMissing.of(), - @JsonProperty("date") - @ExcludeMissing - date: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("dividend_rate") - @ExcludeMissing - dividendRate: JsonField = JsonMissing.of(), - @JsonProperty("nav") - @ExcludeMissing - nav: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonField = JsonMissing.of(), - @JsonProperty("units") - @ExcludeMissing - units: JsonField = JsonMissing.of(), - ) : this( + return other is GovernmentSecurity && + additionalInfo == other.additionalInfo && + isin == other.isin && + name == other.name && + transactions == other.transactions && + units == other.units && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( additionalInfo, - amount, - balance, - date, - description, - dividendRate, - nav, - type, + isin, + name, + transactions, units, - mutableMapOf(), + value, + additionalProperties, ) + } - /** - * Additional transaction-specific fields that vary by source - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun additionalInfo(): Optional = - additionalInfo.getOptional("additional_info") - - /** - * Transaction amount in currency (computed from units × price/NAV) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * Balance units after transaction - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun balance(): Optional = balance.getOptional("balance") + override fun hashCode(): Int = hashCode - /** - * Transaction date (YYYY-MM-DD) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun date(): Optional = date.getOptional("date") + override fun toString() = + "GovernmentSecurity{additionalInfo=$additionalInfo, isin=$isin, name=$name, transactions=$transactions, units=$units, value=$value, additionalProperties=$additionalProperties}" + } - /** - * Transaction description/particulars - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Dividend rate (for DIVIDEND_PAYOUT transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun dividendRate(): Optional = dividendRate.getOptional("dividend_rate") + return other is Holdings && + aifs == other.aifs && + corporateBonds == other.corporateBonds && + dematMutualFunds == other.dematMutualFunds && + equities == other.equities && + governmentSecurities == other.governmentSecurities && + additionalProperties == other.additionalProperties + } - /** - * NAV/price per unit on transaction date - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun nav(): Optional = nav.getOptional("nav") + private val hashCode: Int by lazy { + Objects.hash( + aifs, + corporateBonds, + dematMutualFunds, + equities, + governmentSecurities, + additionalProperties, + ) + } - /** - * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, - * SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, - * DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, - * REVERSAL, UNKNOWN. - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") + override fun hashCode(): Int = hashCode - /** - * Number of units involved in transaction - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun units(): Optional = units.getOptional("units") + override fun toString() = + "Holdings{aifs=$aifs, corporateBonds=$corporateBonds, dematMutualFunds=$dematMutualFunds, equities=$equities, governmentSecurities=$governmentSecurities, additionalProperties=$additionalProperties}" + } - /** - * Returns the raw JSON value of [additionalInfo]. - * - * Unlike [additionalInfo], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("additional_info") - @ExcludeMissing - fun _additionalInfo(): JsonField = additionalInfo + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + return other is DematAccount && + additionalInfo == other.additionalInfo && + boId == other.boId && + clientId == other.clientId && + dematType == other.dematType && + dpId == other.dpId && + dpName == other.dpName && + holdings == other.holdings && + linkedHolders == other.linkedHolders && + value == other.value && + additionalProperties == other.additionalProperties + } - /** - * Returns the raw JSON value of [balance]. - * - * Unlike [balance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("balance") - @ExcludeMissing - fun _balance(): JsonField = balance + private val hashCode: Int by lazy { + Objects.hash( + additionalInfo, + boId, + clientId, + dematType, + dpId, + dpName, + holdings, + linkedHolders, + value, + additionalProperties, + ) + } - /** - * Returns the raw JSON value of [date]. - * - * Unlike [date], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("date") @ExcludeMissing fun _date(): JsonField = date + override fun hashCode(): Int = hashCode - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + override fun toString() = + "DematAccount{additionalInfo=$additionalInfo, boId=$boId, clientId=$clientId, dematType=$dematType, dpId=$dpId, dpName=$dpName, holdings=$holdings, linkedHolders=$linkedHolders, value=$value, additionalProperties=$additionalProperties}" + } - /** - * Returns the raw JSON value of [dividendRate]. - * - * Unlike [dividendRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("dividend_rate") - @ExcludeMissing - fun _dividendRate(): JsonField = dividendRate + class Insurance + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val lifeInsurancePolicies: JsonField>, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [nav]. - * - * Unlike [nav], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("nav") @ExcludeMissing fun _nav(): JsonField = nav + @JsonCreator + private constructor( + @JsonProperty("life_insurance_policies") + @ExcludeMissing + lifeInsurancePolicies: JsonField> = JsonMissing.of() + ) : this(lifeInsurancePolicies, mutableMapOf()) - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lifeInsurancePolicies(): Optional> = + lifeInsurancePolicies.getOptional("life_insurance_policies") - /** - * Returns the raw JSON value of [units]. - * - * Unlike [units], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("units") @ExcludeMissing fun _units(): JsonField = units + /** + * Returns the raw JSON value of [lifeInsurancePolicies]. + * + * Unlike [lifeInsurancePolicies], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("life_insurance_policies") + @ExcludeMissing + fun _lifeInsurancePolicies(): JsonField> = lifeInsurancePolicies - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun toBuilder() = Builder().from(this) + fun toBuilder() = Builder().from(this) - companion object { + companion object { - /** - * Returns a mutable builder for constructing an instance of [Transaction]. - */ - @JvmStatic fun builder() = Builder() - } + /** Returns a mutable builder for constructing an instance of [Insurance]. */ + @JvmStatic fun builder() = Builder() + } - /** A builder for [Transaction]. */ - class Builder internal constructor() { + /** A builder for [Insurance]. */ + class Builder internal constructor() { - private var additionalInfo: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var balance: JsonField = JsonMissing.of() - private var date: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var dividendRate: JsonField = JsonMissing.of() - private var nav: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var units: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() + private var lifeInsurancePolicies: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() - @JvmSynthetic - internal fun from(transaction: Transaction) = apply { - additionalInfo = transaction.additionalInfo - amount = transaction.amount - balance = transaction.balance - date = transaction.date - description = transaction.description - dividendRate = transaction.dividendRate - nav = transaction.nav - type = transaction.type - units = transaction.units - additionalProperties = transaction.additionalProperties.toMutableMap() - } + @JvmSynthetic + internal fun from(insurance: Insurance) = apply { + lifeInsurancePolicies = insurance.lifeInsurancePolicies.map { it.toMutableList() } + additionalProperties = insurance.additionalProperties.toMutableMap() + } - /** Additional transaction-specific fields that vary by source */ - fun additionalInfo(additionalInfo: AdditionalInfo) = - additionalInfo(JsonField.of(additionalInfo)) + fun lifeInsurancePolicies(lifeInsurancePolicies: List) = + lifeInsurancePolicies(JsonField.of(lifeInsurancePolicies)) - /** - * Sets [Builder.additionalInfo] to an arbitrary JSON value. - * - * You should usually call [Builder.additionalInfo] with a well-typed - * [AdditionalInfo] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun additionalInfo(additionalInfo: JsonField) = apply { - this.additionalInfo = additionalInfo - } + /** + * Sets [Builder.lifeInsurancePolicies] to an arbitrary JSON value. + * + * You should usually call [Builder.lifeInsurancePolicies] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun lifeInsurancePolicies(lifeInsurancePolicies: JsonField>) = + apply { + this.lifeInsurancePolicies = lifeInsurancePolicies.map { it.toMutableList() } + } - /** Transaction amount in currency (computed from units × price/NAV) */ - fun amount(amount: Float?) = amount(JsonField.ofNullable(amount)) + /** + * Adds a single [LifeInsurancePolicy] to [lifeInsurancePolicies]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLifeInsurancePolicy(lifeInsurancePolicy: LifeInsurancePolicy) = apply { + lifeInsurancePolicies = + (lifeInsurancePolicies ?: JsonField.of(mutableListOf())).also { + checkKnown("lifeInsurancePolicies", it).add(lifeInsurancePolicy) + } + } - /** - * Alias for [Builder.amount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun amount(amount: Float) = amount(amount as Float?) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - /** Balance units after transaction */ - fun balance(balance: Float) = balance(JsonField.of(balance)) + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - /** - * Sets [Builder.balance] to an arbitrary JSON value. - * - * You should usually call [Builder.balance] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun balance(balance: JsonField) = apply { this.balance = balance } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - /** Transaction date (YYYY-MM-DD) */ - fun date(date: LocalDate) = date(JsonField.of(date)) + /** + * Returns an immutable instance of [Insurance]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Insurance = + Insurance( + (lifeInsurancePolicies ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } - /** - * Sets [Builder.date] to an arbitrary JSON value. - * - * You should usually call [Builder.date] with a well-typed [LocalDate] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun date(date: JsonField) = apply { this.date = date } + private var validated: Boolean = false - /** Transaction description/particulars */ - fun description(description: String) = - description(JsonField.of(description)) + fun validate(): Insurance = apply { + if (validated) { + return@apply + } - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun description(description: JsonField) = apply { - this.description = description - } + lifeInsurancePolicies().ifPresent { it.forEach { it.validate() } } + validated = true + } - /** Dividend rate (for DIVIDEND_PAYOUT transactions) */ - fun dividendRate(dividendRate: Float?) = - dividendRate(JsonField.ofNullable(dividendRate)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } - /** - * Alias for [Builder.dividendRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun dividendRate(dividendRate: Float) = dividendRate(dividendRate as Float?) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (lifeInsurancePolicies.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - /** - * Alias for calling [Builder.dividendRate] with - * `dividendRate.orElse(null)`. - */ - fun dividendRate(dividendRate: Optional) = - dividendRate(dividendRate.getOrNull()) + class LifeInsurancePolicy + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val additionalInfo: JsonValue, + private val lifeAssured: JsonField, + private val policyName: JsonField, + private val policyNumber: JsonField, + private val premiumAmount: JsonField, + private val premiumFrequency: JsonField, + private val provider: JsonField, + private val status: JsonField, + private val sumAssured: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Sets [Builder.dividendRate] to an arbitrary JSON value. - * - * You should usually call [Builder.dividendRate] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun dividendRate(dividendRate: JsonField) = apply { - this.dividendRate = dividendRate - } + @JsonCreator + private constructor( + @JsonProperty("additional_info") + @ExcludeMissing + additionalInfo: JsonValue = JsonMissing.of(), + @JsonProperty("life_assured") + @ExcludeMissing + lifeAssured: JsonField = JsonMissing.of(), + @JsonProperty("policy_name") + @ExcludeMissing + policyName: JsonField = JsonMissing.of(), + @JsonProperty("policy_number") + @ExcludeMissing + policyNumber: JsonField = JsonMissing.of(), + @JsonProperty("premium_amount") + @ExcludeMissing + premiumAmount: JsonField = JsonMissing.of(), + @JsonProperty("premium_frequency") + @ExcludeMissing + premiumFrequency: JsonField = JsonMissing.of(), + @JsonProperty("provider") + @ExcludeMissing + provider: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + status: JsonField = JsonMissing.of(), + @JsonProperty("sum_assured") + @ExcludeMissing + sumAssured: JsonField = JsonMissing.of(), + ) : this( + additionalInfo, + lifeAssured, + policyName, + policyNumber, + premiumAmount, + premiumFrequency, + provider, + status, + sumAssured, + mutableMapOf(), + ) - /** NAV/price per unit on transaction date */ - fun nav(nav: Float?) = nav(JsonField.ofNullable(nav)) + /** + * Additional information specific to the policy + * + * This arbitrary value can be deserialized into a custom type using the `convert` + * method: + * ```java + * MyClass myObject = lifeInsurancePolicy.additionalInfo().convert(MyClass.class); + * ``` + */ + @JsonProperty("additional_info") + @ExcludeMissing + fun _additionalInfo(): JsonValue = additionalInfo - /** - * Alias for [Builder.nav]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun nav(nav: Float) = nav(nav as Float?) + /** + * Name of the life assured + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun lifeAssured(): Optional = lifeAssured.getOptional("life_assured") - /** Alias for calling [Builder.nav] with `nav.orElse(null)`. */ - fun nav(nav: Optional) = nav(nav.getOrNull()) + /** + * Name of the insurance policy + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun policyName(): Optional = policyName.getOptional("policy_name") - /** - * Sets [Builder.nav] to an arbitrary JSON value. - * - * You should usually call [Builder.nav] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun nav(nav: JsonField) = apply { this.nav = nav } + /** + * Insurance policy number + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun policyNumber(): Optional = policyNumber.getOptional("policy_number") - /** - * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, - * SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, - * DIVIDEND_PAYOUT, DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, - * STT_TAX, MISC, REVERSAL, UNKNOWN. - */ - fun type(type: Type) = type(JsonField.of(type)) + /** + * Premium amount + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun premiumAmount(): Optional = premiumAmount.getOptional("premium_amount") - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } + /** + * Frequency of premium payment (e.g., Annual, Monthly) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun premiumFrequency(): Optional = + premiumFrequency.getOptional("premium_frequency") - /** Number of units involved in transaction */ - fun units(units: Float) = units(JsonField.of(units)) + /** + * Insurance company name + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun provider(): Optional = provider.getOptional("provider") - /** - * Sets [Builder.units] to an arbitrary JSON value. - * - * You should usually call [Builder.units] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun units(units: JsonField) = apply { this.units = units } + /** + * Status of the policy (e.g., Active, Lapsed) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Sum assured amount + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun sumAssured(): Optional = sumAssured.getOptional("sum_assured") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [lifeAssured]. + * + * Unlike [lifeAssured], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("life_assured") + @ExcludeMissing + fun _lifeAssured(): JsonField = lifeAssured - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Returns the raw JSON value of [policyName]. + * + * Unlike [policyName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("policy_name") + @ExcludeMissing + fun _policyName(): JsonField = policyName - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Returns the raw JSON value of [policyNumber]. + * + * Unlike [policyNumber], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("policy_number") + @ExcludeMissing + fun _policyNumber(): JsonField = policyNumber - /** - * Returns an immutable instance of [Transaction]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Transaction = - Transaction( - additionalInfo, - amount, - balance, - date, - description, - dividendRate, - nav, - type, - units, - additionalProperties.toMutableMap(), - ) - } + /** + * Returns the raw JSON value of [premiumAmount]. + * + * Unlike [premiumAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("premium_amount") + @ExcludeMissing + fun _premiumAmount(): JsonField = premiumAmount - private var validated: Boolean = false + /** + * Returns the raw JSON value of [premiumFrequency]. + * + * Unlike [premiumFrequency], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("premium_frequency") + @ExcludeMissing + fun _premiumFrequency(): JsonField = premiumFrequency - fun validate(): Transaction = apply { - if (validated) { - return@apply - } + /** + * Returns the raw JSON value of [provider]. + * + * Unlike [provider], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("provider") @ExcludeMissing fun _provider(): JsonField = provider - additionalInfo().ifPresent { it.validate() } - amount() - balance() - date() - description() - dividendRate() - nav() - type().ifPresent { it.validate() } - units() - validated = true - } + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [sumAssured]. + * + * Unlike [sumAssured], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("sum_assured") + @ExcludeMissing + fun _sumAssured(): JsonField = sumAssured - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (additionalInfo.asKnown().getOrNull()?.validity() ?: 0) + - (if (amount.asKnown().isPresent) 1 else 0) + - (if (balance.asKnown().isPresent) 1 else 0) + - (if (date.asKnown().isPresent) 1 else 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (if (dividendRate.asKnown().isPresent) 1 else 0) + - (if (nav.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (units.asKnown().isPresent) 1 else 0) - - /** Additional transaction-specific fields that vary by source */ - class AdditionalInfo - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val capitalWithdrawal: JsonField, - private val credit: JsonField, - private val debit: JsonField, - private val incomeDistribution: JsonField, - private val orderNo: JsonField, - private val price: JsonField, - private val stampDuty: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("capital_withdrawal") - @ExcludeMissing - capitalWithdrawal: JsonField = JsonMissing.of(), - @JsonProperty("credit") - @ExcludeMissing - credit: JsonField = JsonMissing.of(), - @JsonProperty("debit") - @ExcludeMissing - debit: JsonField = JsonMissing.of(), - @JsonProperty("income_distribution") - @ExcludeMissing - incomeDistribution: JsonField = JsonMissing.of(), - @JsonProperty("order_no") - @ExcludeMissing - orderNo: JsonField = JsonMissing.of(), - @JsonProperty("price") - @ExcludeMissing - price: JsonField = JsonMissing.of(), - @JsonProperty("stamp_duty") - @ExcludeMissing - stampDuty: JsonField = JsonMissing.of(), - ) : this( - capitalWithdrawal, - credit, - debit, - incomeDistribution, - orderNo, - price, - stampDuty, - mutableMapOf(), - ) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Capital withdrawal amount (CDSL MF transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun capitalWithdrawal(): Optional = - capitalWithdrawal.getOptional("capital_withdrawal") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Units credited (demat transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun credit(): Optional = credit.getOptional("credit") + fun toBuilder() = Builder().from(this) - /** - * Units debited (demat transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun debit(): Optional = debit.getOptional("debit") + companion object { - /** - * Income distribution amount (CDSL MF transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun incomeDistribution(): Optional = - incomeDistribution.getOptional("income_distribution") + /** + * Returns a mutable builder for constructing an instance of [LifeInsurancePolicy]. + */ + @JvmStatic fun builder() = Builder() + } - /** - * Order/transaction reference number (demat transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun orderNo(): Optional = orderNo.getOptional("order_no") + /** A builder for [LifeInsurancePolicy]. */ + class Builder internal constructor() { - /** - * Price per unit (NSDL/CDSL MF transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun price(): Optional = price.getOptional("price") + private var additionalInfo: JsonValue = JsonMissing.of() + private var lifeAssured: JsonField = JsonMissing.of() + private var policyName: JsonField = JsonMissing.of() + private var policyNumber: JsonField = JsonMissing.of() + private var premiumAmount: JsonField = JsonMissing.of() + private var premiumFrequency: JsonField = JsonMissing.of() + private var provider: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var sumAssured: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Stamp duty charged - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun stampDuty(): Optional = stampDuty.getOptional("stamp_duty") + @JvmSynthetic + internal fun from(lifeInsurancePolicy: LifeInsurancePolicy) = apply { + additionalInfo = lifeInsurancePolicy.additionalInfo + lifeAssured = lifeInsurancePolicy.lifeAssured + policyName = lifeInsurancePolicy.policyName + policyNumber = lifeInsurancePolicy.policyNumber + premiumAmount = lifeInsurancePolicy.premiumAmount + premiumFrequency = lifeInsurancePolicy.premiumFrequency + provider = lifeInsurancePolicy.provider + status = lifeInsurancePolicy.status + sumAssured = lifeInsurancePolicy.sumAssured + additionalProperties = lifeInsurancePolicy.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [capitalWithdrawal]. - * - * Unlike [capitalWithdrawal], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("capital_withdrawal") - @ExcludeMissing - fun _capitalWithdrawal(): JsonField = capitalWithdrawal + /** Additional information specific to the policy */ + fun additionalInfo(additionalInfo: JsonValue) = apply { + this.additionalInfo = additionalInfo + } - /** - * Returns the raw JSON value of [credit]. - * - * Unlike [credit], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("credit") - @ExcludeMissing - fun _credit(): JsonField = credit + /** Name of the life assured */ + fun lifeAssured(lifeAssured: String) = lifeAssured(JsonField.of(lifeAssured)) - /** - * Returns the raw JSON value of [debit]. - * - * Unlike [debit], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("debit") - @ExcludeMissing - fun _debit(): JsonField = debit + /** + * Sets [Builder.lifeAssured] to an arbitrary JSON value. + * + * You should usually call [Builder.lifeAssured] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun lifeAssured(lifeAssured: JsonField) = apply { + this.lifeAssured = lifeAssured + } - /** - * Returns the raw JSON value of [incomeDistribution]. - * - * Unlike [incomeDistribution], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("income_distribution") - @ExcludeMissing - fun _incomeDistribution(): JsonField = incomeDistribution + /** Name of the insurance policy */ + fun policyName(policyName: String) = policyName(JsonField.of(policyName)) - /** - * Returns the raw JSON value of [orderNo]. - * - * Unlike [orderNo], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("order_no") - @ExcludeMissing - fun _orderNo(): JsonField = orderNo + /** + * Sets [Builder.policyName] to an arbitrary JSON value. + * + * You should usually call [Builder.policyName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun policyName(policyName: JsonField) = apply { + this.policyName = policyName + } - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("price") - @ExcludeMissing - fun _price(): JsonField = price + /** Insurance policy number */ + fun policyNumber(policyNumber: String) = policyNumber(JsonField.of(policyNumber)) - /** - * Returns the raw JSON value of [stampDuty]. - * - * Unlike [stampDuty], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("stamp_duty") - @ExcludeMissing - fun _stampDuty(): JsonField = stampDuty + /** + * Sets [Builder.policyNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.policyNumber] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun policyNumber(policyNumber: JsonField) = apply { + this.policyNumber = policyNumber + } - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** Premium amount */ + fun premiumAmount(premiumAmount: Float) = premiumAmount(JsonField.of(premiumAmount)) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** + * Sets [Builder.premiumAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.premiumAmount] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun premiumAmount(premiumAmount: JsonField) = apply { + this.premiumAmount = premiumAmount + } - fun toBuilder() = Builder().from(this) + /** Frequency of premium payment (e.g., Annual, Monthly) */ + fun premiumFrequency(premiumFrequency: String) = + premiumFrequency(JsonField.of(premiumFrequency)) - companion object { + /** + * Sets [Builder.premiumFrequency] to an arbitrary JSON value. + * + * You should usually call [Builder.premiumFrequency] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun premiumFrequency(premiumFrequency: JsonField) = apply { + this.premiumFrequency = premiumFrequency + } - /** - * Returns a mutable builder for constructing an instance of - * [AdditionalInfo]. - */ - @JvmStatic fun builder() = Builder() - } + /** Insurance company name */ + fun provider(provider: String) = provider(JsonField.of(provider)) - /** A builder for [AdditionalInfo]. */ - class Builder internal constructor() { - - private var capitalWithdrawal: JsonField = JsonMissing.of() - private var credit: JsonField = JsonMissing.of() - private var debit: JsonField = JsonMissing.of() - private var incomeDistribution: JsonField = JsonMissing.of() - private var orderNo: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var stampDuty: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(additionalInfo: AdditionalInfo) = apply { - capitalWithdrawal = additionalInfo.capitalWithdrawal - credit = additionalInfo.credit - debit = additionalInfo.debit - incomeDistribution = additionalInfo.incomeDistribution - orderNo = additionalInfo.orderNo - price = additionalInfo.price - stampDuty = additionalInfo.stampDuty - additionalProperties = - additionalInfo.additionalProperties.toMutableMap() - } - - /** Capital withdrawal amount (CDSL MF transactions) */ - fun capitalWithdrawal(capitalWithdrawal: Float) = - capitalWithdrawal(JsonField.of(capitalWithdrawal)) - - /** - * Sets [Builder.capitalWithdrawal] to an arbitrary JSON value. - * - * You should usually call [Builder.capitalWithdrawal] with a well-typed - * [Float] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun capitalWithdrawal(capitalWithdrawal: JsonField) = apply { - this.capitalWithdrawal = capitalWithdrawal - } - - /** Units credited (demat transactions) */ - fun credit(credit: Float) = credit(JsonField.of(credit)) - - /** - * Sets [Builder.credit] to an arbitrary JSON value. - * - * You should usually call [Builder.credit] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun credit(credit: JsonField) = apply { this.credit = credit } - - /** Units debited (demat transactions) */ - fun debit(debit: Float) = debit(JsonField.of(debit)) - - /** - * Sets [Builder.debit] to an arbitrary JSON value. - * - * You should usually call [Builder.debit] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun debit(debit: JsonField) = apply { this.debit = debit } - - /** Income distribution amount (CDSL MF transactions) */ - fun incomeDistribution(incomeDistribution: Float) = - incomeDistribution(JsonField.of(incomeDistribution)) - - /** - * Sets [Builder.incomeDistribution] to an arbitrary JSON value. - * - * You should usually call [Builder.incomeDistribution] with a - * well-typed [Float] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun incomeDistribution(incomeDistribution: JsonField) = apply { - this.incomeDistribution = incomeDistribution - } - - /** Order/transaction reference number (demat transactions) */ - fun orderNo(orderNo: String) = orderNo(JsonField.of(orderNo)) - - /** - * Sets [Builder.orderNo] to an arbitrary JSON value. - * - * You should usually call [Builder.orderNo] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun orderNo(orderNo: JsonField) = apply { - this.orderNo = orderNo - } - - /** Price per unit (NSDL/CDSL MF transactions) */ - fun price(price: Float) = price(JsonField.of(price)) - - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun price(price: JsonField) = apply { this.price = price } - - /** Stamp duty charged */ - fun stampDuty(stampDuty: Float) = stampDuty(JsonField.of(stampDuty)) - - /** - * Sets [Builder.stampDuty] to an arbitrary JSON value. - * - * You should usually call [Builder.stampDuty] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun stampDuty(stampDuty: JsonField) = apply { - this.stampDuty = stampDuty - } + /** + * Sets [Builder.provider] to an arbitrary JSON value. + * + * You should usually call [Builder.provider] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun provider(provider: JsonField) = apply { this.provider = provider } - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** Status of the policy (e.g., Active, Lapsed) */ + fun status(status: String) = status(JsonField.of(status)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } + /** Sum assured amount */ + fun sumAssured(sumAssured: Float) = sumAssured(JsonField.of(sumAssured)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Sets [Builder.sumAssured] to an arbitrary JSON value. + * + * You should usually call [Builder.sumAssured] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun sumAssured(sumAssured: JsonField) = apply { + this.sumAssured = sumAssured + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** - * Returns an immutable instance of [AdditionalInfo]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): AdditionalInfo = - AdditionalInfo( - capitalWithdrawal, - credit, - debit, - incomeDistribution, - orderNo, - price, - stampDuty, - additionalProperties.toMutableMap(), - ) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - private var validated: Boolean = false + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - fun validate(): AdditionalInfo = apply { - if (validated) { - return@apply - } + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - capitalWithdrawal() - credit() - debit() - incomeDistribution() - orderNo() - price() - stampDuty() - validated = true - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } + /** + * Returns an immutable instance of [LifeInsurancePolicy]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LifeInsurancePolicy = + LifeInsurancePolicy( + additionalInfo, + lifeAssured, + policyName, + policyNumber, + premiumAmount, + premiumFrequency, + provider, + status, + sumAssured, + additionalProperties.toMutableMap(), + ) + } - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (capitalWithdrawal.asKnown().isPresent) 1 else 0) + - (if (credit.asKnown().isPresent) 1 else 0) + - (if (debit.asKnown().isPresent) 1 else 0) + - (if (incomeDistribution.asKnown().isPresent) 1 else 0) + - (if (orderNo.asKnown().isPresent) 1 else 0) + - (if (price.asKnown().isPresent) 1 else 0) + - (if (stampDuty.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is AdditionalInfo && - capitalWithdrawal == other.capitalWithdrawal && - credit == other.credit && - debit == other.debit && - incomeDistribution == other.incomeDistribution && - orderNo == other.orderNo && - price == other.price && - stampDuty == other.stampDuty && - additionalProperties == other.additionalProperties - } + fun validate(): LifeInsurancePolicy = apply { + if (validated) { + return@apply + } - private val hashCode: Int by lazy { - Objects.hash( - capitalWithdrawal, - credit, - debit, - incomeDistribution, - orderNo, - price, - stampDuty, - additionalProperties, - ) - } + lifeAssured() + policyName() + policyNumber() + premiumAmount() + premiumFrequency() + provider() + status() + sumAssured() + validated = true + } - override fun hashCode(): Int = hashCode + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } - override fun toString() = - "AdditionalInfo{capitalWithdrawal=$capitalWithdrawal, credit=$credit, debit=$debit, incomeDistribution=$incomeDistribution, orderNo=$orderNo, price=$price, stampDuty=$stampDuty, additionalProperties=$additionalProperties}" - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (lifeAssured.asKnown().isPresent) 1 else 0) + + (if (policyName.asKnown().isPresent) 1 else 0) + + (if (policyNumber.asKnown().isPresent) 1 else 0) + + (if (premiumAmount.asKnown().isPresent) 1 else 0) + + (if (premiumFrequency.asKnown().isPresent) 1 else 0) + + (if (provider.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (if (sumAssured.asKnown().isPresent) 1 else 0) - /** - * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, - * SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, - * DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, - * REVERSAL, UNKNOWN. - */ - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + return other is LifeInsurancePolicy && + additionalInfo == other.additionalInfo && + lifeAssured == other.lifeAssured && + policyName == other.policyName && + policyNumber == other.policyNumber && + premiumAmount == other.premiumAmount && + premiumFrequency == other.premiumFrequency && + provider == other.provider && + status == other.status && + sumAssured == other.sumAssured && + additionalProperties == other.additionalProperties + } - companion object { + private val hashCode: Int by lazy { + Objects.hash( + additionalInfo, + lifeAssured, + policyName, + policyNumber, + premiumAmount, + premiumFrequency, + provider, + status, + sumAssured, + additionalProperties, + ) + } - @JvmField val PURCHASE = of("PURCHASE") + override fun hashCode(): Int = hashCode - @JvmField val PURCHASE_SIP = of("PURCHASE_SIP") + override fun toString() = + "LifeInsurancePolicy{additionalInfo=$additionalInfo, lifeAssured=$lifeAssured, policyName=$policyName, policyNumber=$policyNumber, premiumAmount=$premiumAmount, premiumFrequency=$premiumFrequency, provider=$provider, status=$status, sumAssured=$sumAssured, additionalProperties=$additionalProperties}" + } - @JvmField val REDEMPTION = of("REDEMPTION") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmField val SWITCH_IN = of("SWITCH_IN") + return other is Insurance && + lifeInsurancePolicies == other.lifeInsurancePolicies && + additionalProperties == other.additionalProperties + } - @JvmField val SWITCH_IN_MERGER = of("SWITCH_IN_MERGER") + private val hashCode: Int by lazy { + Objects.hash(lifeInsurancePolicies, additionalProperties) + } - @JvmField val SWITCH_OUT = of("SWITCH_OUT") + override fun hashCode(): Int = hashCode - @JvmField val SWITCH_OUT_MERGER = of("SWITCH_OUT_MERGER") + override fun toString() = + "Insurance{lifeInsurancePolicies=$lifeInsurancePolicies, additionalProperties=$additionalProperties}" + } - @JvmField val DIVIDEND_PAYOUT = of("DIVIDEND_PAYOUT") + class Investor + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val address: JsonField, + private val casId: JsonField, + private val email: JsonField, + private val mobile: JsonField, + private val name: JsonField, + private val pan: JsonField, + private val pincode: JsonField, + private val additionalProperties: MutableMap, + ) { - @JvmField val DIVIDEND_REINVEST = of("DIVIDEND_REINVEST") + @JsonCreator + private constructor( + @JsonProperty("address") @ExcludeMissing address: JsonField = JsonMissing.of(), + @JsonProperty("cas_id") @ExcludeMissing casId: JsonField = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), + @JsonProperty("mobile") @ExcludeMissing mobile: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("pan") @ExcludeMissing pan: JsonField = JsonMissing.of(), + @JsonProperty("pincode") @ExcludeMissing pincode: JsonField = JsonMissing.of(), + ) : this(address, casId, email, mobile, name, pan, pincode, mutableMapOf()) - @JvmField val SEGREGATION = of("SEGREGATION") + /** + * Address of the investor + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun address(): Optional = address.getOptional("address") - @JvmField val STAMP_DUTY_TAX = of("STAMP_DUTY_TAX") + /** + * CAS ID of the investor (only for NSDL and CDSL) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun casId(): Optional = casId.getOptional("cas_id") - @JvmField val TDS_TAX = of("TDS_TAX") + /** + * Email address of the investor + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun email(): Optional = email.getOptional("email") - @JvmField val STT_TAX = of("STT_TAX") + /** + * Mobile number of the investor + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun mobile(): Optional = mobile.getOptional("mobile") - @JvmField val MISC = of("MISC") + /** + * Name of the investor + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") - @JvmField val REVERSAL = of("REVERSAL") + /** + * PAN (Permanent Account Number) of the investor + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun pan(): Optional = pan.getOptional("pan") - @JvmField val UNKNOWN = of("UNKNOWN") + /** + * Postal code of the investor's address + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun pincode(): Optional = pincode.getOptional("pincode") - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } + /** + * Returns the raw JSON value of [address]. + * + * Unlike [address], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("address") @ExcludeMissing fun _address(): JsonField = address - /** An enum containing [Type]'s known values. */ - enum class Known { - PURCHASE, - PURCHASE_SIP, - REDEMPTION, - SWITCH_IN, - SWITCH_IN_MERGER, - SWITCH_OUT, - SWITCH_OUT_MERGER, - DIVIDEND_PAYOUT, - DIVIDEND_REINVEST, - SEGREGATION, - STAMP_DUTY_TAX, - TDS_TAX, - STT_TAX, - MISC, - REVERSAL, - UNKNOWN, - } + /** + * Returns the raw JSON value of [casId]. + * + * Unlike [casId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cas_id") @ExcludeMissing fun _casId(): JsonField = casId - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PURCHASE, - PURCHASE_SIP, - REDEMPTION, - SWITCH_IN, - SWITCH_IN_MERGER, - SWITCH_OUT, - SWITCH_OUT_MERGER, - DIVIDEND_PAYOUT, - DIVIDEND_REINVEST, - SEGREGATION, - STAMP_DUTY_TAX, - TDS_TAX, - STT_TAX, - MISC, - REVERSAL, - UNKNOWN, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PURCHASE -> Value.PURCHASE - PURCHASE_SIP -> Value.PURCHASE_SIP - REDEMPTION -> Value.REDEMPTION - SWITCH_IN -> Value.SWITCH_IN - SWITCH_IN_MERGER -> Value.SWITCH_IN_MERGER - SWITCH_OUT -> Value.SWITCH_OUT - SWITCH_OUT_MERGER -> Value.SWITCH_OUT_MERGER - DIVIDEND_PAYOUT -> Value.DIVIDEND_PAYOUT - DIVIDEND_REINVEST -> Value.DIVIDEND_REINVEST - SEGREGATION -> Value.SEGREGATION - STAMP_DUTY_TAX -> Value.STAMP_DUTY_TAX - TDS_TAX -> Value.TDS_TAX - STT_TAX -> Value.STT_TAX - MISC -> Value.MISC - REVERSAL -> Value.REVERSAL - UNKNOWN -> Value.UNKNOWN - else -> Value._UNKNOWN - } + /** + * Returns the raw JSON value of [mobile]. + * + * Unlike [mobile], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mobile") @ExcludeMissing fun _mobile(): JsonField = mobile - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws CasParserInvalidDataException if this class instance's value is a - * not a known member. - */ - fun known(): Known = - when (this) { - PURCHASE -> Known.PURCHASE - PURCHASE_SIP -> Known.PURCHASE_SIP - REDEMPTION -> Known.REDEMPTION - SWITCH_IN -> Known.SWITCH_IN - SWITCH_IN_MERGER -> Known.SWITCH_IN_MERGER - SWITCH_OUT -> Known.SWITCH_OUT - SWITCH_OUT_MERGER -> Known.SWITCH_OUT_MERGER - DIVIDEND_PAYOUT -> Known.DIVIDEND_PAYOUT - DIVIDEND_REINVEST -> Known.DIVIDEND_REINVEST - SEGREGATION -> Known.SEGREGATION - STAMP_DUTY_TAX -> Known.STAMP_DUTY_TAX - TDS_TAX -> Known.TDS_TAX - STT_TAX -> Known.STT_TAX - MISC -> Known.MISC - REVERSAL -> Known.REVERSAL - UNKNOWN -> Known.UNKNOWN - else -> throw CasParserInvalidDataException("Unknown Type: $value") - } + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws CasParserInvalidDataException if this class instance's value does - * not have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CasParserInvalidDataException("Value is not a String") - } + /** + * Returns the raw JSON value of [pan]. + * + * Unlike [pan], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pan") @ExcludeMissing fun _pan(): JsonField = pan - private var validated: Boolean = false + /** + * Returns the raw JSON value of [pincode]. + * + * Unlike [pincode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pincode") @ExcludeMissing fun _pincode(): JsonField = pincode - fun validate(): Type = apply { - if (validated) { - return@apply - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - known() - validated = true - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } + fun toBuilder() = Builder().from(this) - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + companion object { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** Returns a mutable builder for constructing an instance of [Investor]. */ + @JvmStatic fun builder() = Builder() + } - return other is Type && value == other.value - } + /** A builder for [Investor]. */ + class Builder internal constructor() { - override fun hashCode() = value.hashCode() + private var address: JsonField = JsonMissing.of() + private var casId: JsonField = JsonMissing.of() + private var email: JsonField = JsonMissing.of() + private var mobile: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var pan: JsonField = JsonMissing.of() + private var pincode: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - override fun toString() = value.toString() - } + @JvmSynthetic + internal fun from(investor: Investor) = apply { + address = investor.address + casId = investor.casId + email = investor.email + mobile = investor.mobile + name = investor.name + pan = investor.pan + pincode = investor.pincode + additionalProperties = investor.additionalProperties.toMutableMap() + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** Address of the investor */ + fun address(address: String) = address(JsonField.of(address)) - return other is Transaction && - additionalInfo == other.additionalInfo && - amount == other.amount && - balance == other.balance && - date == other.date && - description == other.description && - dividendRate == other.dividendRate && - nav == other.nav && - type == other.type && - units == other.units && - additionalProperties == other.additionalProperties - } + /** + * Sets [Builder.address] to an arbitrary JSON value. + * + * You should usually call [Builder.address] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun address(address: JsonField) = apply { this.address = address } - private val hashCode: Int by lazy { - Objects.hash( - additionalInfo, - amount, - balance, - date, - description, - dividendRate, - nav, - type, - units, - additionalProperties, - ) - } + /** CAS ID of the investor (only for NSDL and CDSL) */ + fun casId(casId: String) = casId(JsonField.of(casId)) - override fun hashCode(): Int = hashCode + /** + * Sets [Builder.casId] to an arbitrary JSON value. + * + * You should usually call [Builder.casId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun casId(casId: JsonField) = apply { this.casId = casId } - override fun toString() = - "Transaction{additionalInfo=$additionalInfo, amount=$amount, balance=$balance, date=$date, description=$description, dividendRate=$dividendRate, nav=$nav, type=$type, units=$units, additionalProperties=$additionalProperties}" - } + /** Email address of the investor */ + fun email(email: String) = email(JsonField.of(email)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun email(email: JsonField) = apply { this.email = email } - return other is DematMutualFund && - additionalInfo == other.additionalInfo && - isin == other.isin && - name == other.name && - transactions == other.transactions && - units == other.units && - value == other.value && - additionalProperties == other.additionalProperties - } + /** Mobile number of the investor */ + fun mobile(mobile: String) = mobile(JsonField.of(mobile)) - private val hashCode: Int by lazy { - Objects.hash( - additionalInfo, - isin, - name, - transactions, - units, - value, - additionalProperties, - ) - } + /** + * Sets [Builder.mobile] to an arbitrary JSON value. + * + * You should usually call [Builder.mobile] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun mobile(mobile: JsonField) = apply { this.mobile = mobile } - override fun hashCode(): Int = hashCode + /** Name of the investor */ + fun name(name: String) = name(JsonField.of(name)) - override fun toString() = - "DematMutualFund{additionalInfo=$additionalInfo, isin=$isin, name=$name, transactions=$transactions, units=$units, value=$value, additionalProperties=$additionalProperties}" - } + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } - class Equity - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val additionalInfo: JsonField, - private val isin: JsonField, - private val name: JsonField, - private val transactions: JsonField>, - private val units: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { + /** PAN (Permanent Account Number) of the investor */ + fun pan(pan: String) = pan(JsonField.of(pan)) - @JsonCreator - private constructor( - @JsonProperty("additional_info") - @ExcludeMissing - additionalInfo: JsonField = JsonMissing.of(), - @JsonProperty("isin") - @ExcludeMissing - isin: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("transactions") - @ExcludeMissing - transactions: JsonField> = JsonMissing.of(), - @JsonProperty("units") - @ExcludeMissing - units: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - value: JsonField = JsonMissing.of(), - ) : this(additionalInfo, isin, name, transactions, units, value, mutableMapOf()) + /** + * Sets [Builder.pan] to an arbitrary JSON value. + * + * You should usually call [Builder.pan] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun pan(pan: JsonField) = apply { this.pan = pan } - /** - * Additional information specific to the equity - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun additionalInfo(): Optional = - additionalInfo.getOptional("additional_info") - - /** - * ISIN code of the equity - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun isin(): Optional = isin.getOptional("isin") - - /** - * Name of the equity - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * List of transactions for this holding (beta) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun transactions(): Optional> = - transactions.getOptional("transactions") - - /** - * Number of units held - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun units(): Optional = units.getOptional("units") - - /** - * Current market value of the holding - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun value(): Optional = value.getOptional("value") - - /** - * Returns the raw JSON value of [additionalInfo]. - * - * Unlike [additionalInfo], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("additional_info") - @ExcludeMissing - fun _additionalInfo(): JsonField = additionalInfo - - /** - * Returns the raw JSON value of [isin]. - * - * Unlike [isin], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("isin") @ExcludeMissing fun _isin(): JsonField = isin - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [transactions]. - * - * Unlike [transactions], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("transactions") - @ExcludeMissing - fun _transactions(): JsonField> = transactions - - /** - * Returns the raw JSON value of [units]. - * - * Unlike [units], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("units") @ExcludeMissing fun _units(): JsonField = units - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Equity]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Equity]. */ - class Builder internal constructor() { - - private var additionalInfo: JsonField = JsonMissing.of() - private var isin: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var transactions: JsonField>? = null - private var units: JsonField = JsonMissing.of() - private var value: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(equity: Equity) = apply { - additionalInfo = equity.additionalInfo - isin = equity.isin - name = equity.name - transactions = equity.transactions.map { it.toMutableList() } - units = equity.units - value = equity.value - additionalProperties = equity.additionalProperties.toMutableMap() - } - - /** Additional information specific to the equity */ - fun additionalInfo(additionalInfo: AdditionalInfo) = - additionalInfo(JsonField.of(additionalInfo)) - - /** - * Sets [Builder.additionalInfo] to an arbitrary JSON value. - * - * You should usually call [Builder.additionalInfo] with a well-typed - * [AdditionalInfo] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun additionalInfo(additionalInfo: JsonField) = apply { - this.additionalInfo = additionalInfo - } - - /** ISIN code of the equity */ - fun isin(isin: String) = isin(JsonField.of(isin)) - - /** - * Sets [Builder.isin] to an arbitrary JSON value. - * - * You should usually call [Builder.isin] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun isin(isin: JsonField) = apply { this.isin = isin } - - /** Name of the equity */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** List of transactions for this holding (beta) */ - fun transactions(transactions: List) = - transactions(JsonField.of(transactions)) - - /** - * Sets [Builder.transactions] to an arbitrary JSON value. - * - * You should usually call [Builder.transactions] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun transactions(transactions: JsonField>) = apply { - this.transactions = transactions.map { it.toMutableList() } - } - - /** - * Adds a single [Transaction] to [transactions]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTransaction(transaction: Transaction) = apply { - transactions = - (transactions ?: JsonField.of(mutableListOf())).also { - checkKnown("transactions", it).add(transaction) - } - } - - /** Number of units held */ - fun units(units: Float) = units(JsonField.of(units)) - - /** - * Sets [Builder.units] to an arbitrary JSON value. - * - * You should usually call [Builder.units] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun units(units: JsonField) = apply { this.units = units } - - /** Current market value of the holding */ - fun value(value: Float) = value(JsonField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun value(value: JsonField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Equity]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Equity = - Equity( - additionalInfo, - isin, - name, - (transactions ?: JsonMissing.of()).map { it.toImmutable() }, - units, - value, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Equity = apply { - if (validated) { - return@apply - } - - additionalInfo().ifPresent { it.validate() } - isin() - name() - transactions().ifPresent { it.forEach { it.validate() } } - units() - value() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (additionalInfo.asKnown().getOrNull()?.validity() ?: 0) + - (if (isin.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (transactions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (units.asKnown().isPresent) 1 else 0) + - (if (value.asKnown().isPresent) 1 else 0) - - /** Additional information specific to the equity */ - class AdditionalInfo - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val closeUnits: JsonField, - private val openUnits: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("close_units") - @ExcludeMissing - closeUnits: JsonField = JsonMissing.of(), - @JsonProperty("open_units") - @ExcludeMissing - openUnits: JsonField = JsonMissing.of(), - ) : this(closeUnits, openUnits, mutableMapOf()) - - /** - * Closing balance units for the statement period (beta) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun closeUnits(): Optional = closeUnits.getOptional("close_units") - - /** - * Opening balance units for the statement period (beta) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun openUnits(): Optional = openUnits.getOptional("open_units") - - /** - * Returns the raw JSON value of [closeUnits]. - * - * Unlike [closeUnits], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("close_units") - @ExcludeMissing - fun _closeUnits(): JsonField = closeUnits - - /** - * Returns the raw JSON value of [openUnits]. - * - * Unlike [openUnits], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("open_units") - @ExcludeMissing - fun _openUnits(): JsonField = openUnits - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [AdditionalInfo]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AdditionalInfo]. */ - class Builder internal constructor() { - - private var closeUnits: JsonField = JsonMissing.of() - private var openUnits: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(additionalInfo: AdditionalInfo) = apply { - closeUnits = additionalInfo.closeUnits - openUnits = additionalInfo.openUnits - additionalProperties = - additionalInfo.additionalProperties.toMutableMap() - } - - /** Closing balance units for the statement period (beta) */ - fun closeUnits(closeUnits: Float?) = - closeUnits(JsonField.ofNullable(closeUnits)) - - /** - * Alias for [Builder.closeUnits]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun closeUnits(closeUnits: Float) = closeUnits(closeUnits as Float?) - - /** - * Alias for calling [Builder.closeUnits] with `closeUnits.orElse(null)`. - */ - fun closeUnits(closeUnits: Optional) = - closeUnits(closeUnits.getOrNull()) - - /** - * Sets [Builder.closeUnits] to an arbitrary JSON value. - * - * You should usually call [Builder.closeUnits] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun closeUnits(closeUnits: JsonField) = apply { - this.closeUnits = closeUnits - } - - /** Opening balance units for the statement period (beta) */ - fun openUnits(openUnits: Float?) = - openUnits(JsonField.ofNullable(openUnits)) - - /** - * Alias for [Builder.openUnits]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun openUnits(openUnits: Float) = openUnits(openUnits as Float?) - - /** Alias for calling [Builder.openUnits] with `openUnits.orElse(null)`. */ - fun openUnits(openUnits: Optional) = openUnits(openUnits.getOrNull()) - - /** - * Sets [Builder.openUnits] to an arbitrary JSON value. - * - * You should usually call [Builder.openUnits] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun openUnits(openUnits: JsonField) = apply { - this.openUnits = openUnits - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AdditionalInfo]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AdditionalInfo = - AdditionalInfo( - closeUnits, - openUnits, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AdditionalInfo = apply { - if (validated) { - return@apply - } - - closeUnits() - openUnits() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (closeUnits.asKnown().isPresent) 1 else 0) + - (if (openUnits.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AdditionalInfo && - closeUnits == other.closeUnits && - openUnits == other.openUnits && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(closeUnits, openUnits, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AdditionalInfo{closeUnits=$closeUnits, openUnits=$openUnits, additionalProperties=$additionalProperties}" - } - - /** - * Unified transaction schema for all holding types (MF folios, equities, bonds, - * etc.) - */ - class Transaction - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val additionalInfo: JsonField, - private val amount: JsonField, - private val balance: JsonField, - private val date: JsonField, - private val description: JsonField, - private val dividendRate: JsonField, - private val nav: JsonField, - private val type: JsonField, - private val units: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("additional_info") - @ExcludeMissing - additionalInfo: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("balance") - @ExcludeMissing - balance: JsonField = JsonMissing.of(), - @JsonProperty("date") - @ExcludeMissing - date: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("dividend_rate") - @ExcludeMissing - dividendRate: JsonField = JsonMissing.of(), - @JsonProperty("nav") - @ExcludeMissing - nav: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonField = JsonMissing.of(), - @JsonProperty("units") - @ExcludeMissing - units: JsonField = JsonMissing.of(), - ) : this( - additionalInfo, - amount, - balance, - date, - description, - dividendRate, - nav, - type, - units, - mutableMapOf(), - ) - - /** - * Additional transaction-specific fields that vary by source - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun additionalInfo(): Optional = - additionalInfo.getOptional("additional_info") - - /** - * Transaction amount in currency (computed from units × price/NAV) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * Balance units after transaction - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun balance(): Optional = balance.getOptional("balance") - - /** - * Transaction date (YYYY-MM-DD) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun date(): Optional = date.getOptional("date") - - /** - * Transaction description/particulars - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") - - /** - * Dividend rate (for DIVIDEND_PAYOUT transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun dividendRate(): Optional = dividendRate.getOptional("dividend_rate") - - /** - * NAV/price per unit on transaction date - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun nav(): Optional = nav.getOptional("nav") - - /** - * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, - * SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, - * DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, - * REVERSAL, UNKNOWN. - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Number of units involved in transaction - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun units(): Optional = units.getOptional("units") - - /** - * Returns the raw JSON value of [additionalInfo]. - * - * Unlike [additionalInfo], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("additional_info") - @ExcludeMissing - fun _additionalInfo(): JsonField = additionalInfo - - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** - * Returns the raw JSON value of [balance]. - * - * Unlike [balance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("balance") - @ExcludeMissing - fun _balance(): JsonField = balance - - /** - * Returns the raw JSON value of [date]. - * - * Unlike [date], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("date") @ExcludeMissing fun _date(): JsonField = date - - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - /** - * Returns the raw JSON value of [dividendRate]. - * - * Unlike [dividendRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("dividend_rate") - @ExcludeMissing - fun _dividendRate(): JsonField = dividendRate - - /** - * Returns the raw JSON value of [nav]. - * - * Unlike [nav], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("nav") @ExcludeMissing fun _nav(): JsonField = nav - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [units]. - * - * Unlike [units], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("units") @ExcludeMissing fun _units(): JsonField = units - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Transaction]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Transaction]. */ - class Builder internal constructor() { - - private var additionalInfo: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var balance: JsonField = JsonMissing.of() - private var date: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var dividendRate: JsonField = JsonMissing.of() - private var nav: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var units: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(transaction: Transaction) = apply { - additionalInfo = transaction.additionalInfo - amount = transaction.amount - balance = transaction.balance - date = transaction.date - description = transaction.description - dividendRate = transaction.dividendRate - nav = transaction.nav - type = transaction.type - units = transaction.units - additionalProperties = transaction.additionalProperties.toMutableMap() - } - - /** Additional transaction-specific fields that vary by source */ - fun additionalInfo(additionalInfo: AdditionalInfo) = - additionalInfo(JsonField.of(additionalInfo)) - - /** - * Sets [Builder.additionalInfo] to an arbitrary JSON value. - * - * You should usually call [Builder.additionalInfo] with a well-typed - * [AdditionalInfo] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun additionalInfo(additionalInfo: JsonField) = apply { - this.additionalInfo = additionalInfo - } - - /** Transaction amount in currency (computed from units × price/NAV) */ - fun amount(amount: Float?) = amount(JsonField.ofNullable(amount)) - - /** - * Alias for [Builder.amount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun amount(amount: Float) = amount(amount as Float?) - - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) - - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** Balance units after transaction */ - fun balance(balance: Float) = balance(JsonField.of(balance)) - - /** - * Sets [Builder.balance] to an arbitrary JSON value. - * - * You should usually call [Builder.balance] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun balance(balance: JsonField) = apply { this.balance = balance } - - /** Transaction date (YYYY-MM-DD) */ - fun date(date: LocalDate) = date(JsonField.of(date)) - - /** - * Sets [Builder.date] to an arbitrary JSON value. - * - * You should usually call [Builder.date] with a well-typed [LocalDate] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun date(date: JsonField) = apply { this.date = date } - - /** Transaction description/particulars */ - fun description(description: String) = - description(JsonField.of(description)) - - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun description(description: JsonField) = apply { - this.description = description - } - - /** Dividend rate (for DIVIDEND_PAYOUT transactions) */ - fun dividendRate(dividendRate: Float?) = - dividendRate(JsonField.ofNullable(dividendRate)) - - /** - * Alias for [Builder.dividendRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun dividendRate(dividendRate: Float) = dividendRate(dividendRate as Float?) - - /** - * Alias for calling [Builder.dividendRate] with - * `dividendRate.orElse(null)`. - */ - fun dividendRate(dividendRate: Optional) = - dividendRate(dividendRate.getOrNull()) - - /** - * Sets [Builder.dividendRate] to an arbitrary JSON value. - * - * You should usually call [Builder.dividendRate] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun dividendRate(dividendRate: JsonField) = apply { - this.dividendRate = dividendRate - } - - /** NAV/price per unit on transaction date */ - fun nav(nav: Float?) = nav(JsonField.ofNullable(nav)) - - /** - * Alias for [Builder.nav]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun nav(nav: Float) = nav(nav as Float?) - - /** Alias for calling [Builder.nav] with `nav.orElse(null)`. */ - fun nav(nav: Optional) = nav(nav.getOrNull()) - - /** - * Sets [Builder.nav] to an arbitrary JSON value. - * - * You should usually call [Builder.nav] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun nav(nav: JsonField) = apply { this.nav = nav } - - /** - * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, - * SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, - * DIVIDEND_PAYOUT, DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, - * STT_TAX, MISC, REVERSAL, UNKNOWN. - */ - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - /** Number of units involved in transaction */ - fun units(units: Float) = units(JsonField.of(units)) - - /** - * Sets [Builder.units] to an arbitrary JSON value. - * - * You should usually call [Builder.units] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun units(units: JsonField) = apply { this.units = units } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Transaction]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Transaction = - Transaction( - additionalInfo, - amount, - balance, - date, - description, - dividendRate, - nav, - type, - units, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Transaction = apply { - if (validated) { - return@apply - } - - additionalInfo().ifPresent { it.validate() } - amount() - balance() - date() - description() - dividendRate() - nav() - type().ifPresent { it.validate() } - units() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (additionalInfo.asKnown().getOrNull()?.validity() ?: 0) + - (if (amount.asKnown().isPresent) 1 else 0) + - (if (balance.asKnown().isPresent) 1 else 0) + - (if (date.asKnown().isPresent) 1 else 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (if (dividendRate.asKnown().isPresent) 1 else 0) + - (if (nav.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (units.asKnown().isPresent) 1 else 0) - - /** Additional transaction-specific fields that vary by source */ - class AdditionalInfo - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val capitalWithdrawal: JsonField, - private val credit: JsonField, - private val debit: JsonField, - private val incomeDistribution: JsonField, - private val orderNo: JsonField, - private val price: JsonField, - private val stampDuty: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("capital_withdrawal") - @ExcludeMissing - capitalWithdrawal: JsonField = JsonMissing.of(), - @JsonProperty("credit") - @ExcludeMissing - credit: JsonField = JsonMissing.of(), - @JsonProperty("debit") - @ExcludeMissing - debit: JsonField = JsonMissing.of(), - @JsonProperty("income_distribution") - @ExcludeMissing - incomeDistribution: JsonField = JsonMissing.of(), - @JsonProperty("order_no") - @ExcludeMissing - orderNo: JsonField = JsonMissing.of(), - @JsonProperty("price") - @ExcludeMissing - price: JsonField = JsonMissing.of(), - @JsonProperty("stamp_duty") - @ExcludeMissing - stampDuty: JsonField = JsonMissing.of(), - ) : this( - capitalWithdrawal, - credit, - debit, - incomeDistribution, - orderNo, - price, - stampDuty, - mutableMapOf(), - ) - - /** - * Capital withdrawal amount (CDSL MF transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun capitalWithdrawal(): Optional = - capitalWithdrawal.getOptional("capital_withdrawal") - - /** - * Units credited (demat transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun credit(): Optional = credit.getOptional("credit") - - /** - * Units debited (demat transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun debit(): Optional = debit.getOptional("debit") - - /** - * Income distribution amount (CDSL MF transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun incomeDistribution(): Optional = - incomeDistribution.getOptional("income_distribution") - - /** - * Order/transaction reference number (demat transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun orderNo(): Optional = orderNo.getOptional("order_no") - - /** - * Price per unit (NSDL/CDSL MF transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun price(): Optional = price.getOptional("price") - - /** - * Stamp duty charged - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun stampDuty(): Optional = stampDuty.getOptional("stamp_duty") - - /** - * Returns the raw JSON value of [capitalWithdrawal]. - * - * Unlike [capitalWithdrawal], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("capital_withdrawal") - @ExcludeMissing - fun _capitalWithdrawal(): JsonField = capitalWithdrawal - - /** - * Returns the raw JSON value of [credit]. - * - * Unlike [credit], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("credit") - @ExcludeMissing - fun _credit(): JsonField = credit - - /** - * Returns the raw JSON value of [debit]. - * - * Unlike [debit], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("debit") - @ExcludeMissing - fun _debit(): JsonField = debit - - /** - * Returns the raw JSON value of [incomeDistribution]. - * - * Unlike [incomeDistribution], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("income_distribution") - @ExcludeMissing - fun _incomeDistribution(): JsonField = incomeDistribution - - /** - * Returns the raw JSON value of [orderNo]. - * - * Unlike [orderNo], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("order_no") - @ExcludeMissing - fun _orderNo(): JsonField = orderNo - - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("price") - @ExcludeMissing - fun _price(): JsonField = price - - /** - * Returns the raw JSON value of [stampDuty]. - * - * Unlike [stampDuty], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("stamp_duty") - @ExcludeMissing - fun _stampDuty(): JsonField = stampDuty - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [AdditionalInfo]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AdditionalInfo]. */ - class Builder internal constructor() { - - private var capitalWithdrawal: JsonField = JsonMissing.of() - private var credit: JsonField = JsonMissing.of() - private var debit: JsonField = JsonMissing.of() - private var incomeDistribution: JsonField = JsonMissing.of() - private var orderNo: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var stampDuty: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(additionalInfo: AdditionalInfo) = apply { - capitalWithdrawal = additionalInfo.capitalWithdrawal - credit = additionalInfo.credit - debit = additionalInfo.debit - incomeDistribution = additionalInfo.incomeDistribution - orderNo = additionalInfo.orderNo - price = additionalInfo.price - stampDuty = additionalInfo.stampDuty - additionalProperties = - additionalInfo.additionalProperties.toMutableMap() - } - - /** Capital withdrawal amount (CDSL MF transactions) */ - fun capitalWithdrawal(capitalWithdrawal: Float) = - capitalWithdrawal(JsonField.of(capitalWithdrawal)) - - /** - * Sets [Builder.capitalWithdrawal] to an arbitrary JSON value. - * - * You should usually call [Builder.capitalWithdrawal] with a well-typed - * [Float] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun capitalWithdrawal(capitalWithdrawal: JsonField) = apply { - this.capitalWithdrawal = capitalWithdrawal - } - - /** Units credited (demat transactions) */ - fun credit(credit: Float) = credit(JsonField.of(credit)) - - /** - * Sets [Builder.credit] to an arbitrary JSON value. - * - * You should usually call [Builder.credit] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun credit(credit: JsonField) = apply { this.credit = credit } - - /** Units debited (demat transactions) */ - fun debit(debit: Float) = debit(JsonField.of(debit)) - - /** - * Sets [Builder.debit] to an arbitrary JSON value. - * - * You should usually call [Builder.debit] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun debit(debit: JsonField) = apply { this.debit = debit } - - /** Income distribution amount (CDSL MF transactions) */ - fun incomeDistribution(incomeDistribution: Float) = - incomeDistribution(JsonField.of(incomeDistribution)) - - /** - * Sets [Builder.incomeDistribution] to an arbitrary JSON value. - * - * You should usually call [Builder.incomeDistribution] with a - * well-typed [Float] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun incomeDistribution(incomeDistribution: JsonField) = apply { - this.incomeDistribution = incomeDistribution - } - - /** Order/transaction reference number (demat transactions) */ - fun orderNo(orderNo: String) = orderNo(JsonField.of(orderNo)) - - /** - * Sets [Builder.orderNo] to an arbitrary JSON value. - * - * You should usually call [Builder.orderNo] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun orderNo(orderNo: JsonField) = apply { - this.orderNo = orderNo - } - - /** Price per unit (NSDL/CDSL MF transactions) */ - fun price(price: Float) = price(JsonField.of(price)) - - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun price(price: JsonField) = apply { this.price = price } - - /** Stamp duty charged */ - fun stampDuty(stampDuty: Float) = stampDuty(JsonField.of(stampDuty)) - - /** - * Sets [Builder.stampDuty] to an arbitrary JSON value. - * - * You should usually call [Builder.stampDuty] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun stampDuty(stampDuty: JsonField) = apply { - this.stampDuty = stampDuty - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AdditionalInfo]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): AdditionalInfo = - AdditionalInfo( - capitalWithdrawal, - credit, - debit, - incomeDistribution, - orderNo, - price, - stampDuty, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AdditionalInfo = apply { - if (validated) { - return@apply - } - - capitalWithdrawal() - credit() - debit() - incomeDistribution() - orderNo() - price() - stampDuty() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (capitalWithdrawal.asKnown().isPresent) 1 else 0) + - (if (credit.asKnown().isPresent) 1 else 0) + - (if (debit.asKnown().isPresent) 1 else 0) + - (if (incomeDistribution.asKnown().isPresent) 1 else 0) + - (if (orderNo.asKnown().isPresent) 1 else 0) + - (if (price.asKnown().isPresent) 1 else 0) + - (if (stampDuty.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AdditionalInfo && - capitalWithdrawal == other.capitalWithdrawal && - credit == other.credit && - debit == other.debit && - incomeDistribution == other.incomeDistribution && - orderNo == other.orderNo && - price == other.price && - stampDuty == other.stampDuty && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - capitalWithdrawal, - credit, - debit, - incomeDistribution, - orderNo, - price, - stampDuty, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AdditionalInfo{capitalWithdrawal=$capitalWithdrawal, credit=$credit, debit=$debit, incomeDistribution=$incomeDistribution, orderNo=$orderNo, price=$price, stampDuty=$stampDuty, additionalProperties=$additionalProperties}" - } - - /** - * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, - * SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, - * DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, - * REVERSAL, UNKNOWN. - */ - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PURCHASE = of("PURCHASE") - - @JvmField val PURCHASE_SIP = of("PURCHASE_SIP") - - @JvmField val REDEMPTION = of("REDEMPTION") - - @JvmField val SWITCH_IN = of("SWITCH_IN") - - @JvmField val SWITCH_IN_MERGER = of("SWITCH_IN_MERGER") - - @JvmField val SWITCH_OUT = of("SWITCH_OUT") - - @JvmField val SWITCH_OUT_MERGER = of("SWITCH_OUT_MERGER") - - @JvmField val DIVIDEND_PAYOUT = of("DIVIDEND_PAYOUT") - - @JvmField val DIVIDEND_REINVEST = of("DIVIDEND_REINVEST") - - @JvmField val SEGREGATION = of("SEGREGATION") - - @JvmField val STAMP_DUTY_TAX = of("STAMP_DUTY_TAX") - - @JvmField val TDS_TAX = of("TDS_TAX") - - @JvmField val STT_TAX = of("STT_TAX") - - @JvmField val MISC = of("MISC") - - @JvmField val REVERSAL = of("REVERSAL") - - @JvmField val UNKNOWN = of("UNKNOWN") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - PURCHASE, - PURCHASE_SIP, - REDEMPTION, - SWITCH_IN, - SWITCH_IN_MERGER, - SWITCH_OUT, - SWITCH_OUT_MERGER, - DIVIDEND_PAYOUT, - DIVIDEND_REINVEST, - SEGREGATION, - STAMP_DUTY_TAX, - TDS_TAX, - STT_TAX, - MISC, - REVERSAL, - UNKNOWN, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PURCHASE, - PURCHASE_SIP, - REDEMPTION, - SWITCH_IN, - SWITCH_IN_MERGER, - SWITCH_OUT, - SWITCH_OUT_MERGER, - DIVIDEND_PAYOUT, - DIVIDEND_REINVEST, - SEGREGATION, - STAMP_DUTY_TAX, - TDS_TAX, - STT_TAX, - MISC, - REVERSAL, - UNKNOWN, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PURCHASE -> Value.PURCHASE - PURCHASE_SIP -> Value.PURCHASE_SIP - REDEMPTION -> Value.REDEMPTION - SWITCH_IN -> Value.SWITCH_IN - SWITCH_IN_MERGER -> Value.SWITCH_IN_MERGER - SWITCH_OUT -> Value.SWITCH_OUT - SWITCH_OUT_MERGER -> Value.SWITCH_OUT_MERGER - DIVIDEND_PAYOUT -> Value.DIVIDEND_PAYOUT - DIVIDEND_REINVEST -> Value.DIVIDEND_REINVEST - SEGREGATION -> Value.SEGREGATION - STAMP_DUTY_TAX -> Value.STAMP_DUTY_TAX - TDS_TAX -> Value.TDS_TAX - STT_TAX -> Value.STT_TAX - MISC -> Value.MISC - REVERSAL -> Value.REVERSAL - UNKNOWN -> Value.UNKNOWN - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws CasParserInvalidDataException if this class instance's value is a - * not a known member. - */ - fun known(): Known = - when (this) { - PURCHASE -> Known.PURCHASE - PURCHASE_SIP -> Known.PURCHASE_SIP - REDEMPTION -> Known.REDEMPTION - SWITCH_IN -> Known.SWITCH_IN - SWITCH_IN_MERGER -> Known.SWITCH_IN_MERGER - SWITCH_OUT -> Known.SWITCH_OUT - SWITCH_OUT_MERGER -> Known.SWITCH_OUT_MERGER - DIVIDEND_PAYOUT -> Known.DIVIDEND_PAYOUT - DIVIDEND_REINVEST -> Known.DIVIDEND_REINVEST - SEGREGATION -> Known.SEGREGATION - STAMP_DUTY_TAX -> Known.STAMP_DUTY_TAX - TDS_TAX -> Known.TDS_TAX - STT_TAX -> Known.STT_TAX - MISC -> Known.MISC - REVERSAL -> Known.REVERSAL - UNKNOWN -> Known.UNKNOWN - else -> throw CasParserInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws CasParserInvalidDataException if this class instance's value does - * not have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CasParserInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Transaction && - additionalInfo == other.additionalInfo && - amount == other.amount && - balance == other.balance && - date == other.date && - description == other.description && - dividendRate == other.dividendRate && - nav == other.nav && - type == other.type && - units == other.units && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - additionalInfo, - amount, - balance, - date, - description, - dividendRate, - nav, - type, - units, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Transaction{additionalInfo=$additionalInfo, amount=$amount, balance=$balance, date=$date, description=$description, dividendRate=$dividendRate, nav=$nav, type=$type, units=$units, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Equity && - additionalInfo == other.additionalInfo && - isin == other.isin && - name == other.name && - transactions == other.transactions && - units == other.units && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - additionalInfo, - isin, - name, - transactions, - units, - value, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Equity{additionalInfo=$additionalInfo, isin=$isin, name=$name, transactions=$transactions, units=$units, value=$value, additionalProperties=$additionalProperties}" - } - - class GovernmentSecurity - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val additionalInfo: JsonField, - private val isin: JsonField, - private val name: JsonField, - private val transactions: JsonField>, - private val units: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("additional_info") - @ExcludeMissing - additionalInfo: JsonField = JsonMissing.of(), - @JsonProperty("isin") - @ExcludeMissing - isin: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("transactions") - @ExcludeMissing - transactions: JsonField> = JsonMissing.of(), - @JsonProperty("units") - @ExcludeMissing - units: JsonField = JsonMissing.of(), - @JsonProperty("value") - @ExcludeMissing - value: JsonField = JsonMissing.of(), - ) : this(additionalInfo, isin, name, transactions, units, value, mutableMapOf()) - - /** - * Additional information specific to the government security - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun additionalInfo(): Optional = - additionalInfo.getOptional("additional_info") - - /** - * ISIN code of the government security - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun isin(): Optional = isin.getOptional("isin") - - /** - * Name of the government security - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * List of transactions for this holding (beta) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun transactions(): Optional> = - transactions.getOptional("transactions") - - /** - * Number of units held - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun units(): Optional = units.getOptional("units") - - /** - * Current market value of the holding - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun value(): Optional = value.getOptional("value") - - /** - * Returns the raw JSON value of [additionalInfo]. - * - * Unlike [additionalInfo], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("additional_info") - @ExcludeMissing - fun _additionalInfo(): JsonField = additionalInfo - - /** - * Returns the raw JSON value of [isin]. - * - * Unlike [isin], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("isin") @ExcludeMissing fun _isin(): JsonField = isin - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [transactions]. - * - * Unlike [transactions], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("transactions") - @ExcludeMissing - fun _transactions(): JsonField> = transactions - - /** - * Returns the raw JSON value of [units]. - * - * Unlike [units], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("units") @ExcludeMissing fun _units(): JsonField = units - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [GovernmentSecurity]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [GovernmentSecurity]. */ - class Builder internal constructor() { - - private var additionalInfo: JsonField = JsonMissing.of() - private var isin: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var transactions: JsonField>? = null - private var units: JsonField = JsonMissing.of() - private var value: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(governmentSecurity: GovernmentSecurity) = apply { - additionalInfo = governmentSecurity.additionalInfo - isin = governmentSecurity.isin - name = governmentSecurity.name - transactions = governmentSecurity.transactions.map { it.toMutableList() } - units = governmentSecurity.units - value = governmentSecurity.value - additionalProperties = - governmentSecurity.additionalProperties.toMutableMap() - } - - /** Additional information specific to the government security */ - fun additionalInfo(additionalInfo: AdditionalInfo) = - additionalInfo(JsonField.of(additionalInfo)) - - /** - * Sets [Builder.additionalInfo] to an arbitrary JSON value. - * - * You should usually call [Builder.additionalInfo] with a well-typed - * [AdditionalInfo] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun additionalInfo(additionalInfo: JsonField) = apply { - this.additionalInfo = additionalInfo - } - - /** ISIN code of the government security */ - fun isin(isin: String) = isin(JsonField.of(isin)) - - /** - * Sets [Builder.isin] to an arbitrary JSON value. - * - * You should usually call [Builder.isin] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun isin(isin: JsonField) = apply { this.isin = isin } - - /** Name of the government security */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** List of transactions for this holding (beta) */ - fun transactions(transactions: List) = - transactions(JsonField.of(transactions)) - - /** - * Sets [Builder.transactions] to an arbitrary JSON value. - * - * You should usually call [Builder.transactions] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun transactions(transactions: JsonField>) = apply { - this.transactions = transactions.map { it.toMutableList() } - } - - /** - * Adds a single [Transaction] to [transactions]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTransaction(transaction: Transaction) = apply { - transactions = - (transactions ?: JsonField.of(mutableListOf())).also { - checkKnown("transactions", it).add(transaction) - } - } - - /** Number of units held */ - fun units(units: Float) = units(JsonField.of(units)) - - /** - * Sets [Builder.units] to an arbitrary JSON value. - * - * You should usually call [Builder.units] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun units(units: JsonField) = apply { this.units = units } - - /** Current market value of the holding */ - fun value(value: Float) = value(JsonField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun value(value: JsonField) = apply { this.value = value } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [GovernmentSecurity]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): GovernmentSecurity = - GovernmentSecurity( - additionalInfo, - isin, - name, - (transactions ?: JsonMissing.of()).map { it.toImmutable() }, - units, - value, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): GovernmentSecurity = apply { - if (validated) { - return@apply - } - - additionalInfo().ifPresent { it.validate() } - isin() - name() - transactions().ifPresent { it.forEach { it.validate() } } - units() - value() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (additionalInfo.asKnown().getOrNull()?.validity() ?: 0) + - (if (isin.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (transactions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (units.asKnown().isPresent) 1 else 0) + - (if (value.asKnown().isPresent) 1 else 0) - - /** Additional information specific to the government security */ - class AdditionalInfo - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val closeUnits: JsonField, - private val openUnits: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("close_units") - @ExcludeMissing - closeUnits: JsonField = JsonMissing.of(), - @JsonProperty("open_units") - @ExcludeMissing - openUnits: JsonField = JsonMissing.of(), - ) : this(closeUnits, openUnits, mutableMapOf()) - - /** - * Closing balance units for the statement period (beta) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun closeUnits(): Optional = closeUnits.getOptional("close_units") - - /** - * Opening balance units for the statement period (beta) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun openUnits(): Optional = openUnits.getOptional("open_units") - - /** - * Returns the raw JSON value of [closeUnits]. - * - * Unlike [closeUnits], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("close_units") - @ExcludeMissing - fun _closeUnits(): JsonField = closeUnits - - /** - * Returns the raw JSON value of [openUnits]. - * - * Unlike [openUnits], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("open_units") - @ExcludeMissing - fun _openUnits(): JsonField = openUnits - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [AdditionalInfo]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AdditionalInfo]. */ - class Builder internal constructor() { - - private var closeUnits: JsonField = JsonMissing.of() - private var openUnits: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(additionalInfo: AdditionalInfo) = apply { - closeUnits = additionalInfo.closeUnits - openUnits = additionalInfo.openUnits - additionalProperties = - additionalInfo.additionalProperties.toMutableMap() - } - - /** Closing balance units for the statement period (beta) */ - fun closeUnits(closeUnits: Float?) = - closeUnits(JsonField.ofNullable(closeUnits)) - - /** - * Alias for [Builder.closeUnits]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun closeUnits(closeUnits: Float) = closeUnits(closeUnits as Float?) - - /** - * Alias for calling [Builder.closeUnits] with `closeUnits.orElse(null)`. - */ - fun closeUnits(closeUnits: Optional) = - closeUnits(closeUnits.getOrNull()) - - /** - * Sets [Builder.closeUnits] to an arbitrary JSON value. - * - * You should usually call [Builder.closeUnits] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun closeUnits(closeUnits: JsonField) = apply { - this.closeUnits = closeUnits - } - - /** Opening balance units for the statement period (beta) */ - fun openUnits(openUnits: Float?) = - openUnits(JsonField.ofNullable(openUnits)) - - /** - * Alias for [Builder.openUnits]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun openUnits(openUnits: Float) = openUnits(openUnits as Float?) - - /** Alias for calling [Builder.openUnits] with `openUnits.orElse(null)`. */ - fun openUnits(openUnits: Optional) = openUnits(openUnits.getOrNull()) - - /** - * Sets [Builder.openUnits] to an arbitrary JSON value. - * - * You should usually call [Builder.openUnits] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun openUnits(openUnits: JsonField) = apply { - this.openUnits = openUnits - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AdditionalInfo]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AdditionalInfo = - AdditionalInfo( - closeUnits, - openUnits, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AdditionalInfo = apply { - if (validated) { - return@apply - } - - closeUnits() - openUnits() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (closeUnits.asKnown().isPresent) 1 else 0) + - (if (openUnits.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AdditionalInfo && - closeUnits == other.closeUnits && - openUnits == other.openUnits && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(closeUnits, openUnits, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AdditionalInfo{closeUnits=$closeUnits, openUnits=$openUnits, additionalProperties=$additionalProperties}" - } - - /** - * Unified transaction schema for all holding types (MF folios, equities, bonds, - * etc.) - */ - class Transaction - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val additionalInfo: JsonField, - private val amount: JsonField, - private val balance: JsonField, - private val date: JsonField, - private val description: JsonField, - private val dividendRate: JsonField, - private val nav: JsonField, - private val type: JsonField, - private val units: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("additional_info") - @ExcludeMissing - additionalInfo: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("balance") - @ExcludeMissing - balance: JsonField = JsonMissing.of(), - @JsonProperty("date") - @ExcludeMissing - date: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("dividend_rate") - @ExcludeMissing - dividendRate: JsonField = JsonMissing.of(), - @JsonProperty("nav") - @ExcludeMissing - nav: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonField = JsonMissing.of(), - @JsonProperty("units") - @ExcludeMissing - units: JsonField = JsonMissing.of(), - ) : this( - additionalInfo, - amount, - balance, - date, - description, - dividendRate, - nav, - type, - units, - mutableMapOf(), - ) - - /** - * Additional transaction-specific fields that vary by source - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun additionalInfo(): Optional = - additionalInfo.getOptional("additional_info") - - /** - * Transaction amount in currency (computed from units × price/NAV) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * Balance units after transaction - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun balance(): Optional = balance.getOptional("balance") - - /** - * Transaction date (YYYY-MM-DD) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun date(): Optional = date.getOptional("date") - - /** - * Transaction description/particulars - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") - - /** - * Dividend rate (for DIVIDEND_PAYOUT transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun dividendRate(): Optional = dividendRate.getOptional("dividend_rate") - - /** - * NAV/price per unit on transaction date - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun nav(): Optional = nav.getOptional("nav") - - /** - * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, - * SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, - * DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, - * REVERSAL, UNKNOWN. - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Number of units involved in transaction - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun units(): Optional = units.getOptional("units") - - /** - * Returns the raw JSON value of [additionalInfo]. - * - * Unlike [additionalInfo], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("additional_info") - @ExcludeMissing - fun _additionalInfo(): JsonField = additionalInfo - - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** - * Returns the raw JSON value of [balance]. - * - * Unlike [balance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("balance") - @ExcludeMissing - fun _balance(): JsonField = balance - - /** - * Returns the raw JSON value of [date]. - * - * Unlike [date], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("date") @ExcludeMissing fun _date(): JsonField = date - - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - /** - * Returns the raw JSON value of [dividendRate]. - * - * Unlike [dividendRate], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("dividend_rate") - @ExcludeMissing - fun _dividendRate(): JsonField = dividendRate - - /** - * Returns the raw JSON value of [nav]. - * - * Unlike [nav], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("nav") @ExcludeMissing fun _nav(): JsonField = nav - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [units]. - * - * Unlike [units], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("units") @ExcludeMissing fun _units(): JsonField = units - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Transaction]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Transaction]. */ - class Builder internal constructor() { - - private var additionalInfo: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var balance: JsonField = JsonMissing.of() - private var date: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var dividendRate: JsonField = JsonMissing.of() - private var nav: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var units: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(transaction: Transaction) = apply { - additionalInfo = transaction.additionalInfo - amount = transaction.amount - balance = transaction.balance - date = transaction.date - description = transaction.description - dividendRate = transaction.dividendRate - nav = transaction.nav - type = transaction.type - units = transaction.units - additionalProperties = transaction.additionalProperties.toMutableMap() - } - - /** Additional transaction-specific fields that vary by source */ - fun additionalInfo(additionalInfo: AdditionalInfo) = - additionalInfo(JsonField.of(additionalInfo)) - - /** - * Sets [Builder.additionalInfo] to an arbitrary JSON value. - * - * You should usually call [Builder.additionalInfo] with a well-typed - * [AdditionalInfo] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun additionalInfo(additionalInfo: JsonField) = apply { - this.additionalInfo = additionalInfo - } - - /** Transaction amount in currency (computed from units × price/NAV) */ - fun amount(amount: Float?) = amount(JsonField.ofNullable(amount)) - - /** - * Alias for [Builder.amount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun amount(amount: Float) = amount(amount as Float?) - - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) - - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** Balance units after transaction */ - fun balance(balance: Float) = balance(JsonField.of(balance)) - - /** - * Sets [Builder.balance] to an arbitrary JSON value. - * - * You should usually call [Builder.balance] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun balance(balance: JsonField) = apply { this.balance = balance } - - /** Transaction date (YYYY-MM-DD) */ - fun date(date: LocalDate) = date(JsonField.of(date)) - - /** - * Sets [Builder.date] to an arbitrary JSON value. - * - * You should usually call [Builder.date] with a well-typed [LocalDate] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun date(date: JsonField) = apply { this.date = date } - - /** Transaction description/particulars */ - fun description(description: String) = - description(JsonField.of(description)) - - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun description(description: JsonField) = apply { - this.description = description - } - - /** Dividend rate (for DIVIDEND_PAYOUT transactions) */ - fun dividendRate(dividendRate: Float?) = - dividendRate(JsonField.ofNullable(dividendRate)) - - /** - * Alias for [Builder.dividendRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun dividendRate(dividendRate: Float) = dividendRate(dividendRate as Float?) - - /** - * Alias for calling [Builder.dividendRate] with - * `dividendRate.orElse(null)`. - */ - fun dividendRate(dividendRate: Optional) = - dividendRate(dividendRate.getOrNull()) - - /** - * Sets [Builder.dividendRate] to an arbitrary JSON value. - * - * You should usually call [Builder.dividendRate] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun dividendRate(dividendRate: JsonField) = apply { - this.dividendRate = dividendRate - } - - /** NAV/price per unit on transaction date */ - fun nav(nav: Float?) = nav(JsonField.ofNullable(nav)) - - /** - * Alias for [Builder.nav]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun nav(nav: Float) = nav(nav as Float?) - - /** Alias for calling [Builder.nav] with `nav.orElse(null)`. */ - fun nav(nav: Optional) = nav(nav.getOrNull()) - - /** - * Sets [Builder.nav] to an arbitrary JSON value. - * - * You should usually call [Builder.nav] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun nav(nav: JsonField) = apply { this.nav = nav } - - /** - * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, - * SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, - * DIVIDEND_PAYOUT, DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, - * STT_TAX, MISC, REVERSAL, UNKNOWN. - */ - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - /** Number of units involved in transaction */ - fun units(units: Float) = units(JsonField.of(units)) - - /** - * Sets [Builder.units] to an arbitrary JSON value. - * - * You should usually call [Builder.units] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun units(units: JsonField) = apply { this.units = units } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Transaction]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Transaction = - Transaction( - additionalInfo, - amount, - balance, - date, - description, - dividendRate, - nav, - type, - units, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Transaction = apply { - if (validated) { - return@apply - } - - additionalInfo().ifPresent { it.validate() } - amount() - balance() - date() - description() - dividendRate() - nav() - type().ifPresent { it.validate() } - units() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (additionalInfo.asKnown().getOrNull()?.validity() ?: 0) + - (if (amount.asKnown().isPresent) 1 else 0) + - (if (balance.asKnown().isPresent) 1 else 0) + - (if (date.asKnown().isPresent) 1 else 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (if (dividendRate.asKnown().isPresent) 1 else 0) + - (if (nav.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (units.asKnown().isPresent) 1 else 0) - - /** Additional transaction-specific fields that vary by source */ - class AdditionalInfo - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val capitalWithdrawal: JsonField, - private val credit: JsonField, - private val debit: JsonField, - private val incomeDistribution: JsonField, - private val orderNo: JsonField, - private val price: JsonField, - private val stampDuty: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("capital_withdrawal") - @ExcludeMissing - capitalWithdrawal: JsonField = JsonMissing.of(), - @JsonProperty("credit") - @ExcludeMissing - credit: JsonField = JsonMissing.of(), - @JsonProperty("debit") - @ExcludeMissing - debit: JsonField = JsonMissing.of(), - @JsonProperty("income_distribution") - @ExcludeMissing - incomeDistribution: JsonField = JsonMissing.of(), - @JsonProperty("order_no") - @ExcludeMissing - orderNo: JsonField = JsonMissing.of(), - @JsonProperty("price") - @ExcludeMissing - price: JsonField = JsonMissing.of(), - @JsonProperty("stamp_duty") - @ExcludeMissing - stampDuty: JsonField = JsonMissing.of(), - ) : this( - capitalWithdrawal, - credit, - debit, - incomeDistribution, - orderNo, - price, - stampDuty, - mutableMapOf(), - ) - - /** - * Capital withdrawal amount (CDSL MF transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun capitalWithdrawal(): Optional = - capitalWithdrawal.getOptional("capital_withdrawal") - - /** - * Units credited (demat transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun credit(): Optional = credit.getOptional("credit") - - /** - * Units debited (demat transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun debit(): Optional = debit.getOptional("debit") - - /** - * Income distribution amount (CDSL MF transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun incomeDistribution(): Optional = - incomeDistribution.getOptional("income_distribution") - - /** - * Order/transaction reference number (demat transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun orderNo(): Optional = orderNo.getOptional("order_no") - - /** - * Price per unit (NSDL/CDSL MF transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun price(): Optional = price.getOptional("price") - - /** - * Stamp duty charged - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun stampDuty(): Optional = stampDuty.getOptional("stamp_duty") - - /** - * Returns the raw JSON value of [capitalWithdrawal]. - * - * Unlike [capitalWithdrawal], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("capital_withdrawal") - @ExcludeMissing - fun _capitalWithdrawal(): JsonField = capitalWithdrawal - - /** - * Returns the raw JSON value of [credit]. - * - * Unlike [credit], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("credit") - @ExcludeMissing - fun _credit(): JsonField = credit - - /** - * Returns the raw JSON value of [debit]. - * - * Unlike [debit], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("debit") - @ExcludeMissing - fun _debit(): JsonField = debit - - /** - * Returns the raw JSON value of [incomeDistribution]. - * - * Unlike [incomeDistribution], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("income_distribution") - @ExcludeMissing - fun _incomeDistribution(): JsonField = incomeDistribution - - /** - * Returns the raw JSON value of [orderNo]. - * - * Unlike [orderNo], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("order_no") - @ExcludeMissing - fun _orderNo(): JsonField = orderNo - - /** - * Returns the raw JSON value of [price]. - * - * Unlike [price], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("price") - @ExcludeMissing - fun _price(): JsonField = price - - /** - * Returns the raw JSON value of [stampDuty]. - * - * Unlike [stampDuty], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("stamp_duty") - @ExcludeMissing - fun _stampDuty(): JsonField = stampDuty - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [AdditionalInfo]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [AdditionalInfo]. */ - class Builder internal constructor() { - - private var capitalWithdrawal: JsonField = JsonMissing.of() - private var credit: JsonField = JsonMissing.of() - private var debit: JsonField = JsonMissing.of() - private var incomeDistribution: JsonField = JsonMissing.of() - private var orderNo: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var stampDuty: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(additionalInfo: AdditionalInfo) = apply { - capitalWithdrawal = additionalInfo.capitalWithdrawal - credit = additionalInfo.credit - debit = additionalInfo.debit - incomeDistribution = additionalInfo.incomeDistribution - orderNo = additionalInfo.orderNo - price = additionalInfo.price - stampDuty = additionalInfo.stampDuty - additionalProperties = - additionalInfo.additionalProperties.toMutableMap() - } - - /** Capital withdrawal amount (CDSL MF transactions) */ - fun capitalWithdrawal(capitalWithdrawal: Float) = - capitalWithdrawal(JsonField.of(capitalWithdrawal)) - - /** - * Sets [Builder.capitalWithdrawal] to an arbitrary JSON value. - * - * You should usually call [Builder.capitalWithdrawal] with a well-typed - * [Float] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun capitalWithdrawal(capitalWithdrawal: JsonField) = apply { - this.capitalWithdrawal = capitalWithdrawal - } - - /** Units credited (demat transactions) */ - fun credit(credit: Float) = credit(JsonField.of(credit)) - - /** - * Sets [Builder.credit] to an arbitrary JSON value. - * - * You should usually call [Builder.credit] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun credit(credit: JsonField) = apply { this.credit = credit } - - /** Units debited (demat transactions) */ - fun debit(debit: Float) = debit(JsonField.of(debit)) - - /** - * Sets [Builder.debit] to an arbitrary JSON value. - * - * You should usually call [Builder.debit] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun debit(debit: JsonField) = apply { this.debit = debit } - - /** Income distribution amount (CDSL MF transactions) */ - fun incomeDistribution(incomeDistribution: Float) = - incomeDistribution(JsonField.of(incomeDistribution)) - - /** - * Sets [Builder.incomeDistribution] to an arbitrary JSON value. - * - * You should usually call [Builder.incomeDistribution] with a - * well-typed [Float] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun incomeDistribution(incomeDistribution: JsonField) = apply { - this.incomeDistribution = incomeDistribution - } - - /** Order/transaction reference number (demat transactions) */ - fun orderNo(orderNo: String) = orderNo(JsonField.of(orderNo)) - - /** - * Sets [Builder.orderNo] to an arbitrary JSON value. - * - * You should usually call [Builder.orderNo] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun orderNo(orderNo: JsonField) = apply { - this.orderNo = orderNo - } - - /** Price per unit (NSDL/CDSL MF transactions) */ - fun price(price: Float) = price(JsonField.of(price)) - - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun price(price: JsonField) = apply { this.price = price } - - /** Stamp duty charged */ - fun stampDuty(stampDuty: Float) = stampDuty(JsonField.of(stampDuty)) - - /** - * Sets [Builder.stampDuty] to an arbitrary JSON value. - * - * You should usually call [Builder.stampDuty] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun stampDuty(stampDuty: JsonField) = apply { - this.stampDuty = stampDuty - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [AdditionalInfo]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): AdditionalInfo = - AdditionalInfo( - capitalWithdrawal, - credit, - debit, - incomeDistribution, - orderNo, - price, - stampDuty, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): AdditionalInfo = apply { - if (validated) { - return@apply - } - - capitalWithdrawal() - credit() - debit() - incomeDistribution() - orderNo() - price() - stampDuty() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (capitalWithdrawal.asKnown().isPresent) 1 else 0) + - (if (credit.asKnown().isPresent) 1 else 0) + - (if (debit.asKnown().isPresent) 1 else 0) + - (if (incomeDistribution.asKnown().isPresent) 1 else 0) + - (if (orderNo.asKnown().isPresent) 1 else 0) + - (if (price.asKnown().isPresent) 1 else 0) + - (if (stampDuty.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AdditionalInfo && - capitalWithdrawal == other.capitalWithdrawal && - credit == other.credit && - debit == other.debit && - incomeDistribution == other.incomeDistribution && - orderNo == other.orderNo && - price == other.price && - stampDuty == other.stampDuty && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - capitalWithdrawal, - credit, - debit, - incomeDistribution, - orderNo, - price, - stampDuty, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "AdditionalInfo{capitalWithdrawal=$capitalWithdrawal, credit=$credit, debit=$debit, incomeDistribution=$incomeDistribution, orderNo=$orderNo, price=$price, stampDuty=$stampDuty, additionalProperties=$additionalProperties}" - } - - /** - * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, - * SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, - * DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, - * REVERSAL, UNKNOWN. - */ - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PURCHASE = of("PURCHASE") - - @JvmField val PURCHASE_SIP = of("PURCHASE_SIP") - - @JvmField val REDEMPTION = of("REDEMPTION") - - @JvmField val SWITCH_IN = of("SWITCH_IN") - - @JvmField val SWITCH_IN_MERGER = of("SWITCH_IN_MERGER") - - @JvmField val SWITCH_OUT = of("SWITCH_OUT") - - @JvmField val SWITCH_OUT_MERGER = of("SWITCH_OUT_MERGER") - - @JvmField val DIVIDEND_PAYOUT = of("DIVIDEND_PAYOUT") - - @JvmField val DIVIDEND_REINVEST = of("DIVIDEND_REINVEST") - - @JvmField val SEGREGATION = of("SEGREGATION") - - @JvmField val STAMP_DUTY_TAX = of("STAMP_DUTY_TAX") - - @JvmField val TDS_TAX = of("TDS_TAX") - - @JvmField val STT_TAX = of("STT_TAX") - - @JvmField val MISC = of("MISC") - - @JvmField val REVERSAL = of("REVERSAL") - - @JvmField val UNKNOWN = of("UNKNOWN") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - PURCHASE, - PURCHASE_SIP, - REDEMPTION, - SWITCH_IN, - SWITCH_IN_MERGER, - SWITCH_OUT, - SWITCH_OUT_MERGER, - DIVIDEND_PAYOUT, - DIVIDEND_REINVEST, - SEGREGATION, - STAMP_DUTY_TAX, - TDS_TAX, - STT_TAX, - MISC, - REVERSAL, - UNKNOWN, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PURCHASE, - PURCHASE_SIP, - REDEMPTION, - SWITCH_IN, - SWITCH_IN_MERGER, - SWITCH_OUT, - SWITCH_OUT_MERGER, - DIVIDEND_PAYOUT, - DIVIDEND_REINVEST, - SEGREGATION, - STAMP_DUTY_TAX, - TDS_TAX, - STT_TAX, - MISC, - REVERSAL, - UNKNOWN, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PURCHASE -> Value.PURCHASE - PURCHASE_SIP -> Value.PURCHASE_SIP - REDEMPTION -> Value.REDEMPTION - SWITCH_IN -> Value.SWITCH_IN - SWITCH_IN_MERGER -> Value.SWITCH_IN_MERGER - SWITCH_OUT -> Value.SWITCH_OUT - SWITCH_OUT_MERGER -> Value.SWITCH_OUT_MERGER - DIVIDEND_PAYOUT -> Value.DIVIDEND_PAYOUT - DIVIDEND_REINVEST -> Value.DIVIDEND_REINVEST - SEGREGATION -> Value.SEGREGATION - STAMP_DUTY_TAX -> Value.STAMP_DUTY_TAX - TDS_TAX -> Value.TDS_TAX - STT_TAX -> Value.STT_TAX - MISC -> Value.MISC - REVERSAL -> Value.REVERSAL - UNKNOWN -> Value.UNKNOWN - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always - * known and don't want to throw for the unknown case. - * - * @throws CasParserInvalidDataException if this class instance's value is a - * not a known member. - */ - fun known(): Known = - when (this) { - PURCHASE -> Known.PURCHASE - PURCHASE_SIP -> Known.PURCHASE_SIP - REDEMPTION -> Known.REDEMPTION - SWITCH_IN -> Known.SWITCH_IN - SWITCH_IN_MERGER -> Known.SWITCH_IN_MERGER - SWITCH_OUT -> Known.SWITCH_OUT - SWITCH_OUT_MERGER -> Known.SWITCH_OUT_MERGER - DIVIDEND_PAYOUT -> Known.DIVIDEND_PAYOUT - DIVIDEND_REINVEST -> Known.DIVIDEND_REINVEST - SEGREGATION -> Known.SEGREGATION - STAMP_DUTY_TAX -> Known.STAMP_DUTY_TAX - TDS_TAX -> Known.TDS_TAX - STT_TAX -> Known.STT_TAX - MISC -> Known.MISC - REVERSAL -> Known.REVERSAL - UNKNOWN -> Known.UNKNOWN - else -> throw CasParserInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws CasParserInvalidDataException if this class instance's value does - * not have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CasParserInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Transaction && - additionalInfo == other.additionalInfo && - amount == other.amount && - balance == other.balance && - date == other.date && - description == other.description && - dividendRate == other.dividendRate && - nav == other.nav && - type == other.type && - units == other.units && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - additionalInfo, - amount, - balance, - date, - description, - dividendRate, - nav, - type, - units, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Transaction{additionalInfo=$additionalInfo, amount=$amount, balance=$balance, date=$date, description=$description, dividendRate=$dividendRate, nav=$nav, type=$type, units=$units, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is GovernmentSecurity && - additionalInfo == other.additionalInfo && - isin == other.isin && - name == other.name && - transactions == other.transactions && - units == other.units && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - additionalInfo, - isin, - name, - transactions, - units, - value, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "GovernmentSecurity{additionalInfo=$additionalInfo, isin=$isin, name=$name, transactions=$transactions, units=$units, value=$value, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Holdings && - aifs == other.aifs && - corporateBonds == other.corporateBonds && - dematMutualFunds == other.dematMutualFunds && - equities == other.equities && - governmentSecurities == other.governmentSecurities && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - aifs, - corporateBonds, - dematMutualFunds, - equities, - governmentSecurities, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Holdings{aifs=$aifs, corporateBonds=$corporateBonds, dematMutualFunds=$dematMutualFunds, equities=$equities, governmentSecurities=$governmentSecurities, additionalProperties=$additionalProperties}" - } - - class LinkedHolder - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val name: JsonField, - private val pan: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("pan") @ExcludeMissing pan: JsonField = JsonMissing.of(), - ) : this(name, pan, mutableMapOf()) - - /** - * Name of the account holder - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * PAN of the account holder - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun pan(): Optional = pan.getOptional("pan") - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [pan]. - * - * Unlike [pan], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("pan") @ExcludeMissing fun _pan(): JsonField = pan - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [LinkedHolder]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [LinkedHolder]. */ - class Builder internal constructor() { - - private var name: JsonField = JsonMissing.of() - private var pan: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(linkedHolder: LinkedHolder) = apply { - name = linkedHolder.name - pan = linkedHolder.pan - additionalProperties = linkedHolder.additionalProperties.toMutableMap() - } - - /** Name of the account holder */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** PAN of the account holder */ - fun pan(pan: String) = pan(JsonField.of(pan)) - - /** - * Sets [Builder.pan] to an arbitrary JSON value. - * - * You should usually call [Builder.pan] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun pan(pan: JsonField) = apply { this.pan = pan } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [LinkedHolder]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): LinkedHolder = - LinkedHolder(name, pan, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): LinkedHolder = apply { - if (validated) { - return@apply - } - - name() - pan() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (name.asKnown().isPresent) 1 else 0) + (if (pan.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is LinkedHolder && - name == other.name && - pan == other.pan && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(name, pan, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "LinkedHolder{name=$name, pan=$pan, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is DematAccount && - additionalInfo == other.additionalInfo && - boId == other.boId && - clientId == other.clientId && - dematType == other.dematType && - dpId == other.dpId && - dpName == other.dpName && - holdings == other.holdings && - linkedHolders == other.linkedHolders && - value == other.value && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - additionalInfo, - boId, - clientId, - dematType, - dpId, - dpName, - holdings, - linkedHolders, - value, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "DematAccount{additionalInfo=$additionalInfo, boId=$boId, clientId=$clientId, dematType=$dematType, dpId=$dpId, dpName=$dpName, holdings=$holdings, linkedHolders=$linkedHolders, value=$value, additionalProperties=$additionalProperties}" - } - - class Insurance - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val lifeInsurancePolicies: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("life_insurance_policies") - @ExcludeMissing - lifeInsurancePolicies: JsonField> = JsonMissing.of() - ) : this(lifeInsurancePolicies, mutableMapOf()) - - /** - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun lifeInsurancePolicies(): Optional> = - lifeInsurancePolicies.getOptional("life_insurance_policies") - - /** - * Returns the raw JSON value of [lifeInsurancePolicies]. - * - * Unlike [lifeInsurancePolicies], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("life_insurance_policies") - @ExcludeMissing - fun _lifeInsurancePolicies(): JsonField> = lifeInsurancePolicies - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Insurance]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Insurance]. */ - class Builder internal constructor() { - - private var lifeInsurancePolicies: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(insurance: Insurance) = apply { - lifeInsurancePolicies = insurance.lifeInsurancePolicies.map { it.toMutableList() } - additionalProperties = insurance.additionalProperties.toMutableMap() - } - - fun lifeInsurancePolicies(lifeInsurancePolicies: List) = - lifeInsurancePolicies(JsonField.of(lifeInsurancePolicies)) - - /** - * Sets [Builder.lifeInsurancePolicies] to an arbitrary JSON value. - * - * You should usually call [Builder.lifeInsurancePolicies] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun lifeInsurancePolicies(lifeInsurancePolicies: JsonField>) = - apply { - this.lifeInsurancePolicies = lifeInsurancePolicies.map { it.toMutableList() } - } - - /** - * Adds a single [LifeInsurancePolicy] to [lifeInsurancePolicies]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLifeInsurancePolicy(lifeInsurancePolicy: LifeInsurancePolicy) = apply { - lifeInsurancePolicies = - (lifeInsurancePolicies ?: JsonField.of(mutableListOf())).also { - checkKnown("lifeInsurancePolicies", it).add(lifeInsurancePolicy) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Insurance]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Insurance = - Insurance( - (lifeInsurancePolicies ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Insurance = apply { - if (validated) { - return@apply - } - - lifeInsurancePolicies().ifPresent { it.forEach { it.validate() } } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (lifeInsurancePolicies.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - class LifeInsurancePolicy - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val additionalInfo: JsonValue, - private val lifeAssured: JsonField, - private val policyName: JsonField, - private val policyNumber: JsonField, - private val premiumAmount: JsonField, - private val premiumFrequency: JsonField, - private val provider: JsonField, - private val status: JsonField, - private val sumAssured: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("additional_info") - @ExcludeMissing - additionalInfo: JsonValue = JsonMissing.of(), - @JsonProperty("life_assured") - @ExcludeMissing - lifeAssured: JsonField = JsonMissing.of(), - @JsonProperty("policy_name") - @ExcludeMissing - policyName: JsonField = JsonMissing.of(), - @JsonProperty("policy_number") - @ExcludeMissing - policyNumber: JsonField = JsonMissing.of(), - @JsonProperty("premium_amount") - @ExcludeMissing - premiumAmount: JsonField = JsonMissing.of(), - @JsonProperty("premium_frequency") - @ExcludeMissing - premiumFrequency: JsonField = JsonMissing.of(), - @JsonProperty("provider") - @ExcludeMissing - provider: JsonField = JsonMissing.of(), - @JsonProperty("status") - @ExcludeMissing - status: JsonField = JsonMissing.of(), - @JsonProperty("sum_assured") - @ExcludeMissing - sumAssured: JsonField = JsonMissing.of(), - ) : this( - additionalInfo, - lifeAssured, - policyName, - policyNumber, - premiumAmount, - premiumFrequency, - provider, - status, - sumAssured, - mutableMapOf(), - ) - - /** - * Additional information specific to the policy - * - * This arbitrary value can be deserialized into a custom type using the `convert` - * method: - * ```java - * MyClass myObject = lifeInsurancePolicy.additionalInfo().convert(MyClass.class); - * ``` - */ - @JsonProperty("additional_info") - @ExcludeMissing - fun _additionalInfo(): JsonValue = additionalInfo - - /** - * Name of the life assured - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun lifeAssured(): Optional = lifeAssured.getOptional("life_assured") - - /** - * Name of the insurance policy - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun policyName(): Optional = policyName.getOptional("policy_name") - - /** - * Insurance policy number - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun policyNumber(): Optional = policyNumber.getOptional("policy_number") - - /** - * Premium amount - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun premiumAmount(): Optional = premiumAmount.getOptional("premium_amount") - - /** - * Frequency of premium payment (e.g., Annual, Monthly) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun premiumFrequency(): Optional = - premiumFrequency.getOptional("premium_frequency") - - /** - * Insurance company name - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun provider(): Optional = provider.getOptional("provider") - - /** - * Status of the policy (e.g., Active, Lapsed) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun status(): Optional = status.getOptional("status") - - /** - * Sum assured amount - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun sumAssured(): Optional = sumAssured.getOptional("sum_assured") - - /** - * Returns the raw JSON value of [lifeAssured]. - * - * Unlike [lifeAssured], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("life_assured") - @ExcludeMissing - fun _lifeAssured(): JsonField = lifeAssured - - /** - * Returns the raw JSON value of [policyName]. - * - * Unlike [policyName], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("policy_name") - @ExcludeMissing - fun _policyName(): JsonField = policyName - - /** - * Returns the raw JSON value of [policyNumber]. - * - * Unlike [policyNumber], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("policy_number") - @ExcludeMissing - fun _policyNumber(): JsonField = policyNumber - - /** - * Returns the raw JSON value of [premiumAmount]. - * - * Unlike [premiumAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("premium_amount") - @ExcludeMissing - fun _premiumAmount(): JsonField = premiumAmount - - /** - * Returns the raw JSON value of [premiumFrequency]. - * - * Unlike [premiumFrequency], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("premium_frequency") - @ExcludeMissing - fun _premiumFrequency(): JsonField = premiumFrequency - - /** - * Returns the raw JSON value of [provider]. - * - * Unlike [provider], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("provider") @ExcludeMissing fun _provider(): JsonField = provider - - /** - * Returns the raw JSON value of [status]. - * - * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - - /** - * Returns the raw JSON value of [sumAssured]. - * - * Unlike [sumAssured], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("sum_assured") - @ExcludeMissing - fun _sumAssured(): JsonField = sumAssured - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [LifeInsurancePolicy]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [LifeInsurancePolicy]. */ - class Builder internal constructor() { - - private var additionalInfo: JsonValue = JsonMissing.of() - private var lifeAssured: JsonField = JsonMissing.of() - private var policyName: JsonField = JsonMissing.of() - private var policyNumber: JsonField = JsonMissing.of() - private var premiumAmount: JsonField = JsonMissing.of() - private var premiumFrequency: JsonField = JsonMissing.of() - private var provider: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var sumAssured: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(lifeInsurancePolicy: LifeInsurancePolicy) = apply { - additionalInfo = lifeInsurancePolicy.additionalInfo - lifeAssured = lifeInsurancePolicy.lifeAssured - policyName = lifeInsurancePolicy.policyName - policyNumber = lifeInsurancePolicy.policyNumber - premiumAmount = lifeInsurancePolicy.premiumAmount - premiumFrequency = lifeInsurancePolicy.premiumFrequency - provider = lifeInsurancePolicy.provider - status = lifeInsurancePolicy.status - sumAssured = lifeInsurancePolicy.sumAssured - additionalProperties = lifeInsurancePolicy.additionalProperties.toMutableMap() - } - - /** Additional information specific to the policy */ - fun additionalInfo(additionalInfo: JsonValue) = apply { - this.additionalInfo = additionalInfo - } - - /** Name of the life assured */ - fun lifeAssured(lifeAssured: String) = lifeAssured(JsonField.of(lifeAssured)) - - /** - * Sets [Builder.lifeAssured] to an arbitrary JSON value. - * - * You should usually call [Builder.lifeAssured] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun lifeAssured(lifeAssured: JsonField) = apply { - this.lifeAssured = lifeAssured - } - - /** Name of the insurance policy */ - fun policyName(policyName: String) = policyName(JsonField.of(policyName)) - - /** - * Sets [Builder.policyName] to an arbitrary JSON value. - * - * You should usually call [Builder.policyName] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun policyName(policyName: JsonField) = apply { - this.policyName = policyName - } - - /** Insurance policy number */ - fun policyNumber(policyNumber: String) = policyNumber(JsonField.of(policyNumber)) - - /** - * Sets [Builder.policyNumber] to an arbitrary JSON value. - * - * You should usually call [Builder.policyNumber] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun policyNumber(policyNumber: JsonField) = apply { - this.policyNumber = policyNumber - } - - /** Premium amount */ - fun premiumAmount(premiumAmount: Float) = premiumAmount(JsonField.of(premiumAmount)) - - /** - * Sets [Builder.premiumAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.premiumAmount] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun premiumAmount(premiumAmount: JsonField) = apply { - this.premiumAmount = premiumAmount - } - - /** Frequency of premium payment (e.g., Annual, Monthly) */ - fun premiumFrequency(premiumFrequency: String) = - premiumFrequency(JsonField.of(premiumFrequency)) - - /** - * Sets [Builder.premiumFrequency] to an arbitrary JSON value. - * - * You should usually call [Builder.premiumFrequency] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun premiumFrequency(premiumFrequency: JsonField) = apply { - this.premiumFrequency = premiumFrequency - } - - /** Insurance company name */ - fun provider(provider: String) = provider(JsonField.of(provider)) - - /** - * Sets [Builder.provider] to an arbitrary JSON value. - * - * You should usually call [Builder.provider] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun provider(provider: JsonField) = apply { this.provider = provider } - - /** Status of the policy (e.g., Active, Lapsed) */ - fun status(status: String) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - /** Sum assured amount */ - fun sumAssured(sumAssured: Float) = sumAssured(JsonField.of(sumAssured)) - - /** - * Sets [Builder.sumAssured] to an arbitrary JSON value. - * - * You should usually call [Builder.sumAssured] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun sumAssured(sumAssured: JsonField) = apply { - this.sumAssured = sumAssured - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [LifeInsurancePolicy]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): LifeInsurancePolicy = - LifeInsurancePolicy( - additionalInfo, - lifeAssured, - policyName, - policyNumber, - premiumAmount, - premiumFrequency, - provider, - status, - sumAssured, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): LifeInsurancePolicy = apply { - if (validated) { - return@apply - } - - lifeAssured() - policyName() - policyNumber() - premiumAmount() - premiumFrequency() - provider() - status() - sumAssured() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (lifeAssured.asKnown().isPresent) 1 else 0) + - (if (policyName.asKnown().isPresent) 1 else 0) + - (if (policyNumber.asKnown().isPresent) 1 else 0) + - (if (premiumAmount.asKnown().isPresent) 1 else 0) + - (if (premiumFrequency.asKnown().isPresent) 1 else 0) + - (if (provider.asKnown().isPresent) 1 else 0) + - (if (status.asKnown().isPresent) 1 else 0) + - (if (sumAssured.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is LifeInsurancePolicy && - additionalInfo == other.additionalInfo && - lifeAssured == other.lifeAssured && - policyName == other.policyName && - policyNumber == other.policyNumber && - premiumAmount == other.premiumAmount && - premiumFrequency == other.premiumFrequency && - provider == other.provider && - status == other.status && - sumAssured == other.sumAssured && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - additionalInfo, - lifeAssured, - policyName, - policyNumber, - premiumAmount, - premiumFrequency, - provider, - status, - sumAssured, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "LifeInsurancePolicy{additionalInfo=$additionalInfo, lifeAssured=$lifeAssured, policyName=$policyName, policyNumber=$policyNumber, premiumAmount=$premiumAmount, premiumFrequency=$premiumFrequency, provider=$provider, status=$status, sumAssured=$sumAssured, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Insurance && - lifeInsurancePolicies == other.lifeInsurancePolicies && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(lifeInsurancePolicies, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Insurance{lifeInsurancePolicies=$lifeInsurancePolicies, additionalProperties=$additionalProperties}" - } - - class Investor - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val address: JsonField, - private val casId: JsonField, - private val email: JsonField, - private val mobile: JsonField, - private val name: JsonField, - private val pan: JsonField, - private val pincode: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("address") @ExcludeMissing address: JsonField = JsonMissing.of(), - @JsonProperty("cas_id") @ExcludeMissing casId: JsonField = JsonMissing.of(), - @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), - @JsonProperty("mobile") @ExcludeMissing mobile: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("pan") @ExcludeMissing pan: JsonField = JsonMissing.of(), - @JsonProperty("pincode") @ExcludeMissing pincode: JsonField = JsonMissing.of(), - ) : this(address, casId, email, mobile, name, pan, pincode, mutableMapOf()) - - /** - * Address of the investor - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun address(): Optional = address.getOptional("address") - - /** - * CAS ID of the investor (only for NSDL and CDSL) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun casId(): Optional = casId.getOptional("cas_id") - - /** - * Email address of the investor - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun email(): Optional = email.getOptional("email") - - /** - * Mobile number of the investor - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun mobile(): Optional = mobile.getOptional("mobile") - - /** - * Name of the investor - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * PAN (Permanent Account Number) of the investor - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun pan(): Optional = pan.getOptional("pan") - - /** - * Postal code of the investor's address - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun pincode(): Optional = pincode.getOptional("pincode") - - /** - * Returns the raw JSON value of [address]. - * - * Unlike [address], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("address") @ExcludeMissing fun _address(): JsonField = address - - /** - * Returns the raw JSON value of [casId]. - * - * Unlike [casId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("cas_id") @ExcludeMissing fun _casId(): JsonField = casId - - /** - * Returns the raw JSON value of [email]. - * - * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email - - /** - * Returns the raw JSON value of [mobile]. - * - * Unlike [mobile], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("mobile") @ExcludeMissing fun _mobile(): JsonField = mobile - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [pan]. - * - * Unlike [pan], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("pan") @ExcludeMissing fun _pan(): JsonField = pan - - /** - * Returns the raw JSON value of [pincode]. - * - * Unlike [pincode], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("pincode") @ExcludeMissing fun _pincode(): JsonField = pincode - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Investor]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Investor]. */ - class Builder internal constructor() { - - private var address: JsonField = JsonMissing.of() - private var casId: JsonField = JsonMissing.of() - private var email: JsonField = JsonMissing.of() - private var mobile: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var pan: JsonField = JsonMissing.of() - private var pincode: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(investor: Investor) = apply { - address = investor.address - casId = investor.casId - email = investor.email - mobile = investor.mobile - name = investor.name - pan = investor.pan - pincode = investor.pincode - additionalProperties = investor.additionalProperties.toMutableMap() - } - - /** Address of the investor */ - fun address(address: String) = address(JsonField.of(address)) - - /** - * Sets [Builder.address] to an arbitrary JSON value. - * - * You should usually call [Builder.address] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun address(address: JsonField) = apply { this.address = address } - - /** CAS ID of the investor (only for NSDL and CDSL) */ - fun casId(casId: String) = casId(JsonField.of(casId)) - - /** - * Sets [Builder.casId] to an arbitrary JSON value. - * - * You should usually call [Builder.casId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun casId(casId: JsonField) = apply { this.casId = casId } - - /** Email address of the investor */ - fun email(email: String) = email(JsonField.of(email)) - - /** - * Sets [Builder.email] to an arbitrary JSON value. - * - * You should usually call [Builder.email] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun email(email: JsonField) = apply { this.email = email } - - /** Mobile number of the investor */ - fun mobile(mobile: String) = mobile(JsonField.of(mobile)) - - /** - * Sets [Builder.mobile] to an arbitrary JSON value. - * - * You should usually call [Builder.mobile] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun mobile(mobile: JsonField) = apply { this.mobile = mobile } - - /** Name of the investor */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** PAN (Permanent Account Number) of the investor */ - fun pan(pan: String) = pan(JsonField.of(pan)) - - /** - * Sets [Builder.pan] to an arbitrary JSON value. - * - * You should usually call [Builder.pan] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun pan(pan: JsonField) = apply { this.pan = pan } - - /** Postal code of the investor's address */ - fun pincode(pincode: String) = pincode(JsonField.of(pincode)) - - /** - * Sets [Builder.pincode] to an arbitrary JSON value. - * - * You should usually call [Builder.pincode] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun pincode(pincode: JsonField) = apply { this.pincode = pincode } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Investor]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Investor = - Investor( - address, - casId, - email, - mobile, - name, - pan, - pincode, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Investor = apply { - if (validated) { - return@apply - } - - address() - casId() - email() - mobile() - name() - pan() - pincode() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (address.asKnown().isPresent) 1 else 0) + - (if (casId.asKnown().isPresent) 1 else 0) + - (if (email.asKnown().isPresent) 1 else 0) + - (if (mobile.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (pan.asKnown().isPresent) 1 else 0) + - (if (pincode.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Investor && - address == other.address && - casId == other.casId && - email == other.email && - mobile == other.mobile && - name == other.name && - pan == other.pan && - pincode == other.pincode && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(address, casId, email, mobile, name, pan, pincode, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Investor{address=$address, casId=$casId, email=$email, mobile=$mobile, name=$name, pan=$pan, pincode=$pincode, additionalProperties=$additionalProperties}" - } - - class Meta - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val casType: JsonField, - private val generatedAt: JsonField, - private val statementPeriod: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("cas_type") - @ExcludeMissing - casType: JsonField = JsonMissing.of(), - @JsonProperty("generated_at") - @ExcludeMissing - generatedAt: JsonField = JsonMissing.of(), - @JsonProperty("statement_period") - @ExcludeMissing - statementPeriod: JsonField = JsonMissing.of(), - ) : this(casType, generatedAt, statementPeriod, mutableMapOf()) - - /** - * Type of CAS detected and processed - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun casType(): Optional = casType.getOptional("cas_type") - - /** - * Timestamp when the response was generated - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun generatedAt(): Optional = generatedAt.getOptional("generated_at") - - /** - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun statementPeriod(): Optional = - statementPeriod.getOptional("statement_period") - - /** - * Returns the raw JSON value of [casType]. - * - * Unlike [casType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("cas_type") @ExcludeMissing fun _casType(): JsonField = casType - - /** - * Returns the raw JSON value of [generatedAt]. - * - * Unlike [generatedAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("generated_at") - @ExcludeMissing - fun _generatedAt(): JsonField = generatedAt - - /** - * Returns the raw JSON value of [statementPeriod]. - * - * Unlike [statementPeriod], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("statement_period") - @ExcludeMissing - fun _statementPeriod(): JsonField = statementPeriod - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Meta]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Meta]. */ - class Builder internal constructor() { - - private var casType: JsonField = JsonMissing.of() - private var generatedAt: JsonField = JsonMissing.of() - private var statementPeriod: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(meta: Meta) = apply { - casType = meta.casType - generatedAt = meta.generatedAt - statementPeriod = meta.statementPeriod - additionalProperties = meta.additionalProperties.toMutableMap() - } - - /** Type of CAS detected and processed */ - fun casType(casType: CasType) = casType(JsonField.of(casType)) - - /** - * Sets [Builder.casType] to an arbitrary JSON value. - * - * You should usually call [Builder.casType] with a well-typed [CasType] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun casType(casType: JsonField) = apply { this.casType = casType } - - /** Timestamp when the response was generated */ - fun generatedAt(generatedAt: OffsetDateTime) = generatedAt(JsonField.of(generatedAt)) - - /** - * Sets [Builder.generatedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.generatedAt] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun generatedAt(generatedAt: JsonField) = apply { - this.generatedAt = generatedAt - } - - fun statementPeriod(statementPeriod: StatementPeriod) = - statementPeriod(JsonField.of(statementPeriod)) - - /** - * Sets [Builder.statementPeriod] to an arbitrary JSON value. - * - * You should usually call [Builder.statementPeriod] with a well-typed [StatementPeriod] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun statementPeriod(statementPeriod: JsonField) = apply { - this.statementPeriod = statementPeriod - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Meta]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Meta = - Meta(casType, generatedAt, statementPeriod, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Meta = apply { - if (validated) { - return@apply - } - - casType().ifPresent { it.validate() } - generatedAt() - statementPeriod().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (casType.asKnown().getOrNull()?.validity() ?: 0) + - (if (generatedAt.asKnown().isPresent) 1 else 0) + - (statementPeriod.asKnown().getOrNull()?.validity() ?: 0) - - /** Type of CAS detected and processed */ - class CasType @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val NSDL = of("NSDL") - - @JvmField val CDSL = of("CDSL") - - @JvmField val CAMS_KFINTECH = of("CAMS_KFINTECH") - - @JvmStatic fun of(value: String) = CasType(JsonField.of(value)) - } - - /** An enum containing [CasType]'s known values. */ - enum class Known { - NSDL, - CDSL, - CAMS_KFINTECH, - } - - /** - * An enum containing [CasType]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [CasType] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - NSDL, - CDSL, - CAMS_KFINTECH, - /** - * An enum member indicating that [CasType] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - NSDL -> Value.NSDL - CDSL -> Value.CDSL - CAMS_KFINTECH -> Value.CAMS_KFINTECH - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws CasParserInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - NSDL -> Known.NSDL - CDSL -> Known.CDSL - CAMS_KFINTECH -> Known.CAMS_KFINTECH - else -> throw CasParserInvalidDataException("Unknown CasType: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws CasParserInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - CasParserInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): CasType = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is CasType && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class StatementPeriod - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val from: JsonField, - private val to: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("from") @ExcludeMissing from: JsonField = JsonMissing.of(), - @JsonProperty("to") @ExcludeMissing to: JsonField = JsonMissing.of(), - ) : this(from, to, mutableMapOf()) - - /** - * Start date of the statement period - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun from(): Optional = from.getOptional("from") - - /** - * End date of the statement period - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun to(): Optional = to.getOptional("to") - - /** - * Returns the raw JSON value of [from]. - * - * Unlike [from], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("from") @ExcludeMissing fun _from(): JsonField = from - - /** - * Returns the raw JSON value of [to]. - * - * Unlike [to], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("to") @ExcludeMissing fun _to(): JsonField = to - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [StatementPeriod]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [StatementPeriod]. */ - class Builder internal constructor() { - - private var from: JsonField = JsonMissing.of() - private var to: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(statementPeriod: StatementPeriod) = apply { - from = statementPeriod.from - to = statementPeriod.to - additionalProperties = statementPeriod.additionalProperties.toMutableMap() - } - - /** Start date of the statement period */ - fun from(from: LocalDate) = from(JsonField.of(from)) - - /** - * Sets [Builder.from] to an arbitrary JSON value. - * - * You should usually call [Builder.from] with a well-typed [LocalDate] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun from(from: JsonField) = apply { this.from = from } - - /** End date of the statement period */ - fun to(to: LocalDate) = to(JsonField.of(to)) - - /** - * Sets [Builder.to] to an arbitrary JSON value. - * - * You should usually call [Builder.to] with a well-typed [LocalDate] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun to(to: JsonField) = apply { this.to = to } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [StatementPeriod]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): StatementPeriod = - StatementPeriod(from, to, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): StatementPeriod = apply { - if (validated) { - return@apply - } - - from() - to() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (from.asKnown().isPresent) 1 else 0) + (if (to.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is StatementPeriod && - from == other.from && - to == other.to && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(from, to, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "StatementPeriod{from=$from, to=$to, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Meta && - casType == other.casType && - generatedAt == other.generatedAt && - statementPeriod == other.statementPeriod && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(casType, generatedAt, statementPeriod, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Meta{casType=$casType, generatedAt=$generatedAt, statementPeriod=$statementPeriod, additionalProperties=$additionalProperties}" - } - - class MutualFund - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val additionalInfo: JsonField, - private val amc: JsonField, - private val folioNumber: JsonField, - private val linkedHolders: JsonField>, - private val registrar: JsonField, - private val schemes: JsonField>, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("additional_info") - @ExcludeMissing - additionalInfo: JsonField = JsonMissing.of(), - @JsonProperty("amc") @ExcludeMissing amc: JsonField = JsonMissing.of(), - @JsonProperty("folio_number") - @ExcludeMissing - folioNumber: JsonField = JsonMissing.of(), - @JsonProperty("linked_holders") - @ExcludeMissing - linkedHolders: JsonField> = JsonMissing.of(), - @JsonProperty("registrar") - @ExcludeMissing - registrar: JsonField = JsonMissing.of(), - @JsonProperty("schemes") - @ExcludeMissing - schemes: JsonField> = JsonMissing.of(), - @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), - ) : this( - additionalInfo, - amc, - folioNumber, - linkedHolders, - registrar, - schemes, - value, - mutableMapOf(), - ) - - /** - * Additional folio information - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun additionalInfo(): Optional = - additionalInfo.getOptional("additional_info") - - /** - * Asset Management Company name - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun amc(): Optional = amc.getOptional("amc") - - /** - * Folio number - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun folioNumber(): Optional = folioNumber.getOptional("folio_number") - - /** - * List of account holders linked to this mutual fund folio - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun linkedHolders(): Optional> = - linkedHolders.getOptional("linked_holders") - - /** - * Registrar and Transfer Agent name - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun registrar(): Optional = registrar.getOptional("registrar") - - /** - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun schemes(): Optional> = schemes.getOptional("schemes") - - /** - * Total value of the folio - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun value(): Optional = value.getOptional("value") - - /** - * Returns the raw JSON value of [additionalInfo]. - * - * Unlike [additionalInfo], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("additional_info") - @ExcludeMissing - fun _additionalInfo(): JsonField = additionalInfo - - /** - * Returns the raw JSON value of [amc]. - * - * Unlike [amc], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("amc") @ExcludeMissing fun _amc(): JsonField = amc - - /** - * Returns the raw JSON value of [folioNumber]. - * - * Unlike [folioNumber], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("folio_number") - @ExcludeMissing - fun _folioNumber(): JsonField = folioNumber - - /** - * Returns the raw JSON value of [linkedHolders]. - * - * Unlike [linkedHolders], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("linked_holders") - @ExcludeMissing - fun _linkedHolders(): JsonField> = linkedHolders - - /** - * Returns the raw JSON value of [registrar]. - * - * Unlike [registrar], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("registrar") @ExcludeMissing fun _registrar(): JsonField = registrar - - /** - * Returns the raw JSON value of [schemes]. - * - * Unlike [schemes], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("schemes") @ExcludeMissing fun _schemes(): JsonField> = schemes - - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [MutualFund]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [MutualFund]. */ - class Builder internal constructor() { - - private var additionalInfo: JsonField = JsonMissing.of() - private var amc: JsonField = JsonMissing.of() - private var folioNumber: JsonField = JsonMissing.of() - private var linkedHolders: JsonField>? = null - private var registrar: JsonField = JsonMissing.of() - private var schemes: JsonField>? = null - private var value: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(mutualFund: MutualFund) = apply { - additionalInfo = mutualFund.additionalInfo - amc = mutualFund.amc - folioNumber = mutualFund.folioNumber - linkedHolders = mutualFund.linkedHolders.map { it.toMutableList() } - registrar = mutualFund.registrar - schemes = mutualFund.schemes.map { it.toMutableList() } - value = mutualFund.value - additionalProperties = mutualFund.additionalProperties.toMutableMap() - } - - /** Additional folio information */ - fun additionalInfo(additionalInfo: AdditionalInfo) = - additionalInfo(JsonField.of(additionalInfo)) - - /** - * Sets [Builder.additionalInfo] to an arbitrary JSON value. - * - * You should usually call [Builder.additionalInfo] with a well-typed [AdditionalInfo] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun additionalInfo(additionalInfo: JsonField) = apply { - this.additionalInfo = additionalInfo - } - - /** Asset Management Company name */ - fun amc(amc: String) = amc(JsonField.of(amc)) - - /** - * Sets [Builder.amc] to an arbitrary JSON value. - * - * You should usually call [Builder.amc] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun amc(amc: JsonField) = apply { this.amc = amc } - - /** Folio number */ - fun folioNumber(folioNumber: String) = folioNumber(JsonField.of(folioNumber)) - - /** - * Sets [Builder.folioNumber] to an arbitrary JSON value. - * - * You should usually call [Builder.folioNumber] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun folioNumber(folioNumber: JsonField) = apply { - this.folioNumber = folioNumber - } - - /** List of account holders linked to this mutual fund folio */ - fun linkedHolders(linkedHolders: List) = - linkedHolders(JsonField.of(linkedHolders)) - - /** - * Sets [Builder.linkedHolders] to an arbitrary JSON value. - * - * You should usually call [Builder.linkedHolders] with a well-typed - * `List` value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun linkedHolders(linkedHolders: JsonField>) = apply { - this.linkedHolders = linkedHolders.map { it.toMutableList() } - } - - /** - * Adds a single [LinkedHolder] to [linkedHolders]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLinkedHolder(linkedHolder: LinkedHolder) = apply { - linkedHolders = - (linkedHolders ?: JsonField.of(mutableListOf())).also { - checkKnown("linkedHolders", it).add(linkedHolder) - } - } - - /** Registrar and Transfer Agent name */ - fun registrar(registrar: String) = registrar(JsonField.of(registrar)) + /** Postal code of the investor's address */ + fun pincode(pincode: String) = pincode(JsonField.of(pincode)) /** - * Sets [Builder.registrar] to an arbitrary JSON value. + * Sets [Builder.pincode] to an arbitrary JSON value. * - * You should usually call [Builder.registrar] with a well-typed [String] value instead. + * You should usually call [Builder.pincode] with a well-typed [String] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun registrar(registrar: JsonField) = apply { this.registrar = registrar } - - fun schemes(schemes: List) = schemes(JsonField.of(schemes)) - - /** - * Sets [Builder.schemes] to an arbitrary JSON value. - * - * You should usually call [Builder.schemes] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun schemes(schemes: JsonField>) = apply { - this.schemes = schemes.map { it.toMutableList() } - } - - /** - * Adds a single [Scheme] to [schemes]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addScheme(scheme: Scheme) = apply { - schemes = - (schemes ?: JsonField.of(mutableListOf())).also { - checkKnown("schemes", it).add(scheme) - } - } - - /** Total value of the folio */ - fun value(value: Float) = value(JsonField.of(value)) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [Float] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun value(value: JsonField) = apply { this.value = value } + fun pincode(pincode: JsonField) = apply { this.pincode = pincode } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -13007,40 +5828,40 @@ private constructor( fun removeAllAdditionalProperties(keys: Set) = apply { keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [MutualFund]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): MutualFund = - MutualFund( - additionalInfo, - amc, - folioNumber, - (linkedHolders ?: JsonMissing.of()).map { it.toImmutable() }, - registrar, - (schemes ?: JsonMissing.of()).map { it.toImmutable() }, - value, + } + + /** + * Returns an immutable instance of [Investor]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Investor = + Investor( + address, + casId, + email, + mobile, + name, + pan, + pincode, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): MutualFund = apply { + fun validate(): Investor = apply { if (validated) { return@apply } - additionalInfo().ifPresent { it.validate() } - amc() - folioNumber() - linkedHolders().ifPresent { it.forEach { it.validate() } } - registrar() - schemes().ifPresent { it.forEach { it.validate() } } - value() + address() + casId() + email() + mobile() + name() + pan() + pincode() validated = true } @@ -13060,187 +5881,351 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (additionalInfo.asKnown().getOrNull()?.validity() ?: 0) + - (if (amc.asKnown().isPresent) 1 else 0) + - (if (folioNumber.asKnown().isPresent) 1 else 0) + - (linkedHolders.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (registrar.asKnown().isPresent) 1 else 0) + - (schemes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (value.asKnown().isPresent) 1 else 0) + (if (address.asKnown().isPresent) 1 else 0) + + (if (casId.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (if (mobile.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (pan.asKnown().isPresent) 1 else 0) + + (if (pincode.asKnown().isPresent) 1 else 0) - /** Additional folio information */ - class AdditionalInfo - @JsonCreator(mode = JsonCreator.Mode.DISABLED) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Investor && + address == other.address && + casId == other.casId && + email == other.email && + mobile == other.mobile && + name == other.name && + pan == other.pan && + pincode == other.pincode && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(address, casId, email, mobile, name, pan, pincode, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Investor{address=$address, casId=$casId, email=$email, mobile=$mobile, name=$name, pan=$pan, pincode=$pincode, additionalProperties=$additionalProperties}" + } + + class Meta + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val casType: JsonField, + private val generatedAt: JsonField, + private val statementPeriod: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator private constructor( - private val kyc: JsonField, - private val pan: JsonField, - private val pankyc: JsonField, - private val additionalProperties: MutableMap, - ) { + @JsonProperty("cas_type") + @ExcludeMissing + casType: JsonField = JsonMissing.of(), + @JsonProperty("generated_at") + @ExcludeMissing + generatedAt: JsonField = JsonMissing.of(), + @JsonProperty("statement_period") + @ExcludeMissing + statementPeriod: JsonField = JsonMissing.of(), + ) : this(casType, generatedAt, statementPeriod, mutableMapOf()) - @JsonCreator - private constructor( - @JsonProperty("kyc") @ExcludeMissing kyc: JsonField = JsonMissing.of(), - @JsonProperty("pan") @ExcludeMissing pan: JsonField = JsonMissing.of(), - @JsonProperty("pankyc") @ExcludeMissing pankyc: JsonField = JsonMissing.of(), - ) : this(kyc, pan, pankyc, mutableMapOf()) + /** + * Type of CAS detected and processed + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun casType(): Optional = casType.getOptional("cas_type") - /** - * KYC status of the folio - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun kyc(): Optional = kyc.getOptional("kyc") + /** + * Timestamp when the response was generated + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun generatedAt(): Optional = generatedAt.getOptional("generated_at") - /** - * PAN associated with the folio - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun pan(): Optional = pan.getOptional("pan") + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun statementPeriod(): Optional = + statementPeriod.getOptional("statement_period") + + /** + * Returns the raw JSON value of [casType]. + * + * Unlike [casType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cas_type") @ExcludeMissing fun _casType(): JsonField = casType + + /** + * Returns the raw JSON value of [generatedAt]. + * + * Unlike [generatedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("generated_at") + @ExcludeMissing + fun _generatedAt(): JsonField = generatedAt + + /** + * Returns the raw JSON value of [statementPeriod]. + * + * Unlike [statementPeriod], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("statement_period") + @ExcludeMissing + fun _statementPeriod(): JsonField = statementPeriod + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Meta]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Meta]. */ + class Builder internal constructor() { + + private var casType: JsonField = JsonMissing.of() + private var generatedAt: JsonField = JsonMissing.of() + private var statementPeriod: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(meta: Meta) = apply { + casType = meta.casType + generatedAt = meta.generatedAt + statementPeriod = meta.statementPeriod + additionalProperties = meta.additionalProperties.toMutableMap() + } + + /** Type of CAS detected and processed */ + fun casType(casType: CasType) = casType(JsonField.of(casType)) /** - * PAN KYC status + * Sets [Builder.casType] to an arbitrary JSON value. * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.casType] with a well-typed [CasType] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun pankyc(): Optional = pankyc.getOptional("pankyc") + fun casType(casType: JsonField) = apply { this.casType = casType } + + /** Timestamp when the response was generated */ + fun generatedAt(generatedAt: OffsetDateTime) = generatedAt(JsonField.of(generatedAt)) /** - * Returns the raw JSON value of [kyc]. + * Sets [Builder.generatedAt] to an arbitrary JSON value. * - * Unlike [kyc], this method doesn't throw if the JSON field has an unexpected type. + * You should usually call [Builder.generatedAt] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - @JsonProperty("kyc") @ExcludeMissing fun _kyc(): JsonField = kyc + fun generatedAt(generatedAt: JsonField) = apply { + this.generatedAt = generatedAt + } + + fun statementPeriod(statementPeriod: StatementPeriod) = + statementPeriod(JsonField.of(statementPeriod)) /** - * Returns the raw JSON value of [pan]. + * Sets [Builder.statementPeriod] to an arbitrary JSON value. * - * Unlike [pan], this method doesn't throw if the JSON field has an unexpected type. + * You should usually call [Builder.statementPeriod] with a well-typed [StatementPeriod] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - @JsonProperty("pan") @ExcludeMissing fun _pan(): JsonField = pan + fun statementPeriod(statementPeriod: JsonField) = apply { + this.statementPeriod = statementPeriod + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns the raw JSON value of [pankyc]. + * Returns an immutable instance of [Meta]. * - * Unlike [pankyc], this method doesn't throw if the JSON field has an unexpected type. + * Further updates to this [Builder] will not mutate the returned instance. */ - @JsonProperty("pankyc") @ExcludeMissing fun _pankyc(): JsonField = pankyc - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun build(): Meta = + Meta(casType, generatedAt, statementPeriod, additionalProperties.toMutableMap()) + } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + private var validated: Boolean = false - fun toBuilder() = Builder().from(this) + fun validate(): Meta = apply { + if (validated) { + return@apply + } - companion object { + casType().ifPresent { it.validate() } + generatedAt() + statementPeriod().ifPresent { it.validate() } + validated = true + } - /** Returns a mutable builder for constructing an instance of [AdditionalInfo]. */ - @JvmStatic fun builder() = Builder() + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false } - /** A builder for [AdditionalInfo]. */ - class Builder internal constructor() { + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (casType.asKnown().getOrNull()?.validity() ?: 0) + + (if (generatedAt.asKnown().isPresent) 1 else 0) + + (statementPeriod.asKnown().getOrNull()?.validity() ?: 0) - private var kyc: JsonField = JsonMissing.of() - private var pan: JsonField = JsonMissing.of() - private var pankyc: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** Type of CAS detected and processed */ + class CasType @JsonCreator private constructor(private val value: JsonField) : + Enum { - @JvmSynthetic - internal fun from(additionalInfo: AdditionalInfo) = apply { - kyc = additionalInfo.kyc - pan = additionalInfo.pan - pankyc = additionalInfo.pankyc - additionalProperties = additionalInfo.additionalProperties.toMutableMap() - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - /** KYC status of the folio */ - fun kyc(kyc: String) = kyc(JsonField.of(kyc)) + companion object { - /** - * Sets [Builder.kyc] to an arbitrary JSON value. - * - * You should usually call [Builder.kyc] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun kyc(kyc: JsonField) = apply { this.kyc = kyc } + @JvmField val NSDL = of("NSDL") - /** PAN associated with the folio */ - fun pan(pan: String) = pan(JsonField.of(pan)) + @JvmField val CDSL = of("CDSL") - /** - * Sets [Builder.pan] to an arbitrary JSON value. - * - * You should usually call [Builder.pan] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun pan(pan: JsonField) = apply { this.pan = pan } + @JvmField val CAMS_KFINTECH = of("CAMS_KFINTECH") - /** PAN KYC status */ - fun pankyc(pankyc: String) = pankyc(JsonField.of(pankyc)) + @JvmStatic fun of(value: String) = CasType(JsonField.of(value)) + } + + /** An enum containing [CasType]'s known values. */ + enum class Known { + NSDL, + CDSL, + CAMS_KFINTECH, + } + /** + * An enum containing [CasType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [CasType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + NSDL, + CDSL, + CAMS_KFINTECH, /** - * Sets [Builder.pankyc] to an arbitrary JSON value. - * - * You should usually call [Builder.pankyc] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * An enum member indicating that [CasType] was instantiated with an unknown value. */ - fun pankyc(pankyc: JsonField) = apply { this.pankyc = pankyc } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + _UNKNOWN, + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + NSDL -> Value.NSDL + CDSL -> Value.CDSL + CAMS_KFINTECH -> Value.CAMS_KFINTECH + else -> Value._UNKNOWN } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CasParserInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + NSDL -> Known.NSDL + CDSL -> Known.CDSL + CAMS_KFINTECH -> Known.CAMS_KFINTECH + else -> throw CasParserInvalidDataException("Unknown CasType: $value") } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CasParserInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CasParserInvalidDataException("Value is not a String") } - /** - * Returns an immutable instance of [AdditionalInfo]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AdditionalInfo = - AdditionalInfo(kyc, pan, pankyc, additionalProperties.toMutableMap()) - } - private var validated: Boolean = false - fun validate(): AdditionalInfo = apply { + fun validate(): CasType = apply { if (validated) { return@apply } - kyc() - pan() - pankyc() + known() validated = true } @@ -13258,77 +6243,64 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - internal fun validity(): Int = - (if (kyc.asKnown().isPresent) 1 else 0) + - (if (pan.asKnown().isPresent) 1 else 0) + - (if (pankyc.asKnown().isPresent) 1 else 0) + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is AdditionalInfo && - kyc == other.kyc && - pan == other.pan && - pankyc == other.pankyc && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(kyc, pan, pankyc, additionalProperties) + return other is CasType && value == other.value } - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "AdditionalInfo{kyc=$kyc, pan=$pan, pankyc=$pankyc, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } - class LinkedHolder + class StatementPeriod @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val name: JsonField, - private val pan: JsonField, + private val from: JsonField, + private val to: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("pan") @ExcludeMissing pan: JsonField = JsonMissing.of(), - ) : this(name, pan, mutableMapOf()) + @JsonProperty("from") @ExcludeMissing from: JsonField = JsonMissing.of(), + @JsonProperty("to") @ExcludeMissing to: JsonField = JsonMissing.of(), + ) : this(from, to, mutableMapOf()) /** - * Name of the account holder + * Start date of the statement period * * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun name(): Optional = name.getOptional("name") + fun from(): Optional = from.getOptional("from") /** - * PAN of the account holder + * End date of the statement period * * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun pan(): Optional = pan.getOptional("pan") + fun to(): Optional = to.getOptional("to") /** - * Returns the raw JSON value of [name]. + * Returns the raw JSON value of [from]. * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [from], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonProperty("from") @ExcludeMissing fun _from(): JsonField = from /** - * Returns the raw JSON value of [pan]. + * Returns the raw JSON value of [to]. * - * Unlike [pan], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [to], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("pan") @ExcludeMissing fun _pan(): JsonField = pan + @JsonProperty("to") @ExcludeMissing fun _to(): JsonField = to @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -13344,47 +6316,47 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [LinkedHolder]. */ + /** Returns a mutable builder for constructing an instance of [StatementPeriod]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [LinkedHolder]. */ + /** A builder for [StatementPeriod]. */ class Builder internal constructor() { - - private var name: JsonField = JsonMissing.of() - private var pan: JsonField = JsonMissing.of() + + private var from: JsonField = JsonMissing.of() + private var to: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(linkedHolder: LinkedHolder) = apply { - name = linkedHolder.name - pan = linkedHolder.pan - additionalProperties = linkedHolder.additionalProperties.toMutableMap() + internal fun from(statementPeriod: StatementPeriod) = apply { + from = statementPeriod.from + to = statementPeriod.to + additionalProperties = statementPeriod.additionalProperties.toMutableMap() } - /** Name of the account holder */ - fun name(name: String) = name(JsonField.of(name)) + /** Start date of the statement period */ + fun from(from: LocalDate) = from(JsonField.of(from)) /** - * Sets [Builder.name] to an arbitrary JSON value. + * Sets [Builder.from] to an arbitrary JSON value. * - * You should usually call [Builder.name] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.from] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun name(name: JsonField) = apply { this.name = name } + fun from(from: JsonField) = apply { this.from = from } - /** PAN of the account holder */ - fun pan(pan: String) = pan(JsonField.of(pan)) + /** End date of the statement period */ + fun to(to: LocalDate) = to(JsonField.of(to)) /** - * Sets [Builder.pan] to an arbitrary JSON value. + * Sets [Builder.to] to an arbitrary JSON value. * - * You should usually call [Builder.pan] with a well-typed [String] value instead. + * You should usually call [Builder.to] with a well-typed [LocalDate] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun pan(pan: JsonField) = apply { this.pan = pan } + fun to(to: JsonField) = apply { this.to = to } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -13409,23 +6381,23 @@ private constructor( } /** - * Returns an immutable instance of [LinkedHolder]. + * Returns an immutable instance of [StatementPeriod]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): LinkedHolder = - LinkedHolder(name, pan, additionalProperties.toMutableMap()) + fun build(): StatementPeriod = + StatementPeriod(from, to, additionalProperties.toMutableMap()) } private var validated: Boolean = false - fun validate(): LinkedHolder = apply { + fun validate(): StatementPeriod = apply { if (validated) { return@apply } - name() - pan() + from() + to() validated = true } @@ -13445,249 +6417,503 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (name.asKnown().isPresent) 1 else 0) + (if (pan.asKnown().isPresent) 1 else 0) + (if (from.asKnown().isPresent) 1 else 0) + (if (to.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is LinkedHolder && - name == other.name && - pan == other.pan && + return other is StatementPeriod && + from == other.from && + to == other.to && additionalProperties == other.additionalProperties } - private val hashCode: Int by lazy { Objects.hash(name, pan, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(from, to, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "LinkedHolder{name=$name, pan=$pan, additionalProperties=$additionalProperties}" + "StatementPeriod{from=$from, to=$to, additionalProperties=$additionalProperties}" } - class Scheme - @JsonCreator(mode = JsonCreator.Mode.DISABLED) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Meta && + casType == other.casType && + generatedAt == other.generatedAt && + statementPeriod == other.statementPeriod && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(casType, generatedAt, statementPeriod, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Meta{casType=$casType, generatedAt=$generatedAt, statementPeriod=$statementPeriod, additionalProperties=$additionalProperties}" + } + + class MutualFund + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val additionalInfo: JsonField, + private val amc: JsonField, + private val folioNumber: JsonField, + private val linkedHolders: JsonField>, + private val registrar: JsonField, + private val schemes: JsonField>, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator private constructor( - private val additionalInfo: JsonField, - private val cost: JsonField, - private val gain: JsonField, - private val isin: JsonField, - private val name: JsonField, - private val nav: JsonField, - private val nominees: JsonField>, - private val transactions: JsonField>, - private val type: JsonField, - private val units: JsonField, - private val value: JsonField, - private val additionalProperties: MutableMap, - ) { + @JsonProperty("additional_info") + @ExcludeMissing + additionalInfo: JsonField = JsonMissing.of(), + @JsonProperty("amc") @ExcludeMissing amc: JsonField = JsonMissing.of(), + @JsonProperty("folio_number") + @ExcludeMissing + folioNumber: JsonField = JsonMissing.of(), + @JsonProperty("linked_holders") + @ExcludeMissing + linkedHolders: JsonField> = JsonMissing.of(), + @JsonProperty("registrar") + @ExcludeMissing + registrar: JsonField = JsonMissing.of(), + @JsonProperty("schemes") + @ExcludeMissing + schemes: JsonField> = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this( + additionalInfo, + amc, + folioNumber, + linkedHolders, + registrar, + schemes, + value, + mutableMapOf(), + ) + + /** + * Additional folio information + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun additionalInfo(): Optional = + additionalInfo.getOptional("additional_info") + + /** + * Asset Management Company name + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun amc(): Optional = amc.getOptional("amc") + + /** + * Folio number + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun folioNumber(): Optional = folioNumber.getOptional("folio_number") + + /** + * List of account holders linked to this mutual fund folio + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun linkedHolders(): Optional> = + linkedHolders.getOptional("linked_holders") + + /** + * Registrar and Transfer Agent name + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun registrar(): Optional = registrar.getOptional("registrar") + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun schemes(): Optional> = schemes.getOptional("schemes") + + /** + * Total value of the folio + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun value(): Optional = value.getOptional("value") + + /** + * Returns the raw JSON value of [additionalInfo]. + * + * Unlike [additionalInfo], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("additional_info") + @ExcludeMissing + fun _additionalInfo(): JsonField = additionalInfo + + /** + * Returns the raw JSON value of [amc]. + * + * Unlike [amc], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amc") @ExcludeMissing fun _amc(): JsonField = amc + + /** + * Returns the raw JSON value of [folioNumber]. + * + * Unlike [folioNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("folio_number") + @ExcludeMissing + fun _folioNumber(): JsonField = folioNumber + + /** + * Returns the raw JSON value of [linkedHolders]. + * + * Unlike [linkedHolders], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("linked_holders") + @ExcludeMissing + fun _linkedHolders(): JsonField> = linkedHolders + + /** + * Returns the raw JSON value of [registrar]. + * + * Unlike [registrar], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("registrar") @ExcludeMissing fun _registrar(): JsonField = registrar + + /** + * Returns the raw JSON value of [schemes]. + * + * Unlike [schemes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("schemes") @ExcludeMissing fun _schemes(): JsonField> = schemes + + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [MutualFund]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MutualFund]. */ + class Builder internal constructor() { - @JsonCreator - private constructor( - @JsonProperty("additional_info") - @ExcludeMissing - additionalInfo: JsonField = JsonMissing.of(), - @JsonProperty("cost") @ExcludeMissing cost: JsonField = JsonMissing.of(), - @JsonProperty("gain") @ExcludeMissing gain: JsonField = JsonMissing.of(), - @JsonProperty("isin") @ExcludeMissing isin: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("nav") @ExcludeMissing nav: JsonField = JsonMissing.of(), - @JsonProperty("nominees") - @ExcludeMissing - nominees: JsonField> = JsonMissing.of(), - @JsonProperty("transactions") - @ExcludeMissing - transactions: JsonField> = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("units") @ExcludeMissing units: JsonField = JsonMissing.of(), - @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), - ) : this( - additionalInfo, - cost, - gain, - isin, - name, - nav, - nominees, - transactions, - type, - units, - value, - mutableMapOf(), - ) + private var additionalInfo: JsonField = JsonMissing.of() + private var amc: JsonField = JsonMissing.of() + private var folioNumber: JsonField = JsonMissing.of() + private var linkedHolders: JsonField>? = null + private var registrar: JsonField = JsonMissing.of() + private var schemes: JsonField>? = null + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Additional information specific to the scheme - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun additionalInfo(): Optional = - additionalInfo.getOptional("additional_info") + @JvmSynthetic + internal fun from(mutualFund: MutualFund) = apply { + additionalInfo = mutualFund.additionalInfo + amc = mutualFund.amc + folioNumber = mutualFund.folioNumber + linkedHolders = mutualFund.linkedHolders.map { it.toMutableList() } + registrar = mutualFund.registrar + schemes = mutualFund.schemes.map { it.toMutableList() } + value = mutualFund.value + additionalProperties = mutualFund.additionalProperties.toMutableMap() + } + + /** Additional folio information */ + fun additionalInfo(additionalInfo: AdditionalInfo) = + additionalInfo(JsonField.of(additionalInfo)) /** - * Cost of investment + * Sets [Builder.additionalInfo] to an arbitrary JSON value. * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.additionalInfo] with a well-typed [AdditionalInfo] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun cost(): Optional = cost.getOptional("cost") + fun additionalInfo(additionalInfo: JsonField) = apply { + this.additionalInfo = additionalInfo + } - /** - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun gain(): Optional = gain.getOptional("gain") + /** Asset Management Company name */ + fun amc(amc: String) = amc(JsonField.of(amc)) /** - * ISIN code of the scheme + * Sets [Builder.amc] to an arbitrary JSON value. * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.amc] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun isin(): Optional = isin.getOptional("isin") + fun amc(amc: JsonField) = apply { this.amc = amc } + + /** Folio number */ + fun folioNumber(folioNumber: String) = folioNumber(JsonField.of(folioNumber)) /** - * Scheme name + * Sets [Builder.folioNumber] to an arbitrary JSON value. * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.folioNumber] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun name(): Optional = name.getOptional("name") + fun folioNumber(folioNumber: JsonField) = apply { + this.folioNumber = folioNumber + } + + /** List of account holders linked to this mutual fund folio */ + fun linkedHolders(linkedHolders: List) = + linkedHolders(JsonField.of(linkedHolders)) /** - * Net Asset Value per unit + * Sets [Builder.linkedHolders] to an arbitrary JSON value. * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.linkedHolders] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - fun nav(): Optional = nav.getOptional("nav") + fun linkedHolders(linkedHolders: JsonField>) = apply { + this.linkedHolders = linkedHolders.map { it.toMutableList() } + } /** - * List of nominees + * Adds a single [LinkedHolder] to [linkedHolders]. * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * @throws IllegalStateException if the field was previously set to a non-list. */ - fun nominees(): Optional> = nominees.getOptional("nominees") + fun addLinkedHolder(linkedHolder: LinkedHolder) = apply { + linkedHolders = + (linkedHolders ?: JsonField.of(mutableListOf())).also { + checkKnown("linkedHolders", it).add(linkedHolder) + } + } - /** - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun transactions(): Optional> = - transactions.getOptional("transactions") + /** Registrar and Transfer Agent name */ + fun registrar(registrar: String) = registrar(JsonField.of(registrar)) /** - * Type of mutual fund scheme + * Sets [Builder.registrar] to an arbitrary JSON value. * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.registrar] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun type(): Optional = type.getOptional("type") + fun registrar(registrar: JsonField) = apply { this.registrar = registrar } - /** - * Number of units held - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun units(): Optional = units.getOptional("units") + fun schemes(schemes: List) = schemes(JsonField.of(schemes)) /** - * Current market value of the holding + * Sets [Builder.schemes] to an arbitrary JSON value. * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * You should usually call [Builder.schemes] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun value(): Optional = value.getOptional("value") + fun schemes(schemes: JsonField>) = apply { + this.schemes = schemes.map { it.toMutableList() } + } /** - * Returns the raw JSON value of [additionalInfo]. + * Adds a single [Scheme] to [schemes]. * - * Unlike [additionalInfo], this method doesn't throw if the JSON field has an - * unexpected type. + * @throws IllegalStateException if the field was previously set to a non-list. */ - @JsonProperty("additional_info") - @ExcludeMissing - fun _additionalInfo(): JsonField = additionalInfo + fun addScheme(scheme: Scheme) = apply { + schemes = + (schemes ?: JsonField.of(mutableListOf())).also { + checkKnown("schemes", it).add(scheme) + } + } + + /** Total value of the folio */ + fun value(value: Float) = value(JsonField.of(value)) /** - * Returns the raw JSON value of [cost]. + * Sets [Builder.value] to an arbitrary JSON value. * - * Unlike [cost], this method doesn't throw if the JSON field has an unexpected type. + * You should usually call [Builder.value] with a well-typed [Float] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. */ - @JsonProperty("cost") @ExcludeMissing fun _cost(): JsonField = cost + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns the raw JSON value of [gain]. + * Returns an immutable instance of [MutualFund]. * - * Unlike [gain], this method doesn't throw if the JSON field has an unexpected type. + * Further updates to this [Builder] will not mutate the returned instance. */ - @JsonProperty("gain") @ExcludeMissing fun _gain(): JsonField = gain + fun build(): MutualFund = + MutualFund( + additionalInfo, + amc, + folioNumber, + (linkedHolders ?: JsonMissing.of()).map { it.toImmutable() }, + registrar, + (schemes ?: JsonMissing.of()).map { it.toImmutable() }, + value, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MutualFund = apply { + if (validated) { + return@apply + } + + additionalInfo().ifPresent { it.validate() } + amc() + folioNumber() + linkedHolders().ifPresent { it.forEach { it.validate() } } + registrar() + schemes().ifPresent { it.forEach { it.validate() } } + value() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (additionalInfo.asKnown().getOrNull()?.validity() ?: 0) + + (if (amc.asKnown().isPresent) 1 else 0) + + (if (folioNumber.asKnown().isPresent) 1 else 0) + + (linkedHolders.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (registrar.asKnown().isPresent) 1 else 0) + + (schemes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (value.asKnown().isPresent) 1 else 0) - /** - * Returns the raw JSON value of [isin]. - * - * Unlike [isin], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("isin") @ExcludeMissing fun _isin(): JsonField = isin + /** Additional folio information */ + class AdditionalInfo + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val kyc: JsonField, + private val pan: JsonField, + private val pankyc: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + @JsonCreator + private constructor( + @JsonProperty("kyc") @ExcludeMissing kyc: JsonField = JsonMissing.of(), + @JsonProperty("pan") @ExcludeMissing pan: JsonField = JsonMissing.of(), + @JsonProperty("pankyc") @ExcludeMissing pankyc: JsonField = JsonMissing.of(), + ) : this(kyc, pan, pankyc, mutableMapOf()) /** - * Returns the raw JSON value of [nav]. + * KYC status of the folio * - * Unlike [nav], this method doesn't throw if the JSON field has an unexpected type. + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - @JsonProperty("nav") @ExcludeMissing fun _nav(): JsonField = nav + fun kyc(): Optional = kyc.getOptional("kyc") /** - * Returns the raw JSON value of [nominees]. + * PAN associated with the folio * - * Unlike [nominees], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - @JsonProperty("nominees") - @ExcludeMissing - fun _nominees(): JsonField> = nominees + fun pan(): Optional = pan.getOptional("pan") /** - * Returns the raw JSON value of [transactions]. + * PAN KYC status * - * Unlike [transactions], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). */ - @JsonProperty("transactions") - @ExcludeMissing - fun _transactions(): JsonField> = transactions + fun pankyc(): Optional = pankyc.getOptional("pankyc") /** - * Returns the raw JSON value of [type]. + * Returns the raw JSON value of [kyc]. * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [kyc], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("kyc") @ExcludeMissing fun _kyc(): JsonField = kyc /** - * Returns the raw JSON value of [units]. + * Returns the raw JSON value of [pan]. * - * Unlike [units], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [pan], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("units") @ExcludeMissing fun _units(): JsonField = units + @JsonProperty("pan") @ExcludeMissing fun _pan(): JsonField = pan /** - * Returns the raw JSON value of [value]. + * Returns the raw JSON value of [pankyc]. * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [pankyc], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + @JsonProperty("pankyc") @ExcludeMissing fun _pankyc(): JsonField = pankyc @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -13703,203 +6929,61 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Scheme]. */ + /** Returns a mutable builder for constructing an instance of [AdditionalInfo]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Scheme]. */ + /** A builder for [AdditionalInfo]. */ class Builder internal constructor() { - private var additionalInfo: JsonField = JsonMissing.of() - private var cost: JsonField = JsonMissing.of() - private var gain: JsonField = JsonMissing.of() - private var isin: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var nav: JsonField = JsonMissing.of() - private var nominees: JsonField>? = null - private var transactions: JsonField>? = null - private var type: JsonField = JsonMissing.of() - private var units: JsonField = JsonMissing.of() - private var value: JsonField = JsonMissing.of() + private var kyc: JsonField = JsonMissing.of() + private var pan: JsonField = JsonMissing.of() + private var pankyc: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(scheme: Scheme) = apply { - additionalInfo = scheme.additionalInfo - cost = scheme.cost - gain = scheme.gain - isin = scheme.isin - name = scheme.name - nav = scheme.nav - nominees = scheme.nominees.map { it.toMutableList() } - transactions = scheme.transactions.map { it.toMutableList() } - type = scheme.type - units = scheme.units - value = scheme.value - additionalProperties = scheme.additionalProperties.toMutableMap() - } - - /** Additional information specific to the scheme */ - fun additionalInfo(additionalInfo: AdditionalInfo) = - additionalInfo(JsonField.of(additionalInfo)) - - /** - * Sets [Builder.additionalInfo] to an arbitrary JSON value. - * - * You should usually call [Builder.additionalInfo] with a well-typed - * [AdditionalInfo] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun additionalInfo(additionalInfo: JsonField) = apply { - this.additionalInfo = additionalInfo - } - - /** Cost of investment */ - fun cost(cost: Float) = cost(JsonField.of(cost)) - - /** - * Sets [Builder.cost] to an arbitrary JSON value. - * - * You should usually call [Builder.cost] with a well-typed [Float] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun cost(cost: JsonField) = apply { this.cost = cost } - - fun gain(gain: Gain) = gain(JsonField.of(gain)) - - /** - * Sets [Builder.gain] to an arbitrary JSON value. - * - * You should usually call [Builder.gain] with a well-typed [Gain] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun gain(gain: JsonField) = apply { this.gain = gain } - - /** ISIN code of the scheme */ - fun isin(isin: String) = isin(JsonField.of(isin)) - - /** - * Sets [Builder.isin] to an arbitrary JSON value. - * - * You should usually call [Builder.isin] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun isin(isin: JsonField) = apply { this.isin = isin } - - /** Scheme name */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** Net Asset Value per unit */ - fun nav(nav: Float) = nav(JsonField.of(nav)) - - /** - * Sets [Builder.nav] to an arbitrary JSON value. - * - * You should usually call [Builder.nav] with a well-typed [Float] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun nav(nav: JsonField) = apply { this.nav = nav } - - /** List of nominees */ - fun nominees(nominees: List) = nominees(JsonField.of(nominees)) - - /** - * Sets [Builder.nominees] to an arbitrary JSON value. - * - * You should usually call [Builder.nominees] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun nominees(nominees: JsonField>) = apply { - this.nominees = nominees.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [nominees]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addNominee(nominee: String) = apply { - nominees = - (nominees ?: JsonField.of(mutableListOf())).also { - checkKnown("nominees", it).add(nominee) - } - } - - fun transactions(transactions: List) = - transactions(JsonField.of(transactions)) - - /** - * Sets [Builder.transactions] to an arbitrary JSON value. - * - * You should usually call [Builder.transactions] with a well-typed - * `List` value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun transactions(transactions: JsonField>) = apply { - this.transactions = transactions.map { it.toMutableList() } - } - - /** - * Adds a single [Transaction] to [transactions]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTransaction(transaction: Transaction) = apply { - transactions = - (transactions ?: JsonField.of(mutableListOf())).also { - checkKnown("transactions", it).add(transaction) - } + internal fun from(additionalInfo: AdditionalInfo) = apply { + kyc = additionalInfo.kyc + pan = additionalInfo.pan + pankyc = additionalInfo.pankyc + additionalProperties = additionalInfo.additionalProperties.toMutableMap() } - /** Type of mutual fund scheme */ - fun type(type: Type) = type(JsonField.of(type)) + /** KYC status of the folio */ + fun kyc(kyc: String) = kyc(JsonField.of(kyc)) /** - * Sets [Builder.type] to an arbitrary JSON value. + * Sets [Builder.kyc] to an arbitrary JSON value. * - * You should usually call [Builder.type] with a well-typed [Type] value instead. + * You should usually call [Builder.kyc] with a well-typed [String] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun type(type: JsonField) = apply { this.type = type } + fun kyc(kyc: JsonField) = apply { this.kyc = kyc } - /** Number of units held */ - fun units(units: Float) = units(JsonField.of(units)) + /** PAN associated with the folio */ + fun pan(pan: String) = pan(JsonField.of(pan)) /** - * Sets [Builder.units] to an arbitrary JSON value. + * Sets [Builder.pan] to an arbitrary JSON value. * - * You should usually call [Builder.units] with a well-typed [Float] value instead. + * You should usually call [Builder.pan] with a well-typed [String] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun units(units: JsonField) = apply { this.units = units } + fun pan(pan: JsonField) = apply { this.pan = pan } - /** Current market value of the holding */ - fun value(value: Float) = value(JsonField.of(value)) + /** PAN KYC status */ + fun pankyc(pankyc: String) = pankyc(JsonField.of(pankyc)) /** - * Sets [Builder.value] to an arbitrary JSON value. + * Sets [Builder.pankyc] to an arbitrary JSON value. * - * You should usually call [Builder.value] with a well-typed [Float] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.pankyc] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - fun value(value: JsonField) = apply { this.value = value } + fun pankyc(pankyc: JsonField) = apply { this.pankyc = pankyc } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -13924,45 +7008,24 @@ private constructor( } /** - * Returns an immutable instance of [Scheme]. + * Returns an immutable instance of [AdditionalInfo]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Scheme = - Scheme( - additionalInfo, - cost, - gain, - isin, - name, - nav, - (nominees ?: JsonMissing.of()).map { it.toImmutable() }, - (transactions ?: JsonMissing.of()).map { it.toImmutable() }, - type, - units, - value, - additionalProperties.toMutableMap(), - ) + fun build(): AdditionalInfo = + AdditionalInfo(kyc, pan, pankyc, additionalProperties.toMutableMap()) } private var validated: Boolean = false - fun validate(): Scheme = apply { + fun validate(): AdditionalInfo = apply { if (validated) { return@apply } - additionalInfo().ifPresent { it.validate() } - cost() - gain().ifPresent { it.validate() } - isin() - name() - nav() - nominees() - transactions().ifPresent { it.forEach { it.validate() } } - type().ifPresent { it.validate() } - units() - value() + kyc() + pan() + pankyc() validated = true } @@ -13982,1742 +7045,1101 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (additionalInfo.asKnown().getOrNull()?.validity() ?: 0) + - (if (cost.asKnown().isPresent) 1 else 0) + - (gain.asKnown().getOrNull()?.validity() ?: 0) + - (if (isin.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (nav.asKnown().isPresent) 1 else 0) + - (nominees.asKnown().getOrNull()?.size ?: 0) + - (transactions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (units.asKnown().isPresent) 1 else 0) + - (if (value.asKnown().isPresent) 1 else 0) - - /** Additional information specific to the scheme */ - class AdditionalInfo - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val advisor: JsonField, - private val amfi: JsonField, - private val closeUnits: JsonField, - private val openUnits: JsonField, - private val rtaCode: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("advisor") - @ExcludeMissing - advisor: JsonField = JsonMissing.of(), - @JsonProperty("amfi") - @ExcludeMissing - amfi: JsonField = JsonMissing.of(), - @JsonProperty("close_units") - @ExcludeMissing - closeUnits: JsonField = JsonMissing.of(), - @JsonProperty("open_units") - @ExcludeMissing - openUnits: JsonField = JsonMissing.of(), - @JsonProperty("rta_code") - @ExcludeMissing - rtaCode: JsonField = JsonMissing.of(), - ) : this(advisor, amfi, closeUnits, openUnits, rtaCode, mutableMapOf()) - - /** - * Financial advisor name (CAMS/KFintech) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun advisor(): Optional = advisor.getOptional("advisor") - - /** - * AMFI code for the scheme (CAMS/KFintech) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun amfi(): Optional = amfi.getOptional("amfi") + (if (kyc.asKnown().isPresent) 1 else 0) + + (if (pan.asKnown().isPresent) 1 else 0) + + (if (pankyc.asKnown().isPresent) 1 else 0) - /** - * Closing balance units for the statement period - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun closeUnits(): Optional = closeUnits.getOptional("close_units") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Opening balance units for the statement period - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun openUnits(): Optional = openUnits.getOptional("open_units") + return other is AdditionalInfo && + kyc == other.kyc && + pan == other.pan && + pankyc == other.pankyc && + additionalProperties == other.additionalProperties + } - /** - * RTA code for the scheme (CAMS/KFintech) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun rtaCode(): Optional = rtaCode.getOptional("rta_code") + private val hashCode: Int by lazy { + Objects.hash(kyc, pan, pankyc, additionalProperties) + } - /** - * Returns the raw JSON value of [advisor]. - * - * Unlike [advisor], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("advisor") @ExcludeMissing fun _advisor(): JsonField = advisor + override fun hashCode(): Int = hashCode - /** - * Returns the raw JSON value of [amfi]. - * - * Unlike [amfi], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("amfi") @ExcludeMissing fun _amfi(): JsonField = amfi + override fun toString() = + "AdditionalInfo{kyc=$kyc, pan=$pan, pankyc=$pankyc, additionalProperties=$additionalProperties}" + } - /** - * Returns the raw JSON value of [closeUnits]. - * - * Unlike [closeUnits], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("close_units") - @ExcludeMissing - fun _closeUnits(): JsonField = closeUnits + class Scheme + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val additionalInfo: JsonField, + private val cost: JsonField, + private val gain: JsonField, + private val isin: JsonField, + private val name: JsonField, + private val nav: JsonField, + private val nominees: JsonField>, + private val transactions: JsonField>, + private val type: JsonField, + private val units: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Returns the raw JSON value of [openUnits]. - * - * Unlike [openUnits], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("open_units") + @JsonCreator + private constructor( + @JsonProperty("additional_info") @ExcludeMissing - fun _openUnits(): JsonField = openUnits - - /** - * Returns the raw JSON value of [rtaCode]. - * - * Unlike [rtaCode], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("rta_code") + additionalInfo: JsonField = JsonMissing.of(), + @JsonProperty("cost") @ExcludeMissing cost: JsonField = JsonMissing.of(), + @JsonProperty("gain") @ExcludeMissing gain: JsonField = JsonMissing.of(), + @JsonProperty("isin") @ExcludeMissing isin: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("nav") @ExcludeMissing nav: JsonField = JsonMissing.of(), + @JsonProperty("nominees") @ExcludeMissing - fun _rtaCode(): JsonField = rtaCode - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter + nominees: JsonField> = JsonMissing.of(), + @JsonProperty("transactions") @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + transactions: JsonField> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("units") @ExcludeMissing units: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this( + additionalInfo, + cost, + gain, + isin, + name, + nav, + nominees, + transactions, + type, + units, + value, + mutableMapOf(), + ) - fun toBuilder() = Builder().from(this) + /** + * Additional information specific to the scheme + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun additionalInfo(): Optional = + additionalInfo.getOptional("additional_info") - companion object { + /** + * Cost of investment + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun cost(): Optional = cost.getOptional("cost") - /** - * Returns a mutable builder for constructing an instance of [AdditionalInfo]. - */ - @JvmStatic fun builder() = Builder() - } + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun gain(): Optional = gain.getOptional("gain") - /** A builder for [AdditionalInfo]. */ - class Builder internal constructor() { + /** + * ISIN code of the scheme + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun isin(): Optional = isin.getOptional("isin") - private var advisor: JsonField = JsonMissing.of() - private var amfi: JsonField = JsonMissing.of() - private var closeUnits: JsonField = JsonMissing.of() - private var openUnits: JsonField = JsonMissing.of() - private var rtaCode: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + /** + * Scheme name + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") - @JvmSynthetic - internal fun from(additionalInfo: AdditionalInfo) = apply { - advisor = additionalInfo.advisor - amfi = additionalInfo.amfi - closeUnits = additionalInfo.closeUnits - openUnits = additionalInfo.openUnits - rtaCode = additionalInfo.rtaCode - additionalProperties = additionalInfo.additionalProperties.toMutableMap() - } + /** + * Net Asset Value per unit + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun nav(): Optional = nav.getOptional("nav") - /** Financial advisor name (CAMS/KFintech) */ - fun advisor(advisor: String) = advisor(JsonField.of(advisor)) + /** + * List of nominees + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun nominees(): Optional> = nominees.getOptional("nominees") - /** - * Sets [Builder.advisor] to an arbitrary JSON value. - * - * You should usually call [Builder.advisor] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun advisor(advisor: JsonField) = apply { this.advisor = advisor } + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun transactions(): Optional> = + transactions.getOptional("transactions") - /** AMFI code for the scheme (CAMS/KFintech) */ - fun amfi(amfi: String) = amfi(JsonField.of(amfi)) + /** + * Type of mutual fund scheme + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") - /** - * Sets [Builder.amfi] to an arbitrary JSON value. - * - * You should usually call [Builder.amfi] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun amfi(amfi: JsonField) = apply { this.amfi = amfi } + /** + * Number of units held + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun units(): Optional = units.getOptional("units") - /** Closing balance units for the statement period */ - fun closeUnits(closeUnits: Float?) = - closeUnits(JsonField.ofNullable(closeUnits)) + /** + * Current market value of the holding + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun value(): Optional = value.getOptional("value") - /** - * Alias for [Builder.closeUnits]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun closeUnits(closeUnits: Float) = closeUnits(closeUnits as Float?) + /** + * Returns the raw JSON value of [additionalInfo]. + * + * Unlike [additionalInfo], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("additional_info") + @ExcludeMissing + fun _additionalInfo(): JsonField = additionalInfo - /** Alias for calling [Builder.closeUnits] with `closeUnits.orElse(null)`. */ - fun closeUnits(closeUnits: Optional) = closeUnits(closeUnits.getOrNull()) + /** + * Returns the raw JSON value of [cost]. + * + * Unlike [cost], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cost") @ExcludeMissing fun _cost(): JsonField = cost - /** - * Sets [Builder.closeUnits] to an arbitrary JSON value. - * - * You should usually call [Builder.closeUnits] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun closeUnits(closeUnits: JsonField) = apply { - this.closeUnits = closeUnits - } + /** + * Returns the raw JSON value of [gain]. + * + * Unlike [gain], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("gain") @ExcludeMissing fun _gain(): JsonField = gain - /** Opening balance units for the statement period */ - fun openUnits(openUnits: Float?) = openUnits(JsonField.ofNullable(openUnits)) + /** + * Returns the raw JSON value of [isin]. + * + * Unlike [isin], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isin") @ExcludeMissing fun _isin(): JsonField = isin - /** - * Alias for [Builder.openUnits]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun openUnits(openUnits: Float) = openUnits(openUnits as Float?) + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** Alias for calling [Builder.openUnits] with `openUnits.orElse(null)`. */ - fun openUnits(openUnits: Optional) = openUnits(openUnits.getOrNull()) + /** + * Returns the raw JSON value of [nav]. + * + * Unlike [nav], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("nav") @ExcludeMissing fun _nav(): JsonField = nav - /** - * Sets [Builder.openUnits] to an arbitrary JSON value. - * - * You should usually call [Builder.openUnits] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun openUnits(openUnits: JsonField) = apply { - this.openUnits = openUnits - } + /** + * Returns the raw JSON value of [nominees]. + * + * Unlike [nominees], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("nominees") + @ExcludeMissing + fun _nominees(): JsonField> = nominees - /** RTA code for the scheme (CAMS/KFintech) */ - fun rtaCode(rtaCode: String) = rtaCode(JsonField.of(rtaCode)) + /** + * Returns the raw JSON value of [transactions]. + * + * Unlike [transactions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("transactions") + @ExcludeMissing + fun _transactions(): JsonField> = transactions - /** - * Sets [Builder.rtaCode] to an arbitrary JSON value. - * - * You should usually call [Builder.rtaCode] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun rtaCode(rtaCode: JsonField) = apply { this.rtaCode = rtaCode } + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** + * Returns the raw JSON value of [units]. + * + * Unlike [units], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("units") @ExcludeMissing fun _units(): JsonField = units - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [value]. + * + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + fun toBuilder() = Builder().from(this) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + companion object { - /** - * Returns an immutable instance of [AdditionalInfo]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AdditionalInfo = - AdditionalInfo( - advisor, - amfi, - closeUnits, - openUnits, - rtaCode, - additionalProperties.toMutableMap(), - ) - } + /** Returns a mutable builder for constructing an instance of [Scheme]. */ + @JvmStatic fun builder() = Builder() + } - private var validated: Boolean = false + /** A builder for [Scheme]. */ + class Builder internal constructor() { - fun validate(): AdditionalInfo = apply { - if (validated) { - return@apply - } + private var additionalInfo: JsonField = JsonMissing.of() + private var cost: JsonField = JsonMissing.of() + private var gain: JsonField = JsonMissing.of() + private var isin: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var nav: JsonField = JsonMissing.of() + private var nominees: JsonField>? = null + private var transactions: JsonField>? = null + private var type: JsonField = JsonMissing.of() + private var units: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - advisor() - amfi() - closeUnits() - openUnits() - rtaCode() - validated = true + @JvmSynthetic + internal fun from(scheme: Scheme) = apply { + additionalInfo = scheme.additionalInfo + cost = scheme.cost + gain = scheme.gain + isin = scheme.isin + name = scheme.name + nav = scheme.nav + nominees = scheme.nominees.map { it.toMutableList() } + transactions = scheme.transactions.map { it.toMutableList() } + type = scheme.type + units = scheme.units + value = scheme.value + additionalProperties = scheme.additionalProperties.toMutableMap() } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } + /** Additional information specific to the scheme */ + fun additionalInfo(additionalInfo: AdditionalInfo) = + additionalInfo(JsonField.of(additionalInfo)) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.additionalInfo] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.additionalInfo] with a well-typed + * [AdditionalInfo] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. */ - @JvmSynthetic - internal fun validity(): Int = - (if (advisor.asKnown().isPresent) 1 else 0) + - (if (amfi.asKnown().isPresent) 1 else 0) + - (if (closeUnits.asKnown().isPresent) 1 else 0) + - (if (openUnits.asKnown().isPresent) 1 else 0) + - (if (rtaCode.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is AdditionalInfo && - advisor == other.advisor && - amfi == other.amfi && - closeUnits == other.closeUnits && - openUnits == other.openUnits && - rtaCode == other.rtaCode && - additionalProperties == other.additionalProperties + fun additionalInfo(additionalInfo: JsonField) = apply { + this.additionalInfo = additionalInfo } - private val hashCode: Int by lazy { - Objects.hash( - advisor, - amfi, - closeUnits, - openUnits, - rtaCode, - additionalProperties, - ) - } + /** Cost of investment */ + fun cost(cost: Float) = cost(JsonField.of(cost)) - override fun hashCode(): Int = hashCode + /** + * Sets [Builder.cost] to an arbitrary JSON value. + * + * You should usually call [Builder.cost] with a well-typed [Float] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cost(cost: JsonField) = apply { this.cost = cost } - override fun toString() = - "AdditionalInfo{advisor=$advisor, amfi=$amfi, closeUnits=$closeUnits, openUnits=$openUnits, rtaCode=$rtaCode, additionalProperties=$additionalProperties}" - } + fun gain(gain: Gain) = gain(JsonField.of(gain)) - class Gain - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val absolute: JsonField, - private val percentage: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * Sets [Builder.gain] to an arbitrary JSON value. + * + * You should usually call [Builder.gain] with a well-typed [Gain] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun gain(gain: JsonField) = apply { this.gain = gain } - @JsonCreator - private constructor( - @JsonProperty("absolute") - @ExcludeMissing - absolute: JsonField = JsonMissing.of(), - @JsonProperty("percentage") - @ExcludeMissing - percentage: JsonField = JsonMissing.of(), - ) : this(absolute, percentage, mutableMapOf()) + /** ISIN code of the scheme */ + fun isin(isin: String) = isin(JsonField.of(isin)) /** - * Absolute gain or loss + * Sets [Builder.isin] to an arbitrary JSON value. * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * You should usually call [Builder.isin] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun absolute(): Optional = absolute.getOptional("absolute") + fun isin(isin: JsonField) = apply { this.isin = isin } + + /** Scheme name */ + fun name(name: String) = name(JsonField.of(name)) /** - * Percentage gain or loss + * Sets [Builder.name] to an arbitrary JSON value. * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun percentage(): Optional = percentage.getOptional("percentage") + fun name(name: JsonField) = apply { this.name = name } + + /** Net Asset Value per unit */ + fun nav(nav: Float) = nav(JsonField.of(nav)) /** - * Returns the raw JSON value of [absolute]. + * Sets [Builder.nav] to an arbitrary JSON value. * - * Unlike [absolute], this method doesn't throw if the JSON field has an unexpected - * type. + * You should usually call [Builder.nav] with a well-typed [Float] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - @JsonProperty("absolute") - @ExcludeMissing - fun _absolute(): JsonField = absolute + fun nav(nav: JsonField) = apply { this.nav = nav } + + /** List of nominees */ + fun nominees(nominees: List) = nominees(JsonField.of(nominees)) /** - * Returns the raw JSON value of [percentage]. + * Sets [Builder.nominees] to an arbitrary JSON value. * - * Unlike [percentage], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.nominees] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. */ - @JsonProperty("percentage") - @ExcludeMissing - fun _percentage(): JsonField = percentage - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + fun nominees(nominees: JsonField>) = apply { + this.nominees = nominees.map { it.toMutableList() } } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Gain]. */ - @JvmStatic fun builder() = Builder() + /** + * Adds a single [String] to [nominees]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addNominee(nominee: String) = apply { + nominees = + (nominees ?: JsonField.of(mutableListOf())).also { + checkKnown("nominees", it).add(nominee) + } } - /** A builder for [Gain]. */ - class Builder internal constructor() { - - private var absolute: JsonField = JsonMissing.of() - private var percentage: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(gain: Gain) = apply { - absolute = gain.absolute - percentage = gain.percentage - additionalProperties = gain.additionalProperties.toMutableMap() - } - - /** Absolute gain or loss */ - fun absolute(absolute: Float) = absolute(JsonField.of(absolute)) - - /** - * Sets [Builder.absolute] to an arbitrary JSON value. - * - * You should usually call [Builder.absolute] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun absolute(absolute: JsonField) = apply { this.absolute = absolute } + fun transactions(transactions: List) = + transactions(JsonField.of(transactions)) - /** Percentage gain or loss */ - fun percentage(percentage: Float) = percentage(JsonField.of(percentage)) + /** + * Sets [Builder.transactions] to an arbitrary JSON value. + * + * You should usually call [Builder.transactions] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun transactions(transactions: JsonField>) = apply { + this.transactions = transactions.map { it.toMutableList() } + } - /** - * Sets [Builder.percentage] to an arbitrary JSON value. - * - * You should usually call [Builder.percentage] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun percentage(percentage: JsonField) = apply { - this.percentage = percentage - } + /** + * Adds a single [Transaction] to [transactions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTransaction(transaction: Transaction) = apply { + transactions = + (transactions ?: JsonField.of(mutableListOf())).also { + checkKnown("transactions", it).add(transaction) + } + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + /** Type of mutual fund scheme */ + fun type(type: Type) = type(JsonField.of(type)) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + /** Number of units held */ + fun units(units: Float) = units(JsonField.of(units)) - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** + * Sets [Builder.units] to an arbitrary JSON value. + * + * You should usually call [Builder.units] with a well-typed [Float] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun units(units: JsonField) = apply { this.units = units } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** Current market value of the holding */ + fun value(value: Float) = value(JsonField.of(value)) - /** - * Returns an immutable instance of [Gain]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Gain = - Gain(absolute, percentage, additionalProperties.toMutableMap()) + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Float] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun value(value: JsonField) = apply { this.value = value } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - private var validated: Boolean = false + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun validate(): Gain = apply { - if (validated) { - return@apply + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - absolute() - percentage() - validated = true + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an immutable instance of [Scheme]. * - * Used for best match union deserialization. + * Further updates to this [Builder] will not mutate the returned instance. */ - @JvmSynthetic - internal fun validity(): Int = - (if (absolute.asKnown().isPresent) 1 else 0) + - (if (percentage.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun build(): Scheme = + Scheme( + additionalInfo, + cost, + gain, + isin, + name, + nav, + (nominees ?: JsonMissing.of()).map { it.toImmutable() }, + (transactions ?: JsonMissing.of()).map { it.toImmutable() }, + type, + units, + value, + additionalProperties.toMutableMap(), + ) + } - return other is Gain && - absolute == other.absolute && - percentage == other.percentage && - additionalProperties == other.additionalProperties - } + private var validated: Boolean = false - private val hashCode: Int by lazy { - Objects.hash(absolute, percentage, additionalProperties) + fun validate(): Scheme = apply { + if (validated) { + return@apply } - override fun hashCode(): Int = hashCode - - override fun toString() = - "Gain{absolute=$absolute, percentage=$percentage, additionalProperties=$additionalProperties}" + additionalInfo().ifPresent { it.validate() } + cost() + gain().ifPresent { it.validate() } + isin() + name() + nav() + nominees() + transactions().ifPresent { it.forEach { it.validate() } } + type().ifPresent { it.validate() } + units() + value() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + /** - * Unified transaction schema for all holding types (MF folios, equities, bonds, etc.) + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. */ - class Transaction + @JvmSynthetic + internal fun validity(): Int = + (additionalInfo.asKnown().getOrNull()?.validity() ?: 0) + + (if (cost.asKnown().isPresent) 1 else 0) + + (gain.asKnown().getOrNull()?.validity() ?: 0) + + (if (isin.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (nav.asKnown().isPresent) 1 else 0) + + (nominees.asKnown().getOrNull()?.size ?: 0) + + (transactions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (units.asKnown().isPresent) 1 else 0) + + (if (value.asKnown().isPresent) 1 else 0) + + /** Additional information specific to the scheme */ + class AdditionalInfo @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val additionalInfo: JsonField, - private val amount: JsonField, - private val balance: JsonField, - private val date: JsonField, - private val description: JsonField, - private val dividendRate: JsonField, - private val nav: JsonField, - private val type: JsonField, - private val units: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("additional_info") - @ExcludeMissing - additionalInfo: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("balance") - @ExcludeMissing - balance: JsonField = JsonMissing.of(), - @JsonProperty("date") - @ExcludeMissing - date: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("dividend_rate") - @ExcludeMissing - dividendRate: JsonField = JsonMissing.of(), - @JsonProperty("nav") @ExcludeMissing nav: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("units") - @ExcludeMissing - units: JsonField = JsonMissing.of(), - ) : this( - additionalInfo, - amount, - balance, - date, - description, - dividendRate, - nav, - type, - units, - mutableMapOf(), - ) - - /** - * Additional transaction-specific fields that vary by source - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun additionalInfo(): Optional = - additionalInfo.getOptional("additional_info") - - /** - * Transaction amount in currency (computed from units × price/NAV) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * Balance units after transaction - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun balance(): Optional = balance.getOptional("balance") + private val advisor: JsonField, + private val amfi: JsonField, + private val closeUnits: JsonField, + private val openUnits: JsonField, + private val rtaCode: JsonField, + private val additionalProperties: MutableMap, + ) { - /** - * Transaction date (YYYY-MM-DD) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun date(): Optional = date.getOptional("date") + @JsonCreator + private constructor( + @JsonProperty("advisor") + @ExcludeMissing + advisor: JsonField = JsonMissing.of(), + @JsonProperty("amfi") + @ExcludeMissing + amfi: JsonField = JsonMissing.of(), + @JsonProperty("close_units") + @ExcludeMissing + closeUnits: JsonField = JsonMissing.of(), + @JsonProperty("open_units") + @ExcludeMissing + openUnits: JsonField = JsonMissing.of(), + @JsonProperty("rta_code") + @ExcludeMissing + rtaCode: JsonField = JsonMissing.of(), + ) : this(advisor, amfi, closeUnits, openUnits, rtaCode, mutableMapOf()) /** - * Transaction description/particulars + * Financial advisor name (CAMS/KFintech) * * @throws CasParserInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun description(): Optional = description.getOptional("description") + fun advisor(): Optional = advisor.getOptional("advisor") /** - * Dividend rate (for DIVIDEND_PAYOUT transactions) + * AMFI code for the scheme (CAMS/KFintech) * * @throws CasParserInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun dividendRate(): Optional = dividendRate.getOptional("dividend_rate") + fun amfi(): Optional = amfi.getOptional("amfi") /** - * NAV/price per unit on transaction date + * Closing balance units for the statement period * * @throws CasParserInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun nav(): Optional = nav.getOptional("nav") + fun closeUnits(): Optional = closeUnits.getOptional("close_units") /** - * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, - * SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, - * DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, REVERSAL, - * UNKNOWN. + * Opening balance units for the statement period * * @throws CasParserInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun type(): Optional = type.getOptional("type") + fun openUnits(): Optional = openUnits.getOptional("open_units") /** - * Number of units involved in transaction + * RTA code for the scheme (CAMS/KFintech) * * @throws CasParserInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). */ - fun units(): Optional = units.getOptional("units") - - /** - * Returns the raw JSON value of [additionalInfo]. - * - * Unlike [additionalInfo], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("additional_info") - @ExcludeMissing - fun _additionalInfo(): JsonField = additionalInfo - - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + fun rtaCode(): Optional = rtaCode.getOptional("rta_code") /** - * Returns the raw JSON value of [balance]. + * Returns the raw JSON value of [advisor]. * - * Unlike [balance], this method doesn't throw if the JSON field has an unexpected + * Unlike [advisor], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("balance") @ExcludeMissing fun _balance(): JsonField = balance + @JsonProperty("advisor") @ExcludeMissing fun _advisor(): JsonField = advisor /** - * Returns the raw JSON value of [date]. + * Returns the raw JSON value of [amfi]. * - * Unlike [date], this method doesn't throw if the JSON field has an unexpected + * Unlike [amfi], this method doesn't throw if the JSON field has an unexpected * type. */ - @JsonProperty("date") @ExcludeMissing fun _date(): JsonField = date - - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + @JsonProperty("amfi") @ExcludeMissing fun _amfi(): JsonField = amfi /** - * Returns the raw JSON value of [dividendRate]. + * Returns the raw JSON value of [closeUnits]. * - * Unlike [dividendRate], this method doesn't throw if the JSON field has an + * Unlike [closeUnits], this method doesn't throw if the JSON field has an * unexpected type. */ - @JsonProperty("dividend_rate") + @JsonProperty("close_units") @ExcludeMissing - fun _dividendRate(): JsonField = dividendRate - - /** - * Returns the raw JSON value of [nav]. - * - * Unlike [nav], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("nav") @ExcludeMissing fun _nav(): JsonField = nav - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + fun _closeUnits(): JsonField = closeUnits /** - * Returns the raw JSON value of [units]. - * - * Unlike [units], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("units") @ExcludeMissing fun _units(): JsonField = units - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Transaction]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Transaction]. */ - class Builder internal constructor() { - - private var additionalInfo: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var balance: JsonField = JsonMissing.of() - private var date: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var dividendRate: JsonField = JsonMissing.of() - private var nav: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var units: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(transaction: Transaction) = apply { - additionalInfo = transaction.additionalInfo - amount = transaction.amount - balance = transaction.balance - date = transaction.date - description = transaction.description - dividendRate = transaction.dividendRate - nav = transaction.nav - type = transaction.type - units = transaction.units - additionalProperties = transaction.additionalProperties.toMutableMap() - } - - /** Additional transaction-specific fields that vary by source */ - fun additionalInfo(additionalInfo: AdditionalInfo) = - additionalInfo(JsonField.of(additionalInfo)) - - /** - * Sets [Builder.additionalInfo] to an arbitrary JSON value. - * - * You should usually call [Builder.additionalInfo] with a well-typed - * [AdditionalInfo] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun additionalInfo(additionalInfo: JsonField) = apply { - this.additionalInfo = additionalInfo - } - - /** Transaction amount in currency (computed from units × price/NAV) */ - fun amount(amount: Float?) = amount(JsonField.ofNullable(amount)) - - /** - * Alias for [Builder.amount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun amount(amount: Float) = amount(amount as Float?) - - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) - - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** Balance units after transaction */ - fun balance(balance: Float) = balance(JsonField.of(balance)) - - /** - * Sets [Builder.balance] to an arbitrary JSON value. - * - * You should usually call [Builder.balance] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun balance(balance: JsonField) = apply { this.balance = balance } - - /** Transaction date (YYYY-MM-DD) */ - fun date(date: LocalDate) = date(JsonField.of(date)) - - /** - * Sets [Builder.date] to an arbitrary JSON value. - * - * You should usually call [Builder.date] with a well-typed [LocalDate] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun date(date: JsonField) = apply { this.date = date } - - /** Transaction description/particulars */ - fun description(description: String) = description(JsonField.of(description)) - - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun description(description: JsonField) = apply { - this.description = description - } - - /** Dividend rate (for DIVIDEND_PAYOUT transactions) */ - fun dividendRate(dividendRate: Float?) = - dividendRate(JsonField.ofNullable(dividendRate)) - - /** - * Alias for [Builder.dividendRate]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun dividendRate(dividendRate: Float) = dividendRate(dividendRate as Float?) - - /** - * Alias for calling [Builder.dividendRate] with `dividendRate.orElse(null)`. - */ - fun dividendRate(dividendRate: Optional) = - dividendRate(dividendRate.getOrNull()) - - /** - * Sets [Builder.dividendRate] to an arbitrary JSON value. - * - * You should usually call [Builder.dividendRate] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun dividendRate(dividendRate: JsonField) = apply { - this.dividendRate = dividendRate - } - - /** NAV/price per unit on transaction date */ - fun nav(nav: Float?) = nav(JsonField.ofNullable(nav)) - - /** - * Alias for [Builder.nav]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun nav(nav: Float) = nav(nav as Float?) - - /** Alias for calling [Builder.nav] with `nav.orElse(null)`. */ - fun nav(nav: Optional) = nav(nav.getOrNull()) - - /** - * Sets [Builder.nav] to an arbitrary JSON value. - * - * You should usually call [Builder.nav] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun nav(nav: JsonField) = apply { this.nav = nav } - - /** - * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, - * SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, - * DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, - * REVERSAL, UNKNOWN. - */ - fun type(type: Type) = type(JsonField.of(type)) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - /** Number of units involved in transaction */ - fun units(units: Float) = units(JsonField.of(units)) - - /** - * Sets [Builder.units] to an arbitrary JSON value. - * - * You should usually call [Builder.units] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun units(units: JsonField) = apply { this.units = units } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Transaction]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Transaction = - Transaction( - additionalInfo, - amount, - balance, - date, - description, - dividendRate, - nav, - type, - units, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Transaction = apply { - if (validated) { - return@apply - } - - additionalInfo().ifPresent { it.validate() } - amount() - balance() - date() - description() - dividendRate() - nav() - type().ifPresent { it.validate() } - units() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } + * Returns the raw JSON value of [openUnits]. + * + * Unlike [openUnits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("open_units") + @ExcludeMissing + fun _openUnits(): JsonField = openUnits /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns the raw JSON value of [rtaCode]. * - * Used for best match union deserialization. + * Unlike [rtaCode], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JvmSynthetic - internal fun validity(): Int = - (additionalInfo.asKnown().getOrNull()?.validity() ?: 0) + - (if (amount.asKnown().isPresent) 1 else 0) + - (if (balance.asKnown().isPresent) 1 else 0) + - (if (date.asKnown().isPresent) 1 else 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (if (dividendRate.asKnown().isPresent) 1 else 0) + - (if (nav.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (units.asKnown().isPresent) 1 else 0) - - /** Additional transaction-specific fields that vary by source */ - class AdditionalInfo - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val capitalWithdrawal: JsonField, - private val credit: JsonField, - private val debit: JsonField, - private val incomeDistribution: JsonField, - private val orderNo: JsonField, - private val price: JsonField, - private val stampDuty: JsonField, - private val additionalProperties: MutableMap, - ) { + @JsonProperty("rta_code") + @ExcludeMissing + fun _rtaCode(): JsonField = rtaCode - @JsonCreator - private constructor( - @JsonProperty("capital_withdrawal") - @ExcludeMissing - capitalWithdrawal: JsonField = JsonMissing.of(), - @JsonProperty("credit") - @ExcludeMissing - credit: JsonField = JsonMissing.of(), - @JsonProperty("debit") - @ExcludeMissing - debit: JsonField = JsonMissing.of(), - @JsonProperty("income_distribution") - @ExcludeMissing - incomeDistribution: JsonField = JsonMissing.of(), - @JsonProperty("order_no") - @ExcludeMissing - orderNo: JsonField = JsonMissing.of(), - @JsonProperty("price") - @ExcludeMissing - price: JsonField = JsonMissing.of(), - @JsonProperty("stamp_duty") - @ExcludeMissing - stampDuty: JsonField = JsonMissing.of(), - ) : this( - capitalWithdrawal, - credit, - debit, - incomeDistribution, - orderNo, - price, - stampDuty, - mutableMapOf(), - ) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - /** - * Capital withdrawal amount (CDSL MF transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun capitalWithdrawal(): Optional = - capitalWithdrawal.getOptional("capital_withdrawal") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * Units credited (demat transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun credit(): Optional = credit.getOptional("credit") + fun toBuilder() = Builder().from(this) - /** - * Units debited (demat transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun debit(): Optional = debit.getOptional("debit") + companion object { /** - * Income distribution amount (CDSL MF transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). + * Returns a mutable builder for constructing an instance of [AdditionalInfo]. */ - fun incomeDistribution(): Optional = - incomeDistribution.getOptional("income_distribution") + @JvmStatic fun builder() = Builder() + } - /** - * Order/transaction reference number (demat transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun orderNo(): Optional = orderNo.getOptional("order_no") + /** A builder for [AdditionalInfo]. */ + class Builder internal constructor() { - /** - * Price per unit (NSDL/CDSL MF transactions) - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun price(): Optional = price.getOptional("price") + private var advisor: JsonField = JsonMissing.of() + private var amfi: JsonField = JsonMissing.of() + private var closeUnits: JsonField = JsonMissing.of() + private var openUnits: JsonField = JsonMissing.of() + private var rtaCode: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** - * Stamp duty charged - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun stampDuty(): Optional = stampDuty.getOptional("stamp_duty") + @JvmSynthetic + internal fun from(additionalInfo: AdditionalInfo) = apply { + advisor = additionalInfo.advisor + amfi = additionalInfo.amfi + closeUnits = additionalInfo.closeUnits + openUnits = additionalInfo.openUnits + rtaCode = additionalInfo.rtaCode + additionalProperties = additionalInfo.additionalProperties.toMutableMap() + } - /** - * Returns the raw JSON value of [capitalWithdrawal]. - * - * Unlike [capitalWithdrawal], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("capital_withdrawal") - @ExcludeMissing - fun _capitalWithdrawal(): JsonField = capitalWithdrawal + /** Financial advisor name (CAMS/KFintech) */ + fun advisor(advisor: String) = advisor(JsonField.of(advisor)) /** - * Returns the raw JSON value of [credit]. + * Sets [Builder.advisor] to an arbitrary JSON value. * - * Unlike [credit], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.advisor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - @JsonProperty("credit") @ExcludeMissing fun _credit(): JsonField = credit + fun advisor(advisor: JsonField) = apply { this.advisor = advisor } + + /** AMFI code for the scheme (CAMS/KFintech) */ + fun amfi(amfi: String) = amfi(JsonField.of(amfi)) /** - * Returns the raw JSON value of [debit]. + * Sets [Builder.amfi] to an arbitrary JSON value. * - * Unlike [debit], this method doesn't throw if the JSON field has an unexpected - * type. + * You should usually call [Builder.amfi] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - @JsonProperty("debit") @ExcludeMissing fun _debit(): JsonField = debit + fun amfi(amfi: JsonField) = apply { this.amfi = amfi } + + /** Closing balance units for the statement period */ + fun closeUnits(closeUnits: Float?) = + closeUnits(JsonField.ofNullable(closeUnits)) /** - * Returns the raw JSON value of [incomeDistribution]. + * Alias for [Builder.closeUnits]. * - * Unlike [incomeDistribution], this method doesn't throw if the JSON field has - * an unexpected type. + * This unboxed primitive overload exists for backwards compatibility. */ - @JsonProperty("income_distribution") - @ExcludeMissing - fun _incomeDistribution(): JsonField = incomeDistribution + fun closeUnits(closeUnits: Float) = closeUnits(closeUnits as Float?) + + /** Alias for calling [Builder.closeUnits] with `closeUnits.orElse(null)`. */ + fun closeUnits(closeUnits: Optional) = closeUnits(closeUnits.getOrNull()) /** - * Returns the raw JSON value of [orderNo]. + * Sets [Builder.closeUnits] to an arbitrary JSON value. * - * Unlike [orderNo], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.closeUnits] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - @JsonProperty("order_no") - @ExcludeMissing - fun _orderNo(): JsonField = orderNo + fun closeUnits(closeUnits: JsonField) = apply { + this.closeUnits = closeUnits + } + + /** Opening balance units for the statement period */ + fun openUnits(openUnits: Float?) = openUnits(JsonField.ofNullable(openUnits)) /** - * Returns the raw JSON value of [price]. + * Alias for [Builder.openUnits]. * - * Unlike [price], this method doesn't throw if the JSON field has an unexpected - * type. + * This unboxed primitive overload exists for backwards compatibility. */ - @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price + fun openUnits(openUnits: Float) = openUnits(openUnits as Float?) + + /** Alias for calling [Builder.openUnits] with `openUnits.orElse(null)`. */ + fun openUnits(openUnits: Optional) = openUnits(openUnits.getOrNull()) /** - * Returns the raw JSON value of [stampDuty]. + * Sets [Builder.openUnits] to an arbitrary JSON value. * - * Unlike [stampDuty], this method doesn't throw if the JSON field has an - * unexpected type. + * You should usually call [Builder.openUnits] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - @JsonProperty("stamp_duty") - @ExcludeMissing - fun _stampDuty(): JsonField = stampDuty - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [AdditionalInfo]. - */ - @JvmStatic fun builder() = Builder() + fun openUnits(openUnits: JsonField) = apply { + this.openUnits = openUnits } - /** A builder for [AdditionalInfo]. */ - class Builder internal constructor() { - - private var capitalWithdrawal: JsonField = JsonMissing.of() - private var credit: JsonField = JsonMissing.of() - private var debit: JsonField = JsonMissing.of() - private var incomeDistribution: JsonField = JsonMissing.of() - private var orderNo: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var stampDuty: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(additionalInfo: AdditionalInfo) = apply { - capitalWithdrawal = additionalInfo.capitalWithdrawal - credit = additionalInfo.credit - debit = additionalInfo.debit - incomeDistribution = additionalInfo.incomeDistribution - orderNo = additionalInfo.orderNo - price = additionalInfo.price - stampDuty = additionalInfo.stampDuty - additionalProperties = - additionalInfo.additionalProperties.toMutableMap() - } - - /** Capital withdrawal amount (CDSL MF transactions) */ - fun capitalWithdrawal(capitalWithdrawal: Float) = - capitalWithdrawal(JsonField.of(capitalWithdrawal)) - - /** - * Sets [Builder.capitalWithdrawal] to an arbitrary JSON value. - * - * You should usually call [Builder.capitalWithdrawal] with a well-typed - * [Float] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun capitalWithdrawal(capitalWithdrawal: JsonField) = apply { - this.capitalWithdrawal = capitalWithdrawal - } - - /** Units credited (demat transactions) */ - fun credit(credit: Float) = credit(JsonField.of(credit)) - - /** - * Sets [Builder.credit] to an arbitrary JSON value. - * - * You should usually call [Builder.credit] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun credit(credit: JsonField) = apply { this.credit = credit } - - /** Units debited (demat transactions) */ - fun debit(debit: Float) = debit(JsonField.of(debit)) - - /** - * Sets [Builder.debit] to an arbitrary JSON value. - * - * You should usually call [Builder.debit] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun debit(debit: JsonField) = apply { this.debit = debit } - - /** Income distribution amount (CDSL MF transactions) */ - fun incomeDistribution(incomeDistribution: Float) = - incomeDistribution(JsonField.of(incomeDistribution)) - - /** - * Sets [Builder.incomeDistribution] to an arbitrary JSON value. - * - * You should usually call [Builder.incomeDistribution] with a well-typed - * [Float] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun incomeDistribution(incomeDistribution: JsonField) = apply { - this.incomeDistribution = incomeDistribution - } - - /** Order/transaction reference number (demat transactions) */ - fun orderNo(orderNo: String) = orderNo(JsonField.of(orderNo)) - - /** - * Sets [Builder.orderNo] to an arbitrary JSON value. - * - * You should usually call [Builder.orderNo] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun orderNo(orderNo: JsonField) = apply { this.orderNo = orderNo } - - /** Price per unit (NSDL/CDSL MF transactions) */ - fun price(price: Float) = price(JsonField.of(price)) - - /** - * Sets [Builder.price] to an arbitrary JSON value. - * - * You should usually call [Builder.price] with a well-typed [Float] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun price(price: JsonField) = apply { this.price = price } - - /** Stamp duty charged */ - fun stampDuty(stampDuty: Float) = stampDuty(JsonField.of(stampDuty)) - - /** - * Sets [Builder.stampDuty] to an arbitrary JSON value. - * - * You should usually call [Builder.stampDuty] with a well-typed [Float] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun stampDuty(stampDuty: JsonField) = apply { - this.stampDuty = stampDuty - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + /** RTA code for the scheme (CAMS/KFintech) */ + fun rtaCode(rtaCode: String) = rtaCode(JsonField.of(rtaCode)) - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + /** + * Sets [Builder.rtaCode] to an arbitrary JSON value. + * + * You should usually call [Builder.rtaCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun rtaCode(rtaCode: JsonField) = apply { this.rtaCode = rtaCode } - /** - * Returns an immutable instance of [AdditionalInfo]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): AdditionalInfo = - AdditionalInfo( - capitalWithdrawal, - credit, - debit, - incomeDistribution, - orderNo, - price, - stampDuty, - additionalProperties.toMutableMap(), - ) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - private var validated: Boolean = false + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun validate(): AdditionalInfo = apply { - if (validated) { - return@apply + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - capitalWithdrawal() - credit() - debit() - incomeDistribution() - orderNo() - price() - stampDuty() - validated = true + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an immutable instance of [AdditionalInfo]. * - * Used for best match union deserialization. + * Further updates to this [Builder] will not mutate the returned instance. */ - @JvmSynthetic - internal fun validity(): Int = - (if (capitalWithdrawal.asKnown().isPresent) 1 else 0) + - (if (credit.asKnown().isPresent) 1 else 0) + - (if (debit.asKnown().isPresent) 1 else 0) + - (if (incomeDistribution.asKnown().isPresent) 1 else 0) + - (if (orderNo.asKnown().isPresent) 1 else 0) + - (if (price.asKnown().isPresent) 1 else 0) + - (if (stampDuty.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun build(): AdditionalInfo = + AdditionalInfo( + advisor, + amfi, + closeUnits, + openUnits, + rtaCode, + additionalProperties.toMutableMap(), + ) + } - return other is AdditionalInfo && - capitalWithdrawal == other.capitalWithdrawal && - credit == other.credit && - debit == other.debit && - incomeDistribution == other.incomeDistribution && - orderNo == other.orderNo && - price == other.price && - stampDuty == other.stampDuty && - additionalProperties == other.additionalProperties - } + private var validated: Boolean = false - private val hashCode: Int by lazy { - Objects.hash( - capitalWithdrawal, - credit, - debit, - incomeDistribution, - orderNo, - price, - stampDuty, - additionalProperties, - ) + fun validate(): AdditionalInfo = apply { + if (validated) { + return@apply } - override fun hashCode(): Int = hashCode - - override fun toString() = - "AdditionalInfo{capitalWithdrawal=$capitalWithdrawal, credit=$credit, debit=$debit, incomeDistribution=$incomeDistribution, orderNo=$orderNo, price=$price, stampDuty=$stampDuty, additionalProperties=$additionalProperties}" + advisor() + amfi() + closeUnits() + openUnits() + rtaCode() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + /** - * Transaction type. Possible values are PURCHASE, PURCHASE_SIP, REDEMPTION, - * SWITCH_IN, SWITCH_IN_MERGER, SWITCH_OUT, SWITCH_OUT_MERGER, DIVIDEND_PAYOUT, - * DIVIDEND_REINVEST, SEGREGATION, STAMP_DUTY_TAX, TDS_TAX, STT_TAX, MISC, REVERSAL, - * UNKNOWN. + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. */ - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value + @JvmSynthetic + internal fun validity(): Int = + (if (advisor.asKnown().isPresent) 1 else 0) + + (if (amfi.asKnown().isPresent) 1 else 0) + + (if (closeUnits.asKnown().isPresent) 1 else 0) + + (if (openUnits.asKnown().isPresent) 1 else 0) + + (if (rtaCode.asKnown().isPresent) 1 else 0) - companion object { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmField val PURCHASE = of("PURCHASE") + return other is AdditionalInfo && + advisor == other.advisor && + amfi == other.amfi && + closeUnits == other.closeUnits && + openUnits == other.openUnits && + rtaCode == other.rtaCode && + additionalProperties == other.additionalProperties + } - @JvmField val PURCHASE_SIP = of("PURCHASE_SIP") + private val hashCode: Int by lazy { + Objects.hash( + advisor, + amfi, + closeUnits, + openUnits, + rtaCode, + additionalProperties, + ) + } - @JvmField val REDEMPTION = of("REDEMPTION") + override fun hashCode(): Int = hashCode - @JvmField val SWITCH_IN = of("SWITCH_IN") + override fun toString() = + "AdditionalInfo{advisor=$advisor, amfi=$amfi, closeUnits=$closeUnits, openUnits=$openUnits, rtaCode=$rtaCode, additionalProperties=$additionalProperties}" + } - @JvmField val SWITCH_IN_MERGER = of("SWITCH_IN_MERGER") + class Gain + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val absolute: JsonField, + private val percentage: JsonField, + private val additionalProperties: MutableMap, + ) { - @JvmField val SWITCH_OUT = of("SWITCH_OUT") + @JsonCreator + private constructor( + @JsonProperty("absolute") + @ExcludeMissing + absolute: JsonField = JsonMissing.of(), + @JsonProperty("percentage") + @ExcludeMissing + percentage: JsonField = JsonMissing.of(), + ) : this(absolute, percentage, mutableMapOf()) - @JvmField val SWITCH_OUT_MERGER = of("SWITCH_OUT_MERGER") + /** + * Absolute gain or loss + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun absolute(): Optional = absolute.getOptional("absolute") - @JvmField val DIVIDEND_PAYOUT = of("DIVIDEND_PAYOUT") + /** + * Percentage gain or loss + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun percentage(): Optional = percentage.getOptional("percentage") - @JvmField val DIVIDEND_REINVEST = of("DIVIDEND_REINVEST") + /** + * Returns the raw JSON value of [absolute]. + * + * Unlike [absolute], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("absolute") + @ExcludeMissing + fun _absolute(): JsonField = absolute - @JvmField val SEGREGATION = of("SEGREGATION") + /** + * Returns the raw JSON value of [percentage]. + * + * Unlike [percentage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("percentage") + @ExcludeMissing + fun _percentage(): JsonField = percentage - @JvmField val STAMP_DUTY_TAX = of("STAMP_DUTY_TAX") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - @JvmField val TDS_TAX = of("TDS_TAX") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JvmField val STT_TAX = of("STT_TAX") + fun toBuilder() = Builder().from(this) - @JvmField val MISC = of("MISC") + companion object { - @JvmField val REVERSAL = of("REVERSAL") + /** Returns a mutable builder for constructing an instance of [Gain]. */ + @JvmStatic fun builder() = Builder() + } - @JvmField val UNKNOWN = of("UNKNOWN") + /** A builder for [Gain]. */ + class Builder internal constructor() { - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } + private var absolute: JsonField = JsonMissing.of() + private var percentage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - /** An enum containing [Type]'s known values. */ - enum class Known { - PURCHASE, - PURCHASE_SIP, - REDEMPTION, - SWITCH_IN, - SWITCH_IN_MERGER, - SWITCH_OUT, - SWITCH_OUT_MERGER, - DIVIDEND_PAYOUT, - DIVIDEND_REINVEST, - SEGREGATION, - STAMP_DUTY_TAX, - TDS_TAX, - STT_TAX, - MISC, - REVERSAL, - UNKNOWN, + @JvmSynthetic + internal fun from(gain: Gain) = apply { + absolute = gain.absolute + percentage = gain.percentage + additionalProperties = gain.additionalProperties.toMutableMap() } - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PURCHASE, - PURCHASE_SIP, - REDEMPTION, - SWITCH_IN, - SWITCH_IN_MERGER, - SWITCH_OUT, - SWITCH_OUT_MERGER, - DIVIDEND_PAYOUT, - DIVIDEND_REINVEST, - SEGREGATION, - STAMP_DUTY_TAX, - TDS_TAX, - STT_TAX, - MISC, - REVERSAL, - UNKNOWN, - /** - * An enum member indicating that [Type] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + /** Absolute gain or loss */ + fun absolute(absolute: Float) = absolute(JsonField.of(absolute)) /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * Sets [Builder.absolute] to an arbitrary JSON value. * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. + * You should usually call [Builder.absolute] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun value(): Value = - when (this) { - PURCHASE -> Value.PURCHASE - PURCHASE_SIP -> Value.PURCHASE_SIP - REDEMPTION -> Value.REDEMPTION - SWITCH_IN -> Value.SWITCH_IN - SWITCH_IN_MERGER -> Value.SWITCH_IN_MERGER - SWITCH_OUT -> Value.SWITCH_OUT - SWITCH_OUT_MERGER -> Value.SWITCH_OUT_MERGER - DIVIDEND_PAYOUT -> Value.DIVIDEND_PAYOUT - DIVIDEND_REINVEST -> Value.DIVIDEND_REINVEST - SEGREGATION -> Value.SEGREGATION - STAMP_DUTY_TAX -> Value.STAMP_DUTY_TAX - TDS_TAX -> Value.TDS_TAX - STT_TAX -> Value.STT_TAX - MISC -> Value.MISC - REVERSAL -> Value.REVERSAL - UNKNOWN -> Value.UNKNOWN - else -> Value._UNKNOWN - } + fun absolute(absolute: JsonField) = apply { this.absolute = absolute } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws CasParserInvalidDataException if this class instance's value is a not - * a known member. - */ - fun known(): Known = - when (this) { - PURCHASE -> Known.PURCHASE - PURCHASE_SIP -> Known.PURCHASE_SIP - REDEMPTION -> Known.REDEMPTION - SWITCH_IN -> Known.SWITCH_IN - SWITCH_IN_MERGER -> Known.SWITCH_IN_MERGER - SWITCH_OUT -> Known.SWITCH_OUT - SWITCH_OUT_MERGER -> Known.SWITCH_OUT_MERGER - DIVIDEND_PAYOUT -> Known.DIVIDEND_PAYOUT - DIVIDEND_REINVEST -> Known.DIVIDEND_REINVEST - SEGREGATION -> Known.SEGREGATION - STAMP_DUTY_TAX -> Known.STAMP_DUTY_TAX - TDS_TAX -> Known.TDS_TAX - STT_TAX -> Known.STT_TAX - MISC -> Known.MISC - REVERSAL -> Known.REVERSAL - UNKNOWN -> Known.UNKNOWN - else -> throw CasParserInvalidDataException("Unknown Type: $value") - } + /** Percentage gain or loss */ + fun percentage(percentage: Float) = percentage(JsonField.of(percentage)) - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. + /** + * Sets [Builder.percentage] to an arbitrary JSON value. * - * @throws CasParserInvalidDataException if this class instance's value does not - * have the expected primitive type. + * You should usually call [Builder.percentage] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - fun asString(): String = - _value().asString().orElseThrow { - CasParserInvalidDataException("Value is not a String") - } + fun percentage(percentage: JsonField) = apply { + this.percentage = percentage + } - private var validated: Boolean = false + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - fun validate(): Type = apply { - if (validated) { - return@apply + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - known() - validated = true + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an immutable instance of [Gain]. * - * Used for best match union deserialization. + * Further updates to this [Builder] will not mutate the returned instance. */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + fun build(): Gain = + Gain(absolute, percentage, additionalProperties.toMutableMap()) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return other is Type && value == other.value + fun validate(): Gain = apply { + if (validated) { + return@apply } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() + absolute() + percentage() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (absolute.asKnown().isPresent) 1 else 0) + + (if (percentage.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is Transaction && - additionalInfo == other.additionalInfo && - amount == other.amount && - balance == other.balance && - date == other.date && - description == other.description && - dividendRate == other.dividendRate && - nav == other.nav && - type == other.type && - units == other.units && + return other is Gain && + absolute == other.absolute && + percentage == other.percentage && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash( - additionalInfo, - amount, - balance, - date, - description, - dividendRate, - nav, - type, - units, - additionalProperties, - ) + Objects.hash(absolute, percentage, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "Transaction{additionalInfo=$additionalInfo, amount=$amount, balance=$balance, date=$date, description=$description, dividendRate=$dividendRate, nav=$nav, type=$type, units=$units, additionalProperties=$additionalProperties}" + "Gain{absolute=$absolute, percentage=$percentage, additionalProperties=$additionalProperties}" } /** Type of mutual fund scheme */ @@ -16921,186 +9343,6 @@ private constructor( "Fund{additionalInfo=$additionalInfo, cost=$cost, name=$name, nav=$nav, units=$units, value=$value, additionalProperties=$additionalProperties}" } - class LinkedHolder - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val name: JsonField, - private val pan: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("pan") @ExcludeMissing pan: JsonField = JsonMissing.of(), - ) : this(name, pan, mutableMapOf()) - - /** - * Name of the account holder - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * PAN of the account holder - * - * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun pan(): Optional = pan.getOptional("pan") - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [pan]. - * - * Unlike [pan], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("pan") @ExcludeMissing fun _pan(): JsonField = pan - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [LinkedHolder]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [LinkedHolder]. */ - class Builder internal constructor() { - - private var name: JsonField = JsonMissing.of() - private var pan: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(linkedHolder: LinkedHolder) = apply { - name = linkedHolder.name - pan = linkedHolder.pan - additionalProperties = linkedHolder.additionalProperties.toMutableMap() - } - - /** Name of the account holder */ - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** PAN of the account holder */ - fun pan(pan: String) = pan(JsonField.of(pan)) - - /** - * Sets [Builder.pan] to an arbitrary JSON value. - * - * You should usually call [Builder.pan] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun pan(pan: JsonField) = apply { this.pan = pan } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [LinkedHolder]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): LinkedHolder = - LinkedHolder(name, pan, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): LinkedHolder = apply { - if (validated) { - return@apply - } - - name() - pan() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: CasParserInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (name.asKnown().isPresent) 1 else 0) + (if (pan.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is LinkedHolder && - name == other.name && - pan == other.pan && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(name, pan, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "LinkedHolder{name=$name, pan=$pan, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/casparser/CasParserCdslParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/cdsl/CdslParsePdfParams.kt similarity index 95% rename from cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/casparser/CasParserCdslParams.kt rename to cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/cdsl/CdslParsePdfParams.kt index 8d90147..e9440f6 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/casparser/CasParserCdslParams.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/cdsl/CdslParsePdfParams.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.cas_parser.api.models.casparser +package com.cas_parser.api.models.cdsl import com.cas_parser.api.core.ExcludeMissing import com.cas_parser.api.core.JsonValue @@ -21,7 +21,7 @@ import java.util.Optional * This endpoint specifically parses CDSL CAS (Consolidated Account Statement) PDF files and returns * data in a unified format. Use this endpoint when you know the PDF is from CDSL. */ -class CasParserCdslParams +class CdslParsePdfParams private constructor( private val body: Body, private val additionalHeaders: Headers, @@ -85,13 +85,13 @@ private constructor( companion object { - @JvmStatic fun none(): CasParserCdslParams = builder().build() + @JvmStatic fun none(): CdslParsePdfParams = builder().build() - /** Returns a mutable builder for constructing an instance of [CasParserCdslParams]. */ + /** Returns a mutable builder for constructing an instance of [CdslParsePdfParams]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [CasParserCdslParams]. */ + /** A builder for [CdslParsePdfParams]. */ class Builder internal constructor() { private var body: Body.Builder = Body.builder() @@ -99,10 +99,10 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(casParserCdslParams: CasParserCdslParams) = apply { - body = casParserCdslParams.body.toBuilder() - additionalHeaders = casParserCdslParams.additionalHeaders.toBuilder() - additionalQueryParams = casParserCdslParams.additionalQueryParams.toBuilder() + internal fun from(cdslParsePdfParams: CdslParsePdfParams) = apply { + body = cdslParsePdfParams.body.toBuilder() + additionalHeaders = cdslParsePdfParams.additionalHeaders.toBuilder() + additionalQueryParams = cdslParsePdfParams.additionalQueryParams.toBuilder() } /** @@ -267,12 +267,12 @@ private constructor( } /** - * Returns an immutable instance of [CasParserCdslParams]. + * Returns an immutable instance of [CdslParsePdfParams]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): CasParserCdslParams = - CasParserCdslParams( + fun build(): CdslParsePdfParams = + CdslParsePdfParams( body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -489,7 +489,7 @@ private constructor( return true } - return other is CasParserCdslParams && + return other is CdslParsePdfParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams @@ -498,5 +498,5 @@ private constructor( override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = - "CasParserCdslParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "CdslParsePdfParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/cdsl/fetch/FetchRequestOtpParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/cdsl/fetch/FetchRequestOtpParams.kt new file mode 100644 index 0000000..34b641d --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/cdsl/fetch/FetchRequestOtpParams.kt @@ -0,0 +1,561 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.cdsl.fetch + +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.Params +import com.cas_parser.api.core.checkRequired +import com.cas_parser.api.core.http.Headers +import com.cas_parser.api.core.http.QueryParams +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects + +/** + * **Step 1 of 2**: Request OTP for CDSL CAS fetch. + * + * This endpoint: + * 1. Solves reCAPTCHA automatically (~15-20 seconds) + * 2. Submits login credentials to CDSL portal + * 3. Triggers OTP to user's registered mobile number + * + * After user receives OTP, call `/v4/cdsl/fetch/{session_id}/verify` to complete. + */ +class FetchRequestOtpParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * CDSL BO ID (16 digits) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun boId(): String = body.boId() + + /** + * Date of birth (YYYY-MM-DD) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dob(): String = body.dob() + + /** + * PAN number + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun pan(): String = body.pan() + + /** + * Returns the raw JSON value of [boId]. + * + * Unlike [boId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _boId(): JsonField = body._boId() + + /** + * Returns the raw JSON value of [dob]. + * + * Unlike [dob], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _dob(): JsonField = body._dob() + + /** + * Returns the raw JSON value of [pan]. + * + * Unlike [pan], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _pan(): JsonField = body._pan() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [FetchRequestOtpParams]. + * + * The following fields are required: + * ```java + * .boId() + * .dob() + * .pan() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FetchRequestOtpParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(fetchRequestOtpParams: FetchRequestOtpParams) = apply { + body = fetchRequestOtpParams.body.toBuilder() + additionalHeaders = fetchRequestOtpParams.additionalHeaders.toBuilder() + additionalQueryParams = fetchRequestOtpParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [boId] + * - [dob] + * - [pan] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** CDSL BO ID (16 digits) */ + fun boId(boId: String) = apply { body.boId(boId) } + + /** + * Sets [Builder.boId] to an arbitrary JSON value. + * + * You should usually call [Builder.boId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun boId(boId: JsonField) = apply { body.boId(boId) } + + /** Date of birth (YYYY-MM-DD) */ + fun dob(dob: String) = apply { body.dob(dob) } + + /** + * Sets [Builder.dob] to an arbitrary JSON value. + * + * You should usually call [Builder.dob] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun dob(dob: JsonField) = apply { body.dob(dob) } + + /** PAN number */ + fun pan(pan: String) = apply { body.pan(pan) } + + /** + * Sets [Builder.pan] to an arbitrary JSON value. + * + * You should usually call [Builder.pan] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun pan(pan: JsonField) = apply { body.pan(pan) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [FetchRequestOtpParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .boId() + * .dob() + * .pan() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FetchRequestOtpParams = + FetchRequestOtpParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val boId: JsonField, + private val dob: JsonField, + private val pan: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("bo_id") @ExcludeMissing boId: JsonField = JsonMissing.of(), + @JsonProperty("dob") @ExcludeMissing dob: JsonField = JsonMissing.of(), + @JsonProperty("pan") @ExcludeMissing pan: JsonField = JsonMissing.of(), + ) : this(boId, dob, pan, mutableMapOf()) + + /** + * CDSL BO ID (16 digits) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun boId(): String = boId.getRequired("bo_id") + + /** + * Date of birth (YYYY-MM-DD) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun dob(): String = dob.getRequired("dob") + + /** + * PAN number + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun pan(): String = pan.getRequired("pan") + + /** + * Returns the raw JSON value of [boId]. + * + * Unlike [boId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("bo_id") @ExcludeMissing fun _boId(): JsonField = boId + + /** + * Returns the raw JSON value of [dob]. + * + * Unlike [dob], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob + + /** + * Returns the raw JSON value of [pan]. + * + * Unlike [pan], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pan") @ExcludeMissing fun _pan(): JsonField = pan + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .boId() + * .dob() + * .pan() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var boId: JsonField? = null + private var dob: JsonField? = null + private var pan: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + boId = body.boId + dob = body.dob + pan = body.pan + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** CDSL BO ID (16 digits) */ + fun boId(boId: String) = boId(JsonField.of(boId)) + + /** + * Sets [Builder.boId] to an arbitrary JSON value. + * + * You should usually call [Builder.boId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun boId(boId: JsonField) = apply { this.boId = boId } + + /** Date of birth (YYYY-MM-DD) */ + fun dob(dob: String) = dob(JsonField.of(dob)) + + /** + * Sets [Builder.dob] to an arbitrary JSON value. + * + * You should usually call [Builder.dob] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dob(dob: JsonField) = apply { this.dob = dob } + + /** PAN number */ + fun pan(pan: String) = pan(JsonField.of(pan)) + + /** + * Sets [Builder.pan] to an arbitrary JSON value. + * + * You should usually call [Builder.pan] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun pan(pan: JsonField) = apply { this.pan = pan } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .boId() + * .dob() + * .pan() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("boId", boId), + checkRequired("dob", dob), + checkRequired("pan", pan), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + boId() + dob() + pan() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (boId.asKnown().isPresent) 1 else 0) + + (if (dob.asKnown().isPresent) 1 else 0) + + (if (pan.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + boId == other.boId && + dob == other.dob && + pan == other.pan && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(boId, dob, pan, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{boId=$boId, dob=$dob, pan=$pan, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FetchRequestOtpParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FetchRequestOtpParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/cdsl/fetch/FetchRequestOtpResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/cdsl/fetch/FetchRequestOtpResponse.kt new file mode 100644 index 0000000..cf0cf74 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/cdsl/fetch/FetchRequestOtpResponse.kt @@ -0,0 +1,219 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.cdsl.fetch + +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional + +class FetchRequestOtpResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val msg: JsonField, + private val sessionId: JsonField, + private val status: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("msg") @ExcludeMissing msg: JsonField = JsonMissing.of(), + @JsonProperty("session_id") @ExcludeMissing sessionId: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + ) : this(msg, sessionId, status, mutableMapOf()) + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun msg(): Optional = msg.getOptional("msg") + + /** + * Session ID for verify step + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sessionId(): Optional = sessionId.getOptional("session_id") + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * Returns the raw JSON value of [msg]. + * + * Unlike [msg], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("msg") @ExcludeMissing fun _msg(): JsonField = msg + + /** + * Returns the raw JSON value of [sessionId]. + * + * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField = sessionId + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FetchRequestOtpResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FetchRequestOtpResponse]. */ + class Builder internal constructor() { + + private var msg: JsonField = JsonMissing.of() + private var sessionId: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fetchRequestOtpResponse: FetchRequestOtpResponse) = apply { + msg = fetchRequestOtpResponse.msg + sessionId = fetchRequestOtpResponse.sessionId + status = fetchRequestOtpResponse.status + additionalProperties = fetchRequestOtpResponse.additionalProperties.toMutableMap() + } + + fun msg(msg: String) = msg(JsonField.of(msg)) + + /** + * Sets [Builder.msg] to an arbitrary JSON value. + * + * You should usually call [Builder.msg] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun msg(msg: JsonField) = apply { this.msg = msg } + + /** Session ID for verify step */ + fun sessionId(sessionId: String) = sessionId(JsonField.of(sessionId)) + + /** + * Sets [Builder.sessionId] to an arbitrary JSON value. + * + * You should usually call [Builder.sessionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun sessionId(sessionId: JsonField) = apply { this.sessionId = sessionId } + + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FetchRequestOtpResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FetchRequestOtpResponse = + FetchRequestOtpResponse(msg, sessionId, status, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): FetchRequestOtpResponse = apply { + if (validated) { + return@apply + } + + msg() + sessionId() + status() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (msg.asKnown().isPresent) 1 else 0) + + (if (sessionId.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FetchRequestOtpResponse && + msg == other.msg && + sessionId == other.sessionId && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(msg, sessionId, status, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FetchRequestOtpResponse{msg=$msg, sessionId=$sessionId, status=$status, additionalProperties=$additionalProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/cdsl/fetch/FetchVerifyOtpParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/cdsl/fetch/FetchVerifyOtpParams.kt new file mode 100644 index 0000000..854f921 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/cdsl/fetch/FetchVerifyOtpParams.kt @@ -0,0 +1,505 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.cdsl.fetch + +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.Params +import com.cas_parser.api.core.checkRequired +import com.cas_parser.api.core.http.Headers +import com.cas_parser.api.core.http.QueryParams +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * **Step 2 of 2**: Verify OTP and retrieve CDSL CAS files. + * + * After successful verification, CAS PDFs are fetched from CDSL portal, uploaded to cloud storage, + * and returned as direct download URLs. + */ +class FetchVerifyOtpParams +private constructor( + private val sessionId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun sessionId(): Optional = Optional.ofNullable(sessionId) + + /** + * OTP received on mobile + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun otp(): String = body.otp() + + /** + * Number of monthly statements to fetch (default 6) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun numPeriods(): Optional = body.numPeriods() + + /** + * Returns the raw JSON value of [otp]. + * + * Unlike [otp], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _otp(): JsonField = body._otp() + + /** + * Returns the raw JSON value of [numPeriods]. + * + * Unlike [numPeriods], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _numPeriods(): JsonField = body._numPeriods() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [FetchVerifyOtpParams]. + * + * The following fields are required: + * ```java + * .otp() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FetchVerifyOtpParams]. */ + class Builder internal constructor() { + + private var sessionId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(fetchVerifyOtpParams: FetchVerifyOtpParams) = apply { + sessionId = fetchVerifyOtpParams.sessionId + body = fetchVerifyOtpParams.body.toBuilder() + additionalHeaders = fetchVerifyOtpParams.additionalHeaders.toBuilder() + additionalQueryParams = fetchVerifyOtpParams.additionalQueryParams.toBuilder() + } + + fun sessionId(sessionId: String?) = apply { this.sessionId = sessionId } + + /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ + fun sessionId(sessionId: Optional) = sessionId(sessionId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [otp] + * - [numPeriods] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** OTP received on mobile */ + fun otp(otp: String) = apply { body.otp(otp) } + + /** + * Sets [Builder.otp] to an arbitrary JSON value. + * + * You should usually call [Builder.otp] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun otp(otp: JsonField) = apply { body.otp(otp) } + + /** Number of monthly statements to fetch (default 6) */ + fun numPeriods(numPeriods: Long) = apply { body.numPeriods(numPeriods) } + + /** + * Sets [Builder.numPeriods] to an arbitrary JSON value. + * + * You should usually call [Builder.numPeriods] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun numPeriods(numPeriods: JsonField) = apply { body.numPeriods(numPeriods) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [FetchVerifyOtpParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .otp() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FetchVerifyOtpParams = + FetchVerifyOtpParams( + sessionId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> sessionId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val otp: JsonField, + private val numPeriods: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("otp") @ExcludeMissing otp: JsonField = JsonMissing.of(), + @JsonProperty("num_periods") + @ExcludeMissing + numPeriods: JsonField = JsonMissing.of(), + ) : this(otp, numPeriods, mutableMapOf()) + + /** + * OTP received on mobile + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun otp(): String = otp.getRequired("otp") + + /** + * Number of monthly statements to fetch (default 6) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun numPeriods(): Optional = numPeriods.getOptional("num_periods") + + /** + * Returns the raw JSON value of [otp]. + * + * Unlike [otp], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("otp") @ExcludeMissing fun _otp(): JsonField = otp + + /** + * Returns the raw JSON value of [numPeriods]. + * + * Unlike [numPeriods], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("num_periods") @ExcludeMissing fun _numPeriods(): JsonField = numPeriods + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .otp() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var otp: JsonField? = null + private var numPeriods: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + otp = body.otp + numPeriods = body.numPeriods + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** OTP received on mobile */ + fun otp(otp: String) = otp(JsonField.of(otp)) + + /** + * Sets [Builder.otp] to an arbitrary JSON value. + * + * You should usually call [Builder.otp] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun otp(otp: JsonField) = apply { this.otp = otp } + + /** Number of monthly statements to fetch (default 6) */ + fun numPeriods(numPeriods: Long) = numPeriods(JsonField.of(numPeriods)) + + /** + * Sets [Builder.numPeriods] to an arbitrary JSON value. + * + * You should usually call [Builder.numPeriods] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun numPeriods(numPeriods: JsonField) = apply { this.numPeriods = numPeriods } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .otp() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("otp", otp), numPeriods, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + otp() + numPeriods() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (otp.asKnown().isPresent) 1 else 0) + (if (numPeriods.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + otp == other.otp && + numPeriods == other.numPeriods && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(otp, numPeriods, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{otp=$otp, numPeriods=$numPeriods, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FetchVerifyOtpParams && + sessionId == other.sessionId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(sessionId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "FetchVerifyOtpParams{sessionId=$sessionId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/cdsl/fetch/FetchVerifyOtpResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/cdsl/fetch/FetchVerifyOtpResponse.kt new file mode 100644 index 0000000..2e72418 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/cdsl/fetch/FetchVerifyOtpResponse.kt @@ -0,0 +1,411 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.cdsl.fetch + +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.checkKnown +import com.cas_parser.api.core.toImmutable +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class FetchVerifyOtpResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val files: JsonField>, + private val msg: JsonField, + private val status: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("files") @ExcludeMissing files: JsonField> = JsonMissing.of(), + @JsonProperty("msg") @ExcludeMissing msg: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + ) : this(files, msg, status, mutableMapOf()) + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun files(): Optional> = files.getOptional("files") + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun msg(): Optional = msg.getOptional("msg") + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * Returns the raw JSON value of [files]. + * + * Unlike [files], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("files") @ExcludeMissing fun _files(): JsonField> = files + + /** + * Returns the raw JSON value of [msg]. + * + * Unlike [msg], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("msg") @ExcludeMissing fun _msg(): JsonField = msg + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [FetchVerifyOtpResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FetchVerifyOtpResponse]. */ + class Builder internal constructor() { + + private var files: JsonField>? = null + private var msg: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fetchVerifyOtpResponse: FetchVerifyOtpResponse) = apply { + files = fetchVerifyOtpResponse.files.map { it.toMutableList() } + msg = fetchVerifyOtpResponse.msg + status = fetchVerifyOtpResponse.status + additionalProperties = fetchVerifyOtpResponse.additionalProperties.toMutableMap() + } + + fun files(files: List) = files(JsonField.of(files)) + + /** + * Sets [Builder.files] to an arbitrary JSON value. + * + * You should usually call [Builder.files] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun files(files: JsonField>) = apply { + this.files = files.map { it.toMutableList() } + } + + /** + * Adds a single [File] to [files]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFile(file: File) = apply { + files = + (files ?: JsonField.of(mutableListOf())).also { checkKnown("files", it).add(file) } + } + + fun msg(msg: String) = msg(JsonField.of(msg)) + + /** + * Sets [Builder.msg] to an arbitrary JSON value. + * + * You should usually call [Builder.msg] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun msg(msg: JsonField) = apply { this.msg = msg } + + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [FetchVerifyOtpResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FetchVerifyOtpResponse = + FetchVerifyOtpResponse( + (files ?: JsonMissing.of()).map { it.toImmutable() }, + msg, + status, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): FetchVerifyOtpResponse = apply { + if (validated) { + return@apply + } + + files().ifPresent { it.forEach { it.validate() } } + msg() + status() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (files.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (msg.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + class File + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val filename: JsonField, + private val url: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("filename") + @ExcludeMissing + filename: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + ) : this(filename, url, mutableMapOf()) + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun filename(): Optional = filename.getOptional("filename") + + /** + * Direct download URL (cloud storage) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun url(): Optional = url.getOptional("url") + + /** + * Returns the raw JSON value of [filename]. + * + * Unlike [filename], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filename") @ExcludeMissing fun _filename(): JsonField = filename + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [File]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [File]. */ + class Builder internal constructor() { + + private var filename: JsonField = JsonMissing.of() + private var url: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(file: File) = apply { + filename = file.filename + url = file.url + additionalProperties = file.additionalProperties.toMutableMap() + } + + fun filename(filename: String) = filename(JsonField.of(filename)) + + /** + * Sets [Builder.filename] to an arbitrary JSON value. + * + * You should usually call [Builder.filename] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun filename(filename: JsonField) = apply { this.filename = filename } + + /** Direct download URL (cloud storage) */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [File]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): File = File(filename, url, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): File = apply { + if (validated) { + return@apply + } + + filename() + url() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (filename.asKnown().isPresent) 1 else 0) + (if (url.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is File && + filename == other.filename && + url == other.url && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(filename, url, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "File{filename=$filename, url=$url, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FetchVerifyOtpResponse && + files == other.files && + msg == other.msg && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(files, msg, status, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FetchVerifyOtpResponse{files=$files, msg=$msg, status=$status, additionalProperties=$additionalProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/contractnote/ContractNoteParseParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/contractnote/ContractNoteParseParams.kt new file mode 100644 index 0000000..6c6ee9e --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/contractnote/ContractNoteParseParams.kt @@ -0,0 +1,742 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.contractnote + +import com.cas_parser.api.core.Enum +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.MultipartField +import com.cas_parser.api.core.Params +import com.cas_parser.api.core.http.Headers +import com.cas_parser.api.core.http.QueryParams +import com.cas_parser.api.core.toImmutable +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** + * This endpoint parses Contract Note PDF files from various brokers including Zerodha, Groww, + * Upstox, ICICI Securities, and others. + * + * **What is a Contract Note?** A contract note is a legal document that provides details of all + * trades executed by an investor. It includes: + * - Trade details with timestamps, quantities, and prices + * - Brokerage and charges breakdown + * - Settlement information + * - Regulatory compliance details + * + * **Supported Brokers:** + * - Zerodha Broking Limited + * - Groww Invest Tech Private Limited + * - Upstox (RKSV Securities) + * - ICICI Securities Limited + * - Auto-detection for unknown brokers + * + * **Key Features:** + * - **Auto-detection**: Automatically identifies broker type from PDF content + * - **Comprehensive parsing**: Extracts equity transactions, derivatives transactions, detailed + * trades, and charges + * - **Flexible input**: Accepts both file upload and URL-based PDF input + * - **Password protection**: Supports password-protected PDFs + * + * The API returns structured data including contract note information, client details, transaction + * summaries, and detailed trade-by-trade breakdowns. + */ +class ContractNoteParseParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Optional broker type override. If not provided, system will auto-detect. + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun brokerType(): Optional = body.brokerType() + + /** + * Password for the PDF file (usually PAN number for Zerodha) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun password(): Optional = body.password() + + /** + * Base64 encoded contract note PDF file + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun pdfFile(): Optional = body.pdfFile() + + /** + * URL to the contract note PDF file + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun pdfUrl(): Optional = body.pdfUrl() + + /** + * Returns the raw multipart value of [brokerType]. + * + * Unlike [brokerType], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _brokerType(): MultipartField = body._brokerType() + + /** + * Returns the raw multipart value of [password]. + * + * Unlike [password], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _password(): MultipartField = body._password() + + /** + * Returns the raw multipart value of [pdfFile]. + * + * Unlike [pdfFile], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _pdfFile(): MultipartField = body._pdfFile() + + /** + * Returns the raw multipart value of [pdfUrl]. + * + * Unlike [pdfUrl], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _pdfUrl(): MultipartField = body._pdfUrl() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): ContractNoteParseParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ContractNoteParseParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ContractNoteParseParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(contractNoteParseParams: ContractNoteParseParams) = apply { + body = contractNoteParseParams.body.toBuilder() + additionalHeaders = contractNoteParseParams.additionalHeaders.toBuilder() + additionalQueryParams = contractNoteParseParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [brokerType] + * - [password] + * - [pdfFile] + * - [pdfUrl] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Optional broker type override. If not provided, system will auto-detect. */ + fun brokerType(brokerType: BrokerType) = apply { body.brokerType(brokerType) } + + /** + * Sets [Builder.brokerType] to an arbitrary multipart value. + * + * You should usually call [Builder.brokerType] with a well-typed [BrokerType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun brokerType(brokerType: MultipartField) = apply { + body.brokerType(brokerType) + } + + /** Password for the PDF file (usually PAN number for Zerodha) */ + fun password(password: String) = apply { body.password(password) } + + /** + * Sets [Builder.password] to an arbitrary multipart value. + * + * You should usually call [Builder.password] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun password(password: MultipartField) = apply { body.password(password) } + + /** Base64 encoded contract note PDF file */ + fun pdfFile(pdfFile: String) = apply { body.pdfFile(pdfFile) } + + /** + * Sets [Builder.pdfFile] to an arbitrary multipart value. + * + * You should usually call [Builder.pdfFile] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun pdfFile(pdfFile: MultipartField) = apply { body.pdfFile(pdfFile) } + + /** URL to the contract note PDF file */ + fun pdfUrl(pdfUrl: String) = apply { body.pdfUrl(pdfUrl) } + + /** + * Sets [Builder.pdfUrl] to an arbitrary multipart value. + * + * You should usually call [Builder.pdfUrl] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun pdfUrl(pdfUrl: MultipartField) = apply { body.pdfUrl(pdfUrl) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [ContractNoteParseParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ContractNoteParseParams = + ContractNoteParseParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Map> = + (mapOf( + "broker_type" to _brokerType(), + "password" to _password(), + "pdf_file" to _pdfFile(), + "pdf_url" to _pdfUrl(), + ) + _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) + .toImmutable() + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val brokerType: MultipartField, + private val password: MultipartField, + private val pdfFile: MultipartField, + private val pdfUrl: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * Optional broker type override. If not provided, system will auto-detect. + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun brokerType(): Optional = brokerType.value.getOptional("broker_type") + + /** + * Password for the PDF file (usually PAN number for Zerodha) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun password(): Optional = password.value.getOptional("password") + + /** + * Base64 encoded contract note PDF file + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun pdfFile(): Optional = pdfFile.value.getOptional("pdf_file") + + /** + * URL to the contract note PDF file + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun pdfUrl(): Optional = pdfUrl.value.getOptional("pdf_url") + + /** + * Returns the raw multipart value of [brokerType]. + * + * Unlike [brokerType], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("broker_type") + @ExcludeMissing + fun _brokerType(): MultipartField = brokerType + + /** + * Returns the raw multipart value of [password]. + * + * Unlike [password], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("password") @ExcludeMissing fun _password(): MultipartField = password + + /** + * Returns the raw multipart value of [pdfFile]. + * + * Unlike [pdfFile], this method doesn't throw if the multipart field has an unexpected + * type. + */ + @JsonProperty("pdf_file") @ExcludeMissing fun _pdfFile(): MultipartField = pdfFile + + /** + * Returns the raw multipart value of [pdfUrl]. + * + * Unlike [pdfUrl], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("pdf_url") @ExcludeMissing fun _pdfUrl(): MultipartField = pdfUrl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var brokerType: MultipartField = MultipartField.of(null) + private var password: MultipartField = MultipartField.of(null) + private var pdfFile: MultipartField = MultipartField.of(null) + private var pdfUrl: MultipartField = MultipartField.of(null) + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + brokerType = body.brokerType + password = body.password + pdfFile = body.pdfFile + pdfUrl = body.pdfUrl + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** Optional broker type override. If not provided, system will auto-detect. */ + fun brokerType(brokerType: BrokerType) = brokerType(MultipartField.of(brokerType)) + + /** + * Sets [Builder.brokerType] to an arbitrary multipart value. + * + * You should usually call [Builder.brokerType] with a well-typed [BrokerType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun brokerType(brokerType: MultipartField) = apply { + this.brokerType = brokerType + } + + /** Password for the PDF file (usually PAN number for Zerodha) */ + fun password(password: String) = password(MultipartField.of(password)) + + /** + * Sets [Builder.password] to an arbitrary multipart value. + * + * You should usually call [Builder.password] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun password(password: MultipartField) = apply { this.password = password } + + /** Base64 encoded contract note PDF file */ + fun pdfFile(pdfFile: String) = pdfFile(MultipartField.of(pdfFile)) + + /** + * Sets [Builder.pdfFile] to an arbitrary multipart value. + * + * You should usually call [Builder.pdfFile] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pdfFile(pdfFile: MultipartField) = apply { this.pdfFile = pdfFile } + + /** URL to the contract note PDF file */ + fun pdfUrl(pdfUrl: String) = pdfUrl(MultipartField.of(pdfUrl)) + + /** + * Sets [Builder.pdfUrl] to an arbitrary multipart value. + * + * You should usually call [Builder.pdfUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pdfUrl(pdfUrl: MultipartField) = apply { this.pdfUrl = pdfUrl } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body(brokerType, password, pdfFile, pdfUrl, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + brokerType().ifPresent { it.validate() } + password() + pdfFile() + pdfUrl() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + brokerType == other.brokerType && + password == other.password && + pdfFile == other.pdfFile && + pdfUrl == other.pdfUrl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(brokerType, password, pdfFile, pdfUrl, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{brokerType=$brokerType, password=$password, pdfFile=$pdfFile, pdfUrl=$pdfUrl, additionalProperties=$additionalProperties}" + } + + /** Optional broker type override. If not provided, system will auto-detect. */ + class BrokerType @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ZERODHA = of("zerodha") + + @JvmField val GROWW = of("groww") + + @JvmField val UPSTOX = of("upstox") + + @JvmField val ICICI = of("icici") + + @JvmStatic fun of(value: String) = BrokerType(JsonField.of(value)) + } + + /** An enum containing [BrokerType]'s known values. */ + enum class Known { + ZERODHA, + GROWW, + UPSTOX, + ICICI, + } + + /** + * An enum containing [BrokerType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BrokerType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ZERODHA, + GROWW, + UPSTOX, + ICICI, + /** + * An enum member indicating that [BrokerType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ZERODHA -> Value.ZERODHA + GROWW -> Value.GROWW + UPSTOX -> Value.UPSTOX + ICICI -> Value.ICICI + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CasParserInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ZERODHA -> Known.ZERODHA + GROWW -> Known.GROWW + UPSTOX -> Known.UPSTOX + ICICI -> Known.ICICI + else -> throw CasParserInvalidDataException("Unknown BrokerType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CasParserInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CasParserInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): BrokerType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrokerType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ContractNoteParseParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "ContractNoteParseParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/contractnote/ContractNoteParseResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/contractnote/ContractNoteParseResponse.kt new file mode 100644 index 0000000..370d8b0 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/contractnote/ContractNoteParseResponse.kt @@ -0,0 +1,3934 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.contractnote + +import com.cas_parser.api.core.Enum +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.checkKnown +import com.cas_parser.api.core.toImmutable +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.time.LocalDate +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class ContractNoteParseResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val data: JsonField, + private val msg: JsonField, + private val status: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("data") @ExcludeMissing data: JsonField = JsonMissing.of(), + @JsonProperty("msg") @ExcludeMissing msg: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + ) : this(data, msg, status, mutableMapOf()) + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun data(): Optional = data.getOptional("data") + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun msg(): Optional = msg.getOptional("msg") + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * Returns the raw JSON value of [data]. + * + * Unlike [data], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + /** + * Returns the raw JSON value of [msg]. + * + * Unlike [msg], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("msg") @ExcludeMissing fun _msg(): JsonField = msg + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ContractNoteParseResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ContractNoteParseResponse]. */ + class Builder internal constructor() { + + private var data: JsonField = JsonMissing.of() + private var msg: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(contractNoteParseResponse: ContractNoteParseResponse) = apply { + data = contractNoteParseResponse.data + msg = contractNoteParseResponse.msg + status = contractNoteParseResponse.status + additionalProperties = contractNoteParseResponse.additionalProperties.toMutableMap() + } + + fun data(data: Data) = data(JsonField.of(data)) + + /** + * Sets [Builder.data] to an arbitrary JSON value. + * + * You should usually call [Builder.data] with a well-typed [Data] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun data(data: JsonField) = apply { this.data = data } + + fun msg(msg: String) = msg(JsonField.of(msg)) + + /** + * Sets [Builder.msg] to an arbitrary JSON value. + * + * You should usually call [Builder.msg] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun msg(msg: JsonField) = apply { this.msg = msg } + + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ContractNoteParseResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ContractNoteParseResponse = + ContractNoteParseResponse(data, msg, status, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): ContractNoteParseResponse = apply { + if (validated) { + return@apply + } + + data().ifPresent { it.validate() } + msg() + status() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (data.asKnown().getOrNull()?.validity() ?: 0) + + (if (msg.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + class Data + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val brokerInfo: JsonField, + private val chargesSummary: JsonField, + private val clientInfo: JsonField, + private val contractNoteInfo: JsonField, + private val derivativesTransactions: JsonField>, + private val detailedTrades: JsonField>, + private val equityTransactions: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("broker_info") + @ExcludeMissing + brokerInfo: JsonField = JsonMissing.of(), + @JsonProperty("charges_summary") + @ExcludeMissing + chargesSummary: JsonField = JsonMissing.of(), + @JsonProperty("client_info") + @ExcludeMissing + clientInfo: JsonField = JsonMissing.of(), + @JsonProperty("contract_note_info") + @ExcludeMissing + contractNoteInfo: JsonField = JsonMissing.of(), + @JsonProperty("derivatives_transactions") + @ExcludeMissing + derivativesTransactions: JsonField> = JsonMissing.of(), + @JsonProperty("detailed_trades") + @ExcludeMissing + detailedTrades: JsonField> = JsonMissing.of(), + @JsonProperty("equity_transactions") + @ExcludeMissing + equityTransactions: JsonField> = JsonMissing.of(), + ) : this( + brokerInfo, + chargesSummary, + clientInfo, + contractNoteInfo, + derivativesTransactions, + detailedTrades, + equityTransactions, + mutableMapOf(), + ) + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun brokerInfo(): Optional = brokerInfo.getOptional("broker_info") + + /** + * Breakdown of various charges and fees + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun chargesSummary(): Optional = + chargesSummary.getOptional("charges_summary") + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun clientInfo(): Optional = clientInfo.getOptional("client_info") + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun contractNoteInfo(): Optional = + contractNoteInfo.getOptional("contract_note_info") + + /** + * Summary of derivatives transactions + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun derivativesTransactions(): Optional> = + derivativesTransactions.getOptional("derivatives_transactions") + + /** + * Detailed breakdown of all individual trades + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun detailedTrades(): Optional> = + detailedTrades.getOptional("detailed_trades") + + /** + * Summary of equity transactions grouped by security + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun equityTransactions(): Optional> = + equityTransactions.getOptional("equity_transactions") + + /** + * Returns the raw JSON value of [brokerInfo]. + * + * Unlike [brokerInfo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("broker_info") + @ExcludeMissing + fun _brokerInfo(): JsonField = brokerInfo + + /** + * Returns the raw JSON value of [chargesSummary]. + * + * Unlike [chargesSummary], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("charges_summary") + @ExcludeMissing + fun _chargesSummary(): JsonField = chargesSummary + + /** + * Returns the raw JSON value of [clientInfo]. + * + * Unlike [clientInfo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("client_info") + @ExcludeMissing + fun _clientInfo(): JsonField = clientInfo + + /** + * Returns the raw JSON value of [contractNoteInfo]. + * + * Unlike [contractNoteInfo], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("contract_note_info") + @ExcludeMissing + fun _contractNoteInfo(): JsonField = contractNoteInfo + + /** + * Returns the raw JSON value of [derivativesTransactions]. + * + * Unlike [derivativesTransactions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("derivatives_transactions") + @ExcludeMissing + fun _derivativesTransactions(): JsonField> = + derivativesTransactions + + /** + * Returns the raw JSON value of [detailedTrades]. + * + * Unlike [detailedTrades], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("detailed_trades") + @ExcludeMissing + fun _detailedTrades(): JsonField> = detailedTrades + + /** + * Returns the raw JSON value of [equityTransactions]. + * + * Unlike [equityTransactions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("equity_transactions") + @ExcludeMissing + fun _equityTransactions(): JsonField> = equityTransactions + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Data]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Data]. */ + class Builder internal constructor() { + + private var brokerInfo: JsonField = JsonMissing.of() + private var chargesSummary: JsonField = JsonMissing.of() + private var clientInfo: JsonField = JsonMissing.of() + private var contractNoteInfo: JsonField = JsonMissing.of() + private var derivativesTransactions: JsonField>? = + null + private var detailedTrades: JsonField>? = null + private var equityTransactions: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(data: Data) = apply { + brokerInfo = data.brokerInfo + chargesSummary = data.chargesSummary + clientInfo = data.clientInfo + contractNoteInfo = data.contractNoteInfo + derivativesTransactions = data.derivativesTransactions.map { it.toMutableList() } + detailedTrades = data.detailedTrades.map { it.toMutableList() } + equityTransactions = data.equityTransactions.map { it.toMutableList() } + additionalProperties = data.additionalProperties.toMutableMap() + } + + fun brokerInfo(brokerInfo: BrokerInfo) = brokerInfo(JsonField.of(brokerInfo)) + + /** + * Sets [Builder.brokerInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.brokerInfo] with a well-typed [BrokerInfo] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun brokerInfo(brokerInfo: JsonField) = apply { + this.brokerInfo = brokerInfo + } + + /** Breakdown of various charges and fees */ + fun chargesSummary(chargesSummary: ChargesSummary) = + chargesSummary(JsonField.of(chargesSummary)) + + /** + * Sets [Builder.chargesSummary] to an arbitrary JSON value. + * + * You should usually call [Builder.chargesSummary] with a well-typed [ChargesSummary] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun chargesSummary(chargesSummary: JsonField) = apply { + this.chargesSummary = chargesSummary + } + + fun clientInfo(clientInfo: ClientInfo) = clientInfo(JsonField.of(clientInfo)) + + /** + * Sets [Builder.clientInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.clientInfo] with a well-typed [ClientInfo] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun clientInfo(clientInfo: JsonField) = apply { + this.clientInfo = clientInfo + } + + fun contractNoteInfo(contractNoteInfo: ContractNoteInfo) = + contractNoteInfo(JsonField.of(contractNoteInfo)) + + /** + * Sets [Builder.contractNoteInfo] to an arbitrary JSON value. + * + * You should usually call [Builder.contractNoteInfo] with a well-typed + * [ContractNoteInfo] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun contractNoteInfo(contractNoteInfo: JsonField) = apply { + this.contractNoteInfo = contractNoteInfo + } + + /** Summary of derivatives transactions */ + fun derivativesTransactions(derivativesTransactions: List) = + derivativesTransactions(JsonField.of(derivativesTransactions)) + + /** + * Sets [Builder.derivativesTransactions] to an arbitrary JSON value. + * + * You should usually call [Builder.derivativesTransactions] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun derivativesTransactions( + derivativesTransactions: JsonField> + ) = apply { + this.derivativesTransactions = derivativesTransactions.map { it.toMutableList() } + } + + /** + * Adds a single [DerivativesTransaction] to [derivativesTransactions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDerivativesTransaction(derivativesTransaction: DerivativesTransaction) = apply { + derivativesTransactions = + (derivativesTransactions ?: JsonField.of(mutableListOf())).also { + checkKnown("derivativesTransactions", it).add(derivativesTransaction) + } + } + + /** Detailed breakdown of all individual trades */ + fun detailedTrades(detailedTrades: List) = + detailedTrades(JsonField.of(detailedTrades)) + + /** + * Sets [Builder.detailedTrades] to an arbitrary JSON value. + * + * You should usually call [Builder.detailedTrades] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun detailedTrades(detailedTrades: JsonField>) = apply { + this.detailedTrades = detailedTrades.map { it.toMutableList() } + } + + /** + * Adds a single [DetailedTrade] to [detailedTrades]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addDetailedTrade(detailedTrade: DetailedTrade) = apply { + detailedTrades = + (detailedTrades ?: JsonField.of(mutableListOf())).also { + checkKnown("detailedTrades", it).add(detailedTrade) + } + } + + /** Summary of equity transactions grouped by security */ + fun equityTransactions(equityTransactions: List) = + equityTransactions(JsonField.of(equityTransactions)) + + /** + * Sets [Builder.equityTransactions] to an arbitrary JSON value. + * + * You should usually call [Builder.equityTransactions] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun equityTransactions(equityTransactions: JsonField>) = apply { + this.equityTransactions = equityTransactions.map { it.toMutableList() } + } + + /** + * Adds a single [EquityTransaction] to [equityTransactions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEquityTransaction(equityTransaction: EquityTransaction) = apply { + equityTransactions = + (equityTransactions ?: JsonField.of(mutableListOf())).also { + checkKnown("equityTransactions", it).add(equityTransaction) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Data]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Data = + Data( + brokerInfo, + chargesSummary, + clientInfo, + contractNoteInfo, + (derivativesTransactions ?: JsonMissing.of()).map { it.toImmutable() }, + (detailedTrades ?: JsonMissing.of()).map { it.toImmutable() }, + (equityTransactions ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Data = apply { + if (validated) { + return@apply + } + + brokerInfo().ifPresent { it.validate() } + chargesSummary().ifPresent { it.validate() } + clientInfo().ifPresent { it.validate() } + contractNoteInfo().ifPresent { it.validate() } + derivativesTransactions().ifPresent { it.forEach { it.validate() } } + detailedTrades().ifPresent { it.forEach { it.validate() } } + equityTransactions().ifPresent { it.forEach { it.validate() } } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (brokerInfo.asKnown().getOrNull()?.validity() ?: 0) + + (chargesSummary.asKnown().getOrNull()?.validity() ?: 0) + + (clientInfo.asKnown().getOrNull()?.validity() ?: 0) + + (contractNoteInfo.asKnown().getOrNull()?.validity() ?: 0) + + (derivativesTransactions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (detailedTrades.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (equityTransactions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class BrokerInfo + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val brokerType: JsonField, + private val name: JsonField, + private val sebiRegistration: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("broker_type") + @ExcludeMissing + brokerType: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("sebi_registration") + @ExcludeMissing + sebiRegistration: JsonField = JsonMissing.of(), + ) : this(brokerType, name, sebiRegistration, mutableMapOf()) + + /** + * Auto-detected or specified broker type + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun brokerType(): Optional = brokerType.getOptional("broker_type") + + /** + * Broker company name + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * SEBI registration number of the broker + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun sebiRegistration(): Optional = + sebiRegistration.getOptional("sebi_registration") + + /** + * Returns the raw JSON value of [brokerType]. + * + * Unlike [brokerType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("broker_type") + @ExcludeMissing + fun _brokerType(): JsonField = brokerType + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [sebiRegistration]. + * + * Unlike [sebiRegistration], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("sebi_registration") + @ExcludeMissing + fun _sebiRegistration(): JsonField = sebiRegistration + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [BrokerInfo]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BrokerInfo]. */ + class Builder internal constructor() { + + private var brokerType: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var sebiRegistration: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(brokerInfo: BrokerInfo) = apply { + brokerType = brokerInfo.brokerType + name = brokerInfo.name + sebiRegistration = brokerInfo.sebiRegistration + additionalProperties = brokerInfo.additionalProperties.toMutableMap() + } + + /** Auto-detected or specified broker type */ + fun brokerType(brokerType: BrokerType) = brokerType(JsonField.of(brokerType)) + + /** + * Sets [Builder.brokerType] to an arbitrary JSON value. + * + * You should usually call [Builder.brokerType] with a well-typed [BrokerType] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun brokerType(brokerType: JsonField) = apply { + this.brokerType = brokerType + } + + /** Broker company name */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** SEBI registration number of the broker */ + fun sebiRegistration(sebiRegistration: String) = + sebiRegistration(JsonField.of(sebiRegistration)) + + /** + * Sets [Builder.sebiRegistration] to an arbitrary JSON value. + * + * You should usually call [Builder.sebiRegistration] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun sebiRegistration(sebiRegistration: JsonField) = apply { + this.sebiRegistration = sebiRegistration + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BrokerInfo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BrokerInfo = + BrokerInfo( + brokerType, + name, + sebiRegistration, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BrokerInfo = apply { + if (validated) { + return@apply + } + + brokerType().ifPresent { it.validate() } + name() + sebiRegistration() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (brokerType.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (sebiRegistration.asKnown().isPresent) 1 else 0) + + /** Auto-detected or specified broker type */ + class BrokerType + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ZERODHA = of("zerodha") + + @JvmField val GROWW = of("groww") + + @JvmField val UPSTOX = of("upstox") + + @JvmField val ICICI = of("icici") + + @JvmField val UNKNOWN = of("unknown") + + @JvmStatic fun of(value: String) = BrokerType(JsonField.of(value)) + } + + /** An enum containing [BrokerType]'s known values. */ + enum class Known { + ZERODHA, + GROWW, + UPSTOX, + ICICI, + UNKNOWN, + } + + /** + * An enum containing [BrokerType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [BrokerType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ZERODHA, + GROWW, + UPSTOX, + ICICI, + UNKNOWN, + /** + * An enum member indicating that [BrokerType] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ZERODHA -> Value.ZERODHA + GROWW -> Value.GROWW + UPSTOX -> Value.UPSTOX + ICICI -> Value.ICICI + UNKNOWN -> Value.UNKNOWN + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CasParserInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + ZERODHA -> Known.ZERODHA + GROWW -> Known.GROWW + UPSTOX -> Known.UPSTOX + ICICI -> Known.ICICI + UNKNOWN -> Known.UNKNOWN + else -> throw CasParserInvalidDataException("Unknown BrokerType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CasParserInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CasParserInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): BrokerType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrokerType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BrokerInfo && + brokerType == other.brokerType && + name == other.name && + sebiRegistration == other.sebiRegistration && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(brokerType, name, sebiRegistration, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BrokerInfo{brokerType=$brokerType, name=$name, sebiRegistration=$sebiRegistration, additionalProperties=$additionalProperties}" + } + + /** Breakdown of various charges and fees */ + class ChargesSummary + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cgst: JsonField, + private val exchangeTransactionCharges: JsonField, + private val igst: JsonField, + private val netAmountReceivablePayable: JsonField, + private val payInPayOutObligation: JsonField, + private val sebiTurnoverFees: JsonField, + private val securitiesTransactionTax: JsonField, + private val sgst: JsonField, + private val stampDuty: JsonField, + private val taxableValueBrokerage: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cgst") @ExcludeMissing cgst: JsonField = JsonMissing.of(), + @JsonProperty("exchange_transaction_charges") + @ExcludeMissing + exchangeTransactionCharges: JsonField = JsonMissing.of(), + @JsonProperty("igst") @ExcludeMissing igst: JsonField = JsonMissing.of(), + @JsonProperty("net_amount_receivable_payable") + @ExcludeMissing + netAmountReceivablePayable: JsonField = JsonMissing.of(), + @JsonProperty("pay_in_pay_out_obligation") + @ExcludeMissing + payInPayOutObligation: JsonField = JsonMissing.of(), + @JsonProperty("sebi_turnover_fees") + @ExcludeMissing + sebiTurnoverFees: JsonField = JsonMissing.of(), + @JsonProperty("securities_transaction_tax") + @ExcludeMissing + securitiesTransactionTax: JsonField = JsonMissing.of(), + @JsonProperty("sgst") @ExcludeMissing sgst: JsonField = JsonMissing.of(), + @JsonProperty("stamp_duty") + @ExcludeMissing + stampDuty: JsonField = JsonMissing.of(), + @JsonProperty("taxable_value_brokerage") + @ExcludeMissing + taxableValueBrokerage: JsonField = JsonMissing.of(), + ) : this( + cgst, + exchangeTransactionCharges, + igst, + netAmountReceivablePayable, + payInPayOutObligation, + sebiTurnoverFees, + securitiesTransactionTax, + sgst, + stampDuty, + taxableValueBrokerage, + mutableMapOf(), + ) + + /** + * Central GST amount + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun cgst(): Optional = cgst.getOptional("cgst") + + /** + * Exchange transaction charges + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun exchangeTransactionCharges(): Optional = + exchangeTransactionCharges.getOptional("exchange_transaction_charges") + + /** + * Integrated GST amount + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun igst(): Optional = igst.getOptional("igst") + + /** + * Final net amount receivable or payable + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun netAmountReceivablePayable(): Optional = + netAmountReceivablePayable.getOptional("net_amount_receivable_payable") + + /** + * Net pay-in/pay-out obligation + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun payInPayOutObligation(): Optional = + payInPayOutObligation.getOptional("pay_in_pay_out_obligation") + + /** + * SEBI turnover fees + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun sebiTurnoverFees(): Optional = + sebiTurnoverFees.getOptional("sebi_turnover_fees") + + /** + * Securities Transaction Tax + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun securitiesTransactionTax(): Optional = + securitiesTransactionTax.getOptional("securities_transaction_tax") + + /** + * State GST amount + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun sgst(): Optional = sgst.getOptional("sgst") + + /** + * Stamp duty charges + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun stampDuty(): Optional = stampDuty.getOptional("stamp_duty") + + /** + * Taxable brokerage amount + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun taxableValueBrokerage(): Optional = + taxableValueBrokerage.getOptional("taxable_value_brokerage") + + /** + * Returns the raw JSON value of [cgst]. + * + * Unlike [cgst], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cgst") @ExcludeMissing fun _cgst(): JsonField = cgst + + /** + * Returns the raw JSON value of [exchangeTransactionCharges]. + * + * Unlike [exchangeTransactionCharges], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("exchange_transaction_charges") + @ExcludeMissing + fun _exchangeTransactionCharges(): JsonField = exchangeTransactionCharges + + /** + * Returns the raw JSON value of [igst]. + * + * Unlike [igst], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("igst") @ExcludeMissing fun _igst(): JsonField = igst + + /** + * Returns the raw JSON value of [netAmountReceivablePayable]. + * + * Unlike [netAmountReceivablePayable], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("net_amount_receivable_payable") + @ExcludeMissing + fun _netAmountReceivablePayable(): JsonField = netAmountReceivablePayable + + /** + * Returns the raw JSON value of [payInPayOutObligation]. + * + * Unlike [payInPayOutObligation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("pay_in_pay_out_obligation") + @ExcludeMissing + fun _payInPayOutObligation(): JsonField = payInPayOutObligation + + /** + * Returns the raw JSON value of [sebiTurnoverFees]. + * + * Unlike [sebiTurnoverFees], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("sebi_turnover_fees") + @ExcludeMissing + fun _sebiTurnoverFees(): JsonField = sebiTurnoverFees + + /** + * Returns the raw JSON value of [securitiesTransactionTax]. + * + * Unlike [securitiesTransactionTax], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("securities_transaction_tax") + @ExcludeMissing + fun _securitiesTransactionTax(): JsonField = securitiesTransactionTax + + /** + * Returns the raw JSON value of [sgst]. + * + * Unlike [sgst], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sgst") @ExcludeMissing fun _sgst(): JsonField = sgst + + /** + * Returns the raw JSON value of [stampDuty]. + * + * Unlike [stampDuty], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("stamp_duty") + @ExcludeMissing + fun _stampDuty(): JsonField = stampDuty + + /** + * Returns the raw JSON value of [taxableValueBrokerage]. + * + * Unlike [taxableValueBrokerage], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("taxable_value_brokerage") + @ExcludeMissing + fun _taxableValueBrokerage(): JsonField = taxableValueBrokerage + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ChargesSummary]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ChargesSummary]. */ + class Builder internal constructor() { + + private var cgst: JsonField = JsonMissing.of() + private var exchangeTransactionCharges: JsonField = JsonMissing.of() + private var igst: JsonField = JsonMissing.of() + private var netAmountReceivablePayable: JsonField = JsonMissing.of() + private var payInPayOutObligation: JsonField = JsonMissing.of() + private var sebiTurnoverFees: JsonField = JsonMissing.of() + private var securitiesTransactionTax: JsonField = JsonMissing.of() + private var sgst: JsonField = JsonMissing.of() + private var stampDuty: JsonField = JsonMissing.of() + private var taxableValueBrokerage: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(chargesSummary: ChargesSummary) = apply { + cgst = chargesSummary.cgst + exchangeTransactionCharges = chargesSummary.exchangeTransactionCharges + igst = chargesSummary.igst + netAmountReceivablePayable = chargesSummary.netAmountReceivablePayable + payInPayOutObligation = chargesSummary.payInPayOutObligation + sebiTurnoverFees = chargesSummary.sebiTurnoverFees + securitiesTransactionTax = chargesSummary.securitiesTransactionTax + sgst = chargesSummary.sgst + stampDuty = chargesSummary.stampDuty + taxableValueBrokerage = chargesSummary.taxableValueBrokerage + additionalProperties = chargesSummary.additionalProperties.toMutableMap() + } + + /** Central GST amount */ + fun cgst(cgst: Float) = cgst(JsonField.of(cgst)) + + /** + * Sets [Builder.cgst] to an arbitrary JSON value. + * + * You should usually call [Builder.cgst] with a well-typed [Float] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cgst(cgst: JsonField) = apply { this.cgst = cgst } + + /** Exchange transaction charges */ + fun exchangeTransactionCharges(exchangeTransactionCharges: Float) = + exchangeTransactionCharges(JsonField.of(exchangeTransactionCharges)) + + /** + * Sets [Builder.exchangeTransactionCharges] to an arbitrary JSON value. + * + * You should usually call [Builder.exchangeTransactionCharges] with a well-typed + * [Float] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun exchangeTransactionCharges(exchangeTransactionCharges: JsonField) = + apply { + this.exchangeTransactionCharges = exchangeTransactionCharges + } + + /** Integrated GST amount */ + fun igst(igst: Float) = igst(JsonField.of(igst)) + + /** + * Sets [Builder.igst] to an arbitrary JSON value. + * + * You should usually call [Builder.igst] with a well-typed [Float] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun igst(igst: JsonField) = apply { this.igst = igst } + + /** Final net amount receivable or payable */ + fun netAmountReceivablePayable(netAmountReceivablePayable: Float) = + netAmountReceivablePayable(JsonField.of(netAmountReceivablePayable)) + + /** + * Sets [Builder.netAmountReceivablePayable] to an arbitrary JSON value. + * + * You should usually call [Builder.netAmountReceivablePayable] with a well-typed + * [Float] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun netAmountReceivablePayable(netAmountReceivablePayable: JsonField) = + apply { + this.netAmountReceivablePayable = netAmountReceivablePayable + } + + /** Net pay-in/pay-out obligation */ + fun payInPayOutObligation(payInPayOutObligation: Float) = + payInPayOutObligation(JsonField.of(payInPayOutObligation)) + + /** + * Sets [Builder.payInPayOutObligation] to an arbitrary JSON value. + * + * You should usually call [Builder.payInPayOutObligation] with a well-typed [Float] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun payInPayOutObligation(payInPayOutObligation: JsonField) = apply { + this.payInPayOutObligation = payInPayOutObligation + } + + /** SEBI turnover fees */ + fun sebiTurnoverFees(sebiTurnoverFees: Float) = + sebiTurnoverFees(JsonField.of(sebiTurnoverFees)) + + /** + * Sets [Builder.sebiTurnoverFees] to an arbitrary JSON value. + * + * You should usually call [Builder.sebiTurnoverFees] with a well-typed [Float] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun sebiTurnoverFees(sebiTurnoverFees: JsonField) = apply { + this.sebiTurnoverFees = sebiTurnoverFees + } + + /** Securities Transaction Tax */ + fun securitiesTransactionTax(securitiesTransactionTax: Float) = + securitiesTransactionTax(JsonField.of(securitiesTransactionTax)) + + /** + * Sets [Builder.securitiesTransactionTax] to an arbitrary JSON value. + * + * You should usually call [Builder.securitiesTransactionTax] with a well-typed + * [Float] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun securitiesTransactionTax(securitiesTransactionTax: JsonField) = apply { + this.securitiesTransactionTax = securitiesTransactionTax + } + + /** State GST amount */ + fun sgst(sgst: Float) = sgst(JsonField.of(sgst)) + + /** + * Sets [Builder.sgst] to an arbitrary JSON value. + * + * You should usually call [Builder.sgst] with a well-typed [Float] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sgst(sgst: JsonField) = apply { this.sgst = sgst } + + /** Stamp duty charges */ + fun stampDuty(stampDuty: Float) = stampDuty(JsonField.of(stampDuty)) + + /** + * Sets [Builder.stampDuty] to an arbitrary JSON value. + * + * You should usually call [Builder.stampDuty] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun stampDuty(stampDuty: JsonField) = apply { this.stampDuty = stampDuty } + + /** Taxable brokerage amount */ + fun taxableValueBrokerage(taxableValueBrokerage: Float) = + taxableValueBrokerage(JsonField.of(taxableValueBrokerage)) + + /** + * Sets [Builder.taxableValueBrokerage] to an arbitrary JSON value. + * + * You should usually call [Builder.taxableValueBrokerage] with a well-typed [Float] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun taxableValueBrokerage(taxableValueBrokerage: JsonField) = apply { + this.taxableValueBrokerage = taxableValueBrokerage + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ChargesSummary]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ChargesSummary = + ChargesSummary( + cgst, + exchangeTransactionCharges, + igst, + netAmountReceivablePayable, + payInPayOutObligation, + sebiTurnoverFees, + securitiesTransactionTax, + sgst, + stampDuty, + taxableValueBrokerage, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ChargesSummary = apply { + if (validated) { + return@apply + } + + cgst() + exchangeTransactionCharges() + igst() + netAmountReceivablePayable() + payInPayOutObligation() + sebiTurnoverFees() + securitiesTransactionTax() + sgst() + stampDuty() + taxableValueBrokerage() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (cgst.asKnown().isPresent) 1 else 0) + + (if (exchangeTransactionCharges.asKnown().isPresent) 1 else 0) + + (if (igst.asKnown().isPresent) 1 else 0) + + (if (netAmountReceivablePayable.asKnown().isPresent) 1 else 0) + + (if (payInPayOutObligation.asKnown().isPresent) 1 else 0) + + (if (sebiTurnoverFees.asKnown().isPresent) 1 else 0) + + (if (securitiesTransactionTax.asKnown().isPresent) 1 else 0) + + (if (sgst.asKnown().isPresent) 1 else 0) + + (if (stampDuty.asKnown().isPresent) 1 else 0) + + (if (taxableValueBrokerage.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ChargesSummary && + cgst == other.cgst && + exchangeTransactionCharges == other.exchangeTransactionCharges && + igst == other.igst && + netAmountReceivablePayable == other.netAmountReceivablePayable && + payInPayOutObligation == other.payInPayOutObligation && + sebiTurnoverFees == other.sebiTurnoverFees && + securitiesTransactionTax == other.securitiesTransactionTax && + sgst == other.sgst && + stampDuty == other.stampDuty && + taxableValueBrokerage == other.taxableValueBrokerage && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cgst, + exchangeTransactionCharges, + igst, + netAmountReceivablePayable, + payInPayOutObligation, + sebiTurnoverFees, + securitiesTransactionTax, + sgst, + stampDuty, + taxableValueBrokerage, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ChargesSummary{cgst=$cgst, exchangeTransactionCharges=$exchangeTransactionCharges, igst=$igst, netAmountReceivablePayable=$netAmountReceivablePayable, payInPayOutObligation=$payInPayOutObligation, sebiTurnoverFees=$sebiTurnoverFees, securitiesTransactionTax=$securitiesTransactionTax, sgst=$sgst, stampDuty=$stampDuty, taxableValueBrokerage=$taxableValueBrokerage, additionalProperties=$additionalProperties}" + } + + class ClientInfo + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val address: JsonField, + private val gstStateCode: JsonField, + private val name: JsonField, + private val pan: JsonField, + private val placeOfSupply: JsonField, + private val ucc: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("address") + @ExcludeMissing + address: JsonField = JsonMissing.of(), + @JsonProperty("gst_state_code") + @ExcludeMissing + gstStateCode: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("pan") @ExcludeMissing pan: JsonField = JsonMissing.of(), + @JsonProperty("place_of_supply") + @ExcludeMissing + placeOfSupply: JsonField = JsonMissing.of(), + @JsonProperty("ucc") @ExcludeMissing ucc: JsonField = JsonMissing.of(), + ) : this(address, gstStateCode, name, pan, placeOfSupply, ucc, mutableMapOf()) + + /** + * Client address + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun address(): Optional = address.getOptional("address") + + /** + * GST state code + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun gstStateCode(): Optional = gstStateCode.getOptional("gst_state_code") + + /** + * Client name + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Client PAN number + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun pan(): Optional = pan.getOptional("pan") + + /** + * GST place of supply + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun placeOfSupply(): Optional = placeOfSupply.getOptional("place_of_supply") + + /** + * Unique Client Code + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun ucc(): Optional = ucc.getOptional("ucc") + + /** + * Returns the raw JSON value of [address]. + * + * Unlike [address], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("address") @ExcludeMissing fun _address(): JsonField = address + + /** + * Returns the raw JSON value of [gstStateCode]. + * + * Unlike [gstStateCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("gst_state_code") + @ExcludeMissing + fun _gstStateCode(): JsonField = gstStateCode + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [pan]. + * + * Unlike [pan], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pan") @ExcludeMissing fun _pan(): JsonField = pan + + /** + * Returns the raw JSON value of [placeOfSupply]. + * + * Unlike [placeOfSupply], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("place_of_supply") + @ExcludeMissing + fun _placeOfSupply(): JsonField = placeOfSupply + + /** + * Returns the raw JSON value of [ucc]. + * + * Unlike [ucc], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ucc") @ExcludeMissing fun _ucc(): JsonField = ucc + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ClientInfo]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ClientInfo]. */ + class Builder internal constructor() { + + private var address: JsonField = JsonMissing.of() + private var gstStateCode: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var pan: JsonField = JsonMissing.of() + private var placeOfSupply: JsonField = JsonMissing.of() + private var ucc: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(clientInfo: ClientInfo) = apply { + address = clientInfo.address + gstStateCode = clientInfo.gstStateCode + name = clientInfo.name + pan = clientInfo.pan + placeOfSupply = clientInfo.placeOfSupply + ucc = clientInfo.ucc + additionalProperties = clientInfo.additionalProperties.toMutableMap() + } + + /** Client address */ + fun address(address: String) = address(JsonField.of(address)) + + /** + * Sets [Builder.address] to an arbitrary JSON value. + * + * You should usually call [Builder.address] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun address(address: JsonField) = apply { this.address = address } + + /** GST state code */ + fun gstStateCode(gstStateCode: String) = gstStateCode(JsonField.of(gstStateCode)) + + /** + * Sets [Builder.gstStateCode] to an arbitrary JSON value. + * + * You should usually call [Builder.gstStateCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun gstStateCode(gstStateCode: JsonField) = apply { + this.gstStateCode = gstStateCode + } + + /** Client name */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Client PAN number */ + fun pan(pan: String) = pan(JsonField.of(pan)) + + /** + * Sets [Builder.pan] to an arbitrary JSON value. + * + * You should usually call [Builder.pan] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun pan(pan: JsonField) = apply { this.pan = pan } + + /** GST place of supply */ + fun placeOfSupply(placeOfSupply: String) = + placeOfSupply(JsonField.of(placeOfSupply)) + + /** + * Sets [Builder.placeOfSupply] to an arbitrary JSON value. + * + * You should usually call [Builder.placeOfSupply] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun placeOfSupply(placeOfSupply: JsonField) = apply { + this.placeOfSupply = placeOfSupply + } + + /** Unique Client Code */ + fun ucc(ucc: String) = ucc(JsonField.of(ucc)) + + /** + * Sets [Builder.ucc] to an arbitrary JSON value. + * + * You should usually call [Builder.ucc] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun ucc(ucc: JsonField) = apply { this.ucc = ucc } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ClientInfo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ClientInfo = + ClientInfo( + address, + gstStateCode, + name, + pan, + placeOfSupply, + ucc, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ClientInfo = apply { + if (validated) { + return@apply + } + + address() + gstStateCode() + name() + pan() + placeOfSupply() + ucc() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (address.asKnown().isPresent) 1 else 0) + + (if (gstStateCode.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (pan.asKnown().isPresent) 1 else 0) + + (if (placeOfSupply.asKnown().isPresent) 1 else 0) + + (if (ucc.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ClientInfo && + address == other.address && + gstStateCode == other.gstStateCode && + name == other.name && + pan == other.pan && + placeOfSupply == other.placeOfSupply && + ucc == other.ucc && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + address, + gstStateCode, + name, + pan, + placeOfSupply, + ucc, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ClientInfo{address=$address, gstStateCode=$gstStateCode, name=$name, pan=$pan, placeOfSupply=$placeOfSupply, ucc=$ucc, additionalProperties=$additionalProperties}" + } + + class ContractNoteInfo + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val contractNoteNumber: JsonField, + private val settlementDate: JsonField, + private val settlementNumber: JsonField, + private val tradeDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("contract_note_number") + @ExcludeMissing + contractNoteNumber: JsonField = JsonMissing.of(), + @JsonProperty("settlement_date") + @ExcludeMissing + settlementDate: JsonField = JsonMissing.of(), + @JsonProperty("settlement_number") + @ExcludeMissing + settlementNumber: JsonField = JsonMissing.of(), + @JsonProperty("trade_date") + @ExcludeMissing + tradeDate: JsonField = JsonMissing.of(), + ) : this( + contractNoteNumber, + settlementDate, + settlementNumber, + tradeDate, + mutableMapOf(), + ) + + /** + * Contract note reference number + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun contractNoteNumber(): Optional = + contractNoteNumber.getOptional("contract_note_number") + + /** + * Settlement date for the trades + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun settlementDate(): Optional = + settlementDate.getOptional("settlement_date") + + /** + * Settlement reference number + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun settlementNumber(): Optional = + settlementNumber.getOptional("settlement_number") + + /** + * Date when trades were executed + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun tradeDate(): Optional = tradeDate.getOptional("trade_date") + + /** + * Returns the raw JSON value of [contractNoteNumber]. + * + * Unlike [contractNoteNumber], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("contract_note_number") + @ExcludeMissing + fun _contractNoteNumber(): JsonField = contractNoteNumber + + /** + * Returns the raw JSON value of [settlementDate]. + * + * Unlike [settlementDate], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("settlement_date") + @ExcludeMissing + fun _settlementDate(): JsonField = settlementDate + + /** + * Returns the raw JSON value of [settlementNumber]. + * + * Unlike [settlementNumber], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("settlement_number") + @ExcludeMissing + fun _settlementNumber(): JsonField = settlementNumber + + /** + * Returns the raw JSON value of [tradeDate]. + * + * Unlike [tradeDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trade_date") + @ExcludeMissing + fun _tradeDate(): JsonField = tradeDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ContractNoteInfo]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ContractNoteInfo]. */ + class Builder internal constructor() { + + private var contractNoteNumber: JsonField = JsonMissing.of() + private var settlementDate: JsonField = JsonMissing.of() + private var settlementNumber: JsonField = JsonMissing.of() + private var tradeDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(contractNoteInfo: ContractNoteInfo) = apply { + contractNoteNumber = contractNoteInfo.contractNoteNumber + settlementDate = contractNoteInfo.settlementDate + settlementNumber = contractNoteInfo.settlementNumber + tradeDate = contractNoteInfo.tradeDate + additionalProperties = contractNoteInfo.additionalProperties.toMutableMap() + } + + /** Contract note reference number */ + fun contractNoteNumber(contractNoteNumber: String) = + contractNoteNumber(JsonField.of(contractNoteNumber)) + + /** + * Sets [Builder.contractNoteNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.contractNoteNumber] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun contractNoteNumber(contractNoteNumber: JsonField) = apply { + this.contractNoteNumber = contractNoteNumber + } + + /** Settlement date for the trades */ + fun settlementDate(settlementDate: LocalDate) = + settlementDate(JsonField.of(settlementDate)) + + /** + * Sets [Builder.settlementDate] to an arbitrary JSON value. + * + * You should usually call [Builder.settlementDate] with a well-typed [LocalDate] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun settlementDate(settlementDate: JsonField) = apply { + this.settlementDate = settlementDate + } + + /** Settlement reference number */ + fun settlementNumber(settlementNumber: String) = + settlementNumber(JsonField.of(settlementNumber)) + + /** + * Sets [Builder.settlementNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.settlementNumber] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun settlementNumber(settlementNumber: JsonField) = apply { + this.settlementNumber = settlementNumber + } + + /** Date when trades were executed */ + fun tradeDate(tradeDate: LocalDate) = tradeDate(JsonField.of(tradeDate)) + + /** + * Sets [Builder.tradeDate] to an arbitrary JSON value. + * + * You should usually call [Builder.tradeDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tradeDate(tradeDate: JsonField) = apply { + this.tradeDate = tradeDate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ContractNoteInfo]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ContractNoteInfo = + ContractNoteInfo( + contractNoteNumber, + settlementDate, + settlementNumber, + tradeDate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): ContractNoteInfo = apply { + if (validated) { + return@apply + } + + contractNoteNumber() + settlementDate() + settlementNumber() + tradeDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (contractNoteNumber.asKnown().isPresent) 1 else 0) + + (if (settlementDate.asKnown().isPresent) 1 else 0) + + (if (settlementNumber.asKnown().isPresent) 1 else 0) + + (if (tradeDate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ContractNoteInfo && + contractNoteNumber == other.contractNoteNumber && + settlementDate == other.settlementDate && + settlementNumber == other.settlementNumber && + tradeDate == other.tradeDate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + contractNoteNumber, + settlementDate, + settlementNumber, + tradeDate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ContractNoteInfo{contractNoteNumber=$contractNoteNumber, settlementDate=$settlementDate, settlementNumber=$settlementNumber, tradeDate=$tradeDate, additionalProperties=$additionalProperties}" + } + + class DerivativesTransaction + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val brokeragePerUnit: JsonField, + private val buySellBfCf: JsonField, + private val closingRatePerUnit: JsonField, + private val contractDescription: JsonField, + private val netTotal: JsonField, + private val quantity: JsonField, + private val wapPerUnit: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("brokerage_per_unit") + @ExcludeMissing + brokeragePerUnit: JsonField = JsonMissing.of(), + @JsonProperty("buy_sell_bf_cf") + @ExcludeMissing + buySellBfCf: JsonField = JsonMissing.of(), + @JsonProperty("closing_rate_per_unit") + @ExcludeMissing + closingRatePerUnit: JsonField = JsonMissing.of(), + @JsonProperty("contract_description") + @ExcludeMissing + contractDescription: JsonField = JsonMissing.of(), + @JsonProperty("net_total") + @ExcludeMissing + netTotal: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + @JsonProperty("wap_per_unit") + @ExcludeMissing + wapPerUnit: JsonField = JsonMissing.of(), + ) : this( + brokeragePerUnit, + buySellBfCf, + closingRatePerUnit, + contractDescription, + netTotal, + quantity, + wapPerUnit, + mutableMapOf(), + ) + + /** + * Brokerage charged per unit + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun brokeragePerUnit(): Optional = + brokeragePerUnit.getOptional("brokerage_per_unit") + + /** + * Transaction type (Buy/Sell/Bring Forward/Carry Forward) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun buySellBfCf(): Optional = buySellBfCf.getOptional("buy_sell_bf_cf") + + /** + * Closing rate per unit + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun closingRatePerUnit(): Optional = + closingRatePerUnit.getOptional("closing_rate_per_unit") + + /** + * Derivatives contract description + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun contractDescription(): Optional = + contractDescription.getOptional("contract_description") + + /** + * Net total amount + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun netTotal(): Optional = netTotal.getOptional("net_total") + + /** + * Quantity traded + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") + + /** + * Weighted Average Price per unit + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun wapPerUnit(): Optional = wapPerUnit.getOptional("wap_per_unit") + + /** + * Returns the raw JSON value of [brokeragePerUnit]. + * + * Unlike [brokeragePerUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("brokerage_per_unit") + @ExcludeMissing + fun _brokeragePerUnit(): JsonField = brokeragePerUnit + + /** + * Returns the raw JSON value of [buySellBfCf]. + * + * Unlike [buySellBfCf], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("buy_sell_bf_cf") + @ExcludeMissing + fun _buySellBfCf(): JsonField = buySellBfCf + + /** + * Returns the raw JSON value of [closingRatePerUnit]. + * + * Unlike [closingRatePerUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("closing_rate_per_unit") + @ExcludeMissing + fun _closingRatePerUnit(): JsonField = closingRatePerUnit + + /** + * Returns the raw JSON value of [contractDescription]. + * + * Unlike [contractDescription], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("contract_description") + @ExcludeMissing + fun _contractDescription(): JsonField = contractDescription + + /** + * Returns the raw JSON value of [netTotal]. + * + * Unlike [netTotal], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("net_total") @ExcludeMissing fun _netTotal(): JsonField = netTotal + + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity + + /** + * Returns the raw JSON value of [wapPerUnit]. + * + * Unlike [wapPerUnit], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("wap_per_unit") + @ExcludeMissing + fun _wapPerUnit(): JsonField = wapPerUnit + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [DerivativesTransaction]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DerivativesTransaction]. */ + class Builder internal constructor() { + + private var brokeragePerUnit: JsonField = JsonMissing.of() + private var buySellBfCf: JsonField = JsonMissing.of() + private var closingRatePerUnit: JsonField = JsonMissing.of() + private var contractDescription: JsonField = JsonMissing.of() + private var netTotal: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var wapPerUnit: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(derivativesTransaction: DerivativesTransaction) = apply { + brokeragePerUnit = derivativesTransaction.brokeragePerUnit + buySellBfCf = derivativesTransaction.buySellBfCf + closingRatePerUnit = derivativesTransaction.closingRatePerUnit + contractDescription = derivativesTransaction.contractDescription + netTotal = derivativesTransaction.netTotal + quantity = derivativesTransaction.quantity + wapPerUnit = derivativesTransaction.wapPerUnit + additionalProperties = + derivativesTransaction.additionalProperties.toMutableMap() + } + + /** Brokerage charged per unit */ + fun brokeragePerUnit(brokeragePerUnit: Float) = + brokeragePerUnit(JsonField.of(brokeragePerUnit)) + + /** + * Sets [Builder.brokeragePerUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.brokeragePerUnit] with a well-typed [Float] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun brokeragePerUnit(brokeragePerUnit: JsonField) = apply { + this.brokeragePerUnit = brokeragePerUnit + } + + /** Transaction type (Buy/Sell/Bring Forward/Carry Forward) */ + fun buySellBfCf(buySellBfCf: String) = buySellBfCf(JsonField.of(buySellBfCf)) + + /** + * Sets [Builder.buySellBfCf] to an arbitrary JSON value. + * + * You should usually call [Builder.buySellBfCf] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun buySellBfCf(buySellBfCf: JsonField) = apply { + this.buySellBfCf = buySellBfCf + } + + /** Closing rate per unit */ + fun closingRatePerUnit(closingRatePerUnit: Float) = + closingRatePerUnit(JsonField.of(closingRatePerUnit)) + + /** + * Sets [Builder.closingRatePerUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.closingRatePerUnit] with a well-typed [Float] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun closingRatePerUnit(closingRatePerUnit: JsonField) = apply { + this.closingRatePerUnit = closingRatePerUnit + } + + /** Derivatives contract description */ + fun contractDescription(contractDescription: String) = + contractDescription(JsonField.of(contractDescription)) + + /** + * Sets [Builder.contractDescription] to an arbitrary JSON value. + * + * You should usually call [Builder.contractDescription] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun contractDescription(contractDescription: JsonField) = apply { + this.contractDescription = contractDescription + } + + /** Net total amount */ + fun netTotal(netTotal: Float) = netTotal(JsonField.of(netTotal)) + + /** + * Sets [Builder.netTotal] to an arbitrary JSON value. + * + * You should usually call [Builder.netTotal] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun netTotal(netTotal: JsonField) = apply { this.netTotal = netTotal } + + /** Quantity traded */ + fun quantity(quantity: Float) = quantity(JsonField.of(quantity)) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + /** Weighted Average Price per unit */ + fun wapPerUnit(wapPerUnit: Float) = wapPerUnit(JsonField.of(wapPerUnit)) + + /** + * Sets [Builder.wapPerUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.wapPerUnit] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun wapPerUnit(wapPerUnit: JsonField) = apply { + this.wapPerUnit = wapPerUnit + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DerivativesTransaction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DerivativesTransaction = + DerivativesTransaction( + brokeragePerUnit, + buySellBfCf, + closingRatePerUnit, + contractDescription, + netTotal, + quantity, + wapPerUnit, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DerivativesTransaction = apply { + if (validated) { + return@apply + } + + brokeragePerUnit() + buySellBfCf() + closingRatePerUnit() + contractDescription() + netTotal() + quantity() + wapPerUnit() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (brokeragePerUnit.asKnown().isPresent) 1 else 0) + + (if (buySellBfCf.asKnown().isPresent) 1 else 0) + + (if (closingRatePerUnit.asKnown().isPresent) 1 else 0) + + (if (contractDescription.asKnown().isPresent) 1 else 0) + + (if (netTotal.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (wapPerUnit.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DerivativesTransaction && + brokeragePerUnit == other.brokeragePerUnit && + buySellBfCf == other.buySellBfCf && + closingRatePerUnit == other.closingRatePerUnit && + contractDescription == other.contractDescription && + netTotal == other.netTotal && + quantity == other.quantity && + wapPerUnit == other.wapPerUnit && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + brokeragePerUnit, + buySellBfCf, + closingRatePerUnit, + contractDescription, + netTotal, + quantity, + wapPerUnit, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DerivativesTransaction{brokeragePerUnit=$brokeragePerUnit, buySellBfCf=$buySellBfCf, closingRatePerUnit=$closingRatePerUnit, contractDescription=$contractDescription, netTotal=$netTotal, quantity=$quantity, wapPerUnit=$wapPerUnit, additionalProperties=$additionalProperties}" + } + + class DetailedTrade + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val brokerage: JsonField, + private val buySell: JsonField, + private val closingRatePerUnit: JsonField, + private val exchange: JsonField, + private val netRatePerUnit: JsonField, + private val netTotal: JsonField, + private val orderNumber: JsonField, + private val orderTime: JsonField, + private val quantity: JsonField, + private val remarks: JsonField, + private val securityDescription: JsonField, + private val tradeNumber: JsonField, + private val tradeTime: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("brokerage") + @ExcludeMissing + brokerage: JsonField = JsonMissing.of(), + @JsonProperty("buy_sell") + @ExcludeMissing + buySell: JsonField = JsonMissing.of(), + @JsonProperty("closing_rate_per_unit") + @ExcludeMissing + closingRatePerUnit: JsonField = JsonMissing.of(), + @JsonProperty("exchange") + @ExcludeMissing + exchange: JsonField = JsonMissing.of(), + @JsonProperty("net_rate_per_unit") + @ExcludeMissing + netRatePerUnit: JsonField = JsonMissing.of(), + @JsonProperty("net_total") + @ExcludeMissing + netTotal: JsonField = JsonMissing.of(), + @JsonProperty("order_number") + @ExcludeMissing + orderNumber: JsonField = JsonMissing.of(), + @JsonProperty("order_time") + @ExcludeMissing + orderTime: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + @JsonProperty("remarks") + @ExcludeMissing + remarks: JsonField = JsonMissing.of(), + @JsonProperty("security_description") + @ExcludeMissing + securityDescription: JsonField = JsonMissing.of(), + @JsonProperty("trade_number") + @ExcludeMissing + tradeNumber: JsonField = JsonMissing.of(), + @JsonProperty("trade_time") + @ExcludeMissing + tradeTime: JsonField = JsonMissing.of(), + ) : this( + brokerage, + buySell, + closingRatePerUnit, + exchange, + netRatePerUnit, + netTotal, + orderNumber, + orderTime, + quantity, + remarks, + securityDescription, + tradeNumber, + tradeTime, + mutableMapOf(), + ) + + /** + * Brokerage charged for this trade + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun brokerage(): Optional = brokerage.getOptional("brokerage") + + /** + * Transaction type (B for Buy, S for Sell) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun buySell(): Optional = buySell.getOptional("buy_sell") + + /** + * Closing rate per unit + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun closingRatePerUnit(): Optional = + closingRatePerUnit.getOptional("closing_rate_per_unit") + + /** + * Exchange name + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun exchange(): Optional = exchange.getOptional("exchange") + + /** + * Net rate per unit + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun netRatePerUnit(): Optional = netRatePerUnit.getOptional("net_rate_per_unit") + + /** + * Net total for this trade + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun netTotal(): Optional = netTotal.getOptional("net_total") + + /** + * Order reference number + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun orderNumber(): Optional = orderNumber.getOptional("order_number") + + /** + * Time when order was placed + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun orderTime(): Optional = orderTime.getOptional("order_time") + + /** + * Quantity traded + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") + + /** + * Additional remarks or notes + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun remarks(): Optional = remarks.getOptional("remarks") + + /** + * Security name with exchange and ISIN + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun securityDescription(): Optional = + securityDescription.getOptional("security_description") + + /** + * Trade reference number + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun tradeNumber(): Optional = tradeNumber.getOptional("trade_number") + + /** + * Time when trade was executed + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun tradeTime(): Optional = tradeTime.getOptional("trade_time") + + /** + * Returns the raw JSON value of [brokerage]. + * + * Unlike [brokerage], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("brokerage") + @ExcludeMissing + fun _brokerage(): JsonField = brokerage + + /** + * Returns the raw JSON value of [buySell]. + * + * Unlike [buySell], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("buy_sell") @ExcludeMissing fun _buySell(): JsonField = buySell + + /** + * Returns the raw JSON value of [closingRatePerUnit]. + * + * Unlike [closingRatePerUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("closing_rate_per_unit") + @ExcludeMissing + fun _closingRatePerUnit(): JsonField = closingRatePerUnit + + /** + * Returns the raw JSON value of [exchange]. + * + * Unlike [exchange], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("exchange") @ExcludeMissing fun _exchange(): JsonField = exchange + + /** + * Returns the raw JSON value of [netRatePerUnit]. + * + * Unlike [netRatePerUnit], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("net_rate_per_unit") + @ExcludeMissing + fun _netRatePerUnit(): JsonField = netRatePerUnit + + /** + * Returns the raw JSON value of [netTotal]. + * + * Unlike [netTotal], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("net_total") @ExcludeMissing fun _netTotal(): JsonField = netTotal + + /** + * Returns the raw JSON value of [orderNumber]. + * + * Unlike [orderNumber], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("order_number") + @ExcludeMissing + fun _orderNumber(): JsonField = orderNumber + + /** + * Returns the raw JSON value of [orderTime]. + * + * Unlike [orderTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("order_time") + @ExcludeMissing + fun _orderTime(): JsonField = orderTime + + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity + + /** + * Returns the raw JSON value of [remarks]. + * + * Unlike [remarks], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("remarks") @ExcludeMissing fun _remarks(): JsonField = remarks + + /** + * Returns the raw JSON value of [securityDescription]. + * + * Unlike [securityDescription], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("security_description") + @ExcludeMissing + fun _securityDescription(): JsonField = securityDescription + + /** + * Returns the raw JSON value of [tradeNumber]. + * + * Unlike [tradeNumber], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trade_number") + @ExcludeMissing + fun _tradeNumber(): JsonField = tradeNumber + + /** + * Returns the raw JSON value of [tradeTime]. + * + * Unlike [tradeTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("trade_time") + @ExcludeMissing + fun _tradeTime(): JsonField = tradeTime + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [DetailedTrade]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DetailedTrade]. */ + class Builder internal constructor() { + + private var brokerage: JsonField = JsonMissing.of() + private var buySell: JsonField = JsonMissing.of() + private var closingRatePerUnit: JsonField = JsonMissing.of() + private var exchange: JsonField = JsonMissing.of() + private var netRatePerUnit: JsonField = JsonMissing.of() + private var netTotal: JsonField = JsonMissing.of() + private var orderNumber: JsonField = JsonMissing.of() + private var orderTime: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var remarks: JsonField = JsonMissing.of() + private var securityDescription: JsonField = JsonMissing.of() + private var tradeNumber: JsonField = JsonMissing.of() + private var tradeTime: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(detailedTrade: DetailedTrade) = apply { + brokerage = detailedTrade.brokerage + buySell = detailedTrade.buySell + closingRatePerUnit = detailedTrade.closingRatePerUnit + exchange = detailedTrade.exchange + netRatePerUnit = detailedTrade.netRatePerUnit + netTotal = detailedTrade.netTotal + orderNumber = detailedTrade.orderNumber + orderTime = detailedTrade.orderTime + quantity = detailedTrade.quantity + remarks = detailedTrade.remarks + securityDescription = detailedTrade.securityDescription + tradeNumber = detailedTrade.tradeNumber + tradeTime = detailedTrade.tradeTime + additionalProperties = detailedTrade.additionalProperties.toMutableMap() + } + + /** Brokerage charged for this trade */ + fun brokerage(brokerage: Float) = brokerage(JsonField.of(brokerage)) + + /** + * Sets [Builder.brokerage] to an arbitrary JSON value. + * + * You should usually call [Builder.brokerage] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun brokerage(brokerage: JsonField) = apply { this.brokerage = brokerage } + + /** Transaction type (B for Buy, S for Sell) */ + fun buySell(buySell: String) = buySell(JsonField.of(buySell)) + + /** + * Sets [Builder.buySell] to an arbitrary JSON value. + * + * You should usually call [Builder.buySell] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun buySell(buySell: JsonField) = apply { this.buySell = buySell } + + /** Closing rate per unit */ + fun closingRatePerUnit(closingRatePerUnit: Float) = + closingRatePerUnit(JsonField.of(closingRatePerUnit)) + + /** + * Sets [Builder.closingRatePerUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.closingRatePerUnit] with a well-typed [Float] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun closingRatePerUnit(closingRatePerUnit: JsonField) = apply { + this.closingRatePerUnit = closingRatePerUnit + } + + /** Exchange name */ + fun exchange(exchange: String) = exchange(JsonField.of(exchange)) + + /** + * Sets [Builder.exchange] to an arbitrary JSON value. + * + * You should usually call [Builder.exchange] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun exchange(exchange: JsonField) = apply { this.exchange = exchange } + + /** Net rate per unit */ + fun netRatePerUnit(netRatePerUnit: Float) = + netRatePerUnit(JsonField.of(netRatePerUnit)) + + /** + * Sets [Builder.netRatePerUnit] to an arbitrary JSON value. + * + * You should usually call [Builder.netRatePerUnit] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun netRatePerUnit(netRatePerUnit: JsonField) = apply { + this.netRatePerUnit = netRatePerUnit + } + + /** Net total for this trade */ + fun netTotal(netTotal: Float) = netTotal(JsonField.of(netTotal)) + + /** + * Sets [Builder.netTotal] to an arbitrary JSON value. + * + * You should usually call [Builder.netTotal] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun netTotal(netTotal: JsonField) = apply { this.netTotal = netTotal } + + /** Order reference number */ + fun orderNumber(orderNumber: String) = orderNumber(JsonField.of(orderNumber)) + + /** + * Sets [Builder.orderNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.orderNumber] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun orderNumber(orderNumber: JsonField) = apply { + this.orderNumber = orderNumber + } + + /** Time when order was placed */ + fun orderTime(orderTime: String) = orderTime(JsonField.of(orderTime)) + + /** + * Sets [Builder.orderTime] to an arbitrary JSON value. + * + * You should usually call [Builder.orderTime] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun orderTime(orderTime: JsonField) = apply { this.orderTime = orderTime } + + /** Quantity traded */ + fun quantity(quantity: Float) = quantity(JsonField.of(quantity)) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + /** Additional remarks or notes */ + fun remarks(remarks: String) = remarks(JsonField.of(remarks)) + + /** + * Sets [Builder.remarks] to an arbitrary JSON value. + * + * You should usually call [Builder.remarks] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun remarks(remarks: JsonField) = apply { this.remarks = remarks } + + /** Security name with exchange and ISIN */ + fun securityDescription(securityDescription: String) = + securityDescription(JsonField.of(securityDescription)) + + /** + * Sets [Builder.securityDescription] to an arbitrary JSON value. + * + * You should usually call [Builder.securityDescription] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun securityDescription(securityDescription: JsonField) = apply { + this.securityDescription = securityDescription + } + + /** Trade reference number */ + fun tradeNumber(tradeNumber: String) = tradeNumber(JsonField.of(tradeNumber)) + + /** + * Sets [Builder.tradeNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.tradeNumber] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tradeNumber(tradeNumber: JsonField) = apply { + this.tradeNumber = tradeNumber + } + + /** Time when trade was executed */ + fun tradeTime(tradeTime: String) = tradeTime(JsonField.of(tradeTime)) + + /** + * Sets [Builder.tradeTime] to an arbitrary JSON value. + * + * You should usually call [Builder.tradeTime] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun tradeTime(tradeTime: JsonField) = apply { this.tradeTime = tradeTime } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DetailedTrade]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DetailedTrade = + DetailedTrade( + brokerage, + buySell, + closingRatePerUnit, + exchange, + netRatePerUnit, + netTotal, + orderNumber, + orderTime, + quantity, + remarks, + securityDescription, + tradeNumber, + tradeTime, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DetailedTrade = apply { + if (validated) { + return@apply + } + + brokerage() + buySell() + closingRatePerUnit() + exchange() + netRatePerUnit() + netTotal() + orderNumber() + orderTime() + quantity() + remarks() + securityDescription() + tradeNumber() + tradeTime() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (brokerage.asKnown().isPresent) 1 else 0) + + (if (buySell.asKnown().isPresent) 1 else 0) + + (if (closingRatePerUnit.asKnown().isPresent) 1 else 0) + + (if (exchange.asKnown().isPresent) 1 else 0) + + (if (netRatePerUnit.asKnown().isPresent) 1 else 0) + + (if (netTotal.asKnown().isPresent) 1 else 0) + + (if (orderNumber.asKnown().isPresent) 1 else 0) + + (if (orderTime.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (remarks.asKnown().isPresent) 1 else 0) + + (if (securityDescription.asKnown().isPresent) 1 else 0) + + (if (tradeNumber.asKnown().isPresent) 1 else 0) + + (if (tradeTime.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DetailedTrade && + brokerage == other.brokerage && + buySell == other.buySell && + closingRatePerUnit == other.closingRatePerUnit && + exchange == other.exchange && + netRatePerUnit == other.netRatePerUnit && + netTotal == other.netTotal && + orderNumber == other.orderNumber && + orderTime == other.orderTime && + quantity == other.quantity && + remarks == other.remarks && + securityDescription == other.securityDescription && + tradeNumber == other.tradeNumber && + tradeTime == other.tradeTime && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + brokerage, + buySell, + closingRatePerUnit, + exchange, + netRatePerUnit, + netTotal, + orderNumber, + orderTime, + quantity, + remarks, + securityDescription, + tradeNumber, + tradeTime, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DetailedTrade{brokerage=$brokerage, buySell=$buySell, closingRatePerUnit=$closingRatePerUnit, exchange=$exchange, netRatePerUnit=$netRatePerUnit, netTotal=$netTotal, orderNumber=$orderNumber, orderTime=$orderTime, quantity=$quantity, remarks=$remarks, securityDescription=$securityDescription, tradeNumber=$tradeNumber, tradeTime=$tradeTime, additionalProperties=$additionalProperties}" + } + + class EquityTransaction + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val buyQuantity: JsonField, + private val buyTotalValue: JsonField, + private val buyWap: JsonField, + private val isin: JsonField, + private val netObligation: JsonField, + private val securityName: JsonField, + private val securitySymbol: JsonField, + private val sellQuantity: JsonField, + private val sellTotalValue: JsonField, + private val sellWap: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("buy_quantity") + @ExcludeMissing + buyQuantity: JsonField = JsonMissing.of(), + @JsonProperty("buy_total_value") + @ExcludeMissing + buyTotalValue: JsonField = JsonMissing.of(), + @JsonProperty("buy_wap") + @ExcludeMissing + buyWap: JsonField = JsonMissing.of(), + @JsonProperty("isin") @ExcludeMissing isin: JsonField = JsonMissing.of(), + @JsonProperty("net_obligation") + @ExcludeMissing + netObligation: JsonField = JsonMissing.of(), + @JsonProperty("security_name") + @ExcludeMissing + securityName: JsonField = JsonMissing.of(), + @JsonProperty("security_symbol") + @ExcludeMissing + securitySymbol: JsonField = JsonMissing.of(), + @JsonProperty("sell_quantity") + @ExcludeMissing + sellQuantity: JsonField = JsonMissing.of(), + @JsonProperty("sell_total_value") + @ExcludeMissing + sellTotalValue: JsonField = JsonMissing.of(), + @JsonProperty("sell_wap") + @ExcludeMissing + sellWap: JsonField = JsonMissing.of(), + ) : this( + buyQuantity, + buyTotalValue, + buyWap, + isin, + netObligation, + securityName, + securitySymbol, + sellQuantity, + sellTotalValue, + sellWap, + mutableMapOf(), + ) + + /** + * Total quantity purchased + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun buyQuantity(): Optional = buyQuantity.getOptional("buy_quantity") + + /** + * Total value of buy transactions + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun buyTotalValue(): Optional = buyTotalValue.getOptional("buy_total_value") + + /** + * Weighted Average Price for buy transactions + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun buyWap(): Optional = buyWap.getOptional("buy_wap") + + /** + * ISIN code of the security + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun isin(): Optional = isin.getOptional("isin") + + /** + * Net amount payable/receivable for this security + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun netObligation(): Optional = netObligation.getOptional("net_obligation") + + /** + * Name of the security + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun securityName(): Optional = securityName.getOptional("security_name") + + /** + * Trading symbol + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun securitySymbol(): Optional = securitySymbol.getOptional("security_symbol") + + /** + * Total quantity sold + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun sellQuantity(): Optional = sellQuantity.getOptional("sell_quantity") + + /** + * Total value of sell transactions + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun sellTotalValue(): Optional = sellTotalValue.getOptional("sell_total_value") + + /** + * Weighted Average Price for sell transactions + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun sellWap(): Optional = sellWap.getOptional("sell_wap") + + /** + * Returns the raw JSON value of [buyQuantity]. + * + * Unlike [buyQuantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("buy_quantity") + @ExcludeMissing + fun _buyQuantity(): JsonField = buyQuantity + + /** + * Returns the raw JSON value of [buyTotalValue]. + * + * Unlike [buyTotalValue], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("buy_total_value") + @ExcludeMissing + fun _buyTotalValue(): JsonField = buyTotalValue + + /** + * Returns the raw JSON value of [buyWap]. + * + * Unlike [buyWap], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("buy_wap") @ExcludeMissing fun _buyWap(): JsonField = buyWap + + /** + * Returns the raw JSON value of [isin]. + * + * Unlike [isin], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("isin") @ExcludeMissing fun _isin(): JsonField = isin + + /** + * Returns the raw JSON value of [netObligation]. + * + * Unlike [netObligation], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("net_obligation") + @ExcludeMissing + fun _netObligation(): JsonField = netObligation + + /** + * Returns the raw JSON value of [securityName]. + * + * Unlike [securityName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("security_name") + @ExcludeMissing + fun _securityName(): JsonField = securityName + + /** + * Returns the raw JSON value of [securitySymbol]. + * + * Unlike [securitySymbol], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("security_symbol") + @ExcludeMissing + fun _securitySymbol(): JsonField = securitySymbol + + /** + * Returns the raw JSON value of [sellQuantity]. + * + * Unlike [sellQuantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("sell_quantity") + @ExcludeMissing + fun _sellQuantity(): JsonField = sellQuantity + + /** + * Returns the raw JSON value of [sellTotalValue]. + * + * Unlike [sellTotalValue], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("sell_total_value") + @ExcludeMissing + fun _sellTotalValue(): JsonField = sellTotalValue + + /** + * Returns the raw JSON value of [sellWap]. + * + * Unlike [sellWap], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sell_wap") @ExcludeMissing fun _sellWap(): JsonField = sellWap + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [EquityTransaction]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EquityTransaction]. */ + class Builder internal constructor() { + + private var buyQuantity: JsonField = JsonMissing.of() + private var buyTotalValue: JsonField = JsonMissing.of() + private var buyWap: JsonField = JsonMissing.of() + private var isin: JsonField = JsonMissing.of() + private var netObligation: JsonField = JsonMissing.of() + private var securityName: JsonField = JsonMissing.of() + private var securitySymbol: JsonField = JsonMissing.of() + private var sellQuantity: JsonField = JsonMissing.of() + private var sellTotalValue: JsonField = JsonMissing.of() + private var sellWap: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(equityTransaction: EquityTransaction) = apply { + buyQuantity = equityTransaction.buyQuantity + buyTotalValue = equityTransaction.buyTotalValue + buyWap = equityTransaction.buyWap + isin = equityTransaction.isin + netObligation = equityTransaction.netObligation + securityName = equityTransaction.securityName + securitySymbol = equityTransaction.securitySymbol + sellQuantity = equityTransaction.sellQuantity + sellTotalValue = equityTransaction.sellTotalValue + sellWap = equityTransaction.sellWap + additionalProperties = equityTransaction.additionalProperties.toMutableMap() + } + + /** Total quantity purchased */ + fun buyQuantity(buyQuantity: Float) = buyQuantity(JsonField.of(buyQuantity)) + + /** + * Sets [Builder.buyQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.buyQuantity] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun buyQuantity(buyQuantity: JsonField) = apply { + this.buyQuantity = buyQuantity + } + + /** Total value of buy transactions */ + fun buyTotalValue(buyTotalValue: Float) = buyTotalValue(JsonField.of(buyTotalValue)) + + /** + * Sets [Builder.buyTotalValue] to an arbitrary JSON value. + * + * You should usually call [Builder.buyTotalValue] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun buyTotalValue(buyTotalValue: JsonField) = apply { + this.buyTotalValue = buyTotalValue + } + + /** Weighted Average Price for buy transactions */ + fun buyWap(buyWap: Float) = buyWap(JsonField.of(buyWap)) + + /** + * Sets [Builder.buyWap] to an arbitrary JSON value. + * + * You should usually call [Builder.buyWap] with a well-typed [Float] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun buyWap(buyWap: JsonField) = apply { this.buyWap = buyWap } + + /** ISIN code of the security */ + fun isin(isin: String) = isin(JsonField.of(isin)) + + /** + * Sets [Builder.isin] to an arbitrary JSON value. + * + * You should usually call [Builder.isin] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun isin(isin: JsonField) = apply { this.isin = isin } + + /** Net amount payable/receivable for this security */ + fun netObligation(netObligation: Float) = netObligation(JsonField.of(netObligation)) + + /** + * Sets [Builder.netObligation] to an arbitrary JSON value. + * + * You should usually call [Builder.netObligation] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun netObligation(netObligation: JsonField) = apply { + this.netObligation = netObligation + } + + /** Name of the security */ + fun securityName(securityName: String) = securityName(JsonField.of(securityName)) + + /** + * Sets [Builder.securityName] to an arbitrary JSON value. + * + * You should usually call [Builder.securityName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun securityName(securityName: JsonField) = apply { + this.securityName = securityName + } + + /** Trading symbol */ + fun securitySymbol(securitySymbol: String) = + securitySymbol(JsonField.of(securitySymbol)) + + /** + * Sets [Builder.securitySymbol] to an arbitrary JSON value. + * + * You should usually call [Builder.securitySymbol] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun securitySymbol(securitySymbol: JsonField) = apply { + this.securitySymbol = securitySymbol + } + + /** Total quantity sold */ + fun sellQuantity(sellQuantity: Float) = sellQuantity(JsonField.of(sellQuantity)) + + /** + * Sets [Builder.sellQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.sellQuantity] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun sellQuantity(sellQuantity: JsonField) = apply { + this.sellQuantity = sellQuantity + } + + /** Total value of sell transactions */ + fun sellTotalValue(sellTotalValue: Float) = + sellTotalValue(JsonField.of(sellTotalValue)) + + /** + * Sets [Builder.sellTotalValue] to an arbitrary JSON value. + * + * You should usually call [Builder.sellTotalValue] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun sellTotalValue(sellTotalValue: JsonField) = apply { + this.sellTotalValue = sellTotalValue + } + + /** Weighted Average Price for sell transactions */ + fun sellWap(sellWap: Float) = sellWap(JsonField.of(sellWap)) + + /** + * Sets [Builder.sellWap] to an arbitrary JSON value. + * + * You should usually call [Builder.sellWap] with a well-typed [Float] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun sellWap(sellWap: JsonField) = apply { this.sellWap = sellWap } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EquityTransaction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): EquityTransaction = + EquityTransaction( + buyQuantity, + buyTotalValue, + buyWap, + isin, + netObligation, + securityName, + securitySymbol, + sellQuantity, + sellTotalValue, + sellWap, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EquityTransaction = apply { + if (validated) { + return@apply + } + + buyQuantity() + buyTotalValue() + buyWap() + isin() + netObligation() + securityName() + securitySymbol() + sellQuantity() + sellTotalValue() + sellWap() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (buyQuantity.asKnown().isPresent) 1 else 0) + + (if (buyTotalValue.asKnown().isPresent) 1 else 0) + + (if (buyWap.asKnown().isPresent) 1 else 0) + + (if (isin.asKnown().isPresent) 1 else 0) + + (if (netObligation.asKnown().isPresent) 1 else 0) + + (if (securityName.asKnown().isPresent) 1 else 0) + + (if (securitySymbol.asKnown().isPresent) 1 else 0) + + (if (sellQuantity.asKnown().isPresent) 1 else 0) + + (if (sellTotalValue.asKnown().isPresent) 1 else 0) + + (if (sellWap.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is EquityTransaction && + buyQuantity == other.buyQuantity && + buyTotalValue == other.buyTotalValue && + buyWap == other.buyWap && + isin == other.isin && + netObligation == other.netObligation && + securityName == other.securityName && + securitySymbol == other.securitySymbol && + sellQuantity == other.sellQuantity && + sellTotalValue == other.sellTotalValue && + sellWap == other.sellWap && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + buyQuantity, + buyTotalValue, + buyWap, + isin, + netObligation, + securityName, + securitySymbol, + sellQuantity, + sellTotalValue, + sellWap, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EquityTransaction{buyQuantity=$buyQuantity, buyTotalValue=$buyTotalValue, buyWap=$buyWap, isin=$isin, netObligation=$netObligation, securityName=$securityName, securitySymbol=$securitySymbol, sellQuantity=$sellQuantity, sellTotalValue=$sellTotalValue, sellWap=$sellWap, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Data && + brokerInfo == other.brokerInfo && + chargesSummary == other.chargesSummary && + clientInfo == other.clientInfo && + contractNoteInfo == other.contractNoteInfo && + derivativesTransactions == other.derivativesTransactions && + detailedTrades == other.detailedTrades && + equityTransactions == other.equityTransactions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + brokerInfo, + chargesSummary, + clientInfo, + contractNoteInfo, + derivativesTransactions, + detailedTrades, + equityTransactions, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Data{brokerInfo=$brokerInfo, chargesSummary=$chargesSummary, clientInfo=$clientInfo, contractNoteInfo=$contractNoteInfo, derivativesTransactions=$derivativesTransactions, detailedTrades=$detailedTrades, equityTransactions=$equityTransactions, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ContractNoteParseResponse && + data == other.data && + msg == other.msg && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(data, msg, status, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ContractNoteParseResponse{data=$data, msg=$msg, status=$status, additionalProperties=$additionalProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/credits/CreditCheckParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/credits/CreditCheckParams.kt new file mode 100644 index 0000000..aa45ce8 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/credits/CreditCheckParams.kt @@ -0,0 +1,219 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.credits + +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.Params +import com.cas_parser.api.core.http.Headers +import com.cas_parser.api.core.http.QueryParams +import com.cas_parser.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +/** + * Check your remaining API credits and usage for the current billing period. + * + * Returns: + * - Number of API calls used and remaining credits + * - Credit limit and reset date + * - List of enabled features for your plan + * + * Credits reset at the start of each billing period. + */ +class CreditCheckParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CreditCheckParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [CreditCheckParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreditCheckParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(creditCheckParams: CreditCheckParams) = apply { + additionalHeaders = creditCheckParams.additionalHeaders.toBuilder() + additionalQueryParams = creditCheckParams.additionalQueryParams.toBuilder() + additionalBodyProperties = creditCheckParams.additionalBodyProperties.toMutableMap() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [CreditCheckParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CreditCheckParams = + CreditCheckParams( + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreditCheckParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "CreditCheckParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/credits/CreditCheckResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/credits/CreditCheckResponse.kt new file mode 100644 index 0000000..6a3f1a3 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/credits/CreditCheckResponse.kt @@ -0,0 +1,387 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.credits + +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.checkKnown +import com.cas_parser.api.core.toImmutable +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class CreditCheckResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val enabledFeatures: JsonField>, + private val isUnlimited: JsonField, + private val limit: JsonField, + private val remaining: JsonField, + private val resetsAt: JsonField, + private val used: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("enabled_features") + @ExcludeMissing + enabledFeatures: JsonField> = JsonMissing.of(), + @JsonProperty("is_unlimited") + @ExcludeMissing + isUnlimited: JsonField = JsonMissing.of(), + @JsonProperty("limit") @ExcludeMissing limit: JsonField = JsonMissing.of(), + @JsonProperty("remaining") @ExcludeMissing remaining: JsonField = JsonMissing.of(), + @JsonProperty("resets_at") + @ExcludeMissing + resetsAt: JsonField = JsonMissing.of(), + @JsonProperty("used") @ExcludeMissing used: JsonField = JsonMissing.of(), + ) : this(enabledFeatures, isUnlimited, limit, remaining, resetsAt, used, mutableMapOf()) + + /** + * List of API features enabled for your plan + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun enabledFeatures(): Optional> = enabledFeatures.getOptional("enabled_features") + + /** + * Whether the account has unlimited credits + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun isUnlimited(): Optional = isUnlimited.getOptional("is_unlimited") + + /** + * Total credit limit for billing period + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun limit(): Optional = limit.getOptional("limit") + + /** + * Remaining credits (null if unlimited) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun remaining(): Optional = remaining.getOptional("remaining") + + /** + * When credits reset (ISO 8601) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun resetsAt(): Optional = resetsAt.getOptional("resets_at") + + /** + * Number of credits used this billing period + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun used(): Optional = used.getOptional("used") + + /** + * Returns the raw JSON value of [enabledFeatures]. + * + * Unlike [enabledFeatures], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("enabled_features") + @ExcludeMissing + fun _enabledFeatures(): JsonField> = enabledFeatures + + /** + * Returns the raw JSON value of [isUnlimited]. + * + * Unlike [isUnlimited], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_unlimited") + @ExcludeMissing + fun _isUnlimited(): JsonField = isUnlimited + + /** + * Returns the raw JSON value of [limit]. + * + * Unlike [limit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField = limit + + /** + * Returns the raw JSON value of [remaining]. + * + * Unlike [remaining], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("remaining") @ExcludeMissing fun _remaining(): JsonField = remaining + + /** + * Returns the raw JSON value of [resetsAt]. + * + * Unlike [resetsAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("resets_at") @ExcludeMissing fun _resetsAt(): JsonField = resetsAt + + /** + * Returns the raw JSON value of [used]. + * + * Unlike [used], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("used") @ExcludeMissing fun _used(): JsonField = used + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [CreditCheckResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreditCheckResponse]. */ + class Builder internal constructor() { + + private var enabledFeatures: JsonField>? = null + private var isUnlimited: JsonField = JsonMissing.of() + private var limit: JsonField = JsonMissing.of() + private var remaining: JsonField = JsonMissing.of() + private var resetsAt: JsonField = JsonMissing.of() + private var used: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(creditCheckResponse: CreditCheckResponse) = apply { + enabledFeatures = creditCheckResponse.enabledFeatures.map { it.toMutableList() } + isUnlimited = creditCheckResponse.isUnlimited + limit = creditCheckResponse.limit + remaining = creditCheckResponse.remaining + resetsAt = creditCheckResponse.resetsAt + used = creditCheckResponse.used + additionalProperties = creditCheckResponse.additionalProperties.toMutableMap() + } + + /** List of API features enabled for your plan */ + fun enabledFeatures(enabledFeatures: List) = + enabledFeatures(JsonField.of(enabledFeatures)) + + /** + * Sets [Builder.enabledFeatures] to an arbitrary JSON value. + * + * You should usually call [Builder.enabledFeatures] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun enabledFeatures(enabledFeatures: JsonField>) = apply { + this.enabledFeatures = enabledFeatures.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [enabledFeatures]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEnabledFeature(enabledFeature: String) = apply { + enabledFeatures = + (enabledFeatures ?: JsonField.of(mutableListOf())).also { + checkKnown("enabledFeatures", it).add(enabledFeature) + } + } + + /** Whether the account has unlimited credits */ + fun isUnlimited(isUnlimited: Boolean) = isUnlimited(JsonField.of(isUnlimited)) + + /** + * Sets [Builder.isUnlimited] to an arbitrary JSON value. + * + * You should usually call [Builder.isUnlimited] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isUnlimited(isUnlimited: JsonField) = apply { this.isUnlimited = isUnlimited } + + /** Total credit limit for billing period */ + fun limit(limit: Long) = limit(JsonField.of(limit)) + + /** + * Sets [Builder.limit] to an arbitrary JSON value. + * + * You should usually call [Builder.limit] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun limit(limit: JsonField) = apply { this.limit = limit } + + /** Remaining credits (null if unlimited) */ + fun remaining(remaining: Double?) = remaining(JsonField.ofNullable(remaining)) + + /** + * Alias for [Builder.remaining]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun remaining(remaining: Double) = remaining(remaining as Double?) + + /** Alias for calling [Builder.remaining] with `remaining.orElse(null)`. */ + fun remaining(remaining: Optional) = remaining(remaining.getOrNull()) + + /** + * Sets [Builder.remaining] to an arbitrary JSON value. + * + * You should usually call [Builder.remaining] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun remaining(remaining: JsonField) = apply { this.remaining = remaining } + + /** When credits reset (ISO 8601) */ + fun resetsAt(resetsAt: OffsetDateTime?) = resetsAt(JsonField.ofNullable(resetsAt)) + + /** Alias for calling [Builder.resetsAt] with `resetsAt.orElse(null)`. */ + fun resetsAt(resetsAt: Optional) = resetsAt(resetsAt.getOrNull()) + + /** + * Sets [Builder.resetsAt] to an arbitrary JSON value. + * + * You should usually call [Builder.resetsAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun resetsAt(resetsAt: JsonField) = apply { this.resetsAt = resetsAt } + + /** Number of credits used this billing period */ + fun used(used: Double) = used(JsonField.of(used)) + + /** + * Sets [Builder.used] to an arbitrary JSON value. + * + * You should usually call [Builder.used] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun used(used: JsonField) = apply { this.used = used } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [CreditCheckResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CreditCheckResponse = + CreditCheckResponse( + (enabledFeatures ?: JsonMissing.of()).map { it.toImmutable() }, + isUnlimited, + limit, + remaining, + resetsAt, + used, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): CreditCheckResponse = apply { + if (validated) { + return@apply + } + + enabledFeatures() + isUnlimited() + limit() + remaining() + resetsAt() + used() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (enabledFeatures.asKnown().getOrNull()?.size ?: 0) + + (if (isUnlimited.asKnown().isPresent) 1 else 0) + + (if (limit.asKnown().isPresent) 1 else 0) + + (if (remaining.asKnown().isPresent) 1 else 0) + + (if (resetsAt.asKnown().isPresent) 1 else 0) + + (if (used.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreditCheckResponse && + enabledFeatures == other.enabledFeatures && + isUnlimited == other.isUnlimited && + limit == other.limit && + remaining == other.remaining && + resetsAt == other.resetsAt && + used == other.used && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + enabledFeatures, + isUnlimited, + limit, + remaining, + resetsAt, + used, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreditCheckResponse{enabledFeatures=$enabledFeatures, isUnlimited=$isUnlimited, limit=$limit, remaining=$remaining, resetsAt=$resetsAt, used=$used, additionalProperties=$additionalProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxCheckConnectionStatusParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxCheckConnectionStatusParams.kt new file mode 100644 index 0000000..96b1fab --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxCheckConnectionStatusParams.kt @@ -0,0 +1,252 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inbox + +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.Params +import com.cas_parser.api.core.checkRequired +import com.cas_parser.api.core.http.Headers +import com.cas_parser.api.core.http.QueryParams +import com.cas_parser.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +/** + * Verify if an `inbox_token` is still valid and check connection status. + * + * Use this to check if the user needs to re-authenticate (e.g., if they revoked access in their + * email provider settings). + */ +class InboxCheckConnectionStatusParams +private constructor( + private val xInboxToken: String, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun xInboxToken(): String = xInboxToken + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [InboxCheckConnectionStatusParams]. + * + * The following fields are required: + * ```java + * .xInboxToken() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InboxCheckConnectionStatusParams]. */ + class Builder internal constructor() { + + private var xInboxToken: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inboxCheckConnectionStatusParams: InboxCheckConnectionStatusParams) = + apply { + xInboxToken = inboxCheckConnectionStatusParams.xInboxToken + additionalHeaders = inboxCheckConnectionStatusParams.additionalHeaders.toBuilder() + additionalQueryParams = + inboxCheckConnectionStatusParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + inboxCheckConnectionStatusParams.additionalBodyProperties.toMutableMap() + } + + fun xInboxToken(xInboxToken: String) = apply { this.xInboxToken = xInboxToken } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [InboxCheckConnectionStatusParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .xInboxToken() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InboxCheckConnectionStatusParams = + InboxCheckConnectionStatusParams( + checkRequired("xInboxToken", xInboxToken), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + override fun _headers(): Headers = + Headers.builder() + .apply { + put("x-inbox-token", xInboxToken) + putAll(additionalHeaders) + } + .build() + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InboxCheckConnectionStatusParams && + xInboxToken == other.xInboxToken && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + xInboxToken, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "InboxCheckConnectionStatusParams{xInboxToken=$xInboxToken, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxCheckConnectionStatusResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxCheckConnectionStatusResponse.kt new file mode 100644 index 0000000..dad4ab0 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxCheckConnectionStatusResponse.kt @@ -0,0 +1,265 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inbox + +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional + +class InboxCheckConnectionStatusResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val connected: JsonField, + private val email: JsonField, + private val provider: JsonField, + private val status: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("connected") @ExcludeMissing connected: JsonField = JsonMissing.of(), + @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), + @JsonProperty("provider") @ExcludeMissing provider: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + ) : this(connected, email, provider, status, mutableMapOf()) + + /** + * Whether the token is valid and usable + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun connected(): Optional = connected.getOptional("connected") + + /** + * Email address of the connected account + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun email(): Optional = email.getOptional("email") + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun provider(): Optional = provider.getOptional("provider") + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * Returns the raw JSON value of [connected]. + * + * Unlike [connected], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("connected") @ExcludeMissing fun _connected(): JsonField = connected + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + + /** + * Returns the raw JSON value of [provider]. + * + * Unlike [provider], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("provider") @ExcludeMissing fun _provider(): JsonField = provider + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [InboxCheckConnectionStatusResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InboxCheckConnectionStatusResponse]. */ + class Builder internal constructor() { + + private var connected: JsonField = JsonMissing.of() + private var email: JsonField = JsonMissing.of() + private var provider: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inboxCheckConnectionStatusResponse: InboxCheckConnectionStatusResponse) = + apply { + connected = inboxCheckConnectionStatusResponse.connected + email = inboxCheckConnectionStatusResponse.email + provider = inboxCheckConnectionStatusResponse.provider + status = inboxCheckConnectionStatusResponse.status + additionalProperties = + inboxCheckConnectionStatusResponse.additionalProperties.toMutableMap() + } + + /** Whether the token is valid and usable */ + fun connected(connected: Boolean) = connected(JsonField.of(connected)) + + /** + * Sets [Builder.connected] to an arbitrary JSON value. + * + * You should usually call [Builder.connected] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun connected(connected: JsonField) = apply { this.connected = connected } + + /** Email address of the connected account */ + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + + fun provider(provider: String) = provider(JsonField.of(provider)) + + /** + * Sets [Builder.provider] to an arbitrary JSON value. + * + * You should usually call [Builder.provider] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun provider(provider: JsonField) = apply { this.provider = provider } + + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InboxCheckConnectionStatusResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InboxCheckConnectionStatusResponse = + InboxCheckConnectionStatusResponse( + connected, + email, + provider, + status, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InboxCheckConnectionStatusResponse = apply { + if (validated) { + return@apply + } + + connected() + email() + provider() + status() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (connected.asKnown().isPresent) 1 else 0) + + (if (email.asKnown().isPresent) 1 else 0) + + (if (provider.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InboxCheckConnectionStatusResponse && + connected == other.connected && + email == other.email && + provider == other.provider && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(connected, email, provider, status, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InboxCheckConnectionStatusResponse{connected=$connected, email=$email, provider=$provider, status=$status, additionalProperties=$additionalProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxConnectEmailParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxConnectEmailParams.kt new file mode 100644 index 0000000..dc2c277 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxConnectEmailParams.kt @@ -0,0 +1,506 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inbox + +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.Params +import com.cas_parser.api.core.checkRequired +import com.cas_parser.api.core.http.Headers +import com.cas_parser.api.core.http.QueryParams +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** + * Initiate OAuth flow to connect user's email inbox. + * + * Returns an `oauth_url` that you should redirect the user to. After authorization, they are + * redirected back to your `redirect_uri` with the following query parameters: + * + * **On success:** + * - `inbox_token` - Encrypted token to store client-side + * - `email` - Email address of the connected account + * - `state` - Your original state parameter (for CSRF verification) + * + * **On error:** + * - `error` - Error code (e.g., `access_denied`, `token_exchange_failed`) + * - `state` - Your original state parameter + * + * **Store the `inbox_token` client-side** and use it for all subsequent inbox API calls. + */ +class InboxConnectEmailParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Your callback URL to receive the inbox_token (must be http or https) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun redirectUri(): String = body.redirectUri() + + /** + * State parameter for CSRF protection (returned in redirect) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun state(): Optional = body.state() + + /** + * Returns the raw JSON value of [redirectUri]. + * + * Unlike [redirectUri], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _redirectUri(): JsonField = body._redirectUri() + + /** + * Returns the raw JSON value of [state]. + * + * Unlike [state], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _state(): JsonField = body._state() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InboxConnectEmailParams]. + * + * The following fields are required: + * ```java + * .redirectUri() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InboxConnectEmailParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(inboxConnectEmailParams: InboxConnectEmailParams) = apply { + body = inboxConnectEmailParams.body.toBuilder() + additionalHeaders = inboxConnectEmailParams.additionalHeaders.toBuilder() + additionalQueryParams = inboxConnectEmailParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [redirectUri] + * - [state] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Your callback URL to receive the inbox_token (must be http or https) */ + fun redirectUri(redirectUri: String) = apply { body.redirectUri(redirectUri) } + + /** + * Sets [Builder.redirectUri] to an arbitrary JSON value. + * + * You should usually call [Builder.redirectUri] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun redirectUri(redirectUri: JsonField) = apply { body.redirectUri(redirectUri) } + + /** State parameter for CSRF protection (returned in redirect) */ + fun state(state: String) = apply { body.state(state) } + + /** + * Sets [Builder.state] to an arbitrary JSON value. + * + * You should usually call [Builder.state] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun state(state: JsonField) = apply { body.state(state) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [InboxConnectEmailParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .redirectUri() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InboxConnectEmailParams = + InboxConnectEmailParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val redirectUri: JsonField, + private val state: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("redirect_uri") + @ExcludeMissing + redirectUri: JsonField = JsonMissing.of(), + @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), + ) : this(redirectUri, state, mutableMapOf()) + + /** + * Your callback URL to receive the inbox_token (must be http or https) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun redirectUri(): String = redirectUri.getRequired("redirect_uri") + + /** + * State parameter for CSRF protection (returned in redirect) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun state(): Optional = state.getOptional("state") + + /** + * Returns the raw JSON value of [redirectUri]. + * + * Unlike [redirectUri], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("redirect_uri") + @ExcludeMissing + fun _redirectUri(): JsonField = redirectUri + + /** + * Returns the raw JSON value of [state]. + * + * Unlike [state], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .redirectUri() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var redirectUri: JsonField? = null + private var state: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + redirectUri = body.redirectUri + state = body.state + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** Your callback URL to receive the inbox_token (must be http or https) */ + fun redirectUri(redirectUri: String) = redirectUri(JsonField.of(redirectUri)) + + /** + * Sets [Builder.redirectUri] to an arbitrary JSON value. + * + * You should usually call [Builder.redirectUri] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun redirectUri(redirectUri: JsonField) = apply { + this.redirectUri = redirectUri + } + + /** State parameter for CSRF protection (returned in redirect) */ + fun state(state: String) = state(JsonField.of(state)) + + /** + * Sets [Builder.state] to an arbitrary JSON value. + * + * You should usually call [Builder.state] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun state(state: JsonField) = apply { this.state = state } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .redirectUri() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("redirectUri", redirectUri), + state, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + redirectUri() + state() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (redirectUri.asKnown().isPresent) 1 else 0) + + (if (state.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + redirectUri == other.redirectUri && + state == other.state && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(redirectUri, state, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{redirectUri=$redirectUri, state=$state, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InboxConnectEmailParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "InboxConnectEmailParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxConnectEmailResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxConnectEmailResponse.kt new file mode 100644 index 0000000..4511a59 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxConnectEmailResponse.kt @@ -0,0 +1,230 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inbox + +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional + +class InboxConnectEmailResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val expiresIn: JsonField, + private val oauthUrl: JsonField, + private val status: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("expires_in") @ExcludeMissing expiresIn: JsonField = JsonMissing.of(), + @JsonProperty("oauth_url") @ExcludeMissing oauthUrl: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + ) : this(expiresIn, oauthUrl, status, mutableMapOf()) + + /** + * Seconds until the OAuth URL expires (typically 10 minutes) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expiresIn(): Optional = expiresIn.getOptional("expires_in") + + /** + * Redirect user to this URL to start OAuth flow + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun oauthUrl(): Optional = oauthUrl.getOptional("oauth_url") + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * Returns the raw JSON value of [expiresIn]. + * + * Unlike [expiresIn], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expires_in") @ExcludeMissing fun _expiresIn(): JsonField = expiresIn + + /** + * Returns the raw JSON value of [oauthUrl]. + * + * Unlike [oauthUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("oauth_url") @ExcludeMissing fun _oauthUrl(): JsonField = oauthUrl + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InboxConnectEmailResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InboxConnectEmailResponse]. */ + class Builder internal constructor() { + + private var expiresIn: JsonField = JsonMissing.of() + private var oauthUrl: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inboxConnectEmailResponse: InboxConnectEmailResponse) = apply { + expiresIn = inboxConnectEmailResponse.expiresIn + oauthUrl = inboxConnectEmailResponse.oauthUrl + status = inboxConnectEmailResponse.status + additionalProperties = inboxConnectEmailResponse.additionalProperties.toMutableMap() + } + + /** Seconds until the OAuth URL expires (typically 10 minutes) */ + fun expiresIn(expiresIn: Long) = expiresIn(JsonField.of(expiresIn)) + + /** + * Sets [Builder.expiresIn] to an arbitrary JSON value. + * + * You should usually call [Builder.expiresIn] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun expiresIn(expiresIn: JsonField) = apply { this.expiresIn = expiresIn } + + /** Redirect user to this URL to start OAuth flow */ + fun oauthUrl(oauthUrl: String) = oauthUrl(JsonField.of(oauthUrl)) + + /** + * Sets [Builder.oauthUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.oauthUrl] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun oauthUrl(oauthUrl: JsonField) = apply { this.oauthUrl = oauthUrl } + + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InboxConnectEmailResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InboxConnectEmailResponse = + InboxConnectEmailResponse( + expiresIn, + oauthUrl, + status, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InboxConnectEmailResponse = apply { + if (validated) { + return@apply + } + + expiresIn() + oauthUrl() + status() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (expiresIn.asKnown().isPresent) 1 else 0) + + (if (oauthUrl.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InboxConnectEmailResponse && + expiresIn == other.expiresIn && + oauthUrl == other.oauthUrl && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(expiresIn, oauthUrl, status, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InboxConnectEmailResponse{expiresIn=$expiresIn, oauthUrl=$oauthUrl, status=$status, additionalProperties=$additionalProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxDisconnectEmailParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxDisconnectEmailParams.kt new file mode 100644 index 0000000..6caa88e --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxDisconnectEmailParams.kt @@ -0,0 +1,251 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inbox + +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.Params +import com.cas_parser.api.core.checkRequired +import com.cas_parser.api.core.http.Headers +import com.cas_parser.api.core.http.QueryParams +import com.cas_parser.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +/** + * Revoke email access and invalidate the token. + * + * This calls the provider's token revocation API (e.g., Google's revoke endpoint) to ensure the + * user's consent is properly removed. + * + * After calling this, the `inbox_token` becomes unusable. + */ +class InboxDisconnectEmailParams +private constructor( + private val xInboxToken: String, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun xInboxToken(): String = xInboxToken + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InboxDisconnectEmailParams]. + * + * The following fields are required: + * ```java + * .xInboxToken() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InboxDisconnectEmailParams]. */ + class Builder internal constructor() { + + private var xInboxToken: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inboxDisconnectEmailParams: InboxDisconnectEmailParams) = apply { + xInboxToken = inboxDisconnectEmailParams.xInboxToken + additionalHeaders = inboxDisconnectEmailParams.additionalHeaders.toBuilder() + additionalQueryParams = inboxDisconnectEmailParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + inboxDisconnectEmailParams.additionalBodyProperties.toMutableMap() + } + + fun xInboxToken(xInboxToken: String) = apply { this.xInboxToken = xInboxToken } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [InboxDisconnectEmailParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .xInboxToken() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InboxDisconnectEmailParams = + InboxDisconnectEmailParams( + checkRequired("xInboxToken", xInboxToken), + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + override fun _headers(): Headers = + Headers.builder() + .apply { + put("x-inbox-token", xInboxToken) + putAll(additionalHeaders) + } + .build() + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InboxDisconnectEmailParams && + xInboxToken == other.xInboxToken && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + xInboxToken, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "InboxDisconnectEmailParams{xInboxToken=$xInboxToken, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxDisconnectEmailResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxDisconnectEmailResponse.kt new file mode 100644 index 0000000..0214edc --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxDisconnectEmailResponse.kt @@ -0,0 +1,186 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inbox + +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional + +class InboxDisconnectEmailResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val msg: JsonField, + private val status: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("msg") @ExcludeMissing msg: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + ) : this(msg, status, mutableMapOf()) + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun msg(): Optional = msg.getOptional("msg") + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * Returns the raw JSON value of [msg]. + * + * Unlike [msg], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("msg") @ExcludeMissing fun _msg(): JsonField = msg + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InboxDisconnectEmailResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InboxDisconnectEmailResponse]. */ + class Builder internal constructor() { + + private var msg: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inboxDisconnectEmailResponse: InboxDisconnectEmailResponse) = apply { + msg = inboxDisconnectEmailResponse.msg + status = inboxDisconnectEmailResponse.status + additionalProperties = inboxDisconnectEmailResponse.additionalProperties.toMutableMap() + } + + fun msg(msg: String) = msg(JsonField.of(msg)) + + /** + * Sets [Builder.msg] to an arbitrary JSON value. + * + * You should usually call [Builder.msg] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun msg(msg: JsonField) = apply { this.msg = msg } + + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InboxDisconnectEmailResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InboxDisconnectEmailResponse = + InboxDisconnectEmailResponse(msg, status, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): InboxDisconnectEmailResponse = apply { + if (validated) { + return@apply + } + + msg() + status() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (msg.asKnown().isPresent) 1 else 0) + (if (status.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InboxDisconnectEmailResponse && + msg == other.msg && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(msg, status, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InboxDisconnectEmailResponse{msg=$msg, status=$status, additionalProperties=$additionalProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxListCasFilesParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxListCasFilesParams.kt new file mode 100644 index 0000000..b3c976d --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxListCasFilesParams.kt @@ -0,0 +1,755 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inbox + +import com.cas_parser.api.core.Enum +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.Params +import com.cas_parser.api.core.checkKnown +import com.cas_parser.api.core.checkRequired +import com.cas_parser.api.core.http.Headers +import com.cas_parser.api.core.http.QueryParams +import com.cas_parser.api.core.toImmutable +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.time.LocalDate +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Search the user's email inbox for CAS files from known senders (CAMS, KFintech, CDSL, NSDL). + * + * Files are uploaded to temporary cloud storage. **URLs expire in 24 hours.** + * + * Optionally filter by CAS provider and date range. + * + * **Billing:** 0.2 credits per request (charged regardless of success or number of files found). + */ +class InboxListCasFilesParams +private constructor( + private val xInboxToken: String, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun xInboxToken(): String = xInboxToken + + /** + * Filter by CAS provider(s): + * - `cdsl` → eCAS@cdslstatement.com + * - `nsdl` → NSDL-CAS@nsdl.co.in + * - `cams` → donotreply@camsonline.com + * - `kfintech` → samfS@kfintech.com + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun casTypes(): Optional> = body.casTypes() + + /** + * End date in ISO format (YYYY-MM-DD). Defaults to today. + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endDate(): Optional = body.endDate() + + /** + * Start date in ISO format (YYYY-MM-DD). Defaults to 30 days ago. + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun startDate(): Optional = body.startDate() + + /** + * Returns the raw JSON value of [casTypes]. + * + * Unlike [casTypes], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _casTypes(): JsonField> = body._casTypes() + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _endDate(): JsonField = body._endDate() + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _startDate(): JsonField = body._startDate() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InboxListCasFilesParams]. + * + * The following fields are required: + * ```java + * .xInboxToken() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InboxListCasFilesParams]. */ + class Builder internal constructor() { + + private var xInboxToken: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(inboxListCasFilesParams: InboxListCasFilesParams) = apply { + xInboxToken = inboxListCasFilesParams.xInboxToken + body = inboxListCasFilesParams.body.toBuilder() + additionalHeaders = inboxListCasFilesParams.additionalHeaders.toBuilder() + additionalQueryParams = inboxListCasFilesParams.additionalQueryParams.toBuilder() + } + + fun xInboxToken(xInboxToken: String) = apply { this.xInboxToken = xInboxToken } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [casTypes] + * - [endDate] + * - [startDate] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * Filter by CAS provider(s): + * - `cdsl` → eCAS@cdslstatement.com + * - `nsdl` → NSDL-CAS@nsdl.co.in + * - `cams` → donotreply@camsonline.com + * - `kfintech` → samfS@kfintech.com + */ + fun casTypes(casTypes: List) = apply { body.casTypes(casTypes) } + + /** + * Sets [Builder.casTypes] to an arbitrary JSON value. + * + * You should usually call [Builder.casTypes] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun casTypes(casTypes: JsonField>) = apply { body.casTypes(casTypes) } + + /** + * Adds a single [CasType] to [casTypes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCasType(casType: CasType) = apply { body.addCasType(casType) } + + /** End date in ISO format (YYYY-MM-DD). Defaults to today. */ + fun endDate(endDate: LocalDate) = apply { body.endDate(endDate) } + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [LocalDate] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun endDate(endDate: JsonField) = apply { body.endDate(endDate) } + + /** Start date in ISO format (YYYY-MM-DD). Defaults to 30 days ago. */ + fun startDate(startDate: LocalDate) = apply { body.startDate(startDate) } + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [LocalDate] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun startDate(startDate: JsonField) = apply { body.startDate(startDate) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [InboxListCasFilesParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .xInboxToken() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): InboxListCasFilesParams = + InboxListCasFilesParams( + checkRequired("xInboxToken", xInboxToken), + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = + Headers.builder() + .apply { + put("x-inbox-token", xInboxToken) + putAll(additionalHeaders) + } + .build() + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val casTypes: JsonField>, + private val endDate: JsonField, + private val startDate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cas_types") + @ExcludeMissing + casTypes: JsonField> = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + startDate: JsonField = JsonMissing.of(), + ) : this(casTypes, endDate, startDate, mutableMapOf()) + + /** + * Filter by CAS provider(s): + * - `cdsl` → eCAS@cdslstatement.com + * - `nsdl` → NSDL-CAS@nsdl.co.in + * - `cams` → donotreply@camsonline.com + * - `kfintech` → samfS@kfintech.com + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun casTypes(): Optional> = casTypes.getOptional("cas_types") + + /** + * End date in ISO format (YYYY-MM-DD). Defaults to today. + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endDate(): Optional = endDate.getOptional("end_date") + + /** + * Start date in ISO format (YYYY-MM-DD). Defaults to 30 days ago. + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startDate(): Optional = startDate.getOptional("start_date") + + /** + * Returns the raw JSON value of [casTypes]. + * + * Unlike [casTypes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cas_types") + @ExcludeMissing + fun _casTypes(): JsonField> = casTypes + + /** + * Returns the raw JSON value of [endDate]. + * + * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + /** + * Returns the raw JSON value of [startDate]. + * + * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var casTypes: JsonField>? = null + private var endDate: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + casTypes = body.casTypes.map { it.toMutableList() } + endDate = body.endDate + startDate = body.startDate + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * Filter by CAS provider(s): + * - `cdsl` → eCAS@cdslstatement.com + * - `nsdl` → NSDL-CAS@nsdl.co.in + * - `cams` → donotreply@camsonline.com + * - `kfintech` → samfS@kfintech.com + */ + fun casTypes(casTypes: List) = casTypes(JsonField.of(casTypes)) + + /** + * Sets [Builder.casTypes] to an arbitrary JSON value. + * + * You should usually call [Builder.casTypes] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun casTypes(casTypes: JsonField>) = apply { + this.casTypes = casTypes.map { it.toMutableList() } + } + + /** + * Adds a single [CasType] to [casTypes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCasType(casType: CasType) = apply { + casTypes = + (casTypes ?: JsonField.of(mutableListOf())).also { + checkKnown("casTypes", it).add(casType) + } + } + + /** End date in ISO format (YYYY-MM-DD). Defaults to today. */ + fun endDate(endDate: LocalDate) = endDate(JsonField.of(endDate)) + + /** + * Sets [Builder.endDate] to an arbitrary JSON value. + * + * You should usually call [Builder.endDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** Start date in ISO format (YYYY-MM-DD). Defaults to 30 days ago. */ + fun startDate(startDate: LocalDate) = startDate(JsonField.of(startDate)) + + /** + * Sets [Builder.startDate] to an arbitrary JSON value. + * + * You should usually call [Builder.startDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + (casTypes ?: JsonMissing.of()).map { it.toImmutable() }, + endDate, + startDate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + casTypes().ifPresent { it.forEach { it.validate() } } + endDate() + startDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (casTypes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (endDate.asKnown().isPresent) 1 else 0) + + (if (startDate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + casTypes == other.casTypes && + endDate == other.endDate && + startDate == other.startDate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(casTypes, endDate, startDate, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{casTypes=$casTypes, endDate=$endDate, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + class CasType @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CDSL = of("cdsl") + + @JvmField val NSDL = of("nsdl") + + @JvmField val CAMS = of("cams") + + @JvmField val KFINTECH = of("kfintech") + + @JvmStatic fun of(value: String) = CasType(JsonField.of(value)) + } + + /** An enum containing [CasType]'s known values. */ + enum class Known { + CDSL, + NSDL, + CAMS, + KFINTECH, + } + + /** + * An enum containing [CasType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [CasType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CDSL, + NSDL, + CAMS, + KFINTECH, + /** An enum member indicating that [CasType] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CDSL -> Value.CDSL + NSDL -> Value.NSDL + CAMS -> Value.CAMS + KFINTECH -> Value.KFINTECH + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws CasParserInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CDSL -> Known.CDSL + NSDL -> Known.NSDL + CAMS -> Known.CAMS + KFINTECH -> Known.KFINTECH + else -> throw CasParserInvalidDataException("Unknown CasType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws CasParserInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CasParserInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): CasType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CasType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InboxListCasFilesParams && + xInboxToken == other.xInboxToken && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(xInboxToken, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "InboxListCasFilesParams{xInboxToken=$xInboxToken, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxListCasFilesResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxListCasFilesResponse.kt new file mode 100644 index 0000000..84d490e --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/inbox/InboxListCasFilesResponse.kt @@ -0,0 +1,823 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inbox + +import com.cas_parser.api.core.Enum +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.checkKnown +import com.cas_parser.api.core.toImmutable +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.time.LocalDate +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class InboxListCasFilesResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val count: JsonField, + private val files: JsonField>, + private val status: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("count") @ExcludeMissing count: JsonField = JsonMissing.of(), + @JsonProperty("files") @ExcludeMissing files: JsonField> = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + ) : this(count, files, status, mutableMapOf()) + + /** + * Number of CAS files found + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun count(): Optional = count.getOptional("count") + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun files(): Optional> = files.getOptional("files") + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * Returns the raw JSON value of [count]. + * + * Unlike [count], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("count") @ExcludeMissing fun _count(): JsonField = count + + /** + * Returns the raw JSON value of [files]. + * + * Unlike [files], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("files") @ExcludeMissing fun _files(): JsonField> = files + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [InboxListCasFilesResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InboxListCasFilesResponse]. */ + class Builder internal constructor() { + + private var count: JsonField = JsonMissing.of() + private var files: JsonField>? = null + private var status: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(inboxListCasFilesResponse: InboxListCasFilesResponse) = apply { + count = inboxListCasFilesResponse.count + files = inboxListCasFilesResponse.files.map { it.toMutableList() } + status = inboxListCasFilesResponse.status + additionalProperties = inboxListCasFilesResponse.additionalProperties.toMutableMap() + } + + /** Number of CAS files found */ + fun count(count: Long) = count(JsonField.of(count)) + + /** + * Sets [Builder.count] to an arbitrary JSON value. + * + * You should usually call [Builder.count] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun count(count: JsonField) = apply { this.count = count } + + fun files(files: List) = files(JsonField.of(files)) + + /** + * Sets [Builder.files] to an arbitrary JSON value. + * + * You should usually call [Builder.files] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun files(files: JsonField>) = apply { + this.files = files.map { it.toMutableList() } + } + + /** + * Adds a single [File] to [files]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFile(file: File) = apply { + files = + (files ?: JsonField.of(mutableListOf())).also { checkKnown("files", it).add(file) } + } + + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InboxListCasFilesResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InboxListCasFilesResponse = + InboxListCasFilesResponse( + count, + (files ?: JsonMissing.of()).map { it.toImmutable() }, + status, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): InboxListCasFilesResponse = apply { + if (validated) { + return@apply + } + + count() + files().ifPresent { it.forEach { it.validate() } } + status() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (count.asKnown().isPresent) 1 else 0) + + (files.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (status.asKnown().isPresent) 1 else 0) + + /** A CAS file found in the user's email inbox */ + class File + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val casType: JsonField, + private val expiresIn: JsonField, + private val filename: JsonField, + private val messageDate: JsonField, + private val messageId: JsonField, + private val originalFilename: JsonField, + private val size: JsonField, + private val url: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("cas_type") + @ExcludeMissing + casType: JsonField = JsonMissing.of(), + @JsonProperty("expires_in") + @ExcludeMissing + expiresIn: JsonField = JsonMissing.of(), + @JsonProperty("filename") + @ExcludeMissing + filename: JsonField = JsonMissing.of(), + @JsonProperty("message_date") + @ExcludeMissing + messageDate: JsonField = JsonMissing.of(), + @JsonProperty("message_id") + @ExcludeMissing + messageId: JsonField = JsonMissing.of(), + @JsonProperty("original_filename") + @ExcludeMissing + originalFilename: JsonField = JsonMissing.of(), + @JsonProperty("size") @ExcludeMissing size: JsonField = JsonMissing.of(), + @JsonProperty("url") @ExcludeMissing url: JsonField = JsonMissing.of(), + ) : this( + casType, + expiresIn, + filename, + messageDate, + messageId, + originalFilename, + size, + url, + mutableMapOf(), + ) + + /** + * Detected CAS provider based on sender email + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun casType(): Optional = casType.getOptional("cas_type") + + /** + * URL expiration time in seconds (default 86400 = 24 hours) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun expiresIn(): Optional = expiresIn.getOptional("expires_in") + + /** + * Standardized filename (provider_YYYYMMDD_uniqueid.pdf) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun filename(): Optional = filename.getOptional("filename") + + /** + * Date the email was received + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun messageDate(): Optional = messageDate.getOptional("message_date") + + /** + * Unique identifier for the email message (use for subsequent API calls) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun messageId(): Optional = messageId.getOptional("message_id") + + /** + * Original attachment filename from the email + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun originalFilename(): Optional = originalFilename.getOptional("original_filename") + + /** + * File size in bytes + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun size(): Optional = size.getOptional("size") + + /** + * Direct download URL (presigned, expires based on expires_in) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun url(): Optional = url.getOptional("url") + + /** + * Returns the raw JSON value of [casType]. + * + * Unlike [casType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cas_type") @ExcludeMissing fun _casType(): JsonField = casType + + /** + * Returns the raw JSON value of [expiresIn]. + * + * Unlike [expiresIn], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expires_in") @ExcludeMissing fun _expiresIn(): JsonField = expiresIn + + /** + * Returns the raw JSON value of [filename]. + * + * Unlike [filename], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("filename") @ExcludeMissing fun _filename(): JsonField = filename + + /** + * Returns the raw JSON value of [messageDate]. + * + * Unlike [messageDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message_date") + @ExcludeMissing + fun _messageDate(): JsonField = messageDate + + /** + * Returns the raw JSON value of [messageId]. + * + * Unlike [messageId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message_id") @ExcludeMissing fun _messageId(): JsonField = messageId + + /** + * Returns the raw JSON value of [originalFilename]. + * + * Unlike [originalFilename], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("original_filename") + @ExcludeMissing + fun _originalFilename(): JsonField = originalFilename + + /** + * Returns the raw JSON value of [size]. + * + * Unlike [size], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("size") @ExcludeMissing fun _size(): JsonField = size + + /** + * Returns the raw JSON value of [url]. + * + * Unlike [url], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [File]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [File]. */ + class Builder internal constructor() { + + private var casType: JsonField = JsonMissing.of() + private var expiresIn: JsonField = JsonMissing.of() + private var filename: JsonField = JsonMissing.of() + private var messageDate: JsonField = JsonMissing.of() + private var messageId: JsonField = JsonMissing.of() + private var originalFilename: JsonField = JsonMissing.of() + private var size: JsonField = JsonMissing.of() + private var url: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(file: File) = apply { + casType = file.casType + expiresIn = file.expiresIn + filename = file.filename + messageDate = file.messageDate + messageId = file.messageId + originalFilename = file.originalFilename + size = file.size + url = file.url + additionalProperties = file.additionalProperties.toMutableMap() + } + + /** Detected CAS provider based on sender email */ + fun casType(casType: CasType) = casType(JsonField.of(casType)) + + /** + * Sets [Builder.casType] to an arbitrary JSON value. + * + * You should usually call [Builder.casType] with a well-typed [CasType] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun casType(casType: JsonField) = apply { this.casType = casType } + + /** URL expiration time in seconds (default 86400 = 24 hours) */ + fun expiresIn(expiresIn: Long) = expiresIn(JsonField.of(expiresIn)) + + /** + * Sets [Builder.expiresIn] to an arbitrary JSON value. + * + * You should usually call [Builder.expiresIn] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expiresIn(expiresIn: JsonField) = apply { this.expiresIn = expiresIn } + + /** Standardized filename (provider_YYYYMMDD_uniqueid.pdf) */ + fun filename(filename: String) = filename(JsonField.of(filename)) + + /** + * Sets [Builder.filename] to an arbitrary JSON value. + * + * You should usually call [Builder.filename] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun filename(filename: JsonField) = apply { this.filename = filename } + + /** Date the email was received */ + fun messageDate(messageDate: LocalDate) = messageDate(JsonField.of(messageDate)) + + /** + * Sets [Builder.messageDate] to an arbitrary JSON value. + * + * You should usually call [Builder.messageDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun messageDate(messageDate: JsonField) = apply { + this.messageDate = messageDate + } + + /** Unique identifier for the email message (use for subsequent API calls) */ + fun messageId(messageId: String) = messageId(JsonField.of(messageId)) + + /** + * Sets [Builder.messageId] to an arbitrary JSON value. + * + * You should usually call [Builder.messageId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun messageId(messageId: JsonField) = apply { this.messageId = messageId } + + /** Original attachment filename from the email */ + fun originalFilename(originalFilename: String) = + originalFilename(JsonField.of(originalFilename)) + + /** + * Sets [Builder.originalFilename] to an arbitrary JSON value. + * + * You should usually call [Builder.originalFilename] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun originalFilename(originalFilename: JsonField) = apply { + this.originalFilename = originalFilename + } + + /** File size in bytes */ + fun size(size: Long) = size(JsonField.of(size)) + + /** + * Sets [Builder.size] to an arbitrary JSON value. + * + * You should usually call [Builder.size] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun size(size: JsonField) = apply { this.size = size } + + /** Direct download URL (presigned, expires based on expires_in) */ + fun url(url: String) = url(JsonField.of(url)) + + /** + * Sets [Builder.url] to an arbitrary JSON value. + * + * You should usually call [Builder.url] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun url(url: JsonField) = apply { this.url = url } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [File]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): File = + File( + casType, + expiresIn, + filename, + messageDate, + messageId, + originalFilename, + size, + url, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): File = apply { + if (validated) { + return@apply + } + + casType().ifPresent { it.validate() } + expiresIn() + filename() + messageDate() + messageId() + originalFilename() + size() + url() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (casType.asKnown().getOrNull()?.validity() ?: 0) + + (if (expiresIn.asKnown().isPresent) 1 else 0) + + (if (filename.asKnown().isPresent) 1 else 0) + + (if (messageDate.asKnown().isPresent) 1 else 0) + + (if (messageId.asKnown().isPresent) 1 else 0) + + (if (originalFilename.asKnown().isPresent) 1 else 0) + + (if (size.asKnown().isPresent) 1 else 0) + + (if (url.asKnown().isPresent) 1 else 0) + + /** Detected CAS provider based on sender email */ + class CasType @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CDSL = of("cdsl") + + @JvmField val NSDL = of("nsdl") + + @JvmField val CAMS = of("cams") + + @JvmField val KFINTECH = of("kfintech") + + @JvmStatic fun of(value: String) = CasType(JsonField.of(value)) + } + + /** An enum containing [CasType]'s known values. */ + enum class Known { + CDSL, + NSDL, + CAMS, + KFINTECH, + } + + /** + * An enum containing [CasType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [CasType] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CDSL, + NSDL, + CAMS, + KFINTECH, + /** + * An enum member indicating that [CasType] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CDSL -> Value.CDSL + NSDL -> Value.NSDL + CAMS -> Value.CAMS + KFINTECH -> Value.KFINTECH + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws CasParserInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CDSL -> Known.CDSL + NSDL -> Known.NSDL + CAMS -> Known.CAMS + KFINTECH -> Known.KFINTECH + else -> throw CasParserInvalidDataException("Unknown CasType: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws CasParserInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + CasParserInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): CasType = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CasType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is File && + casType == other.casType && + expiresIn == other.expiresIn && + filename == other.filename && + messageDate == other.messageDate && + messageId == other.messageId && + originalFilename == other.originalFilename && + size == other.size && + url == other.url && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + casType, + expiresIn, + filename, + messageDate, + messageId, + originalFilename, + size, + url, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "File{casType=$casType, expiresIn=$expiresIn, filename=$filename, messageDate=$messageDate, messageId=$messageId, originalFilename=$originalFilename, size=$size, url=$url, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InboxListCasFilesResponse && + count == other.count && + files == other.files && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(count, files, status, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InboxListCasFilesResponse{count=$count, files=$files, status=$status, additionalProperties=$additionalProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/kfintech/KfintechGenerateCasParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/kfintech/KfintechGenerateCasParams.kt new file mode 100644 index 0000000..87b8b15 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/kfintech/KfintechGenerateCasParams.kt @@ -0,0 +1,693 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.kfintech + +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.Params +import com.cas_parser.api.core.checkRequired +import com.cas_parser.api.core.http.Headers +import com.cas_parser.api.core.http.QueryParams +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** + * Generate CAS via KFintech mailback. The CAS PDF will be sent to the investor's email. + * + * This is an async operation - the investor receives the CAS via email within a few minutes. For + * instant CAS retrieval, use CDSL Fetch (`/v4/cdsl/fetch`). + */ +class KfintechGenerateCasParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Email address to receive the CAS document + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun email(): String = body.email() + + /** + * Start date (YYYY-MM-DD) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun fromDate(): String = body.fromDate() + + /** + * Password for the PDF + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun password(): String = body.password() + + /** + * End date (YYYY-MM-DD) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun toDate(): String = body.toDate() + + /** + * PAN number (optional) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun panNo(): Optional = body.panNo() + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _email(): JsonField = body._email() + + /** + * Returns the raw JSON value of [fromDate]. + * + * Unlike [fromDate], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _fromDate(): JsonField = body._fromDate() + + /** + * Returns the raw JSON value of [password]. + * + * Unlike [password], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _password(): JsonField = body._password() + + /** + * Returns the raw JSON value of [toDate]. + * + * Unlike [toDate], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _toDate(): JsonField = body._toDate() + + /** + * Returns the raw JSON value of [panNo]. + * + * Unlike [panNo], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _panNo(): JsonField = body._panNo() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [KfintechGenerateCasParams]. + * + * The following fields are required: + * ```java + * .email() + * .fromDate() + * .password() + * .toDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [KfintechGenerateCasParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(kfintechGenerateCasParams: KfintechGenerateCasParams) = apply { + body = kfintechGenerateCasParams.body.toBuilder() + additionalHeaders = kfintechGenerateCasParams.additionalHeaders.toBuilder() + additionalQueryParams = kfintechGenerateCasParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [email] + * - [fromDate] + * - [password] + * - [toDate] + * - [panNo] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Email address to receive the CAS document */ + fun email(email: String) = apply { body.email(email) } + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun email(email: JsonField) = apply { body.email(email) } + + /** Start date (YYYY-MM-DD) */ + fun fromDate(fromDate: String) = apply { body.fromDate(fromDate) } + + /** + * Sets [Builder.fromDate] to an arbitrary JSON value. + * + * You should usually call [Builder.fromDate] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fromDate(fromDate: JsonField) = apply { body.fromDate(fromDate) } + + /** Password for the PDF */ + fun password(password: String) = apply { body.password(password) } + + /** + * Sets [Builder.password] to an arbitrary JSON value. + * + * You should usually call [Builder.password] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun password(password: JsonField) = apply { body.password(password) } + + /** End date (YYYY-MM-DD) */ + fun toDate(toDate: String) = apply { body.toDate(toDate) } + + /** + * Sets [Builder.toDate] to an arbitrary JSON value. + * + * You should usually call [Builder.toDate] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun toDate(toDate: JsonField) = apply { body.toDate(toDate) } + + /** PAN number (optional) */ + fun panNo(panNo: String) = apply { body.panNo(panNo) } + + /** + * Sets [Builder.panNo] to an arbitrary JSON value. + * + * You should usually call [Builder.panNo] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun panNo(panNo: JsonField) = apply { body.panNo(panNo) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [KfintechGenerateCasParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .email() + * .fromDate() + * .password() + * .toDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): KfintechGenerateCasParams = + KfintechGenerateCasParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val email: JsonField, + private val fromDate: JsonField, + private val password: JsonField, + private val toDate: JsonField, + private val panNo: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("email") @ExcludeMissing email: JsonField = JsonMissing.of(), + @JsonProperty("from_date") + @ExcludeMissing + fromDate: JsonField = JsonMissing.of(), + @JsonProperty("password") + @ExcludeMissing + password: JsonField = JsonMissing.of(), + @JsonProperty("to_date") @ExcludeMissing toDate: JsonField = JsonMissing.of(), + @JsonProperty("pan_no") @ExcludeMissing panNo: JsonField = JsonMissing.of(), + ) : this(email, fromDate, password, toDate, panNo, mutableMapOf()) + + /** + * Email address to receive the CAS document + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun email(): String = email.getRequired("email") + + /** + * Start date (YYYY-MM-DD) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun fromDate(): String = fromDate.getRequired("from_date") + + /** + * Password for the PDF + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun password(): String = password.getRequired("password") + + /** + * End date (YYYY-MM-DD) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun toDate(): String = toDate.getRequired("to_date") + + /** + * PAN number (optional) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun panNo(): Optional = panNo.getOptional("pan_no") + + /** + * Returns the raw JSON value of [email]. + * + * Unlike [email], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email + + /** + * Returns the raw JSON value of [fromDate]. + * + * Unlike [fromDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("from_date") @ExcludeMissing fun _fromDate(): JsonField = fromDate + + /** + * Returns the raw JSON value of [password]. + * + * Unlike [password], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("password") @ExcludeMissing fun _password(): JsonField = password + + /** + * Returns the raw JSON value of [toDate]. + * + * Unlike [toDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("to_date") @ExcludeMissing fun _toDate(): JsonField = toDate + + /** + * Returns the raw JSON value of [panNo]. + * + * Unlike [panNo], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pan_no") @ExcludeMissing fun _panNo(): JsonField = panNo + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .email() + * .fromDate() + * .password() + * .toDate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var email: JsonField? = null + private var fromDate: JsonField? = null + private var password: JsonField? = null + private var toDate: JsonField? = null + private var panNo: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + email = body.email + fromDate = body.fromDate + password = body.password + toDate = body.toDate + panNo = body.panNo + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** Email address to receive the CAS document */ + fun email(email: String) = email(JsonField.of(email)) + + /** + * Sets [Builder.email] to an arbitrary JSON value. + * + * You should usually call [Builder.email] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun email(email: JsonField) = apply { this.email = email } + + /** Start date (YYYY-MM-DD) */ + fun fromDate(fromDate: String) = fromDate(JsonField.of(fromDate)) + + /** + * Sets [Builder.fromDate] to an arbitrary JSON value. + * + * You should usually call [Builder.fromDate] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fromDate(fromDate: JsonField) = apply { this.fromDate = fromDate } + + /** Password for the PDF */ + fun password(password: String) = password(JsonField.of(password)) + + /** + * Sets [Builder.password] to an arbitrary JSON value. + * + * You should usually call [Builder.password] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun password(password: JsonField) = apply { this.password = password } + + /** End date (YYYY-MM-DD) */ + fun toDate(toDate: String) = toDate(JsonField.of(toDate)) + + /** + * Sets [Builder.toDate] to an arbitrary JSON value. + * + * You should usually call [Builder.toDate] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun toDate(toDate: JsonField) = apply { this.toDate = toDate } + + /** PAN number (optional) */ + fun panNo(panNo: String) = panNo(JsonField.of(panNo)) + + /** + * Sets [Builder.panNo] to an arbitrary JSON value. + * + * You should usually call [Builder.panNo] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun panNo(panNo: JsonField) = apply { this.panNo = panNo } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .email() + * .fromDate() + * .password() + * .toDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("email", email), + checkRequired("fromDate", fromDate), + checkRequired("password", password), + checkRequired("toDate", toDate), + panNo, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + email() + fromDate() + password() + toDate() + panNo() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (email.asKnown().isPresent) 1 else 0) + + (if (fromDate.asKnown().isPresent) 1 else 0) + + (if (password.asKnown().isPresent) 1 else 0) + + (if (toDate.asKnown().isPresent) 1 else 0) + + (if (panNo.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + email == other.email && + fromDate == other.fromDate && + password == other.password && + toDate == other.toDate && + panNo == other.panNo && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(email, fromDate, password, toDate, panNo, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{email=$email, fromDate=$fromDate, password=$password, toDate=$toDate, panNo=$panNo, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is KfintechGenerateCasParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "KfintechGenerateCasParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/kfintech/KfintechGenerateCasResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/kfintech/KfintechGenerateCasResponse.kt new file mode 100644 index 0000000..40e0359 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/kfintech/KfintechGenerateCasResponse.kt @@ -0,0 +1,186 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.kfintech + +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional + +class KfintechGenerateCasResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val msg: JsonField, + private val status: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("msg") @ExcludeMissing msg: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + ) : this(msg, status, mutableMapOf()) + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun msg(): Optional = msg.getOptional("msg") + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * Returns the raw JSON value of [msg]. + * + * Unlike [msg], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("msg") @ExcludeMissing fun _msg(): JsonField = msg + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [KfintechGenerateCasResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [KfintechGenerateCasResponse]. */ + class Builder internal constructor() { + + private var msg: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(kfintechGenerateCasResponse: KfintechGenerateCasResponse) = apply { + msg = kfintechGenerateCasResponse.msg + status = kfintechGenerateCasResponse.status + additionalProperties = kfintechGenerateCasResponse.additionalProperties.toMutableMap() + } + + fun msg(msg: String) = msg(JsonField.of(msg)) + + /** + * Sets [Builder.msg] to an arbitrary JSON value. + * + * You should usually call [Builder.msg] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun msg(msg: JsonField) = apply { this.msg = msg } + + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [KfintechGenerateCasResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): KfintechGenerateCasResponse = + KfintechGenerateCasResponse(msg, status, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): KfintechGenerateCasResponse = apply { + if (validated) { + return@apply + } + + msg() + status() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (msg.asKnown().isPresent) 1 else 0) + (if (status.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is KfintechGenerateCasResponse && + msg == other.msg && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(msg, status, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "KfintechGenerateCasResponse{msg=$msg, status=$status, additionalProperties=$additionalProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogCreateParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogCreateParams.kt new file mode 100644 index 0000000..c46a795 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogCreateParams.kt @@ -0,0 +1,528 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.logs + +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.Params +import com.cas_parser.api.core.http.Headers +import com.cas_parser.api.core.http.QueryParams +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** + * Retrieve detailed API usage logs for your account. + * + * Returns a list of API calls with timestamps, features used, status codes, and credits consumed. + * Useful for monitoring usage patterns and debugging. + */ +class LogCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * End time filter (ISO 8601). Defaults to now. + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endTime(): Optional = body.endTime() + + /** + * Maximum number of logs to return + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun limit(): Optional = body.limit() + + /** + * Start time filter (ISO 8601). Defaults to 30 days ago. + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun startTime(): Optional = body.startTime() + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _endTime(): JsonField = body._endTime() + + /** + * Returns the raw JSON value of [limit]. + * + * Unlike [limit], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _limit(): JsonField = body._limit() + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _startTime(): JsonField = body._startTime() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): LogCreateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [LogCreateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LogCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(logCreateParams: LogCreateParams) = apply { + body = logCreateParams.body.toBuilder() + additionalHeaders = logCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = logCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [endTime] + * - [limit] + * - [startTime] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** End time filter (ISO 8601). Defaults to now. */ + fun endTime(endTime: OffsetDateTime) = apply { body.endTime(endTime) } + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField) = apply { body.endTime(endTime) } + + /** Maximum number of logs to return */ + fun limit(limit: Long) = apply { body.limit(limit) } + + /** + * Sets [Builder.limit] to an arbitrary JSON value. + * + * You should usually call [Builder.limit] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun limit(limit: JsonField) = apply { body.limit(limit) } + + /** Start time filter (ISO 8601). Defaults to 30 days ago. */ + fun startTime(startTime: OffsetDateTime) = apply { body.startTime(startTime) } + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField) = apply { body.startTime(startTime) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LogCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LogCreateParams = + LogCreateParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val endTime: JsonField, + private val limit: JsonField, + private val startTime: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField = JsonMissing.of(), + @JsonProperty("limit") @ExcludeMissing limit: JsonField = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField = JsonMissing.of(), + ) : this(endTime, limit, startTime, mutableMapOf()) + + /** + * End time filter (ISO 8601). Defaults to now. + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endTime(): Optional = endTime.getOptional("end_time") + + /** + * Maximum number of logs to return + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun limit(): Optional = limit.getOptional("limit") + + /** + * Start time filter (ISO 8601). Defaults to 30 days ago. + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startTime(): Optional = startTime.getOptional("start_time") + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") + @ExcludeMissing + fun _endTime(): JsonField = endTime + + /** + * Returns the raw JSON value of [limit]. + * + * Unlike [limit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField = limit + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField = startTime + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var endTime: JsonField = JsonMissing.of() + private var limit: JsonField = JsonMissing.of() + private var startTime: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + endTime = body.endTime + limit = body.limit + startTime = body.startTime + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** End time filter (ISO 8601). Defaults to now. */ + fun endTime(endTime: OffsetDateTime) = endTime(JsonField.of(endTime)) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField) = apply { this.endTime = endTime } + + /** Maximum number of logs to return */ + fun limit(limit: Long) = limit(JsonField.of(limit)) + + /** + * Sets [Builder.limit] to an arbitrary JSON value. + * + * You should usually call [Builder.limit] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun limit(limit: JsonField) = apply { this.limit = limit } + + /** Start time filter (ISO 8601). Defaults to 30 days ago. */ + fun startTime(startTime: OffsetDateTime) = startTime(JsonField.of(startTime)) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField) = apply { + this.startTime = startTime + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(endTime, limit, startTime, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + endTime() + limit() + startTime() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (limit.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + endTime == other.endTime && + limit == other.limit && + startTime == other.startTime && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(endTime, limit, startTime, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{endTime=$endTime, limit=$limit, startTime=$startTime, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LogCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "LogCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogCreateResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogCreateResponse.kt new file mode 100644 index 0000000..b77a776 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogCreateResponse.kt @@ -0,0 +1,578 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.logs + +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.checkKnown +import com.cas_parser.api.core.toImmutable +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class LogCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val count: JsonField, + private val logs: JsonField>, + private val status: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("count") @ExcludeMissing count: JsonField = JsonMissing.of(), + @JsonProperty("logs") @ExcludeMissing logs: JsonField> = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + ) : this(count, logs, status, mutableMapOf()) + + /** + * Number of logs returned + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun count(): Optional = count.getOptional("count") + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun logs(): Optional> = logs.getOptional("logs") + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * Returns the raw JSON value of [count]. + * + * Unlike [count], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("count") @ExcludeMissing fun _count(): JsonField = count + + /** + * Returns the raw JSON value of [logs]. + * + * Unlike [logs], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("logs") @ExcludeMissing fun _logs(): JsonField> = logs + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [LogCreateResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LogCreateResponse]. */ + class Builder internal constructor() { + + private var count: JsonField = JsonMissing.of() + private var logs: JsonField>? = null + private var status: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(logCreateResponse: LogCreateResponse) = apply { + count = logCreateResponse.count + logs = logCreateResponse.logs.map { it.toMutableList() } + status = logCreateResponse.status + additionalProperties = logCreateResponse.additionalProperties.toMutableMap() + } + + /** Number of logs returned */ + fun count(count: Long) = count(JsonField.of(count)) + + /** + * Sets [Builder.count] to an arbitrary JSON value. + * + * You should usually call [Builder.count] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun count(count: JsonField) = apply { this.count = count } + + fun logs(logs: List) = logs(JsonField.of(logs)) + + /** + * Sets [Builder.logs] to an arbitrary JSON value. + * + * You should usually call [Builder.logs] with a well-typed `List` value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun logs(logs: JsonField>) = apply { this.logs = logs.map { it.toMutableList() } } + + /** + * Adds a single [Log] to [logs]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addLog(log: Log) = apply { + logs = (logs ?: JsonField.of(mutableListOf())).also { checkKnown("logs", it).add(log) } + } + + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LogCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LogCreateResponse = + LogCreateResponse( + count, + (logs ?: JsonMissing.of()).map { it.toImmutable() }, + status, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): LogCreateResponse = apply { + if (validated) { + return@apply + } + + count() + logs().ifPresent { it.forEach { it.validate() } } + status() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (count.asKnown().isPresent) 1 else 0) + + (logs.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (status.asKnown().isPresent) 1 else 0) + + class Log + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val credits: JsonField, + private val feature: JsonField, + private val path: JsonField, + private val requestId: JsonField, + private val statusCode: JsonField, + private val timestamp: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("credits") @ExcludeMissing credits: JsonField = JsonMissing.of(), + @JsonProperty("feature") @ExcludeMissing feature: JsonField = JsonMissing.of(), + @JsonProperty("path") @ExcludeMissing path: JsonField = JsonMissing.of(), + @JsonProperty("request_id") + @ExcludeMissing + requestId: JsonField = JsonMissing.of(), + @JsonProperty("status_code") + @ExcludeMissing + statusCode: JsonField = JsonMissing.of(), + @JsonProperty("timestamp") + @ExcludeMissing + timestamp: JsonField = JsonMissing.of(), + ) : this(credits, feature, path, requestId, statusCode, timestamp, mutableMapOf()) + + /** + * Credits consumed for this request + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun credits(): Optional = credits.getOptional("credits") + + /** + * API feature used + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun feature(): Optional = feature.getOptional("feature") + + /** + * API endpoint path + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun path(): Optional = path.getOptional("path") + + /** + * Unique request identifier + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun requestId(): Optional = requestId.getOptional("request_id") + + /** + * HTTP response status code + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun statusCode(): Optional = statusCode.getOptional("status_code") + + /** + * When the request was made + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun timestamp(): Optional = timestamp.getOptional("timestamp") + + /** + * Returns the raw JSON value of [credits]. + * + * Unlike [credits], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credits") @ExcludeMissing fun _credits(): JsonField = credits + + /** + * Returns the raw JSON value of [feature]. + * + * Unlike [feature], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feature") @ExcludeMissing fun _feature(): JsonField = feature + + /** + * Returns the raw JSON value of [path]. + * + * Unlike [path], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("path") @ExcludeMissing fun _path(): JsonField = path + + /** + * Returns the raw JSON value of [requestId]. + * + * Unlike [requestId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("request_id") @ExcludeMissing fun _requestId(): JsonField = requestId + + /** + * Returns the raw JSON value of [statusCode]. + * + * Unlike [statusCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status_code") @ExcludeMissing fun _statusCode(): JsonField = statusCode + + /** + * Returns the raw JSON value of [timestamp]. + * + * Unlike [timestamp], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("timestamp") + @ExcludeMissing + fun _timestamp(): JsonField = timestamp + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Log]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Log]. */ + class Builder internal constructor() { + + private var credits: JsonField = JsonMissing.of() + private var feature: JsonField = JsonMissing.of() + private var path: JsonField = JsonMissing.of() + private var requestId: JsonField = JsonMissing.of() + private var statusCode: JsonField = JsonMissing.of() + private var timestamp: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(log: Log) = apply { + credits = log.credits + feature = log.feature + path = log.path + requestId = log.requestId + statusCode = log.statusCode + timestamp = log.timestamp + additionalProperties = log.additionalProperties.toMutableMap() + } + + /** Credits consumed for this request */ + fun credits(credits: Double) = credits(JsonField.of(credits)) + + /** + * Sets [Builder.credits] to an arbitrary JSON value. + * + * You should usually call [Builder.credits] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun credits(credits: JsonField) = apply { this.credits = credits } + + /** API feature used */ + fun feature(feature: String) = feature(JsonField.of(feature)) + + /** + * Sets [Builder.feature] to an arbitrary JSON value. + * + * You should usually call [Builder.feature] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun feature(feature: JsonField) = apply { this.feature = feature } + + /** API endpoint path */ + fun path(path: String) = path(JsonField.of(path)) + + /** + * Sets [Builder.path] to an arbitrary JSON value. + * + * You should usually call [Builder.path] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun path(path: JsonField) = apply { this.path = path } + + /** Unique request identifier */ + fun requestId(requestId: String) = requestId(JsonField.of(requestId)) + + /** + * Sets [Builder.requestId] to an arbitrary JSON value. + * + * You should usually call [Builder.requestId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun requestId(requestId: JsonField) = apply { this.requestId = requestId } + + /** HTTP response status code */ + fun statusCode(statusCode: Long) = statusCode(JsonField.of(statusCode)) + + /** + * Sets [Builder.statusCode] to an arbitrary JSON value. + * + * You should usually call [Builder.statusCode] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun statusCode(statusCode: JsonField) = apply { this.statusCode = statusCode } + + /** When the request was made */ + fun timestamp(timestamp: OffsetDateTime) = timestamp(JsonField.of(timestamp)) + + /** + * Sets [Builder.timestamp] to an arbitrary JSON value. + * + * You should usually call [Builder.timestamp] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun timestamp(timestamp: JsonField) = apply { + this.timestamp = timestamp + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Log]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Log = + Log( + credits, + feature, + path, + requestId, + statusCode, + timestamp, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Log = apply { + if (validated) { + return@apply + } + + credits() + feature() + path() + requestId() + statusCode() + timestamp() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (credits.asKnown().isPresent) 1 else 0) + + (if (feature.asKnown().isPresent) 1 else 0) + + (if (path.asKnown().isPresent) 1 else 0) + + (if (requestId.asKnown().isPresent) 1 else 0) + + (if (statusCode.asKnown().isPresent) 1 else 0) + + (if (timestamp.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Log && + credits == other.credits && + feature == other.feature && + path == other.path && + requestId == other.requestId && + statusCode == other.statusCode && + timestamp == other.timestamp && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + credits, + feature, + path, + requestId, + statusCode, + timestamp, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Log{credits=$credits, feature=$feature, path=$path, requestId=$requestId, statusCode=$statusCode, timestamp=$timestamp, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LogCreateResponse && + count == other.count && + logs == other.logs && + status == other.status && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(count, logs, status, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LogCreateResponse{count=$count, logs=$logs, status=$status, additionalProperties=$additionalProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogGetSummaryParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogGetSummaryParams.kt new file mode 100644 index 0000000..f14f253 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogGetSummaryParams.kt @@ -0,0 +1,468 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.logs + +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.Params +import com.cas_parser.api.core.http.Headers +import com.cas_parser.api.core.http.QueryParams +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** + * Get aggregated usage statistics grouped by feature. + * + * Useful for understanding which API features are being used most and tracking usage trends. + */ +class LogGetSummaryParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * End time filter (ISO 8601). Defaults to now. + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun endTime(): Optional = body.endTime() + + /** + * Start time filter (ISO 8601). Defaults to start of current month. + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun startTime(): Optional = body.startTime() + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _endTime(): JsonField = body._endTime() + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _startTime(): JsonField = body._startTime() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): LogGetSummaryParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [LogGetSummaryParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LogGetSummaryParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(logGetSummaryParams: LogGetSummaryParams) = apply { + body = logGetSummaryParams.body.toBuilder() + additionalHeaders = logGetSummaryParams.additionalHeaders.toBuilder() + additionalQueryParams = logGetSummaryParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [endTime] + * - [startTime] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** End time filter (ISO 8601). Defaults to now. */ + fun endTime(endTime: OffsetDateTime) = apply { body.endTime(endTime) } + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField) = apply { body.endTime(endTime) } + + /** Start time filter (ISO 8601). Defaults to start of current month. */ + fun startTime(startTime: OffsetDateTime) = apply { body.startTime(startTime) } + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField) = apply { body.startTime(startTime) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [LogGetSummaryParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LogGetSummaryParams = + LogGetSummaryParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val endTime: JsonField, + private val startTime: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("end_time") + @ExcludeMissing + endTime: JsonField = JsonMissing.of(), + @JsonProperty("start_time") + @ExcludeMissing + startTime: JsonField = JsonMissing.of(), + ) : this(endTime, startTime, mutableMapOf()) + + /** + * End time filter (ISO 8601). Defaults to now. + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun endTime(): Optional = endTime.getOptional("end_time") + + /** + * Start time filter (ISO 8601). Defaults to start of current month. + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun startTime(): Optional = startTime.getOptional("start_time") + + /** + * Returns the raw JSON value of [endTime]. + * + * Unlike [endTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("end_time") + @ExcludeMissing + fun _endTime(): JsonField = endTime + + /** + * Returns the raw JSON value of [startTime]. + * + * Unlike [startTime], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("start_time") + @ExcludeMissing + fun _startTime(): JsonField = startTime + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var endTime: JsonField = JsonMissing.of() + private var startTime: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + endTime = body.endTime + startTime = body.startTime + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** End time filter (ISO 8601). Defaults to now. */ + fun endTime(endTime: OffsetDateTime) = endTime(JsonField.of(endTime)) + + /** + * Sets [Builder.endTime] to an arbitrary JSON value. + * + * You should usually call [Builder.endTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun endTime(endTime: JsonField) = apply { this.endTime = endTime } + + /** Start time filter (ISO 8601). Defaults to start of current month. */ + fun startTime(startTime: OffsetDateTime) = startTime(JsonField.of(startTime)) + + /** + * Sets [Builder.startTime] to an arbitrary JSON value. + * + * You should usually call [Builder.startTime] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun startTime(startTime: JsonField) = apply { + this.startTime = startTime + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = Body(endTime, startTime, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + endTime() + startTime() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (endTime.asKnown().isPresent) 1 else 0) + + (if (startTime.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + endTime == other.endTime && + startTime == other.startTime && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(endTime, startTime, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{endTime=$endTime, startTime=$startTime, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LogGetSummaryParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "LogGetSummaryParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogGetSummaryResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogGetSummaryResponse.kt new file mode 100644 index 0000000..a78d1ba --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/logs/LogGetSummaryResponse.kt @@ -0,0 +1,663 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.logs + +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.checkKnown +import com.cas_parser.api.core.toImmutable +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class LogGetSummaryResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val status: JsonField, + private val summary: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("summary") @ExcludeMissing summary: JsonField = JsonMissing.of(), + ) : this(status, summary, mutableMapOf()) + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun status(): Optional = status.getOptional("status") + + /** + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun summary(): Optional = summary.getOptional("summary") + + /** + * Returns the raw JSON value of [status]. + * + * Unlike [status], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status + + /** + * Returns the raw JSON value of [summary]. + * + * Unlike [summary], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("summary") @ExcludeMissing fun _summary(): JsonField = summary + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [LogGetSummaryResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [LogGetSummaryResponse]. */ + class Builder internal constructor() { + + private var status: JsonField = JsonMissing.of() + private var summary: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(logGetSummaryResponse: LogGetSummaryResponse) = apply { + status = logGetSummaryResponse.status + summary = logGetSummaryResponse.summary + additionalProperties = logGetSummaryResponse.additionalProperties.toMutableMap() + } + + fun status(status: String) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + fun summary(summary: Summary) = summary(JsonField.of(summary)) + + /** + * Sets [Builder.summary] to an arbitrary JSON value. + * + * You should usually call [Builder.summary] with a well-typed [Summary] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun summary(summary: JsonField) = apply { this.summary = summary } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [LogGetSummaryResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): LogGetSummaryResponse = + LogGetSummaryResponse(status, summary, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): LogGetSummaryResponse = apply { + if (validated) { + return@apply + } + + status() + summary().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (status.asKnown().isPresent) 1 else 0) + + (summary.asKnown().getOrNull()?.validity() ?: 0) + + class Summary + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val byFeature: JsonField>, + private val totalCredits: JsonField, + private val totalRequests: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("by_feature") + @ExcludeMissing + byFeature: JsonField> = JsonMissing.of(), + @JsonProperty("total_credits") + @ExcludeMissing + totalCredits: JsonField = JsonMissing.of(), + @JsonProperty("total_requests") + @ExcludeMissing + totalRequests: JsonField = JsonMissing.of(), + ) : this(byFeature, totalCredits, totalRequests, mutableMapOf()) + + /** + * Usage breakdown by feature + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun byFeature(): Optional> = byFeature.getOptional("by_feature") + + /** + * Total credits consumed in the period + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun totalCredits(): Optional = totalCredits.getOptional("total_credits") + + /** + * Total API requests made in the period + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun totalRequests(): Optional = totalRequests.getOptional("total_requests") + + /** + * Returns the raw JSON value of [byFeature]. + * + * Unlike [byFeature], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("by_feature") + @ExcludeMissing + fun _byFeature(): JsonField> = byFeature + + /** + * Returns the raw JSON value of [totalCredits]. + * + * Unlike [totalCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("total_credits") + @ExcludeMissing + fun _totalCredits(): JsonField = totalCredits + + /** + * Returns the raw JSON value of [totalRequests]. + * + * Unlike [totalRequests], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("total_requests") + @ExcludeMissing + fun _totalRequests(): JsonField = totalRequests + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Summary]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Summary]. */ + class Builder internal constructor() { + + private var byFeature: JsonField>? = null + private var totalCredits: JsonField = JsonMissing.of() + private var totalRequests: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(summary: Summary) = apply { + byFeature = summary.byFeature.map { it.toMutableList() } + totalCredits = summary.totalCredits + totalRequests = summary.totalRequests + additionalProperties = summary.additionalProperties.toMutableMap() + } + + /** Usage breakdown by feature */ + fun byFeature(byFeature: List) = byFeature(JsonField.of(byFeature)) + + /** + * Sets [Builder.byFeature] to an arbitrary JSON value. + * + * You should usually call [Builder.byFeature] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun byFeature(byFeature: JsonField>) = apply { + this.byFeature = byFeature.map { it.toMutableList() } + } + + /** + * Adds a single [ByFeature] to [Builder.byFeature]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addByFeature(byFeature: ByFeature) = apply { + this.byFeature = + (this.byFeature ?: JsonField.of(mutableListOf())).also { + checkKnown("byFeature", it).add(byFeature) + } + } + + /** Total credits consumed in the period */ + fun totalCredits(totalCredits: Double) = totalCredits(JsonField.of(totalCredits)) + + /** + * Sets [Builder.totalCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.totalCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun totalCredits(totalCredits: JsonField) = apply { + this.totalCredits = totalCredits + } + + /** Total API requests made in the period */ + fun totalRequests(totalRequests: Long) = totalRequests(JsonField.of(totalRequests)) + + /** + * Sets [Builder.totalRequests] to an arbitrary JSON value. + * + * You should usually call [Builder.totalRequests] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun totalRequests(totalRequests: JsonField) = apply { + this.totalRequests = totalRequests + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Summary]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Summary = + Summary( + (byFeature ?: JsonMissing.of()).map { it.toImmutable() }, + totalCredits, + totalRequests, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Summary = apply { + if (validated) { + return@apply + } + + byFeature().ifPresent { it.forEach { it.validate() } } + totalCredits() + totalRequests() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (byFeature.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (totalCredits.asKnown().isPresent) 1 else 0) + + (if (totalRequests.asKnown().isPresent) 1 else 0) + + class ByFeature + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val credits: JsonField, + private val feature: JsonField, + private val requests: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("credits") + @ExcludeMissing + credits: JsonField = JsonMissing.of(), + @JsonProperty("feature") + @ExcludeMissing + feature: JsonField = JsonMissing.of(), + @JsonProperty("requests") + @ExcludeMissing + requests: JsonField = JsonMissing.of(), + ) : this(credits, feature, requests, mutableMapOf()) + + /** + * Credits consumed by this feature + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun credits(): Optional = credits.getOptional("credits") + + /** + * API feature name + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun feature(): Optional = feature.getOptional("feature") + + /** + * Number of requests for this feature + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun requests(): Optional = requests.getOptional("requests") + + /** + * Returns the raw JSON value of [credits]. + * + * Unlike [credits], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credits") @ExcludeMissing fun _credits(): JsonField = credits + + /** + * Returns the raw JSON value of [feature]. + * + * Unlike [feature], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("feature") @ExcludeMissing fun _feature(): JsonField = feature + + /** + * Returns the raw JSON value of [requests]. + * + * Unlike [requests], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("requests") @ExcludeMissing fun _requests(): JsonField = requests + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [ByFeature]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ByFeature]. */ + class Builder internal constructor() { + + private var credits: JsonField = JsonMissing.of() + private var feature: JsonField = JsonMissing.of() + private var requests: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(byFeature: ByFeature) = apply { + credits = byFeature.credits + feature = byFeature.feature + requests = byFeature.requests + additionalProperties = byFeature.additionalProperties.toMutableMap() + } + + /** Credits consumed by this feature */ + fun credits(credits: Double) = credits(JsonField.of(credits)) + + /** + * Sets [Builder.credits] to an arbitrary JSON value. + * + * You should usually call [Builder.credits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun credits(credits: JsonField) = apply { this.credits = credits } + + /** API feature name */ + fun feature(feature: String) = feature(JsonField.of(feature)) + + /** + * Sets [Builder.feature] to an arbitrary JSON value. + * + * You should usually call [Builder.feature] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun feature(feature: JsonField) = apply { this.feature = feature } + + /** Number of requests for this feature */ + fun requests(requests: Long) = requests(JsonField.of(requests)) + + /** + * Sets [Builder.requests] to an arbitrary JSON value. + * + * You should usually call [Builder.requests] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun requests(requests: JsonField) = apply { this.requests = requests } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [ByFeature]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ByFeature = + ByFeature(credits, feature, requests, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): ByFeature = apply { + if (validated) { + return@apply + } + + credits() + feature() + requests() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (credits.asKnown().isPresent) 1 else 0) + + (if (feature.asKnown().isPresent) 1 else 0) + + (if (requests.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ByFeature && + credits == other.credits && + feature == other.feature && + requests == other.requests && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(credits, feature, requests, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ByFeature{credits=$credits, feature=$feature, requests=$requests, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Summary && + byFeature == other.byFeature && + totalCredits == other.totalCredits && + totalRequests == other.totalRequests && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(byFeature, totalCredits, totalRequests, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Summary{byFeature=$byFeature, totalCredits=$totalCredits, totalRequests=$totalRequests, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is LogGetSummaryResponse && + status == other.status && + summary == other.summary && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(status, summary, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "LogGetSummaryResponse{status=$status, summary=$summary, additionalProperties=$additionalProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/casparser/CasParserNsdlParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/nsdl/NsdlParseParams.kt similarity index 94% rename from cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/casparser/CasParserNsdlParams.kt rename to cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/nsdl/NsdlParseParams.kt index 87cec06..240f71c 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/casparser/CasParserNsdlParams.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/nsdl/NsdlParseParams.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.cas_parser.api.models.casparser +package com.cas_parser.api.models.nsdl import com.cas_parser.api.core.ExcludeMissing import com.cas_parser.api.core.JsonValue @@ -21,7 +21,7 @@ import java.util.Optional * This endpoint specifically parses NSDL CAS (Consolidated Account Statement) PDF files and returns * data in a unified format. Use this endpoint when you know the PDF is from NSDL. */ -class CasParserNsdlParams +class NsdlParseParams private constructor( private val body: Body, private val additionalHeaders: Headers, @@ -85,13 +85,13 @@ private constructor( companion object { - @JvmStatic fun none(): CasParserNsdlParams = builder().build() + @JvmStatic fun none(): NsdlParseParams = builder().build() - /** Returns a mutable builder for constructing an instance of [CasParserNsdlParams]. */ + /** Returns a mutable builder for constructing an instance of [NsdlParseParams]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [CasParserNsdlParams]. */ + /** A builder for [NsdlParseParams]. */ class Builder internal constructor() { private var body: Body.Builder = Body.builder() @@ -99,10 +99,10 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(casParserNsdlParams: CasParserNsdlParams) = apply { - body = casParserNsdlParams.body.toBuilder() - additionalHeaders = casParserNsdlParams.additionalHeaders.toBuilder() - additionalQueryParams = casParserNsdlParams.additionalQueryParams.toBuilder() + internal fun from(nsdlParseParams: NsdlParseParams) = apply { + body = nsdlParseParams.body.toBuilder() + additionalHeaders = nsdlParseParams.additionalHeaders.toBuilder() + additionalQueryParams = nsdlParseParams.additionalQueryParams.toBuilder() } /** @@ -267,16 +267,12 @@ private constructor( } /** - * Returns an immutable instance of [CasParserNsdlParams]. + * Returns an immutable instance of [NsdlParseParams]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): CasParserNsdlParams = - CasParserNsdlParams( - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) + fun build(): NsdlParseParams = + NsdlParseParams(body.build(), additionalHeaders.build(), additionalQueryParams.build()) } fun _body(): Map> = @@ -489,7 +485,7 @@ private constructor( return true } - return other is CasParserNsdlParams && + return other is NsdlParseParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams @@ -498,5 +494,5 @@ private constructor( override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = - "CasParserNsdlParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "NsdlParseParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/casparser/CasParserSmartParseParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/smart/SmartParseCasPdfParams.kt similarity index 94% rename from cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/casparser/CasParserSmartParseParams.kt rename to cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/smart/SmartParseCasPdfParams.kt index 99ecd8a..cbfbeb1 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/casparser/CasParserSmartParseParams.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/smart/SmartParseCasPdfParams.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.cas_parser.api.models.casparser +package com.cas_parser.api.models.smart import com.cas_parser.api.core.ExcludeMissing import com.cas_parser.api.core.JsonValue @@ -22,7 +22,7 @@ import java.util.Optional * CAMS/KFintech and returns data in a unified format. It auto-detects the CAS type and transforms * the data into a consistent structure regardless of the source. */ -class CasParserSmartParseParams +class SmartParseCasPdfParams private constructor( private val body: Body, private val additionalHeaders: Headers, @@ -86,15 +86,13 @@ private constructor( companion object { - @JvmStatic fun none(): CasParserSmartParseParams = builder().build() + @JvmStatic fun none(): SmartParseCasPdfParams = builder().build() - /** - * Returns a mutable builder for constructing an instance of [CasParserSmartParseParams]. - */ + /** Returns a mutable builder for constructing an instance of [SmartParseCasPdfParams]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [CasParserSmartParseParams]. */ + /** A builder for [SmartParseCasPdfParams]. */ class Builder internal constructor() { private var body: Body.Builder = Body.builder() @@ -102,10 +100,10 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(casParserSmartParseParams: CasParserSmartParseParams) = apply { - body = casParserSmartParseParams.body.toBuilder() - additionalHeaders = casParserSmartParseParams.additionalHeaders.toBuilder() - additionalQueryParams = casParserSmartParseParams.additionalQueryParams.toBuilder() + internal fun from(smartParseCasPdfParams: SmartParseCasPdfParams) = apply { + body = smartParseCasPdfParams.body.toBuilder() + additionalHeaders = smartParseCasPdfParams.additionalHeaders.toBuilder() + additionalQueryParams = smartParseCasPdfParams.additionalQueryParams.toBuilder() } /** @@ -270,12 +268,12 @@ private constructor( } /** - * Returns an immutable instance of [CasParserSmartParseParams]. + * Returns an immutable instance of [SmartParseCasPdfParams]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): CasParserSmartParseParams = - CasParserSmartParseParams( + fun build(): SmartParseCasPdfParams = + SmartParseCasPdfParams( body.build(), additionalHeaders.build(), additionalQueryParams.build(), @@ -492,7 +490,7 @@ private constructor( return true } - return other is CasParserSmartParseParams && + return other is SmartParseCasPdfParams && body == other.body && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams @@ -501,5 +499,5 @@ private constructor( override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) override fun toString() = - "CasParserSmartParseParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "SmartParseCasPdfParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyParams.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyParams.kt new file mode 100644 index 0000000..aac1a81 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyParams.kt @@ -0,0 +1,211 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.verifytoken + +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.core.Params +import com.cas_parser.api.core.http.Headers +import com.cas_parser.api.core.http.QueryParams +import com.cas_parser.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +/** Verify an access token and check if it's still valid. Useful for debugging token issues. */ +class VerifyTokenVerifyParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): VerifyTokenVerifyParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [VerifyTokenVerifyParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VerifyTokenVerifyParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(verifyTokenVerifyParams: VerifyTokenVerifyParams) = apply { + additionalHeaders = verifyTokenVerifyParams.additionalHeaders.toBuilder() + additionalQueryParams = verifyTokenVerifyParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + verifyTokenVerifyParams.additionalBodyProperties.toMutableMap() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [VerifyTokenVerifyParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VerifyTokenVerifyParams = + VerifyTokenVerifyParams( + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VerifyTokenVerifyParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "VerifyTokenVerifyParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyResponse.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyResponse.kt new file mode 100644 index 0000000..b8859a0 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyResponse.kt @@ -0,0 +1,240 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.verifytoken + +import com.cas_parser.api.core.ExcludeMissing +import com.cas_parser.api.core.JsonField +import com.cas_parser.api.core.JsonMissing +import com.cas_parser.api.core.JsonValue +import com.cas_parser.api.errors.CasParserInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional + +class VerifyTokenVerifyResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val error: JsonField, + private val maskedApiKey: JsonField, + private val valid: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), + @JsonProperty("masked_api_key") + @ExcludeMissing + maskedApiKey: JsonField = JsonMissing.of(), + @JsonProperty("valid") @ExcludeMissing valid: JsonField = JsonMissing.of(), + ) : this(error, maskedApiKey, valid, mutableMapOf()) + + /** + * Error message (only shown if invalid) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun error(): Optional = error.getOptional("error") + + /** + * Masked API key (only shown if valid) + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun maskedApiKey(): Optional = maskedApiKey.getOptional("masked_api_key") + + /** + * Whether the token is valid + * + * @throws CasParserInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun valid(): Optional = valid.getOptional("valid") + + /** + * Returns the raw JSON value of [error]. + * + * Unlike [error], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error + + /** + * Returns the raw JSON value of [maskedApiKey]. + * + * Unlike [maskedApiKey], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("masked_api_key") + @ExcludeMissing + fun _maskedApiKey(): JsonField = maskedApiKey + + /** + * Returns the raw JSON value of [valid]. + * + * Unlike [valid], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("valid") @ExcludeMissing fun _valid(): JsonField = valid + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [VerifyTokenVerifyResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [VerifyTokenVerifyResponse]. */ + class Builder internal constructor() { + + private var error: JsonField = JsonMissing.of() + private var maskedApiKey: JsonField = JsonMissing.of() + private var valid: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(verifyTokenVerifyResponse: VerifyTokenVerifyResponse) = apply { + error = verifyTokenVerifyResponse.error + maskedApiKey = verifyTokenVerifyResponse.maskedApiKey + valid = verifyTokenVerifyResponse.valid + additionalProperties = verifyTokenVerifyResponse.additionalProperties.toMutableMap() + } + + /** Error message (only shown if invalid) */ + fun error(error: String) = error(JsonField.of(error)) + + /** + * Sets [Builder.error] to an arbitrary JSON value. + * + * You should usually call [Builder.error] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun error(error: JsonField) = apply { this.error = error } + + /** Masked API key (only shown if valid) */ + fun maskedApiKey(maskedApiKey: String) = maskedApiKey(JsonField.of(maskedApiKey)) + + /** + * Sets [Builder.maskedApiKey] to an arbitrary JSON value. + * + * You should usually call [Builder.maskedApiKey] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun maskedApiKey(maskedApiKey: JsonField) = apply { + this.maskedApiKey = maskedApiKey + } + + /** Whether the token is valid */ + fun valid(valid: Boolean) = valid(JsonField.of(valid)) + + /** + * Sets [Builder.valid] to an arbitrary JSON value. + * + * You should usually call [Builder.valid] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun valid(valid: JsonField) = apply { this.valid = valid } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [VerifyTokenVerifyResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): VerifyTokenVerifyResponse = + VerifyTokenVerifyResponse( + error, + maskedApiKey, + valid, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): VerifyTokenVerifyResponse = apply { + if (validated) { + return@apply + } + + error() + maskedApiKey() + valid() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: CasParserInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (error.asKnown().isPresent) 1 else 0) + + (if (maskedApiKey.asKnown().isPresent) 1 else 0) + + (if (valid.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is VerifyTokenVerifyResponse && + error == other.error && + maskedApiKey == other.maskedApiKey && + valid == other.valid && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(error, maskedApiKey, valid, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "VerifyTokenVerifyResponse{error=$error, maskedApiKey=$maskedApiKey, valid=$valid, additionalProperties=$additionalProperties}" +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsync.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsync.kt new file mode 100644 index 0000000..0948924 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsync.kt @@ -0,0 +1,97 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.accesstoken.AccessTokenCreateParams +import com.cas_parser.api.models.accesstoken.AccessTokenCreateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface AccessTokenServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AccessTokenServiceAsync + + /** + * Generate a short-lived access token from your API key. + * + * **Use this endpoint from your backend** to create tokens that can be safely passed to + * frontend/SDK. + * + * Access tokens: + * - Are prefixed with `at_` for easy identification + * - Valid for up to 60 minutes + * - Can be used in place of API keys on all v4 endpoints + * - Cannot be used to generate other access tokens + */ + fun create(): CompletableFuture = + create(AccessTokenCreateParams.none()) + + /** @see create */ + fun create( + params: AccessTokenCreateParams = AccessTokenCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see create */ + fun create( + params: AccessTokenCreateParams = AccessTokenCreateParams.none() + ): CompletableFuture = create(params, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): CompletableFuture = + create(AccessTokenCreateParams.none(), requestOptions) + + /** + * A view of [AccessTokenServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AccessTokenServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/access-token`, but is otherwise the same as + * [AccessTokenServiceAsync.create]. + */ + fun create(): CompletableFuture> = + create(AccessTokenCreateParams.none()) + + /** @see create */ + fun create( + params: AccessTokenCreateParams = AccessTokenCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see create */ + fun create( + params: AccessTokenCreateParams = AccessTokenCreateParams.none() + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + requestOptions: RequestOptions + ): CompletableFuture> = + create(AccessTokenCreateParams.none(), requestOptions) + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncImpl.kt new file mode 100644 index 0000000..e71b99c --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncImpl.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.json +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepareAsync +import com.cas_parser.api.models.accesstoken.AccessTokenCreateParams +import com.cas_parser.api.models.accesstoken.AccessTokenCreateResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class AccessTokenServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + AccessTokenServiceAsync { + + private val withRawResponse: AccessTokenServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): AccessTokenServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): AccessTokenServiceAsync = + AccessTokenServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: AccessTokenCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/access-token + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AccessTokenServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): AccessTokenServiceAsync.WithRawResponse = + AccessTokenServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: AccessTokenCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "access-token") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CamsKfintechServiceAsync.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CamsKfintechServiceAsync.kt new file mode 100644 index 0000000..c7651f1 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CamsKfintechServiceAsync.kt @@ -0,0 +1,89 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams +import com.cas_parser.api.models.camskfintech.UnifiedResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface CamsKfintechServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CamsKfintechServiceAsync + + /** + * This endpoint specifically parses CAMS/KFintech CAS (Consolidated Account Statement) PDF + * files and returns data in a unified format. Use this endpoint when you know the PDF is from + * CAMS or KFintech. + */ + fun parse(): CompletableFuture = parse(CamsKfintechParseParams.none()) + + /** @see parse */ + fun parse( + params: CamsKfintechParseParams = CamsKfintechParseParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see parse */ + fun parse( + params: CamsKfintechParseParams = CamsKfintechParseParams.none() + ): CompletableFuture = parse(params, RequestOptions.none()) + + /** @see parse */ + fun parse(requestOptions: RequestOptions): CompletableFuture = + parse(CamsKfintechParseParams.none(), requestOptions) + + /** + * A view of [CamsKfintechServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CamsKfintechServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v4/cams_kfintech/parse`, but is otherwise the same + * as [CamsKfintechServiceAsync.parse]. + */ + fun parse(): CompletableFuture> = + parse(CamsKfintechParseParams.none()) + + /** @see parse */ + fun parse( + params: CamsKfintechParseParams = CamsKfintechParseParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see parse */ + fun parse( + params: CamsKfintechParseParams = CamsKfintechParseParams.none() + ): CompletableFuture> = + parse(params, RequestOptions.none()) + + /** @see parse */ + fun parse( + requestOptions: RequestOptions + ): CompletableFuture> = + parse(CamsKfintechParseParams.none(), requestOptions) + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CamsKfintechServiceAsyncImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CamsKfintechServiceAsyncImpl.kt new file mode 100644 index 0000000..ef05059 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CamsKfintechServiceAsyncImpl.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.multipartFormData +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepareAsync +import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams +import com.cas_parser.api.models.camskfintech.UnifiedResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class CamsKfintechServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + CamsKfintechServiceAsync { + + private val withRawResponse: CamsKfintechServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CamsKfintechServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CamsKfintechServiceAsync = + CamsKfintechServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun parse( + params: CamsKfintechParseParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v4/cams_kfintech/parse + withRawResponse().parse(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CamsKfintechServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CamsKfintechServiceAsync.WithRawResponse = + CamsKfintechServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val parseHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun parse( + params: CamsKfintechParseParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v4", "cams_kfintech", "parse") + .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { parseHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CasGeneratorServiceAsync.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CasGeneratorServiceAsync.kt deleted file mode 100644 index 0e6995d..0000000 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CasGeneratorServiceAsync.kt +++ /dev/null @@ -1,37 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.services.async - -import com.cas_parser.api.core.ClientOptions -import java.util.function.Consumer - -interface CasGeneratorServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): CasGeneratorServiceAsync - - /** - * A view of [CasGeneratorServiceAsync] that provides access to raw HTTP responses for each - * method. - */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): CasGeneratorServiceAsync.WithRawResponse - } -} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CasGeneratorServiceAsyncImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CasGeneratorServiceAsyncImpl.kt deleted file mode 100644 index 0bbd145..0000000 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CasGeneratorServiceAsyncImpl.kt +++ /dev/null @@ -1,30 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.services.async - -import com.cas_parser.api.core.ClientOptions -import java.util.function.Consumer - -class CasGeneratorServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - CasGeneratorServiceAsync { - - private val withRawResponse: CasGeneratorServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): CasGeneratorServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): CasGeneratorServiceAsync = - CasGeneratorServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - CasGeneratorServiceAsync.WithRawResponse { - - override fun withOptions( - modifier: Consumer - ): CasGeneratorServiceAsync.WithRawResponse = - CasGeneratorServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - } -} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CasParserServiceAsync.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CasParserServiceAsync.kt deleted file mode 100644 index 319748a..0000000 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CasParserServiceAsync.kt +++ /dev/null @@ -1,230 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.services.async - -import com.cas_parser.api.core.ClientOptions -import com.cas_parser.api.core.RequestOptions -import com.cas_parser.api.core.http.HttpResponseFor -import com.cas_parser.api.models.casparser.CasParserCamsKfintechParams -import com.cas_parser.api.models.casparser.CasParserCdslParams -import com.cas_parser.api.models.casparser.CasParserNsdlParams -import com.cas_parser.api.models.casparser.CasParserSmartParseParams -import com.cas_parser.api.models.casparser.UnifiedResponse -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface CasParserServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): CasParserServiceAsync - - /** - * This endpoint specifically parses CAMS/KFintech CAS (Consolidated Account Statement) PDF - * files and returns data in a unified format. Use this endpoint when you know the PDF is from - * CAMS or KFintech. - */ - fun camsKfintech(): CompletableFuture = - camsKfintech(CasParserCamsKfintechParams.none()) - - /** @see camsKfintech */ - fun camsKfintech( - params: CasParserCamsKfintechParams = CasParserCamsKfintechParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see camsKfintech */ - fun camsKfintech( - params: CasParserCamsKfintechParams = CasParserCamsKfintechParams.none() - ): CompletableFuture = camsKfintech(params, RequestOptions.none()) - - /** @see camsKfintech */ - fun camsKfintech(requestOptions: RequestOptions): CompletableFuture = - camsKfintech(CasParserCamsKfintechParams.none(), requestOptions) - - /** - * This endpoint specifically parses CDSL CAS (Consolidated Account Statement) PDF files and - * returns data in a unified format. Use this endpoint when you know the PDF is from CDSL. - */ - fun cdsl(): CompletableFuture = cdsl(CasParserCdslParams.none()) - - /** @see cdsl */ - fun cdsl( - params: CasParserCdslParams = CasParserCdslParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see cdsl */ - fun cdsl( - params: CasParserCdslParams = CasParserCdslParams.none() - ): CompletableFuture = cdsl(params, RequestOptions.none()) - - /** @see cdsl */ - fun cdsl(requestOptions: RequestOptions): CompletableFuture = - cdsl(CasParserCdslParams.none(), requestOptions) - - /** - * This endpoint specifically parses NSDL CAS (Consolidated Account Statement) PDF files and - * returns data in a unified format. Use this endpoint when you know the PDF is from NSDL. - */ - fun nsdl(): CompletableFuture = nsdl(CasParserNsdlParams.none()) - - /** @see nsdl */ - fun nsdl( - params: CasParserNsdlParams = CasParserNsdlParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see nsdl */ - fun nsdl( - params: CasParserNsdlParams = CasParserNsdlParams.none() - ): CompletableFuture = nsdl(params, RequestOptions.none()) - - /** @see nsdl */ - fun nsdl(requestOptions: RequestOptions): CompletableFuture = - nsdl(CasParserNsdlParams.none(), requestOptions) - - /** - * This endpoint parses CAS (Consolidated Account Statement) PDF files from NSDL, CDSL, or - * CAMS/KFintech and returns data in a unified format. It auto-detects the CAS type and - * transforms the data into a consistent structure regardless of the source. - */ - fun smartParse(): CompletableFuture = - smartParse(CasParserSmartParseParams.none()) - - /** @see smartParse */ - fun smartParse( - params: CasParserSmartParseParams = CasParserSmartParseParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see smartParse */ - fun smartParse( - params: CasParserSmartParseParams = CasParserSmartParseParams.none() - ): CompletableFuture = smartParse(params, RequestOptions.none()) - - /** @see smartParse */ - fun smartParse(requestOptions: RequestOptions): CompletableFuture = - smartParse(CasParserSmartParseParams.none(), requestOptions) - - /** - * A view of [CasParserServiceAsync] that provides access to raw HTTP responses for each method. - */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): CasParserServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `post /v4/cams_kfintech/parse`, but is otherwise the same - * as [CasParserServiceAsync.camsKfintech]. - */ - fun camsKfintech(): CompletableFuture> = - camsKfintech(CasParserCamsKfintechParams.none()) - - /** @see camsKfintech */ - fun camsKfintech( - params: CasParserCamsKfintechParams = CasParserCamsKfintechParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see camsKfintech */ - fun camsKfintech( - params: CasParserCamsKfintechParams = CasParserCamsKfintechParams.none() - ): CompletableFuture> = - camsKfintech(params, RequestOptions.none()) - - /** @see camsKfintech */ - fun camsKfintech( - requestOptions: RequestOptions - ): CompletableFuture> = - camsKfintech(CasParserCamsKfintechParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `post /v4/cdsl/parse`, but is otherwise the same as - * [CasParserServiceAsync.cdsl]. - */ - fun cdsl(): CompletableFuture> = - cdsl(CasParserCdslParams.none()) - - /** @see cdsl */ - fun cdsl( - params: CasParserCdslParams = CasParserCdslParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see cdsl */ - fun cdsl( - params: CasParserCdslParams = CasParserCdslParams.none() - ): CompletableFuture> = cdsl(params, RequestOptions.none()) - - /** @see cdsl */ - fun cdsl( - requestOptions: RequestOptions - ): CompletableFuture> = - cdsl(CasParserCdslParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `post /v4/nsdl/parse`, but is otherwise the same as - * [CasParserServiceAsync.nsdl]. - */ - fun nsdl(): CompletableFuture> = - nsdl(CasParserNsdlParams.none()) - - /** @see nsdl */ - fun nsdl( - params: CasParserNsdlParams = CasParserNsdlParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see nsdl */ - fun nsdl( - params: CasParserNsdlParams = CasParserNsdlParams.none() - ): CompletableFuture> = nsdl(params, RequestOptions.none()) - - /** @see nsdl */ - fun nsdl( - requestOptions: RequestOptions - ): CompletableFuture> = - nsdl(CasParserNsdlParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `post /v4/smart/parse`, but is otherwise the same as - * [CasParserServiceAsync.smartParse]. - */ - fun smartParse(): CompletableFuture> = - smartParse(CasParserSmartParseParams.none()) - - /** @see smartParse */ - fun smartParse( - params: CasParserSmartParseParams = CasParserSmartParseParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see smartParse */ - fun smartParse( - params: CasParserSmartParseParams = CasParserSmartParseParams.none() - ): CompletableFuture> = - smartParse(params, RequestOptions.none()) - - /** @see smartParse */ - fun smartParse( - requestOptions: RequestOptions - ): CompletableFuture> = - smartParse(CasParserSmartParseParams.none(), requestOptions) - } -} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CdslServiceAsync.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CdslServiceAsync.kt new file mode 100644 index 0000000..b00e28d --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CdslServiceAsync.kt @@ -0,0 +1,88 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.camskfintech.UnifiedResponse +import com.cas_parser.api.models.cdsl.CdslParsePdfParams +import com.cas_parser.api.services.async.cdsl.FetchServiceAsync +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface CdslServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CdslServiceAsync + + fun fetch(): FetchServiceAsync + + /** + * This endpoint specifically parses CDSL CAS (Consolidated Account Statement) PDF files and + * returns data in a unified format. Use this endpoint when you know the PDF is from CDSL. + */ + fun parsePdf(): CompletableFuture = parsePdf(CdslParsePdfParams.none()) + + /** @see parsePdf */ + fun parsePdf( + params: CdslParsePdfParams = CdslParsePdfParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see parsePdf */ + fun parsePdf( + params: CdslParsePdfParams = CdslParsePdfParams.none() + ): CompletableFuture = parsePdf(params, RequestOptions.none()) + + /** @see parsePdf */ + fun parsePdf(requestOptions: RequestOptions): CompletableFuture = + parsePdf(CdslParsePdfParams.none(), requestOptions) + + /** A view of [CdslServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CdslServiceAsync.WithRawResponse + + fun fetch(): FetchServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v4/cdsl/parse`, but is otherwise the same as + * [CdslServiceAsync.parsePdf]. + */ + fun parsePdf(): CompletableFuture> = + parsePdf(CdslParsePdfParams.none()) + + /** @see parsePdf */ + fun parsePdf( + params: CdslParsePdfParams = CdslParsePdfParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see parsePdf */ + fun parsePdf( + params: CdslParsePdfParams = CdslParsePdfParams.none() + ): CompletableFuture> = + parsePdf(params, RequestOptions.none()) + + /** @see parsePdf */ + fun parsePdf( + requestOptions: RequestOptions + ): CompletableFuture> = + parsePdf(CdslParsePdfParams.none(), requestOptions) + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CdslServiceAsyncImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CdslServiceAsyncImpl.kt new file mode 100644 index 0000000..2531112 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CdslServiceAsyncImpl.kt @@ -0,0 +1,98 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.multipartFormData +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepareAsync +import com.cas_parser.api.models.camskfintech.UnifiedResponse +import com.cas_parser.api.models.cdsl.CdslParsePdfParams +import com.cas_parser.api.services.async.cdsl.FetchServiceAsync +import com.cas_parser.api.services.async.cdsl.FetchServiceAsyncImpl +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class CdslServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + CdslServiceAsync { + + private val withRawResponse: CdslServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val fetch: FetchServiceAsync by lazy { FetchServiceAsyncImpl(clientOptions) } + + override fun withRawResponse(): CdslServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CdslServiceAsync = + CdslServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun fetch(): FetchServiceAsync = fetch + + override fun parsePdf( + params: CdslParsePdfParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v4/cdsl/parse + withRawResponse().parsePdf(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CdslServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val fetch: FetchServiceAsync.WithRawResponse by lazy { + FetchServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): CdslServiceAsync.WithRawResponse = + CdslServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun fetch(): FetchServiceAsync.WithRawResponse = fetch + + private val parsePdfHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun parsePdf( + params: CdslParsePdfParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v4", "cdsl", "parse") + .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { parsePdfHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/ContractNoteServiceAsync.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/ContractNoteServiceAsync.kt new file mode 100644 index 0000000..6168665 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/ContractNoteServiceAsync.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.contractnote.ContractNoteParseParams +import com.cas_parser.api.models.contractnote.ContractNoteParseResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface ContractNoteServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ContractNoteServiceAsync + + /** + * This endpoint parses Contract Note PDF files from various brokers including Zerodha, Groww, + * Upstox, ICICI Securities, and others. + * + * **What is a Contract Note?** A contract note is a legal document that provides details of all + * trades executed by an investor. It includes: + * - Trade details with timestamps, quantities, and prices + * - Brokerage and charges breakdown + * - Settlement information + * - Regulatory compliance details + * + * **Supported Brokers:** + * - Zerodha Broking Limited + * - Groww Invest Tech Private Limited + * - Upstox (RKSV Securities) + * - ICICI Securities Limited + * - Auto-detection for unknown brokers + * + * **Key Features:** + * - **Auto-detection**: Automatically identifies broker type from PDF content + * - **Comprehensive parsing**: Extracts equity transactions, derivatives transactions, detailed + * trades, and charges + * - **Flexible input**: Accepts both file upload and URL-based PDF input + * - **Password protection**: Supports password-protected PDFs + * + * The API returns structured data including contract note information, client details, + * transaction summaries, and detailed trade-by-trade breakdowns. + */ + fun parse(): CompletableFuture = + parse(ContractNoteParseParams.none()) + + /** @see parse */ + fun parse( + params: ContractNoteParseParams = ContractNoteParseParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see parse */ + fun parse( + params: ContractNoteParseParams = ContractNoteParseParams.none() + ): CompletableFuture = parse(params, RequestOptions.none()) + + /** @see parse */ + fun parse(requestOptions: RequestOptions): CompletableFuture = + parse(ContractNoteParseParams.none(), requestOptions) + + /** + * A view of [ContractNoteServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ContractNoteServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v4/contract_note/parse`, but is otherwise the same + * as [ContractNoteServiceAsync.parse]. + */ + fun parse(): CompletableFuture> = + parse(ContractNoteParseParams.none()) + + /** @see parse */ + fun parse( + params: ContractNoteParseParams = ContractNoteParseParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see parse */ + fun parse( + params: ContractNoteParseParams = ContractNoteParseParams.none() + ): CompletableFuture> = + parse(params, RequestOptions.none()) + + /** @see parse */ + fun parse( + requestOptions: RequestOptions + ): CompletableFuture> = + parse(ContractNoteParseParams.none(), requestOptions) + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/ContractNoteServiceAsyncImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/ContractNoteServiceAsyncImpl.kt new file mode 100644 index 0000000..7b8d062 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/ContractNoteServiceAsyncImpl.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.multipartFormData +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepareAsync +import com.cas_parser.api.models.contractnote.ContractNoteParseParams +import com.cas_parser.api.models.contractnote.ContractNoteParseResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class ContractNoteServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + ContractNoteServiceAsync { + + private val withRawResponse: ContractNoteServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ContractNoteServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ContractNoteServiceAsync = + ContractNoteServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun parse( + params: ContractNoteParseParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v4/contract_note/parse + withRawResponse().parse(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ContractNoteServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ContractNoteServiceAsync.WithRawResponse = + ContractNoteServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val parseHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun parse( + params: ContractNoteParseParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v4", "contract_note", "parse") + .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { parseHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CreditServiceAsync.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CreditServiceAsync.kt new file mode 100644 index 0000000..05290f8 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CreditServiceAsync.kt @@ -0,0 +1,93 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +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 java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface CreditServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CreditServiceAsync + + /** + * Check your remaining API credits and usage for the current billing period. + * + * Returns: + * - Number of API calls used and remaining credits + * - Credit limit and reset date + * - List of enabled features for your plan + * + * Credits reset at the start of each billing period. + */ + fun check(): CompletableFuture = check(CreditCheckParams.none()) + + /** @see check */ + fun check( + params: CreditCheckParams = CreditCheckParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see check */ + fun check( + params: CreditCheckParams = CreditCheckParams.none() + ): CompletableFuture = check(params, RequestOptions.none()) + + /** @see check */ + fun check(requestOptions: RequestOptions): CompletableFuture = + check(CreditCheckParams.none(), requestOptions) + + /** + * A view of [CreditServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CreditServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /credits`, but is otherwise the same as + * [CreditServiceAsync.check]. + */ + fun check(): CompletableFuture> = + check(CreditCheckParams.none()) + + /** @see check */ + fun check( + params: CreditCheckParams = CreditCheckParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see check */ + fun check( + params: CreditCheckParams = CreditCheckParams.none() + ): CompletableFuture> = + check(params, RequestOptions.none()) + + /** @see check */ + fun check( + requestOptions: RequestOptions + ): CompletableFuture> = + check(CreditCheckParams.none(), requestOptions) + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncImpl.kt new file mode 100644 index 0000000..6f2806c --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncImpl.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.json +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepareAsync +import com.cas_parser.api.models.credits.CreditCheckParams +import com.cas_parser.api.models.credits.CreditCheckResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class CreditServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + CreditServiceAsync { + + private val withRawResponse: CreditServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CreditServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CreditServiceAsync = + CreditServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun check( + params: CreditCheckParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /credits + withRawResponse().check(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CreditServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CreditServiceAsync.WithRawResponse = + CreditServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val checkHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun check( + params: CreditCheckParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("credits") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { checkHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/InboxServiceAsync.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/InboxServiceAsync.kt new file mode 100644 index 0000000..b488405 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/InboxServiceAsync.kt @@ -0,0 +1,188 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.inbox.InboxCheckConnectionStatusParams +import com.cas_parser.api.models.inbox.InboxCheckConnectionStatusResponse +import com.cas_parser.api.models.inbox.InboxConnectEmailParams +import com.cas_parser.api.models.inbox.InboxConnectEmailResponse +import com.cas_parser.api.models.inbox.InboxDisconnectEmailParams +import com.cas_parser.api.models.inbox.InboxDisconnectEmailResponse +import com.cas_parser.api.models.inbox.InboxListCasFilesParams +import com.cas_parser.api.models.inbox.InboxListCasFilesResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface InboxServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): InboxServiceAsync + + /** + * Verify if an `inbox_token` is still valid and check connection status. + * + * Use this to check if the user needs to re-authenticate (e.g., if they revoked access in their + * email provider settings). + */ + fun checkConnectionStatus( + params: InboxCheckConnectionStatusParams + ): CompletableFuture = + checkConnectionStatus(params, RequestOptions.none()) + + /** @see checkConnectionStatus */ + fun checkConnectionStatus( + params: InboxCheckConnectionStatusParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Initiate OAuth flow to connect user's email inbox. + * + * Returns an `oauth_url` that you should redirect the user to. After authorization, they are + * redirected back to your `redirect_uri` with the following query parameters: + * + * **On success:** + * - `inbox_token` - Encrypted token to store client-side + * - `email` - Email address of the connected account + * - `state` - Your original state parameter (for CSRF verification) + * + * **On error:** + * - `error` - Error code (e.g., `access_denied`, `token_exchange_failed`) + * - `state` - Your original state parameter + * + * **Store the `inbox_token` client-side** and use it for all subsequent inbox API calls. + */ + fun connectEmail( + params: InboxConnectEmailParams + ): CompletableFuture = connectEmail(params, RequestOptions.none()) + + /** @see connectEmail */ + fun connectEmail( + params: InboxConnectEmailParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Revoke email access and invalidate the token. + * + * This calls the provider's token revocation API (e.g., Google's revoke endpoint) to ensure the + * user's consent is properly removed. + * + * After calling this, the `inbox_token` becomes unusable. + */ + fun disconnectEmail( + params: InboxDisconnectEmailParams + ): CompletableFuture = + disconnectEmail(params, RequestOptions.none()) + + /** @see disconnectEmail */ + fun disconnectEmail( + params: InboxDisconnectEmailParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Search the user's email inbox for CAS files from known senders (CAMS, KFintech, CDSL, NSDL). + * + * Files are uploaded to temporary cloud storage. **URLs expire in 24 hours.** + * + * Optionally filter by CAS provider and date range. + * + * **Billing:** 0.2 credits per request (charged regardless of success or number of files + * found). + */ + fun listCasFiles( + params: InboxListCasFilesParams + ): CompletableFuture = listCasFiles(params, RequestOptions.none()) + + /** @see listCasFiles */ + fun listCasFiles( + params: InboxListCasFilesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** A view of [InboxServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): InboxServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v4/inbox/status`, but is otherwise the same as + * [InboxServiceAsync.checkConnectionStatus]. + */ + fun checkConnectionStatus( + params: InboxCheckConnectionStatusParams + ): CompletableFuture> = + checkConnectionStatus(params, RequestOptions.none()) + + /** @see checkConnectionStatus */ + fun checkConnectionStatus( + params: InboxCheckConnectionStatusParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /v4/inbox/connect`, but is otherwise the same as + * [InboxServiceAsync.connectEmail]. + */ + fun connectEmail( + params: InboxConnectEmailParams + ): CompletableFuture> = + connectEmail(params, RequestOptions.none()) + + /** @see connectEmail */ + fun connectEmail( + params: InboxConnectEmailParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /v4/inbox/disconnect`, but is otherwise the same as + * [InboxServiceAsync.disconnectEmail]. + */ + fun disconnectEmail( + params: InboxDisconnectEmailParams + ): CompletableFuture> = + disconnectEmail(params, RequestOptions.none()) + + /** @see disconnectEmail */ + fun disconnectEmail( + params: InboxDisconnectEmailParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /v4/inbox/cas`, but is otherwise the same as + * [InboxServiceAsync.listCasFiles]. + */ + fun listCasFiles( + params: InboxListCasFilesParams + ): CompletableFuture> = + listCasFiles(params, RequestOptions.none()) + + /** @see listCasFiles */ + fun listCasFiles( + params: InboxListCasFilesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CasParserServiceAsyncImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/InboxServiceAsyncImpl.kt similarity index 54% rename from cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CasParserServiceAsyncImpl.kt rename to cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/InboxServiceAsyncImpl.kt index 747e8ed..29c7d03 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/CasParserServiceAsyncImpl.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/InboxServiceAsyncImpl.kt @@ -12,83 +12,86 @@ import com.cas_parser.api.core.http.HttpRequest import com.cas_parser.api.core.http.HttpResponse import com.cas_parser.api.core.http.HttpResponse.Handler import com.cas_parser.api.core.http.HttpResponseFor -import com.cas_parser.api.core.http.multipartFormData +import com.cas_parser.api.core.http.json import com.cas_parser.api.core.http.parseable import com.cas_parser.api.core.prepareAsync -import com.cas_parser.api.models.casparser.CasParserCamsKfintechParams -import com.cas_parser.api.models.casparser.CasParserCdslParams -import com.cas_parser.api.models.casparser.CasParserNsdlParams -import com.cas_parser.api.models.casparser.CasParserSmartParseParams -import com.cas_parser.api.models.casparser.UnifiedResponse +import com.cas_parser.api.models.inbox.InboxCheckConnectionStatusParams +import com.cas_parser.api.models.inbox.InboxCheckConnectionStatusResponse +import com.cas_parser.api.models.inbox.InboxConnectEmailParams +import com.cas_parser.api.models.inbox.InboxConnectEmailResponse +import com.cas_parser.api.models.inbox.InboxDisconnectEmailParams +import com.cas_parser.api.models.inbox.InboxDisconnectEmailResponse +import com.cas_parser.api.models.inbox.InboxListCasFilesParams +import com.cas_parser.api.models.inbox.InboxListCasFilesResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer -class CasParserServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - CasParserServiceAsync { +class InboxServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + InboxServiceAsync { - private val withRawResponse: CasParserServiceAsync.WithRawResponse by lazy { + private val withRawResponse: InboxServiceAsync.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } - override fun withRawResponse(): CasParserServiceAsync.WithRawResponse = withRawResponse + override fun withRawResponse(): InboxServiceAsync.WithRawResponse = withRawResponse - override fun withOptions(modifier: Consumer): CasParserServiceAsync = - CasParserServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun withOptions(modifier: Consumer): InboxServiceAsync = + InboxServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun camsKfintech( - params: CasParserCamsKfintechParams, + override fun checkConnectionStatus( + params: InboxCheckConnectionStatusParams, requestOptions: RequestOptions, - ): CompletableFuture = - // post /v4/cams_kfintech/parse - withRawResponse().camsKfintech(params, requestOptions).thenApply { it.parse() } + ): CompletableFuture = + // post /v4/inbox/status + withRawResponse().checkConnectionStatus(params, requestOptions).thenApply { it.parse() } - override fun cdsl( - params: CasParserCdslParams, + override fun connectEmail( + params: InboxConnectEmailParams, requestOptions: RequestOptions, - ): CompletableFuture = - // post /v4/cdsl/parse - withRawResponse().cdsl(params, requestOptions).thenApply { it.parse() } + ): CompletableFuture = + // post /v4/inbox/connect + withRawResponse().connectEmail(params, requestOptions).thenApply { it.parse() } - override fun nsdl( - params: CasParserNsdlParams, + override fun disconnectEmail( + params: InboxDisconnectEmailParams, requestOptions: RequestOptions, - ): CompletableFuture = - // post /v4/nsdl/parse - withRawResponse().nsdl(params, requestOptions).thenApply { it.parse() } + ): CompletableFuture = + // post /v4/inbox/disconnect + withRawResponse().disconnectEmail(params, requestOptions).thenApply { it.parse() } - override fun smartParse( - params: CasParserSmartParseParams, + override fun listCasFiles( + params: InboxListCasFilesParams, requestOptions: RequestOptions, - ): CompletableFuture = - // post /v4/smart/parse - withRawResponse().smartParse(params, requestOptions).thenApply { it.parse() } + ): CompletableFuture = + // post /v4/inbox/cas + withRawResponse().listCasFiles(params, requestOptions).thenApply { it.parse() } class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - CasParserServiceAsync.WithRawResponse { + InboxServiceAsync.WithRawResponse { private val errorHandler: Handler = errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer - ): CasParserServiceAsync.WithRawResponse = - CasParserServiceAsyncImpl.WithRawResponseImpl( + ): InboxServiceAsync.WithRawResponse = + InboxServiceAsyncImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) - private val camsKfintechHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val checkConnectionStatusHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun camsKfintech( - params: CasParserCamsKfintechParams, + override fun checkConnectionStatus( + params: InboxCheckConnectionStatusParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("v4", "cams_kfintech", "parse") - .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .addPathSegments("v4", "inbox", "status") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepareAsync(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) @@ -97,7 +100,7 @@ class CasParserServiceAsyncImpl internal constructor(private val clientOptions: .thenApply { response -> errorHandler.handle(response).parseable { response - .use { camsKfintechHandler.handle(it) } + .use { checkConnectionStatusHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() @@ -107,19 +110,19 @@ class CasParserServiceAsyncImpl internal constructor(private val clientOptions: } } - private val cdslHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val connectEmailHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun cdsl( - params: CasParserCdslParams, + override fun connectEmail( + params: InboxConnectEmailParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("v4", "cdsl", "parse") - .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .addPathSegments("v4", "inbox", "connect") + .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) @@ -128,7 +131,7 @@ class CasParserServiceAsyncImpl internal constructor(private val clientOptions: .thenApply { response -> errorHandler.handle(response).parseable { response - .use { cdslHandler.handle(it) } + .use { connectEmailHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() @@ -138,19 +141,19 @@ class CasParserServiceAsyncImpl internal constructor(private val clientOptions: } } - private val nsdlHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val disconnectEmailHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun nsdl( - params: CasParserNsdlParams, + override fun disconnectEmail( + params: InboxDisconnectEmailParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("v4", "nsdl", "parse") - .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .addPathSegments("v4", "inbox", "disconnect") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepareAsync(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) @@ -159,7 +162,7 @@ class CasParserServiceAsyncImpl internal constructor(private val clientOptions: .thenApply { response -> errorHandler.handle(response).parseable { response - .use { nsdlHandler.handle(it) } + .use { disconnectEmailHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() @@ -169,19 +172,19 @@ class CasParserServiceAsyncImpl internal constructor(private val clientOptions: } } - private val smartParseHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val listCasFilesHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun smartParse( - params: CasParserSmartParseParams, + override fun listCasFiles( + params: InboxListCasFilesParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.POST) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("v4", "smart", "parse") - .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .addPathSegments("v4", "inbox", "cas") + .body(json(clientOptions.jsonMapper, params._body())) .build() .prepareAsync(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) @@ -190,7 +193,7 @@ class CasParserServiceAsyncImpl internal constructor(private val clientOptions: .thenApply { response -> errorHandler.handle(response).parseable { response - .use { smartParseHandler.handle(it) } + .use { listCasFilesHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/KfintechServiceAsync.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/KfintechServiceAsync.kt new file mode 100644 index 0000000..fa22355 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/KfintechServiceAsync.kt @@ -0,0 +1,72 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.kfintech.KfintechGenerateCasParams +import com.cas_parser.api.models.kfintech.KfintechGenerateCasResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface KfintechServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): KfintechServiceAsync + + /** + * Generate CAS via KFintech mailback. The CAS PDF will be sent to the investor's email. + * + * This is an async operation - the investor receives the CAS via email within a few minutes. + * For instant CAS retrieval, use CDSL Fetch (`/v4/cdsl/fetch`). + */ + fun generateCas( + params: KfintechGenerateCasParams + ): CompletableFuture = generateCas(params, RequestOptions.none()) + + /** @see generateCas */ + fun generateCas( + params: KfintechGenerateCasParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [KfintechServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): KfintechServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v4/kfintech/generate`, but is otherwise the same + * as [KfintechServiceAsync.generateCas]. + */ + fun generateCas( + params: KfintechGenerateCasParams + ): CompletableFuture> = + generateCas(params, RequestOptions.none()) + + /** @see generateCas */ + fun generateCas( + params: KfintechGenerateCasParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/KfintechServiceAsyncImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/KfintechServiceAsyncImpl.kt new file mode 100644 index 0000000..2445261 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/KfintechServiceAsyncImpl.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.json +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepareAsync +import com.cas_parser.api.models.kfintech.KfintechGenerateCasParams +import com.cas_parser.api.models.kfintech.KfintechGenerateCasResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class KfintechServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + KfintechServiceAsync { + + private val withRawResponse: KfintechServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): KfintechServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): KfintechServiceAsync = + KfintechServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun generateCas( + params: KfintechGenerateCasParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v4/kfintech/generate + withRawResponse().generateCas(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + KfintechServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): KfintechServiceAsync.WithRawResponse = + KfintechServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val generateCasHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun generateCas( + params: KfintechGenerateCasParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v4", "kfintech", "generate") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { generateCasHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/LogServiceAsync.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/LogServiceAsync.kt new file mode 100644 index 0000000..641ee6a --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/LogServiceAsync.kt @@ -0,0 +1,135 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.logs.LogCreateParams +import com.cas_parser.api.models.logs.LogCreateResponse +import com.cas_parser.api.models.logs.LogGetSummaryParams +import com.cas_parser.api.models.logs.LogGetSummaryResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface LogServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): LogServiceAsync + + /** + * Retrieve detailed API usage logs for your account. + * + * Returns a list of API calls with timestamps, features used, status codes, and credits + * consumed. Useful for monitoring usage patterns and debugging. + */ + fun create(): CompletableFuture = create(LogCreateParams.none()) + + /** @see create */ + fun create( + params: LogCreateParams = LogCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see create */ + fun create( + params: LogCreateParams = LogCreateParams.none() + ): CompletableFuture = create(params, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): CompletableFuture = + create(LogCreateParams.none(), requestOptions) + + /** + * Get aggregated usage statistics grouped by feature. + * + * Useful for understanding which API features are being used most and tracking usage trends. + */ + fun getSummary(): CompletableFuture = + getSummary(LogGetSummaryParams.none()) + + /** @see getSummary */ + fun getSummary( + params: LogGetSummaryParams = LogGetSummaryParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see getSummary */ + fun getSummary( + params: LogGetSummaryParams = LogGetSummaryParams.none() + ): CompletableFuture = getSummary(params, RequestOptions.none()) + + /** @see getSummary */ + fun getSummary(requestOptions: RequestOptions): CompletableFuture = + getSummary(LogGetSummaryParams.none(), requestOptions) + + /** A view of [LogServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): LogServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /logs`, but is otherwise the same as + * [LogServiceAsync.create]. + */ + fun create(): CompletableFuture> = + create(LogCreateParams.none()) + + /** @see create */ + fun create( + params: LogCreateParams = LogCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see create */ + fun create( + params: LogCreateParams = LogCreateParams.none() + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + requestOptions: RequestOptions + ): CompletableFuture> = + create(LogCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /logs/summary`, but is otherwise the same as + * [LogServiceAsync.getSummary]. + */ + fun getSummary(): CompletableFuture> = + getSummary(LogGetSummaryParams.none()) + + /** @see getSummary */ + fun getSummary( + params: LogGetSummaryParams = LogGetSummaryParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see getSummary */ + fun getSummary( + params: LogGetSummaryParams = LogGetSummaryParams.none() + ): CompletableFuture> = + getSummary(params, RequestOptions.none()) + + /** @see getSummary */ + fun getSummary( + requestOptions: RequestOptions + ): CompletableFuture> = + getSummary(LogGetSummaryParams.none(), requestOptions) + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/LogServiceAsyncImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/LogServiceAsyncImpl.kt new file mode 100644 index 0000000..1dd0192 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/LogServiceAsyncImpl.kt @@ -0,0 +1,126 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.json +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepareAsync +import com.cas_parser.api.models.logs.LogCreateParams +import com.cas_parser.api.models.logs.LogCreateResponse +import com.cas_parser.api.models.logs.LogGetSummaryParams +import com.cas_parser.api.models.logs.LogGetSummaryResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class LogServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + LogServiceAsync { + + private val withRawResponse: LogServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): LogServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): LogServiceAsync = + LogServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: LogCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /logs + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun getSummary( + params: LogGetSummaryParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /logs/summary + withRawResponse().getSummary(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + LogServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): LogServiceAsync.WithRawResponse = + LogServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: LogCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("logs") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val getSummaryHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun getSummary( + params: LogGetSummaryParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("logs", "summary") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { getSummaryHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/NsdlServiceAsync.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/NsdlServiceAsync.kt new file mode 100644 index 0000000..d9571cb --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/NsdlServiceAsync.kt @@ -0,0 +1,83 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.camskfintech.UnifiedResponse +import com.cas_parser.api.models.nsdl.NsdlParseParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface NsdlServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): NsdlServiceAsync + + /** + * This endpoint specifically parses NSDL CAS (Consolidated Account Statement) PDF files and + * returns data in a unified format. Use this endpoint when you know the PDF is from NSDL. + */ + fun parse(): CompletableFuture = parse(NsdlParseParams.none()) + + /** @see parse */ + fun parse( + params: NsdlParseParams = NsdlParseParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see parse */ + fun parse( + params: NsdlParseParams = NsdlParseParams.none() + ): CompletableFuture = parse(params, RequestOptions.none()) + + /** @see parse */ + fun parse(requestOptions: RequestOptions): CompletableFuture = + parse(NsdlParseParams.none(), requestOptions) + + /** A view of [NsdlServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): NsdlServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v4/nsdl/parse`, but is otherwise the same as + * [NsdlServiceAsync.parse]. + */ + fun parse(): CompletableFuture> = + parse(NsdlParseParams.none()) + + /** @see parse */ + fun parse( + params: NsdlParseParams = NsdlParseParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see parse */ + fun parse( + params: NsdlParseParams = NsdlParseParams.none() + ): CompletableFuture> = + parse(params, RequestOptions.none()) + + /** @see parse */ + fun parse( + requestOptions: RequestOptions + ): CompletableFuture> = + parse(NsdlParseParams.none(), requestOptions) + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/NsdlServiceAsyncImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/NsdlServiceAsyncImpl.kt new file mode 100644 index 0000000..8fd0b0c --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/NsdlServiceAsyncImpl.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.multipartFormData +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepareAsync +import com.cas_parser.api.models.camskfintech.UnifiedResponse +import com.cas_parser.api.models.nsdl.NsdlParseParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class NsdlServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + NsdlServiceAsync { + + private val withRawResponse: NsdlServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): NsdlServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): NsdlServiceAsync = + NsdlServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun parse( + params: NsdlParseParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v4/nsdl/parse + withRawResponse().parse(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + NsdlServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): NsdlServiceAsync.WithRawResponse = + NsdlServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val parseHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun parse( + params: NsdlParseParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v4", "nsdl", "parse") + .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { parseHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/SmartServiceAsync.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/SmartServiceAsync.kt new file mode 100644 index 0000000..9fb8951 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/SmartServiceAsync.kt @@ -0,0 +1,87 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.camskfintech.UnifiedResponse +import com.cas_parser.api.models.smart.SmartParseCasPdfParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface SmartServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SmartServiceAsync + + /** + * This endpoint parses CAS (Consolidated Account Statement) PDF files from NSDL, CDSL, or + * CAMS/KFintech and returns data in a unified format. It auto-detects the CAS type and + * transforms the data into a consistent structure regardless of the source. + */ + fun parseCasPdf(): CompletableFuture = + parseCasPdf(SmartParseCasPdfParams.none()) + + /** @see parseCasPdf */ + fun parseCasPdf( + params: SmartParseCasPdfParams = SmartParseCasPdfParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see parseCasPdf */ + fun parseCasPdf( + params: SmartParseCasPdfParams = SmartParseCasPdfParams.none() + ): CompletableFuture = parseCasPdf(params, RequestOptions.none()) + + /** @see parseCasPdf */ + fun parseCasPdf(requestOptions: RequestOptions): CompletableFuture = + parseCasPdf(SmartParseCasPdfParams.none(), requestOptions) + + /** A view of [SmartServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): SmartServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v4/smart/parse`, but is otherwise the same as + * [SmartServiceAsync.parseCasPdf]. + */ + fun parseCasPdf(): CompletableFuture> = + parseCasPdf(SmartParseCasPdfParams.none()) + + /** @see parseCasPdf */ + fun parseCasPdf( + params: SmartParseCasPdfParams = SmartParseCasPdfParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see parseCasPdf */ + fun parseCasPdf( + params: SmartParseCasPdfParams = SmartParseCasPdfParams.none() + ): CompletableFuture> = + parseCasPdf(params, RequestOptions.none()) + + /** @see parseCasPdf */ + fun parseCasPdf( + requestOptions: RequestOptions + ): CompletableFuture> = + parseCasPdf(SmartParseCasPdfParams.none(), requestOptions) + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/SmartServiceAsyncImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/SmartServiceAsyncImpl.kt new file mode 100644 index 0000000..618e4fc --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/SmartServiceAsyncImpl.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.multipartFormData +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepareAsync +import com.cas_parser.api.models.camskfintech.UnifiedResponse +import com.cas_parser.api.models.smart.SmartParseCasPdfParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class SmartServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + SmartServiceAsync { + + private val withRawResponse: SmartServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SmartServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): SmartServiceAsync = + SmartServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun parseCasPdf( + params: SmartParseCasPdfParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v4/smart/parse + withRawResponse().parseCasPdf(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SmartServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): SmartServiceAsync.WithRawResponse = + SmartServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val parseCasPdfHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun parseCasPdf( + params: SmartParseCasPdfParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v4", "smart", "parse") + .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { parseCasPdfHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsync.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsync.kt new file mode 100644 index 0000000..2a7125e --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsync.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.verifytoken.VerifyTokenVerifyParams +import com.cas_parser.api.models.verifytoken.VerifyTokenVerifyResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface VerifyTokenServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): VerifyTokenServiceAsync + + /** Verify an access token and check if it's still valid. Useful for debugging token issues. */ + fun verify(): CompletableFuture = + verify(VerifyTokenVerifyParams.none()) + + /** @see verify */ + fun verify( + params: VerifyTokenVerifyParams = VerifyTokenVerifyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see verify */ + fun verify( + params: VerifyTokenVerifyParams = VerifyTokenVerifyParams.none() + ): CompletableFuture = verify(params, RequestOptions.none()) + + /** @see verify */ + fun verify(requestOptions: RequestOptions): CompletableFuture = + verify(VerifyTokenVerifyParams.none(), requestOptions) + + /** + * A view of [VerifyTokenServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): VerifyTokenServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/verify-token`, but is otherwise the same as + * [VerifyTokenServiceAsync.verify]. + */ + fun verify(): CompletableFuture> = + verify(VerifyTokenVerifyParams.none()) + + /** @see verify */ + fun verify( + params: VerifyTokenVerifyParams = VerifyTokenVerifyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see verify */ + fun verify( + params: VerifyTokenVerifyParams = VerifyTokenVerifyParams.none() + ): CompletableFuture> = + verify(params, RequestOptions.none()) + + /** @see verify */ + fun verify( + requestOptions: RequestOptions + ): CompletableFuture> = + verify(VerifyTokenVerifyParams.none(), requestOptions) + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncImpl.kt new file mode 100644 index 0000000..ba12f1b --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncImpl.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.json +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepareAsync +import com.cas_parser.api.models.verifytoken.VerifyTokenVerifyParams +import com.cas_parser.api.models.verifytoken.VerifyTokenVerifyResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class VerifyTokenServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + VerifyTokenServiceAsync { + + private val withRawResponse: VerifyTokenServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): VerifyTokenServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): VerifyTokenServiceAsync = + VerifyTokenServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun verify( + params: VerifyTokenVerifyParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/verify-token + withRawResponse().verify(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + VerifyTokenServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): VerifyTokenServiceAsync.WithRawResponse = + VerifyTokenServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val verifyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun verify( + params: VerifyTokenVerifyParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "verify-token") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { verifyHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/cdsl/FetchServiceAsync.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/cdsl/FetchServiceAsync.kt new file mode 100644 index 0000000..83b8d52 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/cdsl/FetchServiceAsync.kt @@ -0,0 +1,135 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async.cdsl + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.cdsl.fetch.FetchRequestOtpParams +import com.cas_parser.api.models.cdsl.fetch.FetchRequestOtpResponse +import com.cas_parser.api.models.cdsl.fetch.FetchVerifyOtpParams +import com.cas_parser.api.models.cdsl.fetch.FetchVerifyOtpResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface FetchServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FetchServiceAsync + + /** + * **Step 1 of 2**: Request OTP for CDSL CAS fetch. + * + * This endpoint: + * 1. Solves reCAPTCHA automatically (~15-20 seconds) + * 2. Submits login credentials to CDSL portal + * 3. Triggers OTP to user's registered mobile number + * + * After user receives OTP, call `/v4/cdsl/fetch/{session_id}/verify` to complete. + */ + fun requestOtp(params: FetchRequestOtpParams): CompletableFuture = + requestOtp(params, RequestOptions.none()) + + /** @see requestOtp */ + fun requestOtp( + params: FetchRequestOtpParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * **Step 2 of 2**: Verify OTP and retrieve CDSL CAS files. + * + * After successful verification, CAS PDFs are fetched from CDSL portal, uploaded to cloud + * storage, and returned as direct download URLs. + */ + fun verifyOtp( + sessionId: String, + params: FetchVerifyOtpParams, + ): CompletableFuture = + verifyOtp(sessionId, params, RequestOptions.none()) + + /** @see verifyOtp */ + fun verifyOtp( + sessionId: String, + params: FetchVerifyOtpParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + verifyOtp(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see verifyOtp */ + fun verifyOtp(params: FetchVerifyOtpParams): CompletableFuture = + verifyOtp(params, RequestOptions.none()) + + /** @see verifyOtp */ + fun verifyOtp( + params: FetchVerifyOtpParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** A view of [FetchServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): FetchServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v4/cdsl/fetch`, but is otherwise the same as + * [FetchServiceAsync.requestOtp]. + */ + fun requestOtp( + params: FetchRequestOtpParams + ): CompletableFuture> = + requestOtp(params, RequestOptions.none()) + + /** @see requestOtp */ + fun requestOtp( + params: FetchRequestOtpParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post /v4/cdsl/fetch/{session_id}/verify`, but is + * otherwise the same as [FetchServiceAsync.verifyOtp]. + */ + fun verifyOtp( + sessionId: String, + params: FetchVerifyOtpParams, + ): CompletableFuture> = + verifyOtp(sessionId, params, RequestOptions.none()) + + /** @see verifyOtp */ + fun verifyOtp( + sessionId: String, + params: FetchVerifyOtpParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + verifyOtp(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see verifyOtp */ + fun verifyOtp( + params: FetchVerifyOtpParams + ): CompletableFuture> = + verifyOtp(params, RequestOptions.none()) + + /** @see verifyOtp */ + fun verifyOtp( + params: FetchVerifyOtpParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/cdsl/FetchServiceAsyncImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/cdsl/FetchServiceAsyncImpl.kt new file mode 100644 index 0000000..fb97ea9 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/async/cdsl/FetchServiceAsyncImpl.kt @@ -0,0 +1,131 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async.cdsl + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.checkRequired +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.json +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepareAsync +import com.cas_parser.api.models.cdsl.fetch.FetchRequestOtpParams +import com.cas_parser.api.models.cdsl.fetch.FetchRequestOtpResponse +import com.cas_parser.api.models.cdsl.fetch.FetchVerifyOtpParams +import com.cas_parser.api.models.cdsl.fetch.FetchVerifyOtpResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class FetchServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + FetchServiceAsync { + + private val withRawResponse: FetchServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): FetchServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): FetchServiceAsync = + FetchServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun requestOtp( + params: FetchRequestOtpParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v4/cdsl/fetch + withRawResponse().requestOtp(params, requestOptions).thenApply { it.parse() } + + override fun verifyOtp( + params: FetchVerifyOtpParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v4/cdsl/fetch/{session_id}/verify + withRawResponse().verifyOtp(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + FetchServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): FetchServiceAsync.WithRawResponse = + FetchServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val requestOtpHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun requestOtp( + params: FetchRequestOtpParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v4", "cdsl", "fetch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { requestOtpHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val verifyOtpHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun verifyOtp( + params: FetchVerifyOtpParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sessionId", params.sessionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v4", "cdsl", "fetch", params._pathParam(0), "verify") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { verifyOtpHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/AccessTokenService.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/AccessTokenService.kt new file mode 100644 index 0000000..3414d2a --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/AccessTokenService.kt @@ -0,0 +1,96 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.accesstoken.AccessTokenCreateParams +import com.cas_parser.api.models.accesstoken.AccessTokenCreateResponse +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface AccessTokenService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AccessTokenService + + /** + * Generate a short-lived access token from your API key. + * + * **Use this endpoint from your backend** to create tokens that can be safely passed to + * frontend/SDK. + * + * Access tokens: + * - Are prefixed with `at_` for easy identification + * - Valid for up to 60 minutes + * - Can be used in place of API keys on all v4 endpoints + * - Cannot be used to generate other access tokens + */ + fun create(): AccessTokenCreateResponse = create(AccessTokenCreateParams.none()) + + /** @see create */ + fun create( + params: AccessTokenCreateParams = AccessTokenCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): AccessTokenCreateResponse + + /** @see create */ + fun create( + params: AccessTokenCreateParams = AccessTokenCreateParams.none() + ): AccessTokenCreateResponse = create(params, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): AccessTokenCreateResponse = + create(AccessTokenCreateParams.none(), requestOptions) + + /** + * A view of [AccessTokenService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AccessTokenService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/access-token`, but is otherwise the same as + * [AccessTokenService.create]. + */ + @MustBeClosed + fun create(): HttpResponseFor = + create(AccessTokenCreateParams.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: AccessTokenCreateParams = AccessTokenCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see create */ + @MustBeClosed + fun create( + params: AccessTokenCreateParams = AccessTokenCreateParams.none() + ): HttpResponseFor = create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create(requestOptions: RequestOptions): HttpResponseFor = + create(AccessTokenCreateParams.none(), requestOptions) + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceImpl.kt new file mode 100644 index 0000000..9906e2d --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceImpl.kt @@ -0,0 +1,82 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.json +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepare +import com.cas_parser.api.models.accesstoken.AccessTokenCreateParams +import com.cas_parser.api.models.accesstoken.AccessTokenCreateResponse +import java.util.function.Consumer + +class AccessTokenServiceImpl internal constructor(private val clientOptions: ClientOptions) : + AccessTokenService { + + private val withRawResponse: AccessTokenService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): AccessTokenService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): AccessTokenService = + AccessTokenServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: AccessTokenCreateParams, + requestOptions: RequestOptions, + ): AccessTokenCreateResponse = + // post /v1/access-token + withRawResponse().create(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + AccessTokenService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): AccessTokenService.WithRawResponse = + AccessTokenServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: AccessTokenCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "access-token") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CamsKfintechService.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CamsKfintechService.kt new file mode 100644 index 0000000..294210c --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CamsKfintechService.kt @@ -0,0 +1,87 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams +import com.cas_parser.api.models.camskfintech.UnifiedResponse +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface CamsKfintechService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CamsKfintechService + + /** + * This endpoint specifically parses CAMS/KFintech CAS (Consolidated Account Statement) PDF + * files and returns data in a unified format. Use this endpoint when you know the PDF is from + * CAMS or KFintech. + */ + fun parse(): UnifiedResponse = parse(CamsKfintechParseParams.none()) + + /** @see parse */ + fun parse( + params: CamsKfintechParseParams = CamsKfintechParseParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): UnifiedResponse + + /** @see parse */ + fun parse(params: CamsKfintechParseParams = CamsKfintechParseParams.none()): UnifiedResponse = + parse(params, RequestOptions.none()) + + /** @see parse */ + fun parse(requestOptions: RequestOptions): UnifiedResponse = + parse(CamsKfintechParseParams.none(), requestOptions) + + /** + * A view of [CamsKfintechService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CamsKfintechService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v4/cams_kfintech/parse`, but is otherwise the same + * as [CamsKfintechService.parse]. + */ + @MustBeClosed + fun parse(): HttpResponseFor = parse(CamsKfintechParseParams.none()) + + /** @see parse */ + @MustBeClosed + fun parse( + params: CamsKfintechParseParams = CamsKfintechParseParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see parse */ + @MustBeClosed + fun parse( + params: CamsKfintechParseParams = CamsKfintechParseParams.none() + ): HttpResponseFor = parse(params, RequestOptions.none()) + + /** @see parse */ + @MustBeClosed + fun parse(requestOptions: RequestOptions): HttpResponseFor = + parse(CamsKfintechParseParams.none(), requestOptions) + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CamsKfintechServiceImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CamsKfintechServiceImpl.kt new file mode 100644 index 0000000..867c1c6 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CamsKfintechServiceImpl.kt @@ -0,0 +1,82 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.multipartFormData +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepare +import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams +import com.cas_parser.api.models.camskfintech.UnifiedResponse +import java.util.function.Consumer + +class CamsKfintechServiceImpl internal constructor(private val clientOptions: ClientOptions) : + CamsKfintechService { + + private val withRawResponse: CamsKfintechService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CamsKfintechService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CamsKfintechService = + CamsKfintechServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun parse( + params: CamsKfintechParseParams, + requestOptions: RequestOptions, + ): UnifiedResponse = + // post /v4/cams_kfintech/parse + withRawResponse().parse(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CamsKfintechService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CamsKfintechService.WithRawResponse = + CamsKfintechServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val parseHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun parse( + params: CamsKfintechParseParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v4", "cams_kfintech", "parse") + .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { parseHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CasGeneratorService.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CasGeneratorService.kt deleted file mode 100644 index f0ad062..0000000 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CasGeneratorService.kt +++ /dev/null @@ -1,36 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.services.blocking - -import com.cas_parser.api.core.ClientOptions -import java.util.function.Consumer - -interface CasGeneratorService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): CasGeneratorService - - /** - * A view of [CasGeneratorService] that provides access to raw HTTP responses for each method. - */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): CasGeneratorService.WithRawResponse - } -} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CasGeneratorServiceImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CasGeneratorServiceImpl.kt deleted file mode 100644 index 1d0054b..0000000 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CasGeneratorServiceImpl.kt +++ /dev/null @@ -1,30 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.services.blocking - -import com.cas_parser.api.core.ClientOptions -import java.util.function.Consumer - -class CasGeneratorServiceImpl internal constructor(private val clientOptions: ClientOptions) : - CasGeneratorService { - - private val withRawResponse: CasGeneratorService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): CasGeneratorService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): CasGeneratorService = - CasGeneratorServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - CasGeneratorService.WithRawResponse { - - override fun withOptions( - modifier: Consumer - ): CasGeneratorService.WithRawResponse = - CasGeneratorServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - } -} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CasParserService.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CasParserService.kt deleted file mode 100644 index f526f80..0000000 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CasParserService.kt +++ /dev/null @@ -1,226 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.services.blocking - -import com.cas_parser.api.core.ClientOptions -import com.cas_parser.api.core.RequestOptions -import com.cas_parser.api.core.http.HttpResponseFor -import com.cas_parser.api.models.casparser.CasParserCamsKfintechParams -import com.cas_parser.api.models.casparser.CasParserCdslParams -import com.cas_parser.api.models.casparser.CasParserNsdlParams -import com.cas_parser.api.models.casparser.CasParserSmartParseParams -import com.cas_parser.api.models.casparser.UnifiedResponse -import com.google.errorprone.annotations.MustBeClosed -import java.util.function.Consumer - -interface CasParserService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): CasParserService - - /** - * This endpoint specifically parses CAMS/KFintech CAS (Consolidated Account Statement) PDF - * files and returns data in a unified format. Use this endpoint when you know the PDF is from - * CAMS or KFintech. - */ - fun camsKfintech(): UnifiedResponse = camsKfintech(CasParserCamsKfintechParams.none()) - - /** @see camsKfintech */ - fun camsKfintech( - params: CasParserCamsKfintechParams = CasParserCamsKfintechParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): UnifiedResponse - - /** @see camsKfintech */ - fun camsKfintech( - params: CasParserCamsKfintechParams = CasParserCamsKfintechParams.none() - ): UnifiedResponse = camsKfintech(params, RequestOptions.none()) - - /** @see camsKfintech */ - fun camsKfintech(requestOptions: RequestOptions): UnifiedResponse = - camsKfintech(CasParserCamsKfintechParams.none(), requestOptions) - - /** - * This endpoint specifically parses CDSL CAS (Consolidated Account Statement) PDF files and - * returns data in a unified format. Use this endpoint when you know the PDF is from CDSL. - */ - fun cdsl(): UnifiedResponse = cdsl(CasParserCdslParams.none()) - - /** @see cdsl */ - fun cdsl( - params: CasParserCdslParams = CasParserCdslParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): UnifiedResponse - - /** @see cdsl */ - fun cdsl(params: CasParserCdslParams = CasParserCdslParams.none()): UnifiedResponse = - cdsl(params, RequestOptions.none()) - - /** @see cdsl */ - fun cdsl(requestOptions: RequestOptions): UnifiedResponse = - cdsl(CasParserCdslParams.none(), requestOptions) - - /** - * This endpoint specifically parses NSDL CAS (Consolidated Account Statement) PDF files and - * returns data in a unified format. Use this endpoint when you know the PDF is from NSDL. - */ - fun nsdl(): UnifiedResponse = nsdl(CasParserNsdlParams.none()) - - /** @see nsdl */ - fun nsdl( - params: CasParserNsdlParams = CasParserNsdlParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): UnifiedResponse - - /** @see nsdl */ - fun nsdl(params: CasParserNsdlParams = CasParserNsdlParams.none()): UnifiedResponse = - nsdl(params, RequestOptions.none()) - - /** @see nsdl */ - fun nsdl(requestOptions: RequestOptions): UnifiedResponse = - nsdl(CasParserNsdlParams.none(), requestOptions) - - /** - * This endpoint parses CAS (Consolidated Account Statement) PDF files from NSDL, CDSL, or - * CAMS/KFintech and returns data in a unified format. It auto-detects the CAS type and - * transforms the data into a consistent structure regardless of the source. - */ - fun smartParse(): UnifiedResponse = smartParse(CasParserSmartParseParams.none()) - - /** @see smartParse */ - fun smartParse( - params: CasParserSmartParseParams = CasParserSmartParseParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): UnifiedResponse - - /** @see smartParse */ - fun smartParse( - params: CasParserSmartParseParams = CasParserSmartParseParams.none() - ): UnifiedResponse = smartParse(params, RequestOptions.none()) - - /** @see smartParse */ - fun smartParse(requestOptions: RequestOptions): UnifiedResponse = - smartParse(CasParserSmartParseParams.none(), requestOptions) - - /** A view of [CasParserService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): CasParserService.WithRawResponse - - /** - * Returns a raw HTTP response for `post /v4/cams_kfintech/parse`, but is otherwise the same - * as [CasParserService.camsKfintech]. - */ - @MustBeClosed - fun camsKfintech(): HttpResponseFor = - camsKfintech(CasParserCamsKfintechParams.none()) - - /** @see camsKfintech */ - @MustBeClosed - fun camsKfintech( - params: CasParserCamsKfintechParams = CasParserCamsKfintechParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see camsKfintech */ - @MustBeClosed - fun camsKfintech( - params: CasParserCamsKfintechParams = CasParserCamsKfintechParams.none() - ): HttpResponseFor = camsKfintech(params, RequestOptions.none()) - - /** @see camsKfintech */ - @MustBeClosed - fun camsKfintech(requestOptions: RequestOptions): HttpResponseFor = - camsKfintech(CasParserCamsKfintechParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `post /v4/cdsl/parse`, but is otherwise the same as - * [CasParserService.cdsl]. - */ - @MustBeClosed - fun cdsl(): HttpResponseFor = cdsl(CasParserCdslParams.none()) - - /** @see cdsl */ - @MustBeClosed - fun cdsl( - params: CasParserCdslParams = CasParserCdslParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see cdsl */ - @MustBeClosed - fun cdsl( - params: CasParserCdslParams = CasParserCdslParams.none() - ): HttpResponseFor = cdsl(params, RequestOptions.none()) - - /** @see cdsl */ - @MustBeClosed - fun cdsl(requestOptions: RequestOptions): HttpResponseFor = - cdsl(CasParserCdslParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `post /v4/nsdl/parse`, but is otherwise the same as - * [CasParserService.nsdl]. - */ - @MustBeClosed - fun nsdl(): HttpResponseFor = nsdl(CasParserNsdlParams.none()) - - /** @see nsdl */ - @MustBeClosed - fun nsdl( - params: CasParserNsdlParams = CasParserNsdlParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see nsdl */ - @MustBeClosed - fun nsdl( - params: CasParserNsdlParams = CasParserNsdlParams.none() - ): HttpResponseFor = nsdl(params, RequestOptions.none()) - - /** @see nsdl */ - @MustBeClosed - fun nsdl(requestOptions: RequestOptions): HttpResponseFor = - nsdl(CasParserNsdlParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `post /v4/smart/parse`, but is otherwise the same as - * [CasParserService.smartParse]. - */ - @MustBeClosed - fun smartParse(): HttpResponseFor = - smartParse(CasParserSmartParseParams.none()) - - /** @see smartParse */ - @MustBeClosed - fun smartParse( - params: CasParserSmartParseParams = CasParserSmartParseParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see smartParse */ - @MustBeClosed - fun smartParse( - params: CasParserSmartParseParams = CasParserSmartParseParams.none() - ): HttpResponseFor = smartParse(params, RequestOptions.none()) - - /** @see smartParse */ - @MustBeClosed - fun smartParse(requestOptions: RequestOptions): HttpResponseFor = - smartParse(CasParserSmartParseParams.none(), requestOptions) - } -} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CdslService.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CdslService.kt new file mode 100644 index 0000000..a8241be --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CdslService.kt @@ -0,0 +1,87 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.camskfintech.UnifiedResponse +import com.cas_parser.api.models.cdsl.CdslParsePdfParams +import com.cas_parser.api.services.blocking.cdsl.FetchService +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface CdslService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CdslService + + fun fetch(): FetchService + + /** + * This endpoint specifically parses CDSL CAS (Consolidated Account Statement) PDF files and + * returns data in a unified format. Use this endpoint when you know the PDF is from CDSL. + */ + fun parsePdf(): UnifiedResponse = parsePdf(CdslParsePdfParams.none()) + + /** @see parsePdf */ + fun parsePdf( + params: CdslParsePdfParams = CdslParsePdfParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): UnifiedResponse + + /** @see parsePdf */ + fun parsePdf(params: CdslParsePdfParams = CdslParsePdfParams.none()): UnifiedResponse = + parsePdf(params, RequestOptions.none()) + + /** @see parsePdf */ + fun parsePdf(requestOptions: RequestOptions): UnifiedResponse = + parsePdf(CdslParsePdfParams.none(), requestOptions) + + /** A view of [CdslService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CdslService.WithRawResponse + + fun fetch(): FetchService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v4/cdsl/parse`, but is otherwise the same as + * [CdslService.parsePdf]. + */ + @MustBeClosed + fun parsePdf(): HttpResponseFor = parsePdf(CdslParsePdfParams.none()) + + /** @see parsePdf */ + @MustBeClosed + fun parsePdf( + params: CdslParsePdfParams = CdslParsePdfParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see parsePdf */ + @MustBeClosed + fun parsePdf( + params: CdslParsePdfParams = CdslParsePdfParams.none() + ): HttpResponseFor = parsePdf(params, RequestOptions.none()) + + /** @see parsePdf */ + @MustBeClosed + fun parsePdf(requestOptions: RequestOptions): HttpResponseFor = + parsePdf(CdslParsePdfParams.none(), requestOptions) + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CdslServiceImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CdslServiceImpl.kt new file mode 100644 index 0000000..0155aa6 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CdslServiceImpl.kt @@ -0,0 +1,93 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.multipartFormData +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepare +import com.cas_parser.api.models.camskfintech.UnifiedResponse +import com.cas_parser.api.models.cdsl.CdslParsePdfParams +import com.cas_parser.api.services.blocking.cdsl.FetchService +import com.cas_parser.api.services.blocking.cdsl.FetchServiceImpl +import java.util.function.Consumer + +class CdslServiceImpl internal constructor(private val clientOptions: ClientOptions) : CdslService { + + private val withRawResponse: CdslService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + private val fetch: FetchService by lazy { FetchServiceImpl(clientOptions) } + + override fun withRawResponse(): CdslService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CdslService = + CdslServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun fetch(): FetchService = fetch + + override fun parsePdf( + params: CdslParsePdfParams, + requestOptions: RequestOptions, + ): UnifiedResponse = + // post /v4/cdsl/parse + withRawResponse().parsePdf(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CdslService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + private val fetch: FetchService.WithRawResponse by lazy { + FetchServiceImpl.WithRawResponseImpl(clientOptions) + } + + override fun withOptions( + modifier: Consumer + ): CdslService.WithRawResponse = + CdslServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun fetch(): FetchService.WithRawResponse = fetch + + private val parsePdfHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun parsePdf( + params: CdslParsePdfParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v4", "cdsl", "parse") + .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { parsePdfHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/ContractNoteService.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/ContractNoteService.kt new file mode 100644 index 0000000..d7a1b64 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/ContractNoteService.kt @@ -0,0 +1,112 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.contractnote.ContractNoteParseParams +import com.cas_parser.api.models.contractnote.ContractNoteParseResponse +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface ContractNoteService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ContractNoteService + + /** + * This endpoint parses Contract Note PDF files from various brokers including Zerodha, Groww, + * Upstox, ICICI Securities, and others. + * + * **What is a Contract Note?** A contract note is a legal document that provides details of all + * trades executed by an investor. It includes: + * - Trade details with timestamps, quantities, and prices + * - Brokerage and charges breakdown + * - Settlement information + * - Regulatory compliance details + * + * **Supported Brokers:** + * - Zerodha Broking Limited + * - Groww Invest Tech Private Limited + * - Upstox (RKSV Securities) + * - ICICI Securities Limited + * - Auto-detection for unknown brokers + * + * **Key Features:** + * - **Auto-detection**: Automatically identifies broker type from PDF content + * - **Comprehensive parsing**: Extracts equity transactions, derivatives transactions, detailed + * trades, and charges + * - **Flexible input**: Accepts both file upload and URL-based PDF input + * - **Password protection**: Supports password-protected PDFs + * + * The API returns structured data including contract note information, client details, + * transaction summaries, and detailed trade-by-trade breakdowns. + */ + fun parse(): ContractNoteParseResponse = parse(ContractNoteParseParams.none()) + + /** @see parse */ + fun parse( + params: ContractNoteParseParams = ContractNoteParseParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ContractNoteParseResponse + + /** @see parse */ + fun parse( + params: ContractNoteParseParams = ContractNoteParseParams.none() + ): ContractNoteParseResponse = parse(params, RequestOptions.none()) + + /** @see parse */ + fun parse(requestOptions: RequestOptions): ContractNoteParseResponse = + parse(ContractNoteParseParams.none(), requestOptions) + + /** + * A view of [ContractNoteService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ContractNoteService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v4/contract_note/parse`, but is otherwise the same + * as [ContractNoteService.parse]. + */ + @MustBeClosed + fun parse(): HttpResponseFor = + parse(ContractNoteParseParams.none()) + + /** @see parse */ + @MustBeClosed + fun parse( + params: ContractNoteParseParams = ContractNoteParseParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see parse */ + @MustBeClosed + fun parse( + params: ContractNoteParseParams = ContractNoteParseParams.none() + ): HttpResponseFor = parse(params, RequestOptions.none()) + + /** @see parse */ + @MustBeClosed + fun parse(requestOptions: RequestOptions): HttpResponseFor = + parse(ContractNoteParseParams.none(), requestOptions) + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/ContractNoteServiceImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/ContractNoteServiceImpl.kt new file mode 100644 index 0000000..978c42b --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/ContractNoteServiceImpl.kt @@ -0,0 +1,82 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.multipartFormData +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepare +import com.cas_parser.api.models.contractnote.ContractNoteParseParams +import com.cas_parser.api.models.contractnote.ContractNoteParseResponse +import java.util.function.Consumer + +class ContractNoteServiceImpl internal constructor(private val clientOptions: ClientOptions) : + ContractNoteService { + + private val withRawResponse: ContractNoteService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): ContractNoteService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): ContractNoteService = + ContractNoteServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun parse( + params: ContractNoteParseParams, + requestOptions: RequestOptions, + ): ContractNoteParseResponse = + // post /v4/contract_note/parse + withRawResponse().parse(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + ContractNoteService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): ContractNoteService.WithRawResponse = + ContractNoteServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val parseHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun parse( + params: ContractNoteParseParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v4", "contract_note", "parse") + .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { parseHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CreditService.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CreditService.kt new file mode 100644 index 0000000..5d22d46 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CreditService.kt @@ -0,0 +1,88 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +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.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface CreditService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CreditService + + /** + * Check your remaining API credits and usage for the current billing period. + * + * Returns: + * - Number of API calls used and remaining credits + * - Credit limit and reset date + * - List of enabled features for your plan + * + * Credits reset at the start of each billing period. + */ + fun check(): CreditCheckResponse = check(CreditCheckParams.none()) + + /** @see check */ + fun check( + params: CreditCheckParams = CreditCheckParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CreditCheckResponse + + /** @see check */ + fun check(params: CreditCheckParams = CreditCheckParams.none()): CreditCheckResponse = + check(params, RequestOptions.none()) + + /** @see check */ + fun check(requestOptions: RequestOptions): CreditCheckResponse = + check(CreditCheckParams.none(), requestOptions) + + /** A view of [CreditService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CreditService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /credits`, but is otherwise the same as + * [CreditService.check]. + */ + @MustBeClosed + fun check(): HttpResponseFor = check(CreditCheckParams.none()) + + /** @see check */ + @MustBeClosed + fun check( + params: CreditCheckParams = CreditCheckParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see check */ + @MustBeClosed + fun check( + params: CreditCheckParams = CreditCheckParams.none() + ): HttpResponseFor = check(params, RequestOptions.none()) + + /** @see check */ + @MustBeClosed + fun check(requestOptions: RequestOptions): HttpResponseFor = + check(CreditCheckParams.none(), requestOptions) + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CreditServiceImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CreditServiceImpl.kt new file mode 100644 index 0000000..549e113 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CreditServiceImpl.kt @@ -0,0 +1,82 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.json +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepare +import com.cas_parser.api.models.credits.CreditCheckParams +import com.cas_parser.api.models.credits.CreditCheckResponse +import java.util.function.Consumer + +class CreditServiceImpl internal constructor(private val clientOptions: ClientOptions) : + CreditService { + + private val withRawResponse: CreditService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CreditService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CreditService = + CreditServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun check( + params: CreditCheckParams, + requestOptions: RequestOptions, + ): CreditCheckResponse = + // post /credits + withRawResponse().check(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CreditService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CreditService.WithRawResponse = + CreditServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val checkHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun check( + params: CreditCheckParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("credits") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { checkHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/InboxService.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/InboxService.kt new file mode 100644 index 0000000..e2b5ce0 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/InboxService.kt @@ -0,0 +1,187 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.inbox.InboxCheckConnectionStatusParams +import com.cas_parser.api.models.inbox.InboxCheckConnectionStatusResponse +import com.cas_parser.api.models.inbox.InboxConnectEmailParams +import com.cas_parser.api.models.inbox.InboxConnectEmailResponse +import com.cas_parser.api.models.inbox.InboxDisconnectEmailParams +import com.cas_parser.api.models.inbox.InboxDisconnectEmailResponse +import com.cas_parser.api.models.inbox.InboxListCasFilesParams +import com.cas_parser.api.models.inbox.InboxListCasFilesResponse +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface InboxService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): InboxService + + /** + * Verify if an `inbox_token` is still valid and check connection status. + * + * Use this to check if the user needs to re-authenticate (e.g., if they revoked access in their + * email provider settings). + */ + fun checkConnectionStatus( + params: InboxCheckConnectionStatusParams + ): InboxCheckConnectionStatusResponse = checkConnectionStatus(params, RequestOptions.none()) + + /** @see checkConnectionStatus */ + fun checkConnectionStatus( + params: InboxCheckConnectionStatusParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InboxCheckConnectionStatusResponse + + /** + * Initiate OAuth flow to connect user's email inbox. + * + * Returns an `oauth_url` that you should redirect the user to. After authorization, they are + * redirected back to your `redirect_uri` with the following query parameters: + * + * **On success:** + * - `inbox_token` - Encrypted token to store client-side + * - `email` - Email address of the connected account + * - `state` - Your original state parameter (for CSRF verification) + * + * **On error:** + * - `error` - Error code (e.g., `access_denied`, `token_exchange_failed`) + * - `state` - Your original state parameter + * + * **Store the `inbox_token` client-side** and use it for all subsequent inbox API calls. + */ + fun connectEmail(params: InboxConnectEmailParams): InboxConnectEmailResponse = + connectEmail(params, RequestOptions.none()) + + /** @see connectEmail */ + fun connectEmail( + params: InboxConnectEmailParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InboxConnectEmailResponse + + /** + * Revoke email access and invalidate the token. + * + * This calls the provider's token revocation API (e.g., Google's revoke endpoint) to ensure the + * user's consent is properly removed. + * + * After calling this, the `inbox_token` becomes unusable. + */ + fun disconnectEmail(params: InboxDisconnectEmailParams): InboxDisconnectEmailResponse = + disconnectEmail(params, RequestOptions.none()) + + /** @see disconnectEmail */ + fun disconnectEmail( + params: InboxDisconnectEmailParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InboxDisconnectEmailResponse + + /** + * Search the user's email inbox for CAS files from known senders (CAMS, KFintech, CDSL, NSDL). + * + * Files are uploaded to temporary cloud storage. **URLs expire in 24 hours.** + * + * Optionally filter by CAS provider and date range. + * + * **Billing:** 0.2 credits per request (charged regardless of success or number of files + * found). + */ + fun listCasFiles(params: InboxListCasFilesParams): InboxListCasFilesResponse = + listCasFiles(params, RequestOptions.none()) + + /** @see listCasFiles */ + fun listCasFiles( + params: InboxListCasFilesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): InboxListCasFilesResponse + + /** A view of [InboxService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): InboxService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v4/inbox/status`, but is otherwise the same as + * [InboxService.checkConnectionStatus]. + */ + @MustBeClosed + fun checkConnectionStatus( + params: InboxCheckConnectionStatusParams + ): HttpResponseFor = + checkConnectionStatus(params, RequestOptions.none()) + + /** @see checkConnectionStatus */ + @MustBeClosed + fun checkConnectionStatus( + params: InboxCheckConnectionStatusParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /v4/inbox/connect`, but is otherwise the same as + * [InboxService.connectEmail]. + */ + @MustBeClosed + fun connectEmail( + params: InboxConnectEmailParams + ): HttpResponseFor = connectEmail(params, RequestOptions.none()) + + /** @see connectEmail */ + @MustBeClosed + fun connectEmail( + params: InboxConnectEmailParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /v4/inbox/disconnect`, but is otherwise the same as + * [InboxService.disconnectEmail]. + */ + @MustBeClosed + fun disconnectEmail( + params: InboxDisconnectEmailParams + ): HttpResponseFor = + disconnectEmail(params, RequestOptions.none()) + + /** @see disconnectEmail */ + @MustBeClosed + fun disconnectEmail( + params: InboxDisconnectEmailParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /v4/inbox/cas`, but is otherwise the same as + * [InboxService.listCasFiles]. + */ + @MustBeClosed + fun listCasFiles( + params: InboxListCasFilesParams + ): HttpResponseFor = listCasFiles(params, RequestOptions.none()) + + /** @see listCasFiles */ + @MustBeClosed + fun listCasFiles( + params: InboxListCasFilesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CasParserServiceImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/InboxServiceImpl.kt similarity index 52% rename from cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CasParserServiceImpl.kt rename to cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/InboxServiceImpl.kt index 8826c88..27ebb03 100644 --- a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/CasParserServiceImpl.kt +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/InboxServiceImpl.kt @@ -12,89 +12,92 @@ import com.cas_parser.api.core.http.HttpRequest import com.cas_parser.api.core.http.HttpResponse import com.cas_parser.api.core.http.HttpResponse.Handler import com.cas_parser.api.core.http.HttpResponseFor -import com.cas_parser.api.core.http.multipartFormData +import com.cas_parser.api.core.http.json import com.cas_parser.api.core.http.parseable import com.cas_parser.api.core.prepare -import com.cas_parser.api.models.casparser.CasParserCamsKfintechParams -import com.cas_parser.api.models.casparser.CasParserCdslParams -import com.cas_parser.api.models.casparser.CasParserNsdlParams -import com.cas_parser.api.models.casparser.CasParserSmartParseParams -import com.cas_parser.api.models.casparser.UnifiedResponse +import com.cas_parser.api.models.inbox.InboxCheckConnectionStatusParams +import com.cas_parser.api.models.inbox.InboxCheckConnectionStatusResponse +import com.cas_parser.api.models.inbox.InboxConnectEmailParams +import com.cas_parser.api.models.inbox.InboxConnectEmailResponse +import com.cas_parser.api.models.inbox.InboxDisconnectEmailParams +import com.cas_parser.api.models.inbox.InboxDisconnectEmailResponse +import com.cas_parser.api.models.inbox.InboxListCasFilesParams +import com.cas_parser.api.models.inbox.InboxListCasFilesResponse import java.util.function.Consumer -class CasParserServiceImpl internal constructor(private val clientOptions: ClientOptions) : - CasParserService { +class InboxServiceImpl internal constructor(private val clientOptions: ClientOptions) : + InboxService { - private val withRawResponse: CasParserService.WithRawResponse by lazy { + private val withRawResponse: InboxService.WithRawResponse by lazy { WithRawResponseImpl(clientOptions) } - override fun withRawResponse(): CasParserService.WithRawResponse = withRawResponse + override fun withRawResponse(): InboxService.WithRawResponse = withRawResponse - override fun withOptions(modifier: Consumer): CasParserService = - CasParserServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun withOptions(modifier: Consumer): InboxService = + InboxServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - override fun camsKfintech( - params: CasParserCamsKfintechParams, + override fun checkConnectionStatus( + params: InboxCheckConnectionStatusParams, requestOptions: RequestOptions, - ): UnifiedResponse = - // post /v4/cams_kfintech/parse - withRawResponse().camsKfintech(params, requestOptions).parse() + ): InboxCheckConnectionStatusResponse = + // post /v4/inbox/status + withRawResponse().checkConnectionStatus(params, requestOptions).parse() - override fun cdsl( - params: CasParserCdslParams, + override fun connectEmail( + params: InboxConnectEmailParams, requestOptions: RequestOptions, - ): UnifiedResponse = - // post /v4/cdsl/parse - withRawResponse().cdsl(params, requestOptions).parse() + ): InboxConnectEmailResponse = + // post /v4/inbox/connect + withRawResponse().connectEmail(params, requestOptions).parse() - override fun nsdl( - params: CasParserNsdlParams, + override fun disconnectEmail( + params: InboxDisconnectEmailParams, requestOptions: RequestOptions, - ): UnifiedResponse = - // post /v4/nsdl/parse - withRawResponse().nsdl(params, requestOptions).parse() + ): InboxDisconnectEmailResponse = + // post /v4/inbox/disconnect + withRawResponse().disconnectEmail(params, requestOptions).parse() - override fun smartParse( - params: CasParserSmartParseParams, + override fun listCasFiles( + params: InboxListCasFilesParams, requestOptions: RequestOptions, - ): UnifiedResponse = - // post /v4/smart/parse - withRawResponse().smartParse(params, requestOptions).parse() + ): InboxListCasFilesResponse = + // post /v4/inbox/cas + withRawResponse().listCasFiles(params, requestOptions).parse() class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - CasParserService.WithRawResponse { + InboxService.WithRawResponse { private val errorHandler: Handler = errorHandler(errorBodyHandler(clientOptions.jsonMapper)) override fun withOptions( modifier: Consumer - ): CasParserService.WithRawResponse = - CasParserServiceImpl.WithRawResponseImpl( + ): InboxService.WithRawResponse = + InboxServiceImpl.WithRawResponseImpl( clientOptions.toBuilder().apply(modifier::accept).build() ) - private val camsKfintechHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val checkConnectionStatusHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun camsKfintech( - params: CasParserCamsKfintechParams, + override fun checkConnectionStatus( + params: InboxCheckConnectionStatusParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("v4", "cams_kfintech", "parse") - .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .addPathSegments("v4", "inbox", "status") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { response - .use { camsKfintechHandler.handle(it) } + .use { checkConnectionStatusHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() @@ -103,26 +106,26 @@ class CasParserServiceImpl internal constructor(private val clientOptions: Clien } } - private val cdslHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val connectEmailHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun cdsl( - params: CasParserCdslParams, + override fun connectEmail( + params: InboxConnectEmailParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("v4", "cdsl", "parse") - .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .addPathSegments("v4", "inbox", "connect") + .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { response - .use { cdslHandler.handle(it) } + .use { connectEmailHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() @@ -131,26 +134,26 @@ class CasParserServiceImpl internal constructor(private val clientOptions: Clien } } - private val nsdlHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val disconnectEmailHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun nsdl( - params: CasParserNsdlParams, + override fun disconnectEmail( + params: InboxDisconnectEmailParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("v4", "nsdl", "parse") - .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .addPathSegments("v4", "inbox", "disconnect") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { response - .use { nsdlHandler.handle(it) } + .use { disconnectEmailHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() @@ -159,26 +162,26 @@ class CasParserServiceImpl internal constructor(private val clientOptions: Clien } } - private val smartParseHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val listCasFilesHandler: Handler = + jsonHandler(clientOptions.jsonMapper) - override fun smartParse( - params: CasParserSmartParseParams, + override fun listCasFiles( + params: InboxListCasFilesParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.POST) .baseUrl(clientOptions.baseUrl()) - .addPathSegments("v4", "smart", "parse") - .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .addPathSegments("v4", "inbox", "cas") + .body(json(clientOptions.jsonMapper, params._body())) .build() .prepare(clientOptions, params) val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { response - .use { smartParseHandler.handle(it) } + .use { listCasFilesHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/KfintechService.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/KfintechService.kt new file mode 100644 index 0000000..0bc26c9 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/KfintechService.kt @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.kfintech.KfintechGenerateCasParams +import com.cas_parser.api.models.kfintech.KfintechGenerateCasResponse +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface KfintechService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): KfintechService + + /** + * Generate CAS via KFintech mailback. The CAS PDF will be sent to the investor's email. + * + * This is an async operation - the investor receives the CAS via email within a few minutes. + * For instant CAS retrieval, use CDSL Fetch (`/v4/cdsl/fetch`). + */ + fun generateCas(params: KfintechGenerateCasParams): KfintechGenerateCasResponse = + generateCas(params, RequestOptions.none()) + + /** @see generateCas */ + fun generateCas( + params: KfintechGenerateCasParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): KfintechGenerateCasResponse + + /** A view of [KfintechService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): KfintechService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v4/kfintech/generate`, but is otherwise the same + * as [KfintechService.generateCas]. + */ + @MustBeClosed + fun generateCas( + params: KfintechGenerateCasParams + ): HttpResponseFor = generateCas(params, RequestOptions.none()) + + /** @see generateCas */ + @MustBeClosed + fun generateCas( + params: KfintechGenerateCasParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/KfintechServiceImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/KfintechServiceImpl.kt new file mode 100644 index 0000000..679e4d8 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/KfintechServiceImpl.kt @@ -0,0 +1,82 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.json +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepare +import com.cas_parser.api.models.kfintech.KfintechGenerateCasParams +import com.cas_parser.api.models.kfintech.KfintechGenerateCasResponse +import java.util.function.Consumer + +class KfintechServiceImpl internal constructor(private val clientOptions: ClientOptions) : + KfintechService { + + private val withRawResponse: KfintechService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): KfintechService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): KfintechService = + KfintechServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun generateCas( + params: KfintechGenerateCasParams, + requestOptions: RequestOptions, + ): KfintechGenerateCasResponse = + // post /v4/kfintech/generate + withRawResponse().generateCas(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + KfintechService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): KfintechService.WithRawResponse = + KfintechServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val generateCasHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun generateCas( + params: KfintechGenerateCasParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v4", "kfintech", "generate") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { generateCasHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/LogService.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/LogService.kt new file mode 100644 index 0000000..ce35cba --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/LogService.kt @@ -0,0 +1,134 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.logs.LogCreateParams +import com.cas_parser.api.models.logs.LogCreateResponse +import com.cas_parser.api.models.logs.LogGetSummaryParams +import com.cas_parser.api.models.logs.LogGetSummaryResponse +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface LogService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): LogService + + /** + * Retrieve detailed API usage logs for your account. + * + * Returns a list of API calls with timestamps, features used, status codes, and credits + * consumed. Useful for monitoring usage patterns and debugging. + */ + fun create(): LogCreateResponse = create(LogCreateParams.none()) + + /** @see create */ + fun create( + params: LogCreateParams = LogCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LogCreateResponse + + /** @see create */ + fun create(params: LogCreateParams = LogCreateParams.none()): LogCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create(requestOptions: RequestOptions): LogCreateResponse = + create(LogCreateParams.none(), requestOptions) + + /** + * Get aggregated usage statistics grouped by feature. + * + * Useful for understanding which API features are being used most and tracking usage trends. + */ + fun getSummary(): LogGetSummaryResponse = getSummary(LogGetSummaryParams.none()) + + /** @see getSummary */ + fun getSummary( + params: LogGetSummaryParams = LogGetSummaryParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): LogGetSummaryResponse + + /** @see getSummary */ + fun getSummary( + params: LogGetSummaryParams = LogGetSummaryParams.none() + ): LogGetSummaryResponse = getSummary(params, RequestOptions.none()) + + /** @see getSummary */ + fun getSummary(requestOptions: RequestOptions): LogGetSummaryResponse = + getSummary(LogGetSummaryParams.none(), requestOptions) + + /** A view of [LogService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): LogService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /logs`, but is otherwise the same as + * [LogService.create]. + */ + @MustBeClosed + fun create(): HttpResponseFor = create(LogCreateParams.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: LogCreateParams = LogCreateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see create */ + @MustBeClosed + fun create( + params: LogCreateParams = LogCreateParams.none() + ): HttpResponseFor = create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create(requestOptions: RequestOptions): HttpResponseFor = + create(LogCreateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /logs/summary`, but is otherwise the same as + * [LogService.getSummary]. + */ + @MustBeClosed + fun getSummary(): HttpResponseFor = + getSummary(LogGetSummaryParams.none()) + + /** @see getSummary */ + @MustBeClosed + fun getSummary( + params: LogGetSummaryParams = LogGetSummaryParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see getSummary */ + @MustBeClosed + fun getSummary( + params: LogGetSummaryParams = LogGetSummaryParams.none() + ): HttpResponseFor = getSummary(params, RequestOptions.none()) + + /** @see getSummary */ + @MustBeClosed + fun getSummary(requestOptions: RequestOptions): HttpResponseFor = + getSummary(LogGetSummaryParams.none(), requestOptions) + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/LogServiceImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/LogServiceImpl.kt new file mode 100644 index 0000000..fb303d1 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/LogServiceImpl.kt @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.json +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepare +import com.cas_parser.api.models.logs.LogCreateParams +import com.cas_parser.api.models.logs.LogCreateResponse +import com.cas_parser.api.models.logs.LogGetSummaryParams +import com.cas_parser.api.models.logs.LogGetSummaryResponse +import java.util.function.Consumer + +class LogServiceImpl internal constructor(private val clientOptions: ClientOptions) : LogService { + + private val withRawResponse: LogService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): LogService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): LogService = + LogServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: LogCreateParams, + requestOptions: RequestOptions, + ): LogCreateResponse = + // post /logs + withRawResponse().create(params, requestOptions).parse() + + override fun getSummary( + params: LogGetSummaryParams, + requestOptions: RequestOptions, + ): LogGetSummaryResponse = + // post /logs/summary + withRawResponse().getSummary(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + LogService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): LogService.WithRawResponse = + LogServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: LogCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("logs") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val getSummaryHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun getSummary( + params: LogGetSummaryParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("logs", "summary") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { getSummaryHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/NsdlService.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/NsdlService.kt new file mode 100644 index 0000000..8ca3b7c --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/NsdlService.kt @@ -0,0 +1,81 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.camskfintech.UnifiedResponse +import com.cas_parser.api.models.nsdl.NsdlParseParams +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface NsdlService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): NsdlService + + /** + * This endpoint specifically parses NSDL CAS (Consolidated Account Statement) PDF files and + * returns data in a unified format. Use this endpoint when you know the PDF is from NSDL. + */ + fun parse(): UnifiedResponse = parse(NsdlParseParams.none()) + + /** @see parse */ + fun parse( + params: NsdlParseParams = NsdlParseParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): UnifiedResponse + + /** @see parse */ + fun parse(params: NsdlParseParams = NsdlParseParams.none()): UnifiedResponse = + parse(params, RequestOptions.none()) + + /** @see parse */ + fun parse(requestOptions: RequestOptions): UnifiedResponse = + parse(NsdlParseParams.none(), requestOptions) + + /** A view of [NsdlService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): NsdlService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v4/nsdl/parse`, but is otherwise the same as + * [NsdlService.parse]. + */ + @MustBeClosed fun parse(): HttpResponseFor = parse(NsdlParseParams.none()) + + /** @see parse */ + @MustBeClosed + fun parse( + params: NsdlParseParams = NsdlParseParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see parse */ + @MustBeClosed + fun parse( + params: NsdlParseParams = NsdlParseParams.none() + ): HttpResponseFor = parse(params, RequestOptions.none()) + + /** @see parse */ + @MustBeClosed + fun parse(requestOptions: RequestOptions): HttpResponseFor = + parse(NsdlParseParams.none(), requestOptions) + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/NsdlServiceImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/NsdlServiceImpl.kt new file mode 100644 index 0000000..a887773 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/NsdlServiceImpl.kt @@ -0,0 +1,78 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.multipartFormData +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepare +import com.cas_parser.api.models.camskfintech.UnifiedResponse +import com.cas_parser.api.models.nsdl.NsdlParseParams +import java.util.function.Consumer + +class NsdlServiceImpl internal constructor(private val clientOptions: ClientOptions) : NsdlService { + + private val withRawResponse: NsdlService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): NsdlService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): NsdlService = + NsdlServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun parse(params: NsdlParseParams, requestOptions: RequestOptions): UnifiedResponse = + // post /v4/nsdl/parse + withRawResponse().parse(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + NsdlService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): NsdlService.WithRawResponse = + NsdlServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val parseHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun parse( + params: NsdlParseParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v4", "nsdl", "parse") + .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { parseHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/SmartService.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/SmartService.kt new file mode 100644 index 0000000..fce30ed --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/SmartService.kt @@ -0,0 +1,85 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.camskfintech.UnifiedResponse +import com.cas_parser.api.models.smart.SmartParseCasPdfParams +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface SmartService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SmartService + + /** + * This endpoint parses CAS (Consolidated Account Statement) PDF files from NSDL, CDSL, or + * CAMS/KFintech and returns data in a unified format. It auto-detects the CAS type and + * transforms the data into a consistent structure regardless of the source. + */ + fun parseCasPdf(): UnifiedResponse = parseCasPdf(SmartParseCasPdfParams.none()) + + /** @see parseCasPdf */ + fun parseCasPdf( + params: SmartParseCasPdfParams = SmartParseCasPdfParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): UnifiedResponse + + /** @see parseCasPdf */ + fun parseCasPdf( + params: SmartParseCasPdfParams = SmartParseCasPdfParams.none() + ): UnifiedResponse = parseCasPdf(params, RequestOptions.none()) + + /** @see parseCasPdf */ + fun parseCasPdf(requestOptions: RequestOptions): UnifiedResponse = + parseCasPdf(SmartParseCasPdfParams.none(), requestOptions) + + /** A view of [SmartService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SmartService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v4/smart/parse`, but is otherwise the same as + * [SmartService.parseCasPdf]. + */ + @MustBeClosed + fun parseCasPdf(): HttpResponseFor = + parseCasPdf(SmartParseCasPdfParams.none()) + + /** @see parseCasPdf */ + @MustBeClosed + fun parseCasPdf( + params: SmartParseCasPdfParams = SmartParseCasPdfParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see parseCasPdf */ + @MustBeClosed + fun parseCasPdf( + params: SmartParseCasPdfParams = SmartParseCasPdfParams.none() + ): HttpResponseFor = parseCasPdf(params, RequestOptions.none()) + + /** @see parseCasPdf */ + @MustBeClosed + fun parseCasPdf(requestOptions: RequestOptions): HttpResponseFor = + parseCasPdf(SmartParseCasPdfParams.none(), requestOptions) + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/SmartServiceImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/SmartServiceImpl.kt new file mode 100644 index 0000000..6808cd7 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/SmartServiceImpl.kt @@ -0,0 +1,82 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.multipartFormData +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepare +import com.cas_parser.api.models.camskfintech.UnifiedResponse +import com.cas_parser.api.models.smart.SmartParseCasPdfParams +import java.util.function.Consumer + +class SmartServiceImpl internal constructor(private val clientOptions: ClientOptions) : + SmartService { + + private val withRawResponse: SmartService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SmartService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): SmartService = + SmartServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun parseCasPdf( + params: SmartParseCasPdfParams, + requestOptions: RequestOptions, + ): UnifiedResponse = + // post /v4/smart/parse + withRawResponse().parseCasPdf(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SmartService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): SmartService.WithRawResponse = + SmartServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val parseCasPdfHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun parseCasPdf( + params: SmartParseCasPdfParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v4", "smart", "parse") + .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { parseCasPdfHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/VerifyTokenService.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/VerifyTokenService.kt new file mode 100644 index 0000000..6596370 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/VerifyTokenService.kt @@ -0,0 +1,85 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.verifytoken.VerifyTokenVerifyParams +import com.cas_parser.api.models.verifytoken.VerifyTokenVerifyResponse +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface VerifyTokenService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): VerifyTokenService + + /** Verify an access token and check if it's still valid. Useful for debugging token issues. */ + fun verify(): VerifyTokenVerifyResponse = verify(VerifyTokenVerifyParams.none()) + + /** @see verify */ + fun verify( + params: VerifyTokenVerifyParams = VerifyTokenVerifyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): VerifyTokenVerifyResponse + + /** @see verify */ + fun verify( + params: VerifyTokenVerifyParams = VerifyTokenVerifyParams.none() + ): VerifyTokenVerifyResponse = verify(params, RequestOptions.none()) + + /** @see verify */ + fun verify(requestOptions: RequestOptions): VerifyTokenVerifyResponse = + verify(VerifyTokenVerifyParams.none(), requestOptions) + + /** + * A view of [VerifyTokenService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): VerifyTokenService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v1/verify-token`, but is otherwise the same as + * [VerifyTokenService.verify]. + */ + @MustBeClosed + fun verify(): HttpResponseFor = + verify(VerifyTokenVerifyParams.none()) + + /** @see verify */ + @MustBeClosed + fun verify( + params: VerifyTokenVerifyParams = VerifyTokenVerifyParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see verify */ + @MustBeClosed + fun verify( + params: VerifyTokenVerifyParams = VerifyTokenVerifyParams.none() + ): HttpResponseFor = verify(params, RequestOptions.none()) + + /** @see verify */ + @MustBeClosed + fun verify(requestOptions: RequestOptions): HttpResponseFor = + verify(VerifyTokenVerifyParams.none(), requestOptions) + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceImpl.kt new file mode 100644 index 0000000..6780bb3 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceImpl.kt @@ -0,0 +1,82 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.json +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepare +import com.cas_parser.api.models.verifytoken.VerifyTokenVerifyParams +import com.cas_parser.api.models.verifytoken.VerifyTokenVerifyResponse +import java.util.function.Consumer + +class VerifyTokenServiceImpl internal constructor(private val clientOptions: ClientOptions) : + VerifyTokenService { + + private val withRawResponse: VerifyTokenService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): VerifyTokenService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): VerifyTokenService = + VerifyTokenServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun verify( + params: VerifyTokenVerifyParams, + requestOptions: RequestOptions, + ): VerifyTokenVerifyResponse = + // post /v1/verify-token + withRawResponse().verify(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + VerifyTokenService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): VerifyTokenService.WithRawResponse = + VerifyTokenServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val verifyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun verify( + params: VerifyTokenVerifyParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "verify-token") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { verifyHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/cdsl/FetchService.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/cdsl/FetchService.kt new file mode 100644 index 0000000..81f2bc3 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/cdsl/FetchService.kt @@ -0,0 +1,132 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking.cdsl + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.models.cdsl.fetch.FetchRequestOtpParams +import com.cas_parser.api.models.cdsl.fetch.FetchRequestOtpResponse +import com.cas_parser.api.models.cdsl.fetch.FetchVerifyOtpParams +import com.cas_parser.api.models.cdsl.fetch.FetchVerifyOtpResponse +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface FetchService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FetchService + + /** + * **Step 1 of 2**: Request OTP for CDSL CAS fetch. + * + * This endpoint: + * 1. Solves reCAPTCHA automatically (~15-20 seconds) + * 2. Submits login credentials to CDSL portal + * 3. Triggers OTP to user's registered mobile number + * + * After user receives OTP, call `/v4/cdsl/fetch/{session_id}/verify` to complete. + */ + fun requestOtp(params: FetchRequestOtpParams): FetchRequestOtpResponse = + requestOtp(params, RequestOptions.none()) + + /** @see requestOtp */ + fun requestOtp( + params: FetchRequestOtpParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FetchRequestOtpResponse + + /** + * **Step 2 of 2**: Verify OTP and retrieve CDSL CAS files. + * + * After successful verification, CAS PDFs are fetched from CDSL portal, uploaded to cloud + * storage, and returned as direct download URLs. + */ + fun verifyOtp(sessionId: String, params: FetchVerifyOtpParams): FetchVerifyOtpResponse = + verifyOtp(sessionId, params, RequestOptions.none()) + + /** @see verifyOtp */ + fun verifyOtp( + sessionId: String, + params: FetchVerifyOtpParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FetchVerifyOtpResponse = + verifyOtp(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see verifyOtp */ + fun verifyOtp(params: FetchVerifyOtpParams): FetchVerifyOtpResponse = + verifyOtp(params, RequestOptions.none()) + + /** @see verifyOtp */ + fun verifyOtp( + params: FetchVerifyOtpParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FetchVerifyOtpResponse + + /** A view of [FetchService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FetchService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /v4/cdsl/fetch`, but is otherwise the same as + * [FetchService.requestOtp]. + */ + @MustBeClosed + fun requestOtp(params: FetchRequestOtpParams): HttpResponseFor = + requestOtp(params, RequestOptions.none()) + + /** @see requestOtp */ + @MustBeClosed + fun requestOtp( + params: FetchRequestOtpParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post /v4/cdsl/fetch/{session_id}/verify`, but is + * otherwise the same as [FetchService.verifyOtp]. + */ + @MustBeClosed + fun verifyOtp( + sessionId: String, + params: FetchVerifyOtpParams, + ): HttpResponseFor = + verifyOtp(sessionId, params, RequestOptions.none()) + + /** @see verifyOtp */ + @MustBeClosed + fun verifyOtp( + sessionId: String, + params: FetchVerifyOtpParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + verifyOtp(params.toBuilder().sessionId(sessionId).build(), requestOptions) + + /** @see verifyOtp */ + @MustBeClosed + fun verifyOtp(params: FetchVerifyOtpParams): HttpResponseFor = + verifyOtp(params, RequestOptions.none()) + + /** @see verifyOtp */ + @MustBeClosed + fun verifyOtp( + params: FetchVerifyOtpParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/cdsl/FetchServiceImpl.kt b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/cdsl/FetchServiceImpl.kt new file mode 100644 index 0000000..e9a3246 --- /dev/null +++ b/cas-parser-java-core/src/main/kotlin/com/cas_parser/api/services/blocking/cdsl/FetchServiceImpl.kt @@ -0,0 +1,124 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking.cdsl + +import com.cas_parser.api.core.ClientOptions +import com.cas_parser.api.core.RequestOptions +import com.cas_parser.api.core.checkRequired +import com.cas_parser.api.core.handlers.errorBodyHandler +import com.cas_parser.api.core.handlers.errorHandler +import com.cas_parser.api.core.handlers.jsonHandler +import com.cas_parser.api.core.http.HttpMethod +import com.cas_parser.api.core.http.HttpRequest +import com.cas_parser.api.core.http.HttpResponse +import com.cas_parser.api.core.http.HttpResponse.Handler +import com.cas_parser.api.core.http.HttpResponseFor +import com.cas_parser.api.core.http.json +import com.cas_parser.api.core.http.parseable +import com.cas_parser.api.core.prepare +import com.cas_parser.api.models.cdsl.fetch.FetchRequestOtpParams +import com.cas_parser.api.models.cdsl.fetch.FetchRequestOtpResponse +import com.cas_parser.api.models.cdsl.fetch.FetchVerifyOtpParams +import com.cas_parser.api.models.cdsl.fetch.FetchVerifyOtpResponse +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class FetchServiceImpl internal constructor(private val clientOptions: ClientOptions) : + FetchService { + + private val withRawResponse: FetchService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): FetchService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): FetchService = + FetchServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun requestOtp( + params: FetchRequestOtpParams, + requestOptions: RequestOptions, + ): FetchRequestOtpResponse = + // post /v4/cdsl/fetch + withRawResponse().requestOtp(params, requestOptions).parse() + + override fun verifyOtp( + params: FetchVerifyOtpParams, + requestOptions: RequestOptions, + ): FetchVerifyOtpResponse = + // post /v4/cdsl/fetch/{session_id}/verify + withRawResponse().verifyOtp(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + FetchService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): FetchService.WithRawResponse = + FetchServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val requestOtpHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun requestOtp( + params: FetchRequestOtpParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v4", "cdsl", "fetch") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { requestOtpHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val verifyOtpHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun verifyOtp( + params: FetchVerifyOtpParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("sessionId", params.sessionId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v4", "cdsl", "fetch", params._pathParam(0), "verify") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { verifyOtpHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateParamsTest.kt new file mode 100644 index 0000000..a6a696b --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateParamsTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.accesstoken + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AccessTokenCreateParamsTest { + + @Test + fun create() { + AccessTokenCreateParams.builder().expiryMinutes(60L).build() + } + + @Test + fun body() { + val params = AccessTokenCreateParams.builder().expiryMinutes(60L).build() + + val body = params._body() + + assertThat(body.expiryMinutes()).contains(60L) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = AccessTokenCreateParams.builder().build() + + val body = params._body() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateResponseTest.kt new file mode 100644 index 0000000..09382b7 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/accesstoken/AccessTokenCreateResponseTest.kt @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.accesstoken + +import com.cas_parser.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AccessTokenCreateResponseTest { + + @Test + fun create() { + val accessTokenCreateResponse = + AccessTokenCreateResponse.builder() + .accessToken("at_eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...") + .expiresIn(3600L) + .tokenType("api_key") + .build() + + assertThat(accessTokenCreateResponse.accessToken()) + .contains("at_eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...") + assertThat(accessTokenCreateResponse.expiresIn()).contains(3600L) + assertThat(accessTokenCreateResponse.tokenType()).contains("api_key") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val accessTokenCreateResponse = + AccessTokenCreateResponse.builder() + .accessToken("at_eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...") + .expiresIn(3600L) + .tokenType("api_key") + .build() + + val roundtrippedAccessTokenCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(accessTokenCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAccessTokenCreateResponse).isEqualTo(accessTokenCreateResponse) + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/casparser/CasParserSmartParseParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/camskfintech/CamsKfintechParseParamsTest.kt similarity index 86% rename from cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/casparser/CasParserSmartParseParamsTest.kt rename to cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/camskfintech/CamsKfintechParseParamsTest.kt index 795fbfd..4cf0889 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/casparser/CasParserSmartParseParamsTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/camskfintech/CamsKfintechParseParamsTest.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package com.cas_parser.api.models.casparser +package com.cas_parser.api.models.camskfintech import com.cas_parser.api.core.MultipartField import java.io.InputStream import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class CasParserSmartParseParamsTest { +internal class CamsKfintechParseParamsTest { @Test fun create() { - CasParserSmartParseParams.builder() + CamsKfintechParseParams.builder() .password("password") .pdfFile("pdf_file") .pdfUrl("https://example.com") @@ -21,7 +21,7 @@ internal class CasParserSmartParseParamsTest { @Test fun body() { val params = - CasParserSmartParseParams.builder() + CamsKfintechParseParams.builder() .password("password") .pdfFile("pdf_file") .pdfUrl("https://example.com") @@ -51,7 +51,7 @@ internal class CasParserSmartParseParamsTest { @Test fun bodyWithoutOptionalFields() { - val params = CasParserSmartParseParams.builder().build() + val params = CamsKfintechParseParams.builder().build() val body = params._body() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/camskfintech/LinkedHolderTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/camskfintech/LinkedHolderTest.kt new file mode 100644 index 0000000..7382244 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/camskfintech/LinkedHolderTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.camskfintech + +import com.cas_parser.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LinkedHolderTest { + + @Test + fun create() { + val linkedHolder = LinkedHolder.builder().name("name").pan("pan").build() + + assertThat(linkedHolder.name()).contains("name") + assertThat(linkedHolder.pan()).contains("pan") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val linkedHolder = LinkedHolder.builder().name("name").pan("pan").build() + + val roundtrippedLinkedHolder = + jsonMapper.readValue( + jsonMapper.writeValueAsString(linkedHolder), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLinkedHolder).isEqualTo(linkedHolder) + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/camskfintech/TransactionTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/camskfintech/TransactionTest.kt new file mode 100644 index 0000000..e133f0c --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/camskfintech/TransactionTest.kt @@ -0,0 +1,94 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.camskfintech + +import com.cas_parser.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TransactionTest { + + @Test + fun create() { + val transaction = + Transaction.builder() + .additionalInfo( + Transaction.AdditionalInfo.builder() + .capitalWithdrawal(0.0f) + .credit(0.0f) + .debit(0.0f) + .incomeDistribution(0.0f) + .orderNo("order_no") + .price(0.0f) + .stampDuty(0.0f) + .build() + ) + .amount(0.0f) + .balance(0.0f) + .date(LocalDate.parse("2019-12-27")) + .description("description") + .dividendRate(0.0f) + .nav(0.0f) + .type(Transaction.Type.PURCHASE) + .units(0.0f) + .build() + + assertThat(transaction.additionalInfo()) + .contains( + Transaction.AdditionalInfo.builder() + .capitalWithdrawal(0.0f) + .credit(0.0f) + .debit(0.0f) + .incomeDistribution(0.0f) + .orderNo("order_no") + .price(0.0f) + .stampDuty(0.0f) + .build() + ) + assertThat(transaction.amount()).contains(0.0f) + assertThat(transaction.balance()).contains(0.0f) + assertThat(transaction.date()).contains(LocalDate.parse("2019-12-27")) + assertThat(transaction.description()).contains("description") + assertThat(transaction.dividendRate()).contains(0.0f) + assertThat(transaction.nav()).contains(0.0f) + assertThat(transaction.type()).contains(Transaction.Type.PURCHASE) + assertThat(transaction.units()).contains(0.0f) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val transaction = + Transaction.builder() + .additionalInfo( + Transaction.AdditionalInfo.builder() + .capitalWithdrawal(0.0f) + .credit(0.0f) + .debit(0.0f) + .incomeDistribution(0.0f) + .orderNo("order_no") + .price(0.0f) + .stampDuty(0.0f) + .build() + ) + .amount(0.0f) + .balance(0.0f) + .date(LocalDate.parse("2019-12-27")) + .description("description") + .dividendRate(0.0f) + .nav(0.0f) + .type(Transaction.Type.PURCHASE) + .units(0.0f) + .build() + + val roundtrippedTransaction = + jsonMapper.readValue( + jsonMapper.writeValueAsString(transaction), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTransaction).isEqualTo(transaction) + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/casparser/UnifiedResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/camskfintech/UnifiedResponseTest.kt similarity index 77% rename from cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/casparser/UnifiedResponseTest.kt rename to cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/camskfintech/UnifiedResponseTest.kt index f0fa2ca..ab37900 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/casparser/UnifiedResponseTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/camskfintech/UnifiedResponseTest.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package com.cas_parser.api.models.casparser +package com.cas_parser.api.models.camskfintech import com.cas_parser.api.core.JsonValue import com.cas_parser.api.core.jsonMapper @@ -50,13 +50,9 @@ internal class UnifiedResponseTest { .isin("isin") .name("name") .addTransaction( - UnifiedResponse.DematAccount.Holdings.Aif.Transaction - .builder() + Transaction.builder() .additionalInfo( - UnifiedResponse.DematAccount.Holdings.Aif - .Transaction - .AdditionalInfo - .builder() + Transaction.AdditionalInfo.builder() .capitalWithdrawal(0.0f) .credit(0.0f) .debit(0.0f) @@ -72,12 +68,7 @@ internal class UnifiedResponseTest { .description("description") .dividendRate(0.0f) .nav(0.0f) - .type( - UnifiedResponse.DematAccount.Holdings.Aif - .Transaction - .Type - .PURCHASE - ) + .type(Transaction.Type.PURCHASE) .units(0.0f) .build() ) @@ -98,15 +89,9 @@ internal class UnifiedResponseTest { .isin("isin") .name("name") .addTransaction( - UnifiedResponse.DematAccount.Holdings.CorporateBond - .Transaction - .builder() + Transaction.builder() .additionalInfo( - UnifiedResponse.DematAccount.Holdings - .CorporateBond - .Transaction - .AdditionalInfo - .builder() + Transaction.AdditionalInfo.builder() .capitalWithdrawal(0.0f) .credit(0.0f) .debit(0.0f) @@ -122,13 +107,7 @@ internal class UnifiedResponseTest { .description("description") .dividendRate(0.0f) .nav(0.0f) - .type( - UnifiedResponse.DematAccount.Holdings - .CorporateBond - .Transaction - .Type - .PURCHASE - ) + .type(Transaction.Type.PURCHASE) .units(0.0f) .build() ) @@ -149,15 +128,9 @@ internal class UnifiedResponseTest { .isin("isin") .name("name") .addTransaction( - UnifiedResponse.DematAccount.Holdings.DematMutualFund - .Transaction - .builder() + Transaction.builder() .additionalInfo( - UnifiedResponse.DematAccount.Holdings - .DematMutualFund - .Transaction - .AdditionalInfo - .builder() + Transaction.AdditionalInfo.builder() .capitalWithdrawal(0.0f) .credit(0.0f) .debit(0.0f) @@ -173,13 +146,7 @@ internal class UnifiedResponseTest { .description("description") .dividendRate(0.0f) .nav(0.0f) - .type( - UnifiedResponse.DematAccount.Holdings - .DematMutualFund - .Transaction - .Type - .PURCHASE - ) + .type(Transaction.Type.PURCHASE) .units(0.0f) .build() ) @@ -200,13 +167,9 @@ internal class UnifiedResponseTest { .isin("isin") .name("name") .addTransaction( - UnifiedResponse.DematAccount.Holdings.Equity.Transaction - .builder() + Transaction.builder() .additionalInfo( - UnifiedResponse.DematAccount.Holdings.Equity - .Transaction - .AdditionalInfo - .builder() + Transaction.AdditionalInfo.builder() .capitalWithdrawal(0.0f) .credit(0.0f) .debit(0.0f) @@ -222,12 +185,7 @@ internal class UnifiedResponseTest { .description("description") .dividendRate(0.0f) .nav(0.0f) - .type( - UnifiedResponse.DematAccount.Holdings.Equity - .Transaction - .Type - .PURCHASE - ) + .type(Transaction.Type.PURCHASE) .units(0.0f) .build() ) @@ -249,15 +207,9 @@ internal class UnifiedResponseTest { .isin("isin") .name("name") .addTransaction( - UnifiedResponse.DematAccount.Holdings.GovernmentSecurity - .Transaction - .builder() + Transaction.builder() .additionalInfo( - UnifiedResponse.DematAccount.Holdings - .GovernmentSecurity - .Transaction - .AdditionalInfo - .builder() + Transaction.AdditionalInfo.builder() .capitalWithdrawal(0.0f) .credit(0.0f) .debit(0.0f) @@ -273,13 +225,7 @@ internal class UnifiedResponseTest { .description("description") .dividendRate(0.0f) .nav(0.0f) - .type( - UnifiedResponse.DematAccount.Holdings - .GovernmentSecurity - .Transaction - .Type - .PURCHASE - ) + .type(Transaction.Type.PURCHASE) .units(0.0f) .build() ) @@ -289,12 +235,7 @@ internal class UnifiedResponseTest { ) .build() ) - .addLinkedHolder( - UnifiedResponse.DematAccount.LinkedHolder.builder() - .name("name") - .pan("pan") - .build() - ) + .addLinkedHolder(LinkedHolder.builder().name("name").pan("pan").build()) .value(0.0f) .build() ) @@ -349,12 +290,7 @@ internal class UnifiedResponseTest { ) .amc("amc") .folioNumber("folio_number") - .addLinkedHolder( - UnifiedResponse.MutualFund.LinkedHolder.builder() - .name("name") - .pan("pan") - .build() - ) + .addLinkedHolder(LinkedHolder.builder().name("name").pan("pan").build()) .registrar("registrar") .addScheme( UnifiedResponse.MutualFund.Scheme.builder() @@ -379,11 +315,9 @@ internal class UnifiedResponseTest { .nav(0.0f) .addNominee("string") .addTransaction( - UnifiedResponse.MutualFund.Scheme.Transaction.builder() + Transaction.builder() .additionalInfo( - UnifiedResponse.MutualFund.Scheme.Transaction - .AdditionalInfo - .builder() + Transaction.AdditionalInfo.builder() .capitalWithdrawal(0.0f) .credit(0.0f) .debit(0.0f) @@ -399,10 +333,7 @@ internal class UnifiedResponseTest { .description("description") .dividendRate(0.0f) .nav(0.0f) - .type( - UnifiedResponse.MutualFund.Scheme.Transaction.Type - .PURCHASE - ) + .type(Transaction.Type.PURCHASE) .units(0.0f) .build() ) @@ -433,12 +364,7 @@ internal class UnifiedResponseTest { .value(0.0f) .build() ) - .addLinkedHolder( - UnifiedResponse.Np.LinkedHolder.builder() - .name("name") - .pan("pan") - .build() - ) + .addLinkedHolder(LinkedHolder.builder().name("name").pan("pan").build()) .pran("pran") .value(0.0f) .build() @@ -512,13 +438,9 @@ internal class UnifiedResponseTest { .isin("isin") .name("name") .addTransaction( - UnifiedResponse.DematAccount.Holdings.Aif.Transaction - .builder() + Transaction.builder() .additionalInfo( - UnifiedResponse.DematAccount.Holdings.Aif - .Transaction - .AdditionalInfo - .builder() + Transaction.AdditionalInfo.builder() .capitalWithdrawal(0.0f) .credit(0.0f) .debit(0.0f) @@ -534,12 +456,7 @@ internal class UnifiedResponseTest { .description("description") .dividendRate(0.0f) .nav(0.0f) - .type( - UnifiedResponse.DematAccount.Holdings.Aif - .Transaction - .Type - .PURCHASE - ) + .type(Transaction.Type.PURCHASE) .units(0.0f) .build() ) @@ -560,14 +477,9 @@ internal class UnifiedResponseTest { .isin("isin") .name("name") .addTransaction( - UnifiedResponse.DematAccount.Holdings.CorporateBond - .Transaction - .builder() + Transaction.builder() .additionalInfo( - UnifiedResponse.DematAccount.Holdings.CorporateBond - .Transaction - .AdditionalInfo - .builder() + Transaction.AdditionalInfo.builder() .capitalWithdrawal(0.0f) .credit(0.0f) .debit(0.0f) @@ -583,12 +495,7 @@ internal class UnifiedResponseTest { .description("description") .dividendRate(0.0f) .nav(0.0f) - .type( - UnifiedResponse.DematAccount.Holdings.CorporateBond - .Transaction - .Type - .PURCHASE - ) + .type(Transaction.Type.PURCHASE) .units(0.0f) .build() ) @@ -609,15 +516,9 @@ internal class UnifiedResponseTest { .isin("isin") .name("name") .addTransaction( - UnifiedResponse.DematAccount.Holdings.DematMutualFund - .Transaction - .builder() + Transaction.builder() .additionalInfo( - UnifiedResponse.DematAccount.Holdings - .DematMutualFund - .Transaction - .AdditionalInfo - .builder() + Transaction.AdditionalInfo.builder() .capitalWithdrawal(0.0f) .credit(0.0f) .debit(0.0f) @@ -633,13 +534,7 @@ internal class UnifiedResponseTest { .description("description") .dividendRate(0.0f) .nav(0.0f) - .type( - UnifiedResponse.DematAccount.Holdings - .DematMutualFund - .Transaction - .Type - .PURCHASE - ) + .type(Transaction.Type.PURCHASE) .units(0.0f) .build() ) @@ -659,13 +554,9 @@ internal class UnifiedResponseTest { .isin("isin") .name("name") .addTransaction( - UnifiedResponse.DematAccount.Holdings.Equity.Transaction - .builder() + Transaction.builder() .additionalInfo( - UnifiedResponse.DematAccount.Holdings.Equity - .Transaction - .AdditionalInfo - .builder() + Transaction.AdditionalInfo.builder() .capitalWithdrawal(0.0f) .credit(0.0f) .debit(0.0f) @@ -681,12 +572,7 @@ internal class UnifiedResponseTest { .description("description") .dividendRate(0.0f) .nav(0.0f) - .type( - UnifiedResponse.DematAccount.Holdings.Equity - .Transaction - .Type - .PURCHASE - ) + .type(Transaction.Type.PURCHASE) .units(0.0f) .build() ) @@ -707,15 +593,9 @@ internal class UnifiedResponseTest { .isin("isin") .name("name") .addTransaction( - UnifiedResponse.DematAccount.Holdings.GovernmentSecurity - .Transaction - .builder() + Transaction.builder() .additionalInfo( - UnifiedResponse.DematAccount.Holdings - .GovernmentSecurity - .Transaction - .AdditionalInfo - .builder() + Transaction.AdditionalInfo.builder() .capitalWithdrawal(0.0f) .credit(0.0f) .debit(0.0f) @@ -731,13 +611,7 @@ internal class UnifiedResponseTest { .description("description") .dividendRate(0.0f) .nav(0.0f) - .type( - UnifiedResponse.DematAccount.Holdings - .GovernmentSecurity - .Transaction - .Type - .PURCHASE - ) + .type(Transaction.Type.PURCHASE) .units(0.0f) .build() ) @@ -747,12 +621,7 @@ internal class UnifiedResponseTest { ) .build() ) - .addLinkedHolder( - UnifiedResponse.DematAccount.LinkedHolder.builder() - .name("name") - .pan("pan") - .build() - ) + .addLinkedHolder(LinkedHolder.builder().name("name").pan("pan").build()) .value(0.0f) .build() ) @@ -811,12 +680,7 @@ internal class UnifiedResponseTest { ) .amc("amc") .folioNumber("folio_number") - .addLinkedHolder( - UnifiedResponse.MutualFund.LinkedHolder.builder() - .name("name") - .pan("pan") - .build() - ) + .addLinkedHolder(LinkedHolder.builder().name("name").pan("pan").build()) .registrar("registrar") .addScheme( UnifiedResponse.MutualFund.Scheme.builder() @@ -841,10 +705,9 @@ internal class UnifiedResponseTest { .nav(0.0f) .addNominee("string") .addTransaction( - UnifiedResponse.MutualFund.Scheme.Transaction.builder() + Transaction.builder() .additionalInfo( - UnifiedResponse.MutualFund.Scheme.Transaction.AdditionalInfo - .builder() + Transaction.AdditionalInfo.builder() .capitalWithdrawal(0.0f) .credit(0.0f) .debit(0.0f) @@ -860,9 +723,7 @@ internal class UnifiedResponseTest { .description("description") .dividendRate(0.0f) .nav(0.0f) - .type( - UnifiedResponse.MutualFund.Scheme.Transaction.Type.PURCHASE - ) + .type(Transaction.Type.PURCHASE) .units(0.0f) .build() ) @@ -894,9 +755,7 @@ internal class UnifiedResponseTest { .value(0.0f) .build() ) - .addLinkedHolder( - UnifiedResponse.Np.LinkedHolder.builder().name("name").pan("pan").build() - ) + .addLinkedHolder(LinkedHolder.builder().name("name").pan("pan").build()) .pran("pran") .value(0.0f) .build() @@ -975,13 +834,9 @@ internal class UnifiedResponseTest { .isin("isin") .name("name") .addTransaction( - UnifiedResponse.DematAccount.Holdings.Aif.Transaction - .builder() + Transaction.builder() .additionalInfo( - UnifiedResponse.DematAccount.Holdings.Aif - .Transaction - .AdditionalInfo - .builder() + Transaction.AdditionalInfo.builder() .capitalWithdrawal(0.0f) .credit(0.0f) .debit(0.0f) @@ -997,12 +852,7 @@ internal class UnifiedResponseTest { .description("description") .dividendRate(0.0f) .nav(0.0f) - .type( - UnifiedResponse.DematAccount.Holdings.Aif - .Transaction - .Type - .PURCHASE - ) + .type(Transaction.Type.PURCHASE) .units(0.0f) .build() ) @@ -1023,15 +873,9 @@ internal class UnifiedResponseTest { .isin("isin") .name("name") .addTransaction( - UnifiedResponse.DematAccount.Holdings.CorporateBond - .Transaction - .builder() + Transaction.builder() .additionalInfo( - UnifiedResponse.DematAccount.Holdings - .CorporateBond - .Transaction - .AdditionalInfo - .builder() + Transaction.AdditionalInfo.builder() .capitalWithdrawal(0.0f) .credit(0.0f) .debit(0.0f) @@ -1047,13 +891,7 @@ internal class UnifiedResponseTest { .description("description") .dividendRate(0.0f) .nav(0.0f) - .type( - UnifiedResponse.DematAccount.Holdings - .CorporateBond - .Transaction - .Type - .PURCHASE - ) + .type(Transaction.Type.PURCHASE) .units(0.0f) .build() ) @@ -1074,15 +912,9 @@ internal class UnifiedResponseTest { .isin("isin") .name("name") .addTransaction( - UnifiedResponse.DematAccount.Holdings.DematMutualFund - .Transaction - .builder() + Transaction.builder() .additionalInfo( - UnifiedResponse.DematAccount.Holdings - .DematMutualFund - .Transaction - .AdditionalInfo - .builder() + Transaction.AdditionalInfo.builder() .capitalWithdrawal(0.0f) .credit(0.0f) .debit(0.0f) @@ -1098,13 +930,7 @@ internal class UnifiedResponseTest { .description("description") .dividendRate(0.0f) .nav(0.0f) - .type( - UnifiedResponse.DematAccount.Holdings - .DematMutualFund - .Transaction - .Type - .PURCHASE - ) + .type(Transaction.Type.PURCHASE) .units(0.0f) .build() ) @@ -1125,13 +951,9 @@ internal class UnifiedResponseTest { .isin("isin") .name("name") .addTransaction( - UnifiedResponse.DematAccount.Holdings.Equity.Transaction - .builder() + Transaction.builder() .additionalInfo( - UnifiedResponse.DematAccount.Holdings.Equity - .Transaction - .AdditionalInfo - .builder() + Transaction.AdditionalInfo.builder() .capitalWithdrawal(0.0f) .credit(0.0f) .debit(0.0f) @@ -1147,12 +969,7 @@ internal class UnifiedResponseTest { .description("description") .dividendRate(0.0f) .nav(0.0f) - .type( - UnifiedResponse.DematAccount.Holdings.Equity - .Transaction - .Type - .PURCHASE - ) + .type(Transaction.Type.PURCHASE) .units(0.0f) .build() ) @@ -1174,15 +991,9 @@ internal class UnifiedResponseTest { .isin("isin") .name("name") .addTransaction( - UnifiedResponse.DematAccount.Holdings.GovernmentSecurity - .Transaction - .builder() + Transaction.builder() .additionalInfo( - UnifiedResponse.DematAccount.Holdings - .GovernmentSecurity - .Transaction - .AdditionalInfo - .builder() + Transaction.AdditionalInfo.builder() .capitalWithdrawal(0.0f) .credit(0.0f) .debit(0.0f) @@ -1198,13 +1009,7 @@ internal class UnifiedResponseTest { .description("description") .dividendRate(0.0f) .nav(0.0f) - .type( - UnifiedResponse.DematAccount.Holdings - .GovernmentSecurity - .Transaction - .Type - .PURCHASE - ) + .type(Transaction.Type.PURCHASE) .units(0.0f) .build() ) @@ -1214,12 +1019,7 @@ internal class UnifiedResponseTest { ) .build() ) - .addLinkedHolder( - UnifiedResponse.DematAccount.LinkedHolder.builder() - .name("name") - .pan("pan") - .build() - ) + .addLinkedHolder(LinkedHolder.builder().name("name").pan("pan").build()) .value(0.0f) .build() ) @@ -1274,12 +1074,7 @@ internal class UnifiedResponseTest { ) .amc("amc") .folioNumber("folio_number") - .addLinkedHolder( - UnifiedResponse.MutualFund.LinkedHolder.builder() - .name("name") - .pan("pan") - .build() - ) + .addLinkedHolder(LinkedHolder.builder().name("name").pan("pan").build()) .registrar("registrar") .addScheme( UnifiedResponse.MutualFund.Scheme.builder() @@ -1304,11 +1099,9 @@ internal class UnifiedResponseTest { .nav(0.0f) .addNominee("string") .addTransaction( - UnifiedResponse.MutualFund.Scheme.Transaction.builder() + Transaction.builder() .additionalInfo( - UnifiedResponse.MutualFund.Scheme.Transaction - .AdditionalInfo - .builder() + Transaction.AdditionalInfo.builder() .capitalWithdrawal(0.0f) .credit(0.0f) .debit(0.0f) @@ -1324,10 +1117,7 @@ internal class UnifiedResponseTest { .description("description") .dividendRate(0.0f) .nav(0.0f) - .type( - UnifiedResponse.MutualFund.Scheme.Transaction.Type - .PURCHASE - ) + .type(Transaction.Type.PURCHASE) .units(0.0f) .build() ) @@ -1358,12 +1148,7 @@ internal class UnifiedResponseTest { .value(0.0f) .build() ) - .addLinkedHolder( - UnifiedResponse.Np.LinkedHolder.builder() - .name("name") - .pan("pan") - .build() - ) + .addLinkedHolder(LinkedHolder.builder().name("name").pan("pan").build()) .pran("pran") .value(0.0f) .build() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/casparser/CasParserNsdlParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/cdsl/CdslParsePdfParamsTest.kt similarity index 87% rename from cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/casparser/CasParserNsdlParamsTest.kt rename to cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/cdsl/CdslParsePdfParamsTest.kt index fba23f6..d848d88 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/casparser/CasParserNsdlParamsTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/cdsl/CdslParsePdfParamsTest.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package com.cas_parser.api.models.casparser +package com.cas_parser.api.models.cdsl import com.cas_parser.api.core.MultipartField import java.io.InputStream import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class CasParserNsdlParamsTest { +internal class CdslParsePdfParamsTest { @Test fun create() { - CasParserNsdlParams.builder() + CdslParsePdfParams.builder() .password("password") .pdfFile("pdf_file") .pdfUrl("https://example.com") @@ -21,7 +21,7 @@ internal class CasParserNsdlParamsTest { @Test fun body() { val params = - CasParserNsdlParams.builder() + CdslParsePdfParams.builder() .password("password") .pdfFile("pdf_file") .pdfUrl("https://example.com") @@ -51,7 +51,7 @@ internal class CasParserNsdlParamsTest { @Test fun bodyWithoutOptionalFields() { - val params = CasParserNsdlParams.builder().build() + val params = CdslParsePdfParams.builder().build() val body = params._body() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/cdsl/fetch/FetchRequestOtpParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/cdsl/fetch/FetchRequestOtpParamsTest.kt new file mode 100644 index 0000000..3f56894 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/cdsl/fetch/FetchRequestOtpParamsTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.cdsl.fetch + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FetchRequestOtpParamsTest { + + @Test + fun create() { + FetchRequestOtpParams.builder() + .boId("1234567890123456") + .dob("1990-01-15") + .pan("ABCDE1234F") + .build() + } + + @Test + fun body() { + val params = + FetchRequestOtpParams.builder() + .boId("1234567890123456") + .dob("1990-01-15") + .pan("ABCDE1234F") + .build() + + val body = params._body() + + assertThat(body.boId()).isEqualTo("1234567890123456") + assertThat(body.dob()).isEqualTo("1990-01-15") + assertThat(body.pan()).isEqualTo("ABCDE1234F") + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/cdsl/fetch/FetchRequestOtpResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/cdsl/fetch/FetchRequestOtpResponseTest.kt new file mode 100644 index 0000000..a63b5e2 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/cdsl/fetch/FetchRequestOtpResponseTest.kt @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.cdsl.fetch + +import com.cas_parser.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FetchRequestOtpResponseTest { + + @Test + fun create() { + val fetchRequestOtpResponse = + FetchRequestOtpResponse.builder() + .msg("OTP sent to registered mobile") + .sessionId("550e8400-e29b-41d4-a716-446655440000") + .status("success") + .build() + + assertThat(fetchRequestOtpResponse.msg()).contains("OTP sent to registered mobile") + assertThat(fetchRequestOtpResponse.sessionId()) + .contains("550e8400-e29b-41d4-a716-446655440000") + assertThat(fetchRequestOtpResponse.status()).contains("success") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val fetchRequestOtpResponse = + FetchRequestOtpResponse.builder() + .msg("OTP sent to registered mobile") + .sessionId("550e8400-e29b-41d4-a716-446655440000") + .status("success") + .build() + + val roundtrippedFetchRequestOtpResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(fetchRequestOtpResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFetchRequestOtpResponse).isEqualTo(fetchRequestOtpResponse) + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/cdsl/fetch/FetchVerifyOtpParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/cdsl/fetch/FetchVerifyOtpParamsTest.kt new file mode 100644 index 0000000..5b4f38d --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/cdsl/fetch/FetchVerifyOtpParamsTest.kt @@ -0,0 +1,47 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.cdsl.fetch + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FetchVerifyOtpParamsTest { + + @Test + fun create() { + FetchVerifyOtpParams.builder().sessionId("session_id").otp("123456").numPeriods(6L).build() + } + + @Test + fun pathParams() { + val params = FetchVerifyOtpParams.builder().sessionId("session_id").otp("123456").build() + + assertThat(params._pathParam(0)).isEqualTo("session_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + FetchVerifyOtpParams.builder() + .sessionId("session_id") + .otp("123456") + .numPeriods(6L) + .build() + + val body = params._body() + + assertThat(body.otp()).isEqualTo("123456") + assertThat(body.numPeriods()).contains(6L) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = FetchVerifyOtpParams.builder().sessionId("session_id").otp("123456").build() + + val body = params._body() + + assertThat(body.otp()).isEqualTo("123456") + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/cdsl/fetch/FetchVerifyOtpResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/cdsl/fetch/FetchVerifyOtpResponseTest.kt new file mode 100644 index 0000000..fbad184 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/cdsl/fetch/FetchVerifyOtpResponseTest.kt @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.cdsl.fetch + +import com.cas_parser.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FetchVerifyOtpResponseTest { + + @Test + fun create() { + val fetchVerifyOtpResponse = + FetchVerifyOtpResponse.builder() + .addFile( + FetchVerifyOtpResponse.File.builder() + .filename("CDSL_CAS_1234567890123456_NOV2025.pdf") + .url( + "https://cdn.casparser.in/cdsl-cas/session-id/CDSL_CAS_1234567890123456_NOV2025.pdf" + ) + .build() + ) + .msg("Fetched 6 CAS files") + .status("success") + .build() + + assertThat(fetchVerifyOtpResponse.files().getOrNull()) + .containsExactly( + FetchVerifyOtpResponse.File.builder() + .filename("CDSL_CAS_1234567890123456_NOV2025.pdf") + .url( + "https://cdn.casparser.in/cdsl-cas/session-id/CDSL_CAS_1234567890123456_NOV2025.pdf" + ) + .build() + ) + assertThat(fetchVerifyOtpResponse.msg()).contains("Fetched 6 CAS files") + assertThat(fetchVerifyOtpResponse.status()).contains("success") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val fetchVerifyOtpResponse = + FetchVerifyOtpResponse.builder() + .addFile( + FetchVerifyOtpResponse.File.builder() + .filename("CDSL_CAS_1234567890123456_NOV2025.pdf") + .url( + "https://cdn.casparser.in/cdsl-cas/session-id/CDSL_CAS_1234567890123456_NOV2025.pdf" + ) + .build() + ) + .msg("Fetched 6 CAS files") + .status("success") + .build() + + val roundtrippedFetchVerifyOtpResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(fetchVerifyOtpResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFetchVerifyOtpResponse).isEqualTo(fetchVerifyOtpResponse) + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/contractnote/ContractNoteParseParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/contractnote/ContractNoteParseParamsTest.kt new file mode 100644 index 0000000..71e01fd --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/contractnote/ContractNoteParseParamsTest.kt @@ -0,0 +1,65 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.contractnote + +import com.cas_parser.api.core.MultipartField +import java.io.InputStream +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ContractNoteParseParamsTest { + + @Test + fun create() { + ContractNoteParseParams.builder() + .brokerType(ContractNoteParseParams.BrokerType.ZERODHA) + .password("FAXAK2545F") + .pdfFile("JVBERi0xLjQKMSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZwo...") + .pdfUrl("https://example.com/contract_note.pdf") + .build() + } + + @Test + fun body() { + val params = + ContractNoteParseParams.builder() + .brokerType(ContractNoteParseParams.BrokerType.ZERODHA) + .password("FAXAK2545F") + .pdfFile("JVBERi0xLjQKMSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZwo...") + .pdfUrl("https://example.com/contract_note.pdf") + .build() + + val body = params._body() + + assertThat(body.filterValues { !it.value.isNull() }) + .usingRecursiveComparison() + // TODO(AssertJ): Replace this and the `mapValues` below with: + // https://github.com/assertj/assertj/issues/3165 + .withEqualsForType( + { a, b -> a.readBytes() contentEquals b.readBytes() }, + InputStream::class.java, + ) + .isEqualTo( + mapOf( + "broker_type" to + MultipartField.of(ContractNoteParseParams.BrokerType.ZERODHA), + "password" to MultipartField.of("FAXAK2545F"), + "pdf_file" to + MultipartField.of("JVBERi0xLjQKMSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZwo..."), + "pdf_url" to MultipartField.of("https://example.com/contract_note.pdf"), + ) + .mapValues { (_, field) -> + field.map { (it as? ByteArray)?.inputStream() ?: it } + } + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = ContractNoteParseParams.builder().build() + + val body = params._body() + + assertThat(body.filterValues { !it.value.isNull() }).isEmpty() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/contractnote/ContractNoteParseResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/contractnote/ContractNoteParseResponseTest.kt new file mode 100644 index 0000000..9d524f4 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/contractnote/ContractNoteParseResponseTest.kt @@ -0,0 +1,304 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.contractnote + +import com.cas_parser.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ContractNoteParseResponseTest { + + @Test + fun create() { + val contractNoteParseResponse = + ContractNoteParseResponse.builder() + .data( + ContractNoteParseResponse.Data.builder() + .brokerInfo( + ContractNoteParseResponse.Data.BrokerInfo.builder() + .brokerType( + ContractNoteParseResponse.Data.BrokerInfo.BrokerType.ZERODHA + ) + .name("Zerodha Broking Limited") + .sebiRegistration("INZ000031633") + .build() + ) + .chargesSummary( + ContractNoteParseResponse.Data.ChargesSummary.builder() + .cgst(0.0f) + .exchangeTransactionCharges(0.0f) + .igst(0.0f) + .netAmountReceivablePayable(0.0f) + .payInPayOutObligation(0.0f) + .sebiTurnoverFees(0.0f) + .securitiesTransactionTax(0.0f) + .sgst(0.0f) + .stampDuty(0.0f) + .taxableValueBrokerage(0.0f) + .build() + ) + .clientInfo( + ContractNoteParseResponse.Data.ClientInfo.builder() + .address("address") + .gstStateCode("7") + .name("VIRENDER KUMAR") + .pan("FAXAK2545F") + .placeOfSupply("DELHI") + .ucc("YS3654") + .build() + ) + .contractNoteInfo( + ContractNoteParseResponse.Data.ContractNoteInfo.builder() + .contractNoteNumber("CNT-25/26-73436720") + .settlementDate(LocalDate.parse("2025-08-06")) + .settlementNumber("2025149") + .tradeDate(LocalDate.parse("2025-08-05")) + .build() + ) + .addDerivativesTransaction( + ContractNoteParseResponse.Data.DerivativesTransaction.builder() + .brokeragePerUnit(0.0f) + .buySellBfCf("B") + .closingRatePerUnit(0.0f) + .contractDescription("NIFTY24802410DPE") + .netTotal(0.0f) + .quantity(0.0f) + .wapPerUnit(0.0f) + .build() + ) + .addDetailedTrade( + ContractNoteParseResponse.Data.DetailedTrade.builder() + .brokerage(0.0f) + .buySell("B") + .closingRatePerUnit(0.0f) + .exchange("NSE") + .netRatePerUnit(0.0f) + .netTotal(0.0f) + .orderNumber("1000000042939390") + .orderTime("13:13:13") + .quantity(0.0f) + .remarks("remarks") + .securityDescription("CASTROLIND-EQ/INE172A01027") + .tradeNumber("4006567") + .tradeTime("13:13:13") + .build() + ) + .addEquityTransaction( + ContractNoteParseResponse.Data.EquityTransaction.builder() + .buyQuantity(0.0f) + .buyTotalValue(0.0f) + .buyWap(0.0f) + .isin("INE172A01027") + .netObligation(0.0f) + .securityName("CASTROLIND") + .securitySymbol("CASTROLIND") + .sellQuantity(0.0f) + .sellTotalValue(0.0f) + .sellWap(0.0f) + .build() + ) + .build() + ) + .msg("success") + .status("success") + .build() + + assertThat(contractNoteParseResponse.data()) + .contains( + ContractNoteParseResponse.Data.builder() + .brokerInfo( + ContractNoteParseResponse.Data.BrokerInfo.builder() + .brokerType( + ContractNoteParseResponse.Data.BrokerInfo.BrokerType.ZERODHA + ) + .name("Zerodha Broking Limited") + .sebiRegistration("INZ000031633") + .build() + ) + .chargesSummary( + ContractNoteParseResponse.Data.ChargesSummary.builder() + .cgst(0.0f) + .exchangeTransactionCharges(0.0f) + .igst(0.0f) + .netAmountReceivablePayable(0.0f) + .payInPayOutObligation(0.0f) + .sebiTurnoverFees(0.0f) + .securitiesTransactionTax(0.0f) + .sgst(0.0f) + .stampDuty(0.0f) + .taxableValueBrokerage(0.0f) + .build() + ) + .clientInfo( + ContractNoteParseResponse.Data.ClientInfo.builder() + .address("address") + .gstStateCode("7") + .name("VIRENDER KUMAR") + .pan("FAXAK2545F") + .placeOfSupply("DELHI") + .ucc("YS3654") + .build() + ) + .contractNoteInfo( + ContractNoteParseResponse.Data.ContractNoteInfo.builder() + .contractNoteNumber("CNT-25/26-73436720") + .settlementDate(LocalDate.parse("2025-08-06")) + .settlementNumber("2025149") + .tradeDate(LocalDate.parse("2025-08-05")) + .build() + ) + .addDerivativesTransaction( + ContractNoteParseResponse.Data.DerivativesTransaction.builder() + .brokeragePerUnit(0.0f) + .buySellBfCf("B") + .closingRatePerUnit(0.0f) + .contractDescription("NIFTY24802410DPE") + .netTotal(0.0f) + .quantity(0.0f) + .wapPerUnit(0.0f) + .build() + ) + .addDetailedTrade( + ContractNoteParseResponse.Data.DetailedTrade.builder() + .brokerage(0.0f) + .buySell("B") + .closingRatePerUnit(0.0f) + .exchange("NSE") + .netRatePerUnit(0.0f) + .netTotal(0.0f) + .orderNumber("1000000042939390") + .orderTime("13:13:13") + .quantity(0.0f) + .remarks("remarks") + .securityDescription("CASTROLIND-EQ/INE172A01027") + .tradeNumber("4006567") + .tradeTime("13:13:13") + .build() + ) + .addEquityTransaction( + ContractNoteParseResponse.Data.EquityTransaction.builder() + .buyQuantity(0.0f) + .buyTotalValue(0.0f) + .buyWap(0.0f) + .isin("INE172A01027") + .netObligation(0.0f) + .securityName("CASTROLIND") + .securitySymbol("CASTROLIND") + .sellQuantity(0.0f) + .sellTotalValue(0.0f) + .sellWap(0.0f) + .build() + ) + .build() + ) + assertThat(contractNoteParseResponse.msg()).contains("success") + assertThat(contractNoteParseResponse.status()).contains("success") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val contractNoteParseResponse = + ContractNoteParseResponse.builder() + .data( + ContractNoteParseResponse.Data.builder() + .brokerInfo( + ContractNoteParseResponse.Data.BrokerInfo.builder() + .brokerType( + ContractNoteParseResponse.Data.BrokerInfo.BrokerType.ZERODHA + ) + .name("Zerodha Broking Limited") + .sebiRegistration("INZ000031633") + .build() + ) + .chargesSummary( + ContractNoteParseResponse.Data.ChargesSummary.builder() + .cgst(0.0f) + .exchangeTransactionCharges(0.0f) + .igst(0.0f) + .netAmountReceivablePayable(0.0f) + .payInPayOutObligation(0.0f) + .sebiTurnoverFees(0.0f) + .securitiesTransactionTax(0.0f) + .sgst(0.0f) + .stampDuty(0.0f) + .taxableValueBrokerage(0.0f) + .build() + ) + .clientInfo( + ContractNoteParseResponse.Data.ClientInfo.builder() + .address("address") + .gstStateCode("7") + .name("VIRENDER KUMAR") + .pan("FAXAK2545F") + .placeOfSupply("DELHI") + .ucc("YS3654") + .build() + ) + .contractNoteInfo( + ContractNoteParseResponse.Data.ContractNoteInfo.builder() + .contractNoteNumber("CNT-25/26-73436720") + .settlementDate(LocalDate.parse("2025-08-06")) + .settlementNumber("2025149") + .tradeDate(LocalDate.parse("2025-08-05")) + .build() + ) + .addDerivativesTransaction( + ContractNoteParseResponse.Data.DerivativesTransaction.builder() + .brokeragePerUnit(0.0f) + .buySellBfCf("B") + .closingRatePerUnit(0.0f) + .contractDescription("NIFTY24802410DPE") + .netTotal(0.0f) + .quantity(0.0f) + .wapPerUnit(0.0f) + .build() + ) + .addDetailedTrade( + ContractNoteParseResponse.Data.DetailedTrade.builder() + .brokerage(0.0f) + .buySell("B") + .closingRatePerUnit(0.0f) + .exchange("NSE") + .netRatePerUnit(0.0f) + .netTotal(0.0f) + .orderNumber("1000000042939390") + .orderTime("13:13:13") + .quantity(0.0f) + .remarks("remarks") + .securityDescription("CASTROLIND-EQ/INE172A01027") + .tradeNumber("4006567") + .tradeTime("13:13:13") + .build() + ) + .addEquityTransaction( + ContractNoteParseResponse.Data.EquityTransaction.builder() + .buyQuantity(0.0f) + .buyTotalValue(0.0f) + .buyWap(0.0f) + .isin("INE172A01027") + .netObligation(0.0f) + .securityName("CASTROLIND") + .securitySymbol("CASTROLIND") + .sellQuantity(0.0f) + .sellTotalValue(0.0f) + .sellWap(0.0f) + .build() + ) + .build() + ) + .msg("success") + .status("success") + .build() + + val roundtrippedContractNoteParseResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(contractNoteParseResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedContractNoteParseResponse).isEqualTo(contractNoteParseResponse) + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/credits/CreditCheckParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/credits/CreditCheckParamsTest.kt new file mode 100644 index 0000000..b26664b --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/credits/CreditCheckParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.credits + +import org.junit.jupiter.api.Test + +internal class CreditCheckParamsTest { + + @Test + fun create() { + CreditCheckParams.builder().build() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/credits/CreditCheckResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/credits/CreditCheckResponseTest.kt new file mode 100644 index 0000000..17d52f9 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/credits/CreditCheckResponseTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.credits + +import com.cas_parser.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CreditCheckResponseTest { + + @Test + fun create() { + val creditCheckResponse = + CreditCheckResponse.builder() + .enabledFeatures( + listOf("cams_kfintech_cas_parser", "cdsl_cas_parser", "nsdl_cas_parser") + ) + .isUnlimited(false) + .limit(50L) + .remaining(35.0) + .resetsAt(OffsetDateTime.parse("2026-02-15T00:00:00Z")) + .used(15.0) + .build() + + assertThat(creditCheckResponse.enabledFeatures().getOrNull()) + .containsExactly("cams_kfintech_cas_parser", "cdsl_cas_parser", "nsdl_cas_parser") + assertThat(creditCheckResponse.isUnlimited()).contains(false) + assertThat(creditCheckResponse.limit()).contains(50L) + assertThat(creditCheckResponse.remaining()).contains(35.0) + assertThat(creditCheckResponse.resetsAt()) + .contains(OffsetDateTime.parse("2026-02-15T00:00:00Z")) + assertThat(creditCheckResponse.used()).contains(15.0) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val creditCheckResponse = + CreditCheckResponse.builder() + .enabledFeatures( + listOf("cams_kfintech_cas_parser", "cdsl_cas_parser", "nsdl_cas_parser") + ) + .isUnlimited(false) + .limit(50L) + .remaining(35.0) + .resetsAt(OffsetDateTime.parse("2026-02-15T00:00:00Z")) + .used(15.0) + .build() + + val roundtrippedCreditCheckResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(creditCheckResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedCreditCheckResponse).isEqualTo(creditCheckResponse) + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inbox/InboxCheckConnectionStatusParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inbox/InboxCheckConnectionStatusParamsTest.kt new file mode 100644 index 0000000..082807a --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inbox/InboxCheckConnectionStatusParamsTest.kt @@ -0,0 +1,25 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inbox + +import com.cas_parser.api.core.http.Headers +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InboxCheckConnectionStatusParamsTest { + + @Test + fun create() { + InboxCheckConnectionStatusParams.builder().xInboxToken("x-inbox-token").build() + } + + @Test + fun headers() { + val params = InboxCheckConnectionStatusParams.builder().xInboxToken("x-inbox-token").build() + + val headers = params._headers() + + assertThat(headers) + .isEqualTo(Headers.builder().put("x-inbox-token", "x-inbox-token").build()) + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inbox/InboxCheckConnectionStatusResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inbox/InboxCheckConnectionStatusResponseTest.kt new file mode 100644 index 0000000..1c78969 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inbox/InboxCheckConnectionStatusResponseTest.kt @@ -0,0 +1,48 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inbox + +import com.cas_parser.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InboxCheckConnectionStatusResponseTest { + + @Test + fun create() { + val inboxCheckConnectionStatusResponse = + InboxCheckConnectionStatusResponse.builder() + .connected(true) + .email("user@gmail.com") + .provider("gmail") + .status("success") + .build() + + assertThat(inboxCheckConnectionStatusResponse.connected()).contains(true) + assertThat(inboxCheckConnectionStatusResponse.email()).contains("user@gmail.com") + assertThat(inboxCheckConnectionStatusResponse.provider()).contains("gmail") + assertThat(inboxCheckConnectionStatusResponse.status()).contains("success") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val inboxCheckConnectionStatusResponse = + InboxCheckConnectionStatusResponse.builder() + .connected(true) + .email("user@gmail.com") + .provider("gmail") + .status("success") + .build() + + val roundtrippedInboxCheckConnectionStatusResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(inboxCheckConnectionStatusResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInboxCheckConnectionStatusResponse) + .isEqualTo(inboxCheckConnectionStatusResponse) + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inbox/InboxConnectEmailParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inbox/InboxConnectEmailParamsTest.kt new file mode 100644 index 0000000..568051f --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inbox/InboxConnectEmailParamsTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inbox + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InboxConnectEmailParamsTest { + + @Test + fun create() { + InboxConnectEmailParams.builder() + .redirectUri("https://yourapp.com/oauth-callback") + .state("abc123") + .build() + } + + @Test + fun body() { + val params = + InboxConnectEmailParams.builder() + .redirectUri("https://yourapp.com/oauth-callback") + .state("abc123") + .build() + + val body = params._body() + + assertThat(body.redirectUri()).isEqualTo("https://yourapp.com/oauth-callback") + assertThat(body.state()).contains("abc123") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + InboxConnectEmailParams.builder() + .redirectUri("https://yourapp.com/oauth-callback") + .build() + + val body = params._body() + + assertThat(body.redirectUri()).isEqualTo("https://yourapp.com/oauth-callback") + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inbox/InboxConnectEmailResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inbox/InboxConnectEmailResponseTest.kt new file mode 100644 index 0000000..2a2f511 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inbox/InboxConnectEmailResponseTest.kt @@ -0,0 +1,45 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inbox + +import com.cas_parser.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InboxConnectEmailResponseTest { + + @Test + fun create() { + val inboxConnectEmailResponse = + InboxConnectEmailResponse.builder() + .expiresIn(600L) + .oauthUrl("https://accounts.google.com/o/oauth2/v2/auth?client_id=...") + .status("success") + .build() + + assertThat(inboxConnectEmailResponse.expiresIn()).contains(600L) + assertThat(inboxConnectEmailResponse.oauthUrl()) + .contains("https://accounts.google.com/o/oauth2/v2/auth?client_id=...") + assertThat(inboxConnectEmailResponse.status()).contains("success") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val inboxConnectEmailResponse = + InboxConnectEmailResponse.builder() + .expiresIn(600L) + .oauthUrl("https://accounts.google.com/o/oauth2/v2/auth?client_id=...") + .status("success") + .build() + + val roundtrippedInboxConnectEmailResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(inboxConnectEmailResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInboxConnectEmailResponse).isEqualTo(inboxConnectEmailResponse) + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inbox/InboxDisconnectEmailParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inbox/InboxDisconnectEmailParamsTest.kt new file mode 100644 index 0000000..90269ad --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inbox/InboxDisconnectEmailParamsTest.kt @@ -0,0 +1,25 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inbox + +import com.cas_parser.api.core.http.Headers +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InboxDisconnectEmailParamsTest { + + @Test + fun create() { + InboxDisconnectEmailParams.builder().xInboxToken("x-inbox-token").build() + } + + @Test + fun headers() { + val params = InboxDisconnectEmailParams.builder().xInboxToken("x-inbox-token").build() + + val headers = params._headers() + + assertThat(headers) + .isEqualTo(Headers.builder().put("x-inbox-token", "x-inbox-token").build()) + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inbox/InboxDisconnectEmailResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inbox/InboxDisconnectEmailResponseTest.kt new file mode 100644 index 0000000..ea186c6 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inbox/InboxDisconnectEmailResponseTest.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inbox + +import com.cas_parser.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InboxDisconnectEmailResponseTest { + + @Test + fun create() { + val inboxDisconnectEmailResponse = + InboxDisconnectEmailResponse.builder() + .msg("Email disconnected successfully") + .status("success") + .build() + + assertThat(inboxDisconnectEmailResponse.msg()).contains("Email disconnected successfully") + assertThat(inboxDisconnectEmailResponse.status()).contains("success") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val inboxDisconnectEmailResponse = + InboxDisconnectEmailResponse.builder() + .msg("Email disconnected successfully") + .status("success") + .build() + + val roundtrippedInboxDisconnectEmailResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(inboxDisconnectEmailResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInboxDisconnectEmailResponse).isEqualTo(inboxDisconnectEmailResponse) + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inbox/InboxListCasFilesParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inbox/InboxListCasFilesParamsTest.kt new file mode 100644 index 0000000..1d56f77 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inbox/InboxListCasFilesParamsTest.kt @@ -0,0 +1,79 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inbox + +import com.cas_parser.api.core.http.Headers +import java.time.LocalDate +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InboxListCasFilesParamsTest { + + @Test + fun create() { + InboxListCasFilesParams.builder() + .xInboxToken("x-inbox-token") + .addCasType(InboxListCasFilesParams.CasType.CDSL) + .addCasType(InboxListCasFilesParams.CasType.NSDL) + .endDate(LocalDate.parse("2025-12-31")) + .startDate(LocalDate.parse("2025-12-01")) + .build() + } + + @Test + fun headers() { + val params = + InboxListCasFilesParams.builder() + .xInboxToken("x-inbox-token") + .addCasType(InboxListCasFilesParams.CasType.CDSL) + .addCasType(InboxListCasFilesParams.CasType.NSDL) + .endDate(LocalDate.parse("2025-12-31")) + .startDate(LocalDate.parse("2025-12-01")) + .build() + + val headers = params._headers() + + assertThat(headers) + .isEqualTo(Headers.builder().put("x-inbox-token", "x-inbox-token").build()) + } + + @Test + fun headersWithoutOptionalFields() { + val params = InboxListCasFilesParams.builder().xInboxToken("x-inbox-token").build() + + val headers = params._headers() + + assertThat(headers) + .isEqualTo(Headers.builder().put("x-inbox-token", "x-inbox-token").build()) + } + + @Test + fun body() { + val params = + InboxListCasFilesParams.builder() + .xInboxToken("x-inbox-token") + .addCasType(InboxListCasFilesParams.CasType.CDSL) + .addCasType(InboxListCasFilesParams.CasType.NSDL) + .endDate(LocalDate.parse("2025-12-31")) + .startDate(LocalDate.parse("2025-12-01")) + .build() + + val body = params._body() + + assertThat(body.casTypes().getOrNull()) + .containsExactly( + InboxListCasFilesParams.CasType.CDSL, + InboxListCasFilesParams.CasType.NSDL, + ) + assertThat(body.endDate()).contains(LocalDate.parse("2025-12-31")) + assertThat(body.startDate()).contains(LocalDate.parse("2025-12-01")) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = InboxListCasFilesParams.builder().xInboxToken("x-inbox-token").build() + + val body = params._body() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inbox/InboxListCasFilesResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inbox/InboxListCasFilesResponseTest.kt new file mode 100644 index 0000000..1f710cb --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/inbox/InboxListCasFilesResponseTest.kt @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.inbox + +import com.cas_parser.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class InboxListCasFilesResponseTest { + + @Test + fun create() { + val inboxListCasFilesResponse = + InboxListCasFilesResponse.builder() + .count(5L) + .addFile( + InboxListCasFilesResponse.File.builder() + .casType(InboxListCasFilesResponse.File.CasType.CDSL) + .expiresIn(86400L) + .filename("cdsl_20250115_a1b2c3d4.pdf") + .messageDate(LocalDate.parse("2025-01-15")) + .messageId("18d4a2b3c4d5e6f7") + .originalFilename("CDSL_CAS_Statement.pdf") + .size(245000L) + .url( + "https://cdn.casparser.in/email-cas/user123/cdsl_20250115_a1b2c3d4.pdf" + ) + .build() + ) + .status("success") + .build() + + assertThat(inboxListCasFilesResponse.count()).contains(5L) + assertThat(inboxListCasFilesResponse.files().getOrNull()) + .containsExactly( + InboxListCasFilesResponse.File.builder() + .casType(InboxListCasFilesResponse.File.CasType.CDSL) + .expiresIn(86400L) + .filename("cdsl_20250115_a1b2c3d4.pdf") + .messageDate(LocalDate.parse("2025-01-15")) + .messageId("18d4a2b3c4d5e6f7") + .originalFilename("CDSL_CAS_Statement.pdf") + .size(245000L) + .url("https://cdn.casparser.in/email-cas/user123/cdsl_20250115_a1b2c3d4.pdf") + .build() + ) + assertThat(inboxListCasFilesResponse.status()).contains("success") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val inboxListCasFilesResponse = + InboxListCasFilesResponse.builder() + .count(5L) + .addFile( + InboxListCasFilesResponse.File.builder() + .casType(InboxListCasFilesResponse.File.CasType.CDSL) + .expiresIn(86400L) + .filename("cdsl_20250115_a1b2c3d4.pdf") + .messageDate(LocalDate.parse("2025-01-15")) + .messageId("18d4a2b3c4d5e6f7") + .originalFilename("CDSL_CAS_Statement.pdf") + .size(245000L) + .url( + "https://cdn.casparser.in/email-cas/user123/cdsl_20250115_a1b2c3d4.pdf" + ) + .build() + ) + .status("success") + .build() + + val roundtrippedInboxListCasFilesResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(inboxListCasFilesResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedInboxListCasFilesResponse).isEqualTo(inboxListCasFilesResponse) + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/kfintech/KfintechGenerateCasParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/kfintech/KfintechGenerateCasParamsTest.kt new file mode 100644 index 0000000..bed6b13 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/kfintech/KfintechGenerateCasParamsTest.kt @@ -0,0 +1,58 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.kfintech + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class KfintechGenerateCasParamsTest { + + @Test + fun create() { + KfintechGenerateCasParams.builder() + .email("user@example.com") + .fromDate("2023-01-01") + .password("Abcdefghi12\$") + .toDate("2023-12-31") + .panNo("ABCDE1234F") + .build() + } + + @Test + fun body() { + val params = + KfintechGenerateCasParams.builder() + .email("user@example.com") + .fromDate("2023-01-01") + .password("Abcdefghi12\$") + .toDate("2023-12-31") + .panNo("ABCDE1234F") + .build() + + val body = params._body() + + assertThat(body.email()).isEqualTo("user@example.com") + assertThat(body.fromDate()).isEqualTo("2023-01-01") + assertThat(body.password()).isEqualTo("Abcdefghi12\$") + assertThat(body.toDate()).isEqualTo("2023-12-31") + assertThat(body.panNo()).contains("ABCDE1234F") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + KfintechGenerateCasParams.builder() + .email("user@example.com") + .fromDate("2023-01-01") + .password("Abcdefghi12\$") + .toDate("2023-12-31") + .build() + + val body = params._body() + + assertThat(body.email()).isEqualTo("user@example.com") + assertThat(body.fromDate()).isEqualTo("2023-01-01") + assertThat(body.password()).isEqualTo("Abcdefghi12\$") + assertThat(body.toDate()).isEqualTo("2023-12-31") + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/kfintech/KfintechGenerateCasResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/kfintech/KfintechGenerateCasResponseTest.kt new file mode 100644 index 0000000..57b2d09 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/kfintech/KfintechGenerateCasResponseTest.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.kfintech + +import com.cas_parser.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class KfintechGenerateCasResponseTest { + + @Test + fun create() { + val kfintechGenerateCasResponse = + KfintechGenerateCasResponse.builder() + .msg("CAS request submitted. Check email shortly.") + .status("success") + .build() + + assertThat(kfintechGenerateCasResponse.msg()) + .contains("CAS request submitted. Check email shortly.") + assertThat(kfintechGenerateCasResponse.status()).contains("success") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val kfintechGenerateCasResponse = + KfintechGenerateCasResponse.builder() + .msg("CAS request submitted. Check email shortly.") + .status("success") + .build() + + val roundtrippedKfintechGenerateCasResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(kfintechGenerateCasResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedKfintechGenerateCasResponse).isEqualTo(kfintechGenerateCasResponse) + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogCreateParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogCreateParamsTest.kt new file mode 100644 index 0000000..e7212ba --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogCreateParamsTest.kt @@ -0,0 +1,42 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.logs + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LogCreateParamsTest { + + @Test + fun create() { + LogCreateParams.builder() + .endTime(OffsetDateTime.parse("2026-01-31T23:59:59Z")) + .limit(1L) + .startTime(OffsetDateTime.parse("2026-01-01T00:00:00Z")) + .build() + } + + @Test + fun body() { + val params = + LogCreateParams.builder() + .endTime(OffsetDateTime.parse("2026-01-31T23:59:59Z")) + .limit(1L) + .startTime(OffsetDateTime.parse("2026-01-01T00:00:00Z")) + .build() + + val body = params._body() + + assertThat(body.endTime()).contains(OffsetDateTime.parse("2026-01-31T23:59:59Z")) + assertThat(body.limit()).contains(1L) + assertThat(body.startTime()).contains(OffsetDateTime.parse("2026-01-01T00:00:00Z")) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = LogCreateParams.builder().build() + + val body = params._body() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogCreateResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogCreateResponseTest.kt new file mode 100644 index 0000000..0f24a21 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogCreateResponseTest.kt @@ -0,0 +1,74 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.logs + +import com.cas_parser.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LogCreateResponseTest { + + @Test + fun create() { + val logCreateResponse = + LogCreateResponse.builder() + .count(25L) + .addLog( + LogCreateResponse.Log.builder() + .credits(1.0) + .feature("cdsl_cas_parser") + .path("/v4/cdsl/parse") + .requestId("req_2xYz7KpL8mN3Ab") + .statusCode(200L) + .timestamp(OffsetDateTime.parse("2026-01-15T14:30:00Z")) + .build() + ) + .status("success") + .build() + + assertThat(logCreateResponse.count()).contains(25L) + assertThat(logCreateResponse.logs().getOrNull()) + .containsExactly( + LogCreateResponse.Log.builder() + .credits(1.0) + .feature("cdsl_cas_parser") + .path("/v4/cdsl/parse") + .requestId("req_2xYz7KpL8mN3Ab") + .statusCode(200L) + .timestamp(OffsetDateTime.parse("2026-01-15T14:30:00Z")) + .build() + ) + assertThat(logCreateResponse.status()).contains("success") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val logCreateResponse = + LogCreateResponse.builder() + .count(25L) + .addLog( + LogCreateResponse.Log.builder() + .credits(1.0) + .feature("cdsl_cas_parser") + .path("/v4/cdsl/parse") + .requestId("req_2xYz7KpL8mN3Ab") + .statusCode(200L) + .timestamp(OffsetDateTime.parse("2026-01-15T14:30:00Z")) + .build() + ) + .status("success") + .build() + + val roundtrippedLogCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(logCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLogCreateResponse).isEqualTo(logCreateResponse) + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogGetSummaryParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogGetSummaryParamsTest.kt new file mode 100644 index 0000000..a2cfd4a --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogGetSummaryParamsTest.kt @@ -0,0 +1,39 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.logs + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LogGetSummaryParamsTest { + + @Test + fun create() { + LogGetSummaryParams.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + } + + @Test + fun body() { + val params = + LogGetSummaryParams.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val body = params._body() + + assertThat(body.endTime()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.startTime()).contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = LogGetSummaryParams.builder().build() + + val body = params._body() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogGetSummaryResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogGetSummaryResponseTest.kt new file mode 100644 index 0000000..94e8bc7 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/logs/LogGetSummaryResponseTest.kt @@ -0,0 +1,78 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.logs + +import com.cas_parser.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class LogGetSummaryResponseTest { + + @Test + fun create() { + val logGetSummaryResponse = + LogGetSummaryResponse.builder() + .status("success") + .summary( + LogGetSummaryResponse.Summary.builder() + .addByFeature( + LogGetSummaryResponse.Summary.ByFeature.builder() + .credits(15.0) + .feature("cdsl_cas_parser") + .requests(15L) + .build() + ) + .totalCredits(45.5) + .totalRequests(42L) + .build() + ) + .build() + + assertThat(logGetSummaryResponse.status()).contains("success") + assertThat(logGetSummaryResponse.summary()) + .contains( + LogGetSummaryResponse.Summary.builder() + .addByFeature( + LogGetSummaryResponse.Summary.ByFeature.builder() + .credits(15.0) + .feature("cdsl_cas_parser") + .requests(15L) + .build() + ) + .totalCredits(45.5) + .totalRequests(42L) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val logGetSummaryResponse = + LogGetSummaryResponse.builder() + .status("success") + .summary( + LogGetSummaryResponse.Summary.builder() + .addByFeature( + LogGetSummaryResponse.Summary.ByFeature.builder() + .credits(15.0) + .feature("cdsl_cas_parser") + .requests(15L) + .build() + ) + .totalCredits(45.5) + .totalRequests(42L) + .build() + ) + .build() + + val roundtrippedLogGetSummaryResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(logGetSummaryResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedLogGetSummaryResponse).isEqualTo(logGetSummaryResponse) + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/casparser/CasParserCdslParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/nsdl/NsdlParseParamsTest.kt similarity index 87% rename from cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/casparser/CasParserCdslParamsTest.kt rename to cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/nsdl/NsdlParseParamsTest.kt index 6293280..a7631d5 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/casparser/CasParserCdslParamsTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/nsdl/NsdlParseParamsTest.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package com.cas_parser.api.models.casparser +package com.cas_parser.api.models.nsdl import com.cas_parser.api.core.MultipartField import java.io.InputStream import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class CasParserCdslParamsTest { +internal class NsdlParseParamsTest { @Test fun create() { - CasParserCdslParams.builder() + NsdlParseParams.builder() .password("password") .pdfFile("pdf_file") .pdfUrl("https://example.com") @@ -21,7 +21,7 @@ internal class CasParserCdslParamsTest { @Test fun body() { val params = - CasParserCdslParams.builder() + NsdlParseParams.builder() .password("password") .pdfFile("pdf_file") .pdfUrl("https://example.com") @@ -51,7 +51,7 @@ internal class CasParserCdslParamsTest { @Test fun bodyWithoutOptionalFields() { - val params = CasParserCdslParams.builder().build() + val params = NsdlParseParams.builder().build() val body = params._body() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/casparser/CasParserCamsKfintechParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/smart/SmartParseCasPdfParamsTest.kt similarity index 86% rename from cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/casparser/CasParserCamsKfintechParamsTest.kt rename to cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/smart/SmartParseCasPdfParamsTest.kt index 7fd81ef..1c1b2c2 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/casparser/CasParserCamsKfintechParamsTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/smart/SmartParseCasPdfParamsTest.kt @@ -1,17 +1,17 @@ // File generated from our OpenAPI spec by Stainless. -package com.cas_parser.api.models.casparser +package com.cas_parser.api.models.smart import com.cas_parser.api.core.MultipartField import java.io.InputStream import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class CasParserCamsKfintechParamsTest { +internal class SmartParseCasPdfParamsTest { @Test fun create() { - CasParserCamsKfintechParams.builder() + SmartParseCasPdfParams.builder() .password("password") .pdfFile("pdf_file") .pdfUrl("https://example.com") @@ -21,7 +21,7 @@ internal class CasParserCamsKfintechParamsTest { @Test fun body() { val params = - CasParserCamsKfintechParams.builder() + SmartParseCasPdfParams.builder() .password("password") .pdfFile("pdf_file") .pdfUrl("https://example.com") @@ -51,7 +51,7 @@ internal class CasParserCamsKfintechParamsTest { @Test fun bodyWithoutOptionalFields() { - val params = CasParserCamsKfintechParams.builder().build() + val params = SmartParseCasPdfParams.builder().build() val body = params._body() diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyParamsTest.kt new file mode 100644 index 0000000..6e75d40 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.verifytoken + +import org.junit.jupiter.api.Test + +internal class VerifyTokenVerifyParamsTest { + + @Test + fun create() { + VerifyTokenVerifyParams.builder().build() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyResponseTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyResponseTest.kt new file mode 100644 index 0000000..813bc45 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/models/verifytoken/VerifyTokenVerifyResponseTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.models.verifytoken + +import com.cas_parser.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class VerifyTokenVerifyResponseTest { + + @Test + fun create() { + val verifyTokenVerifyResponse = + VerifyTokenVerifyResponse.builder() + .error("Token has expired") + .maskedApiKey("abc1****ef23") + .valid(true) + .build() + + assertThat(verifyTokenVerifyResponse.error()).contains("Token has expired") + assertThat(verifyTokenVerifyResponse.maskedApiKey()).contains("abc1****ef23") + assertThat(verifyTokenVerifyResponse.valid()).contains(true) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val verifyTokenVerifyResponse = + VerifyTokenVerifyResponse.builder() + .error("Token has expired") + .maskedApiKey("abc1****ef23") + .valid(true) + .build() + + val roundtrippedVerifyTokenVerifyResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(verifyTokenVerifyResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedVerifyTokenVerifyResponse).isEqualTo(verifyTokenVerifyResponse) + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/ErrorHandlingTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/ErrorHandlingTest.kt index 71fb9b3..f58190a 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/ErrorHandlingTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/ErrorHandlingTest.kt @@ -16,7 +16,6 @@ import com.cas_parser.api.errors.RateLimitException import com.cas_parser.api.errors.UnauthorizedException import com.cas_parser.api.errors.UnexpectedStatusCodeException import com.cas_parser.api.errors.UnprocessableEntityException -import com.cas_parser.api.models.casparser.CasParserSmartParseParams import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.post import com.github.tomakehurst.wiremock.client.WireMock.status @@ -59,8 +58,8 @@ internal class ErrorHandlingTest { } @Test - fun casParserSmartParse400() { - val casParserService = client.casParser() + fun creditsCheck400() { + val creditService = client.credits() stubFor( post(anyUrl()) .willReturn( @@ -68,16 +67,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - casParserService.smartParse( - CasParserSmartParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(400) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -85,8 +75,8 @@ internal class ErrorHandlingTest { } @Test - fun casParserSmartParse400WithRawResponse() { - val casParserService = client.casParser().withRawResponse() + fun creditsCheck400WithRawResponse() { + val creditService = client.credits().withRawResponse() stubFor( post(anyUrl()) .willReturn( @@ -94,16 +84,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - casParserService.smartParse( - CasParserSmartParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(400) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -111,8 +92,8 @@ internal class ErrorHandlingTest { } @Test - fun casParserSmartParse401() { - val casParserService = client.casParser() + fun creditsCheck401() { + val creditService = client.credits() stubFor( post(anyUrl()) .willReturn( @@ -120,16 +101,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - casParserService.smartParse( - CasParserSmartParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(401) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -137,8 +109,8 @@ internal class ErrorHandlingTest { } @Test - fun casParserSmartParse401WithRawResponse() { - val casParserService = client.casParser().withRawResponse() + fun creditsCheck401WithRawResponse() { + val creditService = client.credits().withRawResponse() stubFor( post(anyUrl()) .willReturn( @@ -146,16 +118,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - casParserService.smartParse( - CasParserSmartParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(401) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -163,8 +126,8 @@ internal class ErrorHandlingTest { } @Test - fun casParserSmartParse403() { - val casParserService = client.casParser() + fun creditsCheck403() { + val creditService = client.credits() stubFor( post(anyUrl()) .willReturn( @@ -172,16 +135,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - casParserService.smartParse( - CasParserSmartParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(403) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -189,8 +143,8 @@ internal class ErrorHandlingTest { } @Test - fun casParserSmartParse403WithRawResponse() { - val casParserService = client.casParser().withRawResponse() + fun creditsCheck403WithRawResponse() { + val creditService = client.credits().withRawResponse() stubFor( post(anyUrl()) .willReturn( @@ -198,16 +152,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - casParserService.smartParse( - CasParserSmartParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(403) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -215,8 +160,8 @@ internal class ErrorHandlingTest { } @Test - fun casParserSmartParse404() { - val casParserService = client.casParser() + fun creditsCheck404() { + val creditService = client.credits() stubFor( post(anyUrl()) .willReturn( @@ -224,16 +169,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - casParserService.smartParse( - CasParserSmartParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(404) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -241,8 +177,8 @@ internal class ErrorHandlingTest { } @Test - fun casParserSmartParse404WithRawResponse() { - val casParserService = client.casParser().withRawResponse() + fun creditsCheck404WithRawResponse() { + val creditService = client.credits().withRawResponse() stubFor( post(anyUrl()) .willReturn( @@ -250,16 +186,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - casParserService.smartParse( - CasParserSmartParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(404) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -267,8 +194,8 @@ internal class ErrorHandlingTest { } @Test - fun casParserSmartParse422() { - val casParserService = client.casParser() + fun creditsCheck422() { + val creditService = client.credits() stubFor( post(anyUrl()) .willReturn( @@ -276,16 +203,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - casParserService.smartParse( - CasParserSmartParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(422) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -293,8 +211,8 @@ internal class ErrorHandlingTest { } @Test - fun casParserSmartParse422WithRawResponse() { - val casParserService = client.casParser().withRawResponse() + fun creditsCheck422WithRawResponse() { + val creditService = client.credits().withRawResponse() stubFor( post(anyUrl()) .willReturn( @@ -302,16 +220,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - casParserService.smartParse( - CasParserSmartParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(422) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -319,8 +228,8 @@ internal class ErrorHandlingTest { } @Test - fun casParserSmartParse429() { - val casParserService = client.casParser() + fun creditsCheck429() { + val creditService = client.credits() stubFor( post(anyUrl()) .willReturn( @@ -328,16 +237,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - casParserService.smartParse( - CasParserSmartParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(429) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -345,8 +245,8 @@ internal class ErrorHandlingTest { } @Test - fun casParserSmartParse429WithRawResponse() { - val casParserService = client.casParser().withRawResponse() + fun creditsCheck429WithRawResponse() { + val creditService = client.credits().withRawResponse() stubFor( post(anyUrl()) .willReturn( @@ -354,16 +254,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - casParserService.smartParse( - CasParserSmartParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(429) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -371,8 +262,8 @@ internal class ErrorHandlingTest { } @Test - fun casParserSmartParse500() { - val casParserService = client.casParser() + fun creditsCheck500() { + val creditService = client.credits() stubFor( post(anyUrl()) .willReturn( @@ -380,16 +271,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - casParserService.smartParse( - CasParserSmartParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(500) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -397,8 +279,8 @@ internal class ErrorHandlingTest { } @Test - fun casParserSmartParse500WithRawResponse() { - val casParserService = client.casParser().withRawResponse() + fun creditsCheck500WithRawResponse() { + val creditService = client.credits().withRawResponse() stubFor( post(anyUrl()) .willReturn( @@ -406,16 +288,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - casParserService.smartParse( - CasParserSmartParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(500) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -423,8 +296,8 @@ internal class ErrorHandlingTest { } @Test - fun casParserSmartParse999() { - val casParserService = client.casParser() + fun creditsCheck999() { + val creditService = client.credits() stubFor( post(anyUrl()) .willReturn( @@ -432,16 +305,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - casParserService.smartParse( - CasParserSmartParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(999) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -449,8 +313,8 @@ internal class ErrorHandlingTest { } @Test - fun casParserSmartParse999WithRawResponse() { - val casParserService = client.casParser().withRawResponse() + fun creditsCheck999WithRawResponse() { + val creditService = client.credits().withRawResponse() stubFor( post(anyUrl()) .willReturn( @@ -458,16 +322,7 @@ internal class ErrorHandlingTest { ) ) - val e = - assertThrows { - casParserService.smartParse( - CasParserSmartParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e.statusCode()).isEqualTo(999) assertThat(e.headers().toMap()).contains(entry(HEADER_NAME, listOf(HEADER_VALUE))) @@ -475,23 +330,14 @@ internal class ErrorHandlingTest { } @Test - fun casParserSmartParseInvalidJsonBody() { - val casParserService = client.casParser() + fun creditsCheckInvalidJsonBody() { + val creditService = client.credits() stubFor( post(anyUrl()) .willReturn(status(200).withHeader(HEADER_NAME, HEADER_VALUE).withBody(NOT_JSON)) ) - val e = - assertThrows { - casParserService.smartParse( - CasParserSmartParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - } + val e = assertThrows { creditService.check() } assertThat(e).hasMessage("Error reading response") } diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/ServiceParamsTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/ServiceParamsTest.kt index 5454df2..2d2074d 100644 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/ServiceParamsTest.kt +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/ServiceParamsTest.kt @@ -5,7 +5,7 @@ package com.cas_parser.api.services import com.cas_parser.api.client.CasParserClient import com.cas_parser.api.client.okhttp.CasParserOkHttpClient import com.cas_parser.api.core.JsonValue -import com.cas_parser.api.models.casparser.CasParserSmartParseParams +import com.cas_parser.api.models.credits.CreditCheckParams import com.github.tomakehurst.wiremock.client.WireMock.anyUrl import com.github.tomakehurst.wiremock.client.WireMock.equalTo import com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath @@ -38,15 +38,12 @@ internal class ServiceParamsTest { @Disabled("Prism tests are disabled") @Test - fun smartParse() { - val casParserService = client.casParser() + fun check() { + val creditService = client.credits() stubFor(post(anyUrl()).willReturn(ok("{}"))) - casParserService.smartParse( - CasParserSmartParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") + creditService.check( + CreditCheckParams.builder() .putAdditionalHeader("Secret-Header", "42") .putAdditionalQueryParam("secret_query_param", "42") .putAdditionalBodyProperty("secretProperty", JsonValue.from("42")) diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncTest.kt new file mode 100644 index 0000000..d1a2caa --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/AccessTokenServiceAsyncTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.TestServerExtension +import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync +import com.cas_parser.api.models.accesstoken.AccessTokenCreateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class AccessTokenServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + CasParserOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val accessTokenServiceAsync = client.accessToken() + + val accessTokenFuture = + accessTokenServiceAsync.create( + AccessTokenCreateParams.builder().expiryMinutes(60L).build() + ) + + val accessToken = accessTokenFuture.get() + accessToken.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CamsKfintechServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CamsKfintechServiceAsyncTest.kt new file mode 100644 index 0000000..2f14e4a --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CamsKfintechServiceAsyncTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.TestServerExtension +import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync +import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CamsKfintechServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun parse() { + val client = + CasParserOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val camsKfintechServiceAsync = client.camsKfintech() + + val unifiedResponseFuture = + camsKfintechServiceAsync.parse( + CamsKfintechParseParams.builder() + .password("password") + .pdfFile("pdf_file") + .pdfUrl("https://example.com") + .build() + ) + + val unifiedResponse = unifiedResponseFuture.get() + unifiedResponse.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CasParserServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CasParserServiceAsyncTest.kt deleted file mode 100644 index 363c5eb..0000000 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CasParserServiceAsyncTest.kt +++ /dev/null @@ -1,109 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.services.async - -import com.cas_parser.api.TestServerExtension -import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync -import com.cas_parser.api.models.casparser.CasParserCamsKfintechParams -import com.cas_parser.api.models.casparser.CasParserCdslParams -import com.cas_parser.api.models.casparser.CasParserNsdlParams -import com.cas_parser.api.models.casparser.CasParserSmartParseParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class CasParserServiceAsyncTest { - - @Disabled("Prism tests are disabled") - @Test - fun camsKfintech() { - val client = - CasParserOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val casParserServiceAsync = client.casParser() - - val unifiedResponseFuture = - casParserServiceAsync.camsKfintech( - CasParserCamsKfintechParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - - val unifiedResponse = unifiedResponseFuture.get() - unifiedResponse.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun cdsl() { - val client = - CasParserOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val casParserServiceAsync = client.casParser() - - val unifiedResponseFuture = - casParserServiceAsync.cdsl( - CasParserCdslParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - - val unifiedResponse = unifiedResponseFuture.get() - unifiedResponse.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun nsdl() { - val client = - CasParserOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val casParserServiceAsync = client.casParser() - - val unifiedResponseFuture = - casParserServiceAsync.nsdl( - CasParserNsdlParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - - val unifiedResponse = unifiedResponseFuture.get() - unifiedResponse.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun smartParse() { - val client = - CasParserOkHttpClientAsync.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val casParserServiceAsync = client.casParser() - - val unifiedResponseFuture = - casParserServiceAsync.smartParse( - CasParserSmartParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - - val unifiedResponse = unifiedResponseFuture.get() - unifiedResponse.validate() - } -} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CdslServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CdslServiceAsyncTest.kt new file mode 100644 index 0000000..36a9797 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CdslServiceAsyncTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.TestServerExtension +import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync +import com.cas_parser.api.models.cdsl.CdslParsePdfParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CdslServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun parsePdf() { + val client = + CasParserOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cdslServiceAsync = client.cdsl() + + val unifiedResponseFuture = + cdslServiceAsync.parsePdf( + CdslParsePdfParams.builder() + .password("password") + .pdfFile("pdf_file") + .pdfUrl("https://example.com") + .build() + ) + + val unifiedResponse = unifiedResponseFuture.get() + unifiedResponse.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/ContractNoteServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/ContractNoteServiceAsyncTest.kt new file mode 100644 index 0000000..8e7907e --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/ContractNoteServiceAsyncTest.kt @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.TestServerExtension +import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync +import com.cas_parser.api.models.contractnote.ContractNoteParseParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ContractNoteServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun parse() { + val client = + CasParserOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val contractNoteServiceAsync = client.contractNote() + + val responseFuture = + contractNoteServiceAsync.parse( + ContractNoteParseParams.builder() + .brokerType(ContractNoteParseParams.BrokerType.ZERODHA) + .password("FAXAK2545F") + .pdfFile("JVBERi0xLjQKMSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZwo...") + .pdfUrl("https://example.com/contract_note.pdf") + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncTest.kt new file mode 100644 index 0000000..bedb74b --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/CreditServiceAsyncTest.kt @@ -0,0 +1,29 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.TestServerExtension +import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CreditServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun check() { + val client = + CasParserOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val creditServiceAsync = client.credits() + + val responseFuture = creditServiceAsync.check() + + val response = responseFuture.get() + response.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/InboxServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/InboxServiceAsyncTest.kt new file mode 100644 index 0000000..45759bf --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/InboxServiceAsyncTest.kt @@ -0,0 +1,103 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.TestServerExtension +import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync +import com.cas_parser.api.models.inbox.InboxCheckConnectionStatusParams +import com.cas_parser.api.models.inbox.InboxConnectEmailParams +import com.cas_parser.api.models.inbox.InboxDisconnectEmailParams +import com.cas_parser.api.models.inbox.InboxListCasFilesParams +import java.time.LocalDate +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class InboxServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun checkConnectionStatus() { + val client = + CasParserOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val inboxServiceAsync = client.inbox() + + val responseFuture = + inboxServiceAsync.checkConnectionStatus( + InboxCheckConnectionStatusParams.builder().xInboxToken("x-inbox-token").build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun connectEmail() { + val client = + CasParserOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val inboxServiceAsync = client.inbox() + + val responseFuture = + inboxServiceAsync.connectEmail( + InboxConnectEmailParams.builder() + .redirectUri("https://yourapp.com/oauth-callback") + .state("abc123") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun disconnectEmail() { + val client = + CasParserOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val inboxServiceAsync = client.inbox() + + val responseFuture = + inboxServiceAsync.disconnectEmail( + InboxDisconnectEmailParams.builder().xInboxToken("x-inbox-token").build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun listCasFiles() { + val client = + CasParserOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val inboxServiceAsync = client.inbox() + + val responseFuture = + inboxServiceAsync.listCasFiles( + InboxListCasFilesParams.builder() + .xInboxToken("x-inbox-token") + .addCasType(InboxListCasFilesParams.CasType.CDSL) + .addCasType(InboxListCasFilesParams.CasType.NSDL) + .endDate(LocalDate.parse("2025-12-31")) + .startDate(LocalDate.parse("2025-12-01")) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/KfintechServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/KfintechServiceAsyncTest.kt new file mode 100644 index 0000000..8409abc --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/KfintechServiceAsyncTest.kt @@ -0,0 +1,39 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.TestServerExtension +import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync +import com.cas_parser.api.models.kfintech.KfintechGenerateCasParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class KfintechServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun generateCas() { + val client = + CasParserOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val kfintechServiceAsync = client.kfintech() + + val responseFuture = + kfintechServiceAsync.generateCas( + KfintechGenerateCasParams.builder() + .email("user@example.com") + .fromDate("2023-01-01") + .password("Abcdefghi12\$") + .toDate("2023-12-31") + .panNo("ABCDE1234F") + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/LogServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/LogServiceAsyncTest.kt new file mode 100644 index 0000000..bcb12c3 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/LogServiceAsyncTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.TestServerExtension +import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync +import com.cas_parser.api.models.logs.LogCreateParams +import com.cas_parser.api.models.logs.LogGetSummaryParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class LogServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + CasParserOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logServiceAsync = client.logs() + + val logFuture = + logServiceAsync.create( + LogCreateParams.builder() + .endTime(OffsetDateTime.parse("2026-01-31T23:59:59Z")) + .limit(1L) + .startTime(OffsetDateTime.parse("2026-01-01T00:00:00Z")) + .build() + ) + + val log = logFuture.get() + log.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun getSummary() { + val client = + CasParserOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logServiceAsync = client.logs() + + val responseFuture = + logServiceAsync.getSummary( + LogGetSummaryParams.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/NsdlServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/NsdlServiceAsyncTest.kt new file mode 100644 index 0000000..b8db02d --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/NsdlServiceAsyncTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.TestServerExtension +import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync +import com.cas_parser.api.models.nsdl.NsdlParseParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class NsdlServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun parse() { + val client = + CasParserOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val nsdlServiceAsync = client.nsdl() + + val unifiedResponseFuture = + nsdlServiceAsync.parse( + NsdlParseParams.builder() + .password("password") + .pdfFile("pdf_file") + .pdfUrl("https://example.com") + .build() + ) + + val unifiedResponse = unifiedResponseFuture.get() + unifiedResponse.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/SmartServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/SmartServiceAsyncTest.kt new file mode 100644 index 0000000..9cc398a --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/SmartServiceAsyncTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.TestServerExtension +import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync +import com.cas_parser.api.models.smart.SmartParseCasPdfParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SmartServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun parseCasPdf() { + val client = + CasParserOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val smartServiceAsync = client.smart() + + val unifiedResponseFuture = + smartServiceAsync.parseCasPdf( + SmartParseCasPdfParams.builder() + .password("password") + .pdfFile("pdf_file") + .pdfUrl("https://example.com") + .build() + ) + + val unifiedResponse = unifiedResponseFuture.get() + unifiedResponse.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncTest.kt new file mode 100644 index 0000000..c521605 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/VerifyTokenServiceAsyncTest.kt @@ -0,0 +1,29 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async + +import com.cas_parser.api.TestServerExtension +import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class VerifyTokenServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun verify() { + val client = + CasParserOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val verifyTokenServiceAsync = client.verifyToken() + + val responseFuture = verifyTokenServiceAsync.verify() + + val response = responseFuture.get() + response.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/cdsl/FetchServiceAsyncTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/cdsl/FetchServiceAsyncTest.kt new file mode 100644 index 0000000..7cc38ca --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/async/cdsl/FetchServiceAsyncTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.async.cdsl + +import com.cas_parser.api.TestServerExtension +import com.cas_parser.api.client.okhttp.CasParserOkHttpClientAsync +import com.cas_parser.api.models.cdsl.fetch.FetchRequestOtpParams +import com.cas_parser.api.models.cdsl.fetch.FetchVerifyOtpParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class FetchServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun requestOtp() { + val client = + CasParserOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val fetchServiceAsync = client.cdsl().fetch() + + val responseFuture = + fetchServiceAsync.requestOtp( + FetchRequestOtpParams.builder() + .boId("1234567890123456") + .dob("1990-01-15") + .pan("ABCDE1234F") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun verifyOtp() { + val client = + CasParserOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val fetchServiceAsync = client.cdsl().fetch() + + val responseFuture = + fetchServiceAsync.verifyOtp( + FetchVerifyOtpParams.builder() + .sessionId("session_id") + .otp("123456") + .numPeriods(6L) + .build() + ) + + val response = responseFuture.get() + response.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceTest.kt new file mode 100644 index 0000000..278e2a8 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/AccessTokenServiceTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.TestServerExtension +import com.cas_parser.api.client.okhttp.CasParserOkHttpClient +import com.cas_parser.api.models.accesstoken.AccessTokenCreateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class AccessTokenServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + CasParserOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val accessTokenService = client.accessToken() + + val accessToken = + accessTokenService.create(AccessTokenCreateParams.builder().expiryMinutes(60L).build()) + + accessToken.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CamsKfintechServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CamsKfintechServiceTest.kt new file mode 100644 index 0000000..86de188 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CamsKfintechServiceTest.kt @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.TestServerExtension +import com.cas_parser.api.client.okhttp.CasParserOkHttpClient +import com.cas_parser.api.models.camskfintech.CamsKfintechParseParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CamsKfintechServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun parse() { + val client = + CasParserOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val camsKfintechService = client.camsKfintech() + + val unifiedResponse = + camsKfintechService.parse( + CamsKfintechParseParams.builder() + .password("password") + .pdfFile("pdf_file") + .pdfUrl("https://example.com") + .build() + ) + + unifiedResponse.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CasParserServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CasParserServiceTest.kt deleted file mode 100644 index 9724ba1..0000000 --- a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CasParserServiceTest.kt +++ /dev/null @@ -1,105 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.cas_parser.api.services.blocking - -import com.cas_parser.api.TestServerExtension -import com.cas_parser.api.client.okhttp.CasParserOkHttpClient -import com.cas_parser.api.models.casparser.CasParserCamsKfintechParams -import com.cas_parser.api.models.casparser.CasParserCdslParams -import com.cas_parser.api.models.casparser.CasParserNsdlParams -import com.cas_parser.api.models.casparser.CasParserSmartParseParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.extension.ExtendWith - -@ExtendWith(TestServerExtension::class) -internal class CasParserServiceTest { - - @Disabled("Prism tests are disabled") - @Test - fun camsKfintech() { - val client = - CasParserOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val casParserService = client.casParser() - - val unifiedResponse = - casParserService.camsKfintech( - CasParserCamsKfintechParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - - unifiedResponse.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun cdsl() { - val client = - CasParserOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val casParserService = client.casParser() - - val unifiedResponse = - casParserService.cdsl( - CasParserCdslParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - - unifiedResponse.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun nsdl() { - val client = - CasParserOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val casParserService = client.casParser() - - val unifiedResponse = - casParserService.nsdl( - CasParserNsdlParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - - unifiedResponse.validate() - } - - @Disabled("Prism tests are disabled") - @Test - fun smartParse() { - val client = - CasParserOkHttpClient.builder() - .baseUrl(TestServerExtension.BASE_URL) - .apiKey("My API Key") - .build() - val casParserService = client.casParser() - - val unifiedResponse = - casParserService.smartParse( - CasParserSmartParseParams.builder() - .password("password") - .pdfFile("pdf_file") - .pdfUrl("https://example.com") - .build() - ) - - unifiedResponse.validate() - } -} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CdslServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CdslServiceTest.kt new file mode 100644 index 0000000..492dd5c --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CdslServiceTest.kt @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.TestServerExtension +import com.cas_parser.api.client.okhttp.CasParserOkHttpClient +import com.cas_parser.api.models.cdsl.CdslParsePdfParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CdslServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun parsePdf() { + val client = + CasParserOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cdslService = client.cdsl() + + val unifiedResponse = + cdslService.parsePdf( + CdslParsePdfParams.builder() + .password("password") + .pdfFile("pdf_file") + .pdfUrl("https://example.com") + .build() + ) + + unifiedResponse.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/ContractNoteServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/ContractNoteServiceTest.kt new file mode 100644 index 0000000..07164ca --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/ContractNoteServiceTest.kt @@ -0,0 +1,37 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.TestServerExtension +import com.cas_parser.api.client.okhttp.CasParserOkHttpClient +import com.cas_parser.api.models.contractnote.ContractNoteParseParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class ContractNoteServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun parse() { + val client = + CasParserOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val contractNoteService = client.contractNote() + + val response = + contractNoteService.parse( + ContractNoteParseParams.builder() + .brokerType(ContractNoteParseParams.BrokerType.ZERODHA) + .password("FAXAK2545F") + .pdfFile("JVBERi0xLjQKMSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZwo...") + .pdfUrl("https://example.com/contract_note.pdf") + .build() + ) + + response.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CreditServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CreditServiceTest.kt new file mode 100644 index 0000000..750948f --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/CreditServiceTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.TestServerExtension +import com.cas_parser.api.client.okhttp.CasParserOkHttpClient +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CreditServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun check() { + val client = + CasParserOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val creditService = client.credits() + + val response = creditService.check() + + response.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/InboxServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/InboxServiceTest.kt new file mode 100644 index 0000000..8b62e2d --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/InboxServiceTest.kt @@ -0,0 +1,99 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.TestServerExtension +import com.cas_parser.api.client.okhttp.CasParserOkHttpClient +import com.cas_parser.api.models.inbox.InboxCheckConnectionStatusParams +import com.cas_parser.api.models.inbox.InboxConnectEmailParams +import com.cas_parser.api.models.inbox.InboxDisconnectEmailParams +import com.cas_parser.api.models.inbox.InboxListCasFilesParams +import java.time.LocalDate +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class InboxServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun checkConnectionStatus() { + val client = + CasParserOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val inboxService = client.inbox() + + val response = + inboxService.checkConnectionStatus( + InboxCheckConnectionStatusParams.builder().xInboxToken("x-inbox-token").build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun connectEmail() { + val client = + CasParserOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val inboxService = client.inbox() + + val response = + inboxService.connectEmail( + InboxConnectEmailParams.builder() + .redirectUri("https://yourapp.com/oauth-callback") + .state("abc123") + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun disconnectEmail() { + val client = + CasParserOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val inboxService = client.inbox() + + val response = + inboxService.disconnectEmail( + InboxDisconnectEmailParams.builder().xInboxToken("x-inbox-token").build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun listCasFiles() { + val client = + CasParserOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val inboxService = client.inbox() + + val response = + inboxService.listCasFiles( + InboxListCasFilesParams.builder() + .xInboxToken("x-inbox-token") + .addCasType(InboxListCasFilesParams.CasType.CDSL) + .addCasType(InboxListCasFilesParams.CasType.NSDL) + .endDate(LocalDate.parse("2025-12-31")) + .startDate(LocalDate.parse("2025-12-01")) + .build() + ) + + response.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/KfintechServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/KfintechServiceTest.kt new file mode 100644 index 0000000..963c6f6 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/KfintechServiceTest.kt @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.TestServerExtension +import com.cas_parser.api.client.okhttp.CasParserOkHttpClient +import com.cas_parser.api.models.kfintech.KfintechGenerateCasParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class KfintechServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun generateCas() { + val client = + CasParserOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val kfintechService = client.kfintech() + + val response = + kfintechService.generateCas( + KfintechGenerateCasParams.builder() + .email("user@example.com") + .fromDate("2023-01-01") + .password("Abcdefghi12\$") + .toDate("2023-12-31") + .panNo("ABCDE1234F") + .build() + ) + + response.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/LogServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/LogServiceTest.kt new file mode 100644 index 0000000..20549fa --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/LogServiceTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.TestServerExtension +import com.cas_parser.api.client.okhttp.CasParserOkHttpClient +import com.cas_parser.api.models.logs.LogCreateParams +import com.cas_parser.api.models.logs.LogGetSummaryParams +import java.time.OffsetDateTime +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class LogServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun create() { + val client = + CasParserOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logService = client.logs() + + val log = + logService.create( + LogCreateParams.builder() + .endTime(OffsetDateTime.parse("2026-01-31T23:59:59Z")) + .limit(1L) + .startTime(OffsetDateTime.parse("2026-01-01T00:00:00Z")) + .build() + ) + + log.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun getSummary() { + val client = + CasParserOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val logService = client.logs() + + val response = + logService.getSummary( + LogGetSummaryParams.builder() + .endTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .startTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + + response.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/NsdlServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/NsdlServiceTest.kt new file mode 100644 index 0000000..44b520c --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/NsdlServiceTest.kt @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.TestServerExtension +import com.cas_parser.api.client.okhttp.CasParserOkHttpClient +import com.cas_parser.api.models.nsdl.NsdlParseParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class NsdlServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun parse() { + val client = + CasParserOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val nsdlService = client.nsdl() + + val unifiedResponse = + nsdlService.parse( + NsdlParseParams.builder() + .password("password") + .pdfFile("pdf_file") + .pdfUrl("https://example.com") + .build() + ) + + unifiedResponse.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/SmartServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/SmartServiceTest.kt new file mode 100644 index 0000000..0f96eb7 --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/SmartServiceTest.kt @@ -0,0 +1,36 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.TestServerExtension +import com.cas_parser.api.client.okhttp.CasParserOkHttpClient +import com.cas_parser.api.models.smart.SmartParseCasPdfParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class SmartServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun parseCasPdf() { + val client = + CasParserOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val smartService = client.smart() + + val unifiedResponse = + smartService.parseCasPdf( + SmartParseCasPdfParams.builder() + .password("password") + .pdfFile("pdf_file") + .pdfUrl("https://example.com") + .build() + ) + + unifiedResponse.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceTest.kt new file mode 100644 index 0000000..05a1f9f --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/VerifyTokenServiceTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking + +import com.cas_parser.api.TestServerExtension +import com.cas_parser.api.client.okhttp.CasParserOkHttpClient +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class VerifyTokenServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun verify() { + val client = + CasParserOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val verifyTokenService = client.verifyToken() + + val response = verifyTokenService.verify() + + response.validate() + } +} diff --git a/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/cdsl/FetchServiceTest.kt b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/cdsl/FetchServiceTest.kt new file mode 100644 index 0000000..eedc3dd --- /dev/null +++ b/cas-parser-java-core/src/test/kotlin/com/cas_parser/api/services/blocking/cdsl/FetchServiceTest.kt @@ -0,0 +1,59 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.cas_parser.api.services.blocking.cdsl + +import com.cas_parser.api.TestServerExtension +import com.cas_parser.api.client.okhttp.CasParserOkHttpClient +import com.cas_parser.api.models.cdsl.fetch.FetchRequestOtpParams +import com.cas_parser.api.models.cdsl.fetch.FetchVerifyOtpParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class FetchServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun requestOtp() { + val client = + CasParserOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val fetchService = client.cdsl().fetch() + + val response = + fetchService.requestOtp( + FetchRequestOtpParams.builder() + .boId("1234567890123456") + .dob("1990-01-15") + .pan("ABCDE1234F") + .build() + ) + + response.validate() + } + + @Disabled("Prism tests are disabled") + @Test + fun verifyOtp() { + val client = + CasParserOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val fetchService = client.cdsl().fetch() + + val response = + fetchService.verifyOtp( + FetchVerifyOtpParams.builder() + .sessionId("session_id") + .otp("123456") + .numPeriods(6L) + .build() + ) + + response.validate() + } +} diff --git a/cas-parser-java-proguard-test/src/test/kotlin/com/cas_parser/api/proguard/ProGuardCompatibilityTest.kt b/cas-parser-java-proguard-test/src/test/kotlin/com/cas_parser/api/proguard/ProGuardCompatibilityTest.kt index a975237..bdbc9b7 100644 --- a/cas-parser-java-proguard-test/src/test/kotlin/com/cas_parser/api/proguard/ProGuardCompatibilityTest.kt +++ b/cas-parser-java-proguard-test/src/test/kotlin/com/cas_parser/api/proguard/ProGuardCompatibilityTest.kt @@ -3,11 +3,9 @@ package com.cas_parser.api.proguard import com.cas_parser.api.client.okhttp.CasParserOkHttpClient -import com.cas_parser.api.core.JsonValue import com.cas_parser.api.core.jsonMapper -import com.cas_parser.api.models.casparser.UnifiedResponse +import com.cas_parser.api.models.credits.CreditCheckResponse import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.LocalDate import java.time.OffsetDateTime import kotlin.reflect.full.memberFunctions import kotlin.reflect.jvm.javaMethod @@ -50,482 +48,40 @@ internal class ProGuardCompatibilityTest { val client = CasParserOkHttpClient.builder().apiKey("My API Key").build() assertThat(client).isNotNull() - assertThat(client.casParser()).isNotNull() - assertThat(client.casGenerator()).isNotNull() + assertThat(client.credits()).isNotNull() + assertThat(client.logs()).isNotNull() + assertThat(client.accessToken()).isNotNull() + assertThat(client.verifyToken()).isNotNull() + assertThat(client.camsKfintech()).isNotNull() + assertThat(client.cdsl()).isNotNull() + assertThat(client.contractNote()).isNotNull() + assertThat(client.inbox()).isNotNull() + assertThat(client.kfintech()).isNotNull() + assertThat(client.nsdl()).isNotNull() + assertThat(client.smart()).isNotNull() } @Test - fun unifiedResponseRoundtrip() { + fun creditCheckResponseRoundtrip() { val jsonMapper = jsonMapper() - val unifiedResponse = - UnifiedResponse.builder() - .addDematAccount( - UnifiedResponse.DematAccount.builder() - .additionalInfo( - UnifiedResponse.DematAccount.AdditionalInfo.builder() - .boStatus("bo_status") - .boSubStatus("bo_sub_status") - .boType("bo_type") - .bsda("bsda") - .email("dev@stainless.com") - .addLinkedPan("string") - .nominee("nominee") - .status("status") - .build() - ) - .boId("bo_id") - .clientId("client_id") - .dematType(UnifiedResponse.DematAccount.DematType.NSDL) - .dpId("dp_id") - .dpName("dp_name") - .holdings( - UnifiedResponse.DematAccount.Holdings.builder() - .addAif( - UnifiedResponse.DematAccount.Holdings.Aif.builder() - .additionalInfo( - UnifiedResponse.DematAccount.Holdings.Aif.AdditionalInfo - .builder() - .closeUnits(0.0f) - .openUnits(0.0f) - .build() - ) - .isin("isin") - .name("name") - .addTransaction( - UnifiedResponse.DematAccount.Holdings.Aif.Transaction - .builder() - .additionalInfo( - UnifiedResponse.DematAccount.Holdings.Aif - .Transaction - .AdditionalInfo - .builder() - .capitalWithdrawal(0.0f) - .credit(0.0f) - .debit(0.0f) - .incomeDistribution(0.0f) - .orderNo("order_no") - .price(0.0f) - .stampDuty(0.0f) - .build() - ) - .amount(0.0f) - .balance(0.0f) - .date(LocalDate.parse("2019-12-27")) - .description("description") - .dividendRate(0.0f) - .nav(0.0f) - .type( - UnifiedResponse.DematAccount.Holdings.Aif - .Transaction - .Type - .PURCHASE - ) - .units(0.0f) - .build() - ) - .units(0.0f) - .value(0.0f) - .build() - ) - .addCorporateBond( - UnifiedResponse.DematAccount.Holdings.CorporateBond.builder() - .additionalInfo( - UnifiedResponse.DematAccount.Holdings.CorporateBond - .AdditionalInfo - .builder() - .closeUnits(0.0f) - .openUnits(0.0f) - .build() - ) - .isin("isin") - .name("name") - .addTransaction( - UnifiedResponse.DematAccount.Holdings.CorporateBond - .Transaction - .builder() - .additionalInfo( - UnifiedResponse.DematAccount.Holdings - .CorporateBond - .Transaction - .AdditionalInfo - .builder() - .capitalWithdrawal(0.0f) - .credit(0.0f) - .debit(0.0f) - .incomeDistribution(0.0f) - .orderNo("order_no") - .price(0.0f) - .stampDuty(0.0f) - .build() - ) - .amount(0.0f) - .balance(0.0f) - .date(LocalDate.parse("2019-12-27")) - .description("description") - .dividendRate(0.0f) - .nav(0.0f) - .type( - UnifiedResponse.DematAccount.Holdings - .CorporateBond - .Transaction - .Type - .PURCHASE - ) - .units(0.0f) - .build() - ) - .units(0.0f) - .value(0.0f) - .build() - ) - .addDematMutualFund( - UnifiedResponse.DematAccount.Holdings.DematMutualFund.builder() - .additionalInfo( - UnifiedResponse.DematAccount.Holdings.DematMutualFund - .AdditionalInfo - .builder() - .closeUnits(0.0f) - .openUnits(0.0f) - .build() - ) - .isin("isin") - .name("name") - .addTransaction( - UnifiedResponse.DematAccount.Holdings.DematMutualFund - .Transaction - .builder() - .additionalInfo( - UnifiedResponse.DematAccount.Holdings - .DematMutualFund - .Transaction - .AdditionalInfo - .builder() - .capitalWithdrawal(0.0f) - .credit(0.0f) - .debit(0.0f) - .incomeDistribution(0.0f) - .orderNo("order_no") - .price(0.0f) - .stampDuty(0.0f) - .build() - ) - .amount(0.0f) - .balance(0.0f) - .date(LocalDate.parse("2019-12-27")) - .description("description") - .dividendRate(0.0f) - .nav(0.0f) - .type( - UnifiedResponse.DematAccount.Holdings - .DematMutualFund - .Transaction - .Type - .PURCHASE - ) - .units(0.0f) - .build() - ) - .units(0.0f) - .value(0.0f) - .build() - ) - .addEquity( - UnifiedResponse.DematAccount.Holdings.Equity.builder() - .additionalInfo( - UnifiedResponse.DematAccount.Holdings.Equity - .AdditionalInfo - .builder() - .closeUnits(0.0f) - .openUnits(0.0f) - .build() - ) - .isin("isin") - .name("name") - .addTransaction( - UnifiedResponse.DematAccount.Holdings.Equity.Transaction - .builder() - .additionalInfo( - UnifiedResponse.DematAccount.Holdings.Equity - .Transaction - .AdditionalInfo - .builder() - .capitalWithdrawal(0.0f) - .credit(0.0f) - .debit(0.0f) - .incomeDistribution(0.0f) - .orderNo("order_no") - .price(0.0f) - .stampDuty(0.0f) - .build() - ) - .amount(0.0f) - .balance(0.0f) - .date(LocalDate.parse("2019-12-27")) - .description("description") - .dividendRate(0.0f) - .nav(0.0f) - .type( - UnifiedResponse.DematAccount.Holdings.Equity - .Transaction - .Type - .PURCHASE - ) - .units(0.0f) - .build() - ) - .units(0.0f) - .value(0.0f) - .build() - ) - .addGovernmentSecurity( - UnifiedResponse.DematAccount.Holdings.GovernmentSecurity - .builder() - .additionalInfo( - UnifiedResponse.DematAccount.Holdings.GovernmentSecurity - .AdditionalInfo - .builder() - .closeUnits(0.0f) - .openUnits(0.0f) - .build() - ) - .isin("isin") - .name("name") - .addTransaction( - UnifiedResponse.DematAccount.Holdings.GovernmentSecurity - .Transaction - .builder() - .additionalInfo( - UnifiedResponse.DematAccount.Holdings - .GovernmentSecurity - .Transaction - .AdditionalInfo - .builder() - .capitalWithdrawal(0.0f) - .credit(0.0f) - .debit(0.0f) - .incomeDistribution(0.0f) - .orderNo("order_no") - .price(0.0f) - .stampDuty(0.0f) - .build() - ) - .amount(0.0f) - .balance(0.0f) - .date(LocalDate.parse("2019-12-27")) - .description("description") - .dividendRate(0.0f) - .nav(0.0f) - .type( - UnifiedResponse.DematAccount.Holdings - .GovernmentSecurity - .Transaction - .Type - .PURCHASE - ) - .units(0.0f) - .build() - ) - .units(0.0f) - .value(0.0f) - .build() - ) - .build() - ) - .addLinkedHolder( - UnifiedResponse.DematAccount.LinkedHolder.builder() - .name("name") - .pan("pan") - .build() - ) - .value(0.0f) - .build() - ) - .insurance( - UnifiedResponse.Insurance.builder() - .addLifeInsurancePolicy( - UnifiedResponse.Insurance.LifeInsurancePolicy.builder() - .additionalInfo(JsonValue.from(mapOf())) - .lifeAssured("life_assured") - .policyName("policy_name") - .policyNumber("policy_number") - .premiumAmount(0.0f) - .premiumFrequency("premium_frequency") - .provider("provider") - .status("status") - .sumAssured(0.0f) - .build() - ) - .build() - ) - .investor( - UnifiedResponse.Investor.builder() - .address("address") - .casId("cas_id") - .email("dev@stainless.com") - .mobile("mobile") - .name("name") - .pan("pan") - .pincode("pincode") - .build() - ) - .meta( - UnifiedResponse.Meta.builder() - .casType(UnifiedResponse.Meta.CasType.NSDL) - .generatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .statementPeriod( - UnifiedResponse.Meta.StatementPeriod.builder() - .from(LocalDate.parse("2019-12-27")) - .to(LocalDate.parse("2019-12-27")) - .build() - ) - .build() - ) - .addMutualFund( - UnifiedResponse.MutualFund.builder() - .additionalInfo( - UnifiedResponse.MutualFund.AdditionalInfo.builder() - .kyc("kyc") - .pan("pan") - .pankyc("pankyc") - .build() - ) - .amc("amc") - .folioNumber("folio_number") - .addLinkedHolder( - UnifiedResponse.MutualFund.LinkedHolder.builder() - .name("name") - .pan("pan") - .build() - ) - .registrar("registrar") - .addScheme( - UnifiedResponse.MutualFund.Scheme.builder() - .additionalInfo( - UnifiedResponse.MutualFund.Scheme.AdditionalInfo.builder() - .advisor("advisor") - .amfi("amfi") - .closeUnits(0.0f) - .openUnits(0.0f) - .rtaCode("rta_code") - .build() - ) - .cost(0.0f) - .gain( - UnifiedResponse.MutualFund.Scheme.Gain.builder() - .absolute(0.0f) - .percentage(0.0f) - .build() - ) - .isin("isin") - .name("name") - .nav(0.0f) - .addNominee("string") - .addTransaction( - UnifiedResponse.MutualFund.Scheme.Transaction.builder() - .additionalInfo( - UnifiedResponse.MutualFund.Scheme.Transaction - .AdditionalInfo - .builder() - .capitalWithdrawal(0.0f) - .credit(0.0f) - .debit(0.0f) - .incomeDistribution(0.0f) - .orderNo("order_no") - .price(0.0f) - .stampDuty(0.0f) - .build() - ) - .amount(0.0f) - .balance(0.0f) - .date(LocalDate.parse("2019-12-27")) - .description("description") - .dividendRate(0.0f) - .nav(0.0f) - .type( - UnifiedResponse.MutualFund.Scheme.Transaction.Type - .PURCHASE - ) - .units(0.0f) - .build() - ) - .type(UnifiedResponse.MutualFund.Scheme.Type.EQUITY) - .units(0.0f) - .value(0.0f) - .build() - ) - .value(0.0f) - .build() - ) - .addNp( - UnifiedResponse.Np.builder() - .additionalInfo(JsonValue.from(mapOf())) - .cra("cra") - .addFund( - UnifiedResponse.Np.Fund.builder() - .additionalInfo( - UnifiedResponse.Np.Fund.AdditionalInfo.builder() - .manager("manager") - .tier(UnifiedResponse.Np.Fund.AdditionalInfo.Tier._1) - .build() - ) - .cost(0.0f) - .name("name") - .nav(0.0f) - .units(0.0f) - .value(0.0f) - .build() - ) - .addLinkedHolder( - UnifiedResponse.Np.LinkedHolder.builder() - .name("name") - .pan("pan") - .build() - ) - .pran("pran") - .value(0.0f) - .build() - ) - .summary( - UnifiedResponse.Summary.builder() - .accounts( - UnifiedResponse.Summary.Accounts.builder() - .demat( - UnifiedResponse.Summary.Accounts.Demat.builder() - .count(0L) - .totalValue(0.0f) - .build() - ) - .insurance( - UnifiedResponse.Summary.Accounts.Insurance.builder() - .count(0L) - .totalValue(0.0f) - .build() - ) - .mutualFunds( - UnifiedResponse.Summary.Accounts.MutualFunds.builder() - .count(0L) - .totalValue(0.0f) - .build() - ) - .nps( - UnifiedResponse.Summary.Accounts.Nps.builder() - .count(0L) - .totalValue(0.0f) - .build() - ) - .build() - ) - .totalValue(0.0f) - .build() + val creditCheckResponse = + CreditCheckResponse.builder() + .enabledFeatures( + listOf("cams_kfintech_cas_parser", "cdsl_cas_parser", "nsdl_cas_parser") ) + .isUnlimited(false) + .limit(50L) + .remaining(35.0) + .resetsAt(OffsetDateTime.parse("2026-02-15T00:00:00Z")) + .used(15.0) .build() - val roundtrippedUnifiedResponse = + val roundtrippedCreditCheckResponse = jsonMapper.readValue( - jsonMapper.writeValueAsString(unifiedResponse), - jacksonTypeRef(), + jsonMapper.writeValueAsString(creditCheckResponse), + jacksonTypeRef(), ) - assertThat(roundtrippedUnifiedResponse).isEqualTo(unifiedResponse) + assertThat(roundtrippedCreditCheckResponse).isEqualTo(creditCheckResponse) } }