diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index b2cacc9..cc9f68a 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -20,10 +20,10 @@ jobs:
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
- name: Set up Java
- uses: actions/setup-java@v4
+ uses: actions/setup-java@v5
with:
distribution: temurin
java-version: |
@@ -40,14 +40,17 @@ jobs:
build:
timeout-minutes: 15
name: build
+ permissions:
+ contents: read
+ id-token: write
runs-on: ${{ github.repository == 'stainless-sdks/e-invoice-api-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
- name: Set up Java
- uses: actions/setup-java@v4
+ uses: actions/setup-java@v5
with:
distribution: temurin
java-version: |
@@ -61,16 +64,31 @@ jobs:
- name: Build SDK
run: ./scripts/build
+ - name: Get GitHub OIDC Token
+ if: github.repository == 'stainless-sdks/e-invoice-api-java'
+ id: github-oidc
+ uses: actions/github-script@v8
+ with:
+ script: core.setOutput('github_token', await core.getIDToken());
+
+ - name: Build and upload Maven artifacts
+ if: github.repository == 'stainless-sdks/e-invoice-api-java'
+ env:
+ URL: https://pkg.stainless.com/s
+ AUTH: ${{ steps.github-oidc.outputs.github_token }}
+ SHA: ${{ github.sha }}
+ PROJECT: e-invoice-api-java
+ run: ./scripts/upload-artifacts
test:
timeout-minutes: 15
name: test
runs-on: ${{ github.repository == 'stainless-sdks/e-invoice-api-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
if: github.event_name == 'push' || github.event.pull_request.head.repo.fork
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
- name: Set up Java
- uses: actions/setup-java@v4
+ uses: actions/setup-java@v5
with:
distribution: temurin
java-version: |
diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml
index c498ce6..8e5483e 100644
--- a/.github/workflows/publish-sonatype.yml
+++ b/.github/workflows/publish-sonatype.yml
@@ -14,10 +14,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
- name: Set up Java
- uses: actions/setup-java@v4
+ uses: actions/setup-java@v5
with:
distribution: temurin
java-version: |
diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml
index 4c260b7..6a059b2 100644
--- a/.github/workflows/release-doctor.yml
+++ b/.github/workflows/release-doctor.yml
@@ -12,7 +12,7 @@ jobs:
if: github.repository == 'e-invoice-be/e-invoice-java' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next')
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
- name: Check release environment
run: |
diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index fd0ccba..000572e 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "0.1.0-alpha.12"
+ ".": "0.1.0-alpha.13"
}
\ No newline at end of file
diff --git a/.stats.yml b/.stats.yml
index 5507ef0..6da94ee 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
-configured_endpoints: 24
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-6bf85ca7bc7eac16815d912ab0720537e72e39e6234b030c9c3644b3df327788.yml
-openapi_spec_hash: f9ac6f267c1fde475250d7893cf966c7
-config_hash: d627f345d2cab6590eeea9820301272e
+configured_endpoints: 28
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-456484895d394520a1179d60cd2df0b377207849fa84562e406d66886bf8244f.yml
+openapi_spec_hash: b51d0365469bbe89d7e1e8c13983475d
+config_hash: 852a0117abb3db077933876ad1185f41
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 851053c..d948f44 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,61 @@
# Changelog
+## 0.1.0-alpha.13 (2026-02-09)
+
+Full Changelog: [v0.1.0-alpha.12...v0.1.0-alpha.13](https://github.com/e-invoice-be/e-invoice-java/compare/v0.1.0-alpha.12...v0.1.0-alpha.13)
+
+### Features
+
+* **api:** api update ([60dbcea](https://github.com/e-invoice-be/e-invoice-java/commit/60dbcea186a99adbde90154602023e831daf3632))
+* **api:** api update ([c634578](https://github.com/e-invoice-be/e-invoice-java/commit/c63457882b2760456275e531d05f289c716e5934))
+* **api:** api update ([8af9305](https://github.com/e-invoice-be/e-invoice-java/commit/8af9305dcb70550adbd23bc6b31119eaa5aaf23c))
+* **api:** api update ([2b90fa4](https://github.com/e-invoice-be/e-invoice-java/commit/2b90fa4367258ccc96cdf4fe039efeede2a7048e))
+* **api:** api update ([74c4c9e](https://github.com/e-invoice-be/e-invoice-java/commit/74c4c9e381b260df4545a7180365cf517a65b26f))
+* **api:** api update ([5c08714](https://github.com/e-invoice-be/e-invoice-java/commit/5c0871400561a727de59401802a44d4722e6a09a))
+* **api:** api update ([3ef5ab9](https://github.com/e-invoice-be/e-invoice-java/commit/3ef5ab9f1fd50c8dc83094c6d58212e350e1000e))
+* **api:** api update ([4a468b2](https://github.com/e-invoice-be/e-invoice-java/commit/4a468b27a6b2a2c8e748131b3d4f35176a4e3d98))
+* **api:** api update ([d42fb14](https://github.com/e-invoice-be/e-invoice-java/commit/d42fb14927fcae080a39896743dade19a3f23c81))
+* **api:** api update ([3bc4883](https://github.com/e-invoice-be/e-invoice-java/commit/3bc4883a59e0cc7352dfa41a3c6f67f4efc8ba19))
+* **api:** api update ([010d7f1](https://github.com/e-invoice-be/e-invoice-java/commit/010d7f1fc776ed37da2fb55f96ade8267e184cee))
+* **api:** api update ([02308b8](https://github.com/e-invoice-be/e-invoice-java/commit/02308b86f70414c3008b61e1776f17f1fa8d38f0))
+* **api:** api update ([50eb173](https://github.com/e-invoice-be/e-invoice-java/commit/50eb173e52614313f0474c525571300d31f47003))
+* **api:** api update ([88a2388](https://github.com/e-invoice-be/e-invoice-java/commit/88a2388ce1f68f3ad01ac7ae30aa6fd25c1daa15))
+* **api:** api update ([5b447b4](https://github.com/e-invoice-be/e-invoice-java/commit/5b447b4473189cf6675d79480758e989808dab38))
+* **api:** api update ([7c8d5d6](https://github.com/e-invoice-be/e-invoice-java/commit/7c8d5d6baaf53b8fa24983e413280c44ef6783bb))
+* **api:** api update ([16e58bd](https://github.com/e-invoice-be/e-invoice-java/commit/16e58bd343a028e65724cd766aaea0c96b8a01aa))
+* **api:** manual updates ([4f7dc90](https://github.com/e-invoice-be/e-invoice-java/commit/4f7dc90de5d979ea18f9650a25a4b747e28ce5af))
+* **client:** send `X-Stainless-Kotlin-Version` header ([310f45e](https://github.com/e-invoice-be/e-invoice-java/commit/310f45e949318fdc406d157cebe1525e048e1f7c))
+
+
+### Bug Fixes
+
+* **client:** cancel okhttp call when future cancelled ([f34d373](https://github.com/e-invoice-be/e-invoice-java/commit/f34d373cab9477deb15c0c5670166984fe83c850))
+* **client:** multi-value header serialization ([57c75d9](https://github.com/e-invoice-be/e-invoice-java/commit/57c75d98fc1b53bdc1d1544476c6a31cec525601))
+* **client:** preserve time zone in lenient date-time parsing ([2bc9f75](https://github.com/e-invoice-be/e-invoice-java/commit/2bc9f757bcc64596e9db1b2fab3bdeb504e92534))
+* **tests:** add missing query/header params ([a1039c6](https://github.com/e-invoice-be/e-invoice-java/commit/a1039c67421588b13f9a5d522b5baa7c1b150931))
+
+
+### Chores
+
+* **internal:** codegen related update ([0bd96de](https://github.com/e-invoice-be/e-invoice-java/commit/0bd96de349c640f0757190242e91a9e315c133e1))
+* **internal:** codegen related update ([20dd5a8](https://github.com/e-invoice-be/e-invoice-java/commit/20dd5a8e841a3649ffe0f76098e1046e1d8f00e9))
+* **internal:** codegen related update ([04ffe93](https://github.com/e-invoice-be/e-invoice-java/commit/04ffe93692ea6714f8825df585864c39b84a2663))
+* **internal:** codegen related update ([eb5c7e5](https://github.com/e-invoice-be/e-invoice-java/commit/eb5c7e54df6ca465861af705907ed654e844d5a5))
+* **internal:** codegen related update ([34d3b25](https://github.com/e-invoice-be/e-invoice-java/commit/34d3b2519e014679f33b0e66e807b13134c12741))
+* **internal:** codegen related update ([6c5b431](https://github.com/e-invoice-be/e-invoice-java/commit/6c5b4313f318f8c7e7a99cade9644bbb2103be72))
+* **internal:** codegen related update ([0059a2f](https://github.com/e-invoice-be/e-invoice-java/commit/0059a2f619a5e17c3bc9f17e7f684e4af983fe60))
+* **internal:** codegen related update ([ee9459a](https://github.com/e-invoice-be/e-invoice-java/commit/ee9459ac80af991d3a9d719f46d28bee16ac1d49))
+* **internal:** codegen related update ([52e1ebb](https://github.com/e-invoice-be/e-invoice-java/commit/52e1ebbb83280db67feb3581a08d3f7241a500f0))
+* **internal:** codegen related update ([b3aad10](https://github.com/e-invoice-be/e-invoice-java/commit/b3aad10fd43571a39c18361ddf3597d68a643531))
+* **internal:** codegen related update ([b5a6a0f](https://github.com/e-invoice-be/e-invoice-java/commit/b5a6a0f7aa5ed8d9a44f27f818da15da3ff30d3f))
+* **internal:** correct cache invalidation for `SKIP_MOCK_TESTS` ([524c037](https://github.com/e-invoice-be/e-invoice-java/commit/524c0373a029f9e0ac7429d05d0e9869dca8a723))
+* **internal:** update maven repo doc to include authentication ([9e69b7f](https://github.com/e-invoice-be/e-invoice-java/commit/9e69b7ff607be2392d5ab6e9796518e129c46fcc))
+
+
+### Documentation
+
+* remove `$` for better copy-pasteabality ([4b1c946](https://github.com/e-invoice-be/e-invoice-java/commit/4b1c946cf5e6403194165bf0c92f5160a5e95e32))
+
## 0.1.0-alpha.12 (2025-09-26)
Full Changelog: [v0.1.0-alpha.11...v0.1.0-alpha.12](https://github.com/e-invoice-be/e-invoice-java/compare/v0.1.0-alpha.11...v0.1.0-alpha.12)
diff --git a/LICENSE b/LICENSE
index 735c9bb..05f8e0b 100644
--- a/LICENSE
+++ b/LICENSE
@@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.
- Copyright 2025 E Invoice
+ Copyright 2026 E Invoice
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/README.md b/README.md
index af73d52..3b9ed83 100644
--- a/README.md
+++ b/README.md
@@ -2,16 +2,25 @@
-[](https://central.sonatype.com/artifact/com.e_invoice.api/e-invoice-java/0.1.0-alpha.12)
-[](https://javadoc.io/doc/com.e_invoice.api/e-invoice-java/0.1.0-alpha.12)
+[](https://central.sonatype.com/artifact/com.e_invoice.api/e-invoice-java/0.1.0-alpha.13)
+[](https://javadoc.io/doc/com.e_invoice.api/e-invoice-java/0.1.0-alpha.13)
The e-invoice.be Peppol SDK provides convenient access to the [e-invoice.be REST API](https://api.e-invoice.be) from applications written in Java.
+## MCP Server
+
+Use the E Invoice 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.
+
+[](https://cursor.com/en-US/install-mcp?name=e-invoice-api-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsImUtaW52b2ljZS1hcGktbWNwIl0sImVudiI6eyJFX0lOVk9JQ0VfQVBJX0tFWSI6Ik15IEFQSSBLZXkifX0)
+[](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22e-invoice-api-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22e-invoice-api-mcp%22%5D%2C%22env%22%3A%7B%22E_INVOICE_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 [api.e-invoice.be](https://api.e-invoice.be). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.e_invoice.api/e-invoice-java/0.1.0-alpha.12).
+The REST API documentation can be found on [api.e-invoice.be](https://api.e-invoice.be). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.e_invoice.api/e-invoice-java/0.1.0-alpha.13).
@@ -22,7 +31,7 @@ The REST API documentation can be found on [api.e-invoice.be](https://api.e-invo
### Gradle
```kotlin
-implementation("com.e_invoice.api:e-invoice-java:0.1.0-alpha.12")
+implementation("com.e_invoice.api:e-invoice-java:0.1.0-alpha.13")
```
### Maven
@@ -31,7 +40,7 @@ implementation("com.e_invoice.api:e-invoice-java:0.1.0-alpha.12")
com.e_invoice.api
e-invoice-java
- 0.1.0-alpha.12
+ 0.1.0-alpha.13
```
@@ -185,61 +194,57 @@ The SDK defines methods that accept files.
To upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html):
```java
-import com.e_invoice.api.models.documents.attachments.AttachmentAddParams;
-import com.e_invoice.api.models.documents.attachments.DocumentAttachment;
+import com.e_invoice.api.models.documents.DocumentCreateFromPdfParams;
+import com.e_invoice.api.models.documents.DocumentCreateFromPdfResponse;
import java.nio.file.Paths;
-AttachmentAddParams params = AttachmentAddParams.builder()
- .documentId("document_id")
+DocumentCreateFromPdfParams params = DocumentCreateFromPdfParams.builder()
.file(Paths.get("/path/to/file"))
.build();
-DocumentAttachment documentAttachment = client.documents().attachments().add(params);
+DocumentCreateFromPdfResponse response = client.documents().createFromPdf(params);
```
Or an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html):
```java
-import com.e_invoice.api.models.documents.attachments.AttachmentAddParams;
-import com.e_invoice.api.models.documents.attachments.DocumentAttachment;
+import com.e_invoice.api.models.documents.DocumentCreateFromPdfParams;
+import com.e_invoice.api.models.documents.DocumentCreateFromPdfResponse;
import java.net.URL;
-AttachmentAddParams params = AttachmentAddParams.builder()
- .documentId("document_id")
+DocumentCreateFromPdfParams params = DocumentCreateFromPdfParams.builder()
.file(new URL("https://example.com//path/to/file").openStream())
.build();
-DocumentAttachment documentAttachment = client.documents().attachments().add(params);
+DocumentCreateFromPdfResponse response = client.documents().createFromPdf(params);
```
Or a `byte[]` array:
```java
-import com.e_invoice.api.models.documents.attachments.AttachmentAddParams;
-import com.e_invoice.api.models.documents.attachments.DocumentAttachment;
+import com.e_invoice.api.models.documents.DocumentCreateFromPdfParams;
+import com.e_invoice.api.models.documents.DocumentCreateFromPdfResponse;
-AttachmentAddParams params = AttachmentAddParams.builder()
- .documentId("document_id")
+DocumentCreateFromPdfParams params = DocumentCreateFromPdfParams.builder()
.file("content".getBytes())
.build();
-DocumentAttachment documentAttachment = client.documents().attachments().add(params);
+DocumentCreateFromPdfResponse response = client.documents().createFromPdf(params);
```
Note that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/Values.kt):
```java
import com.e_invoice.api.core.MultipartField;
-import com.e_invoice.api.models.documents.attachments.AttachmentAddParams;
-import com.e_invoice.api.models.documents.attachments.DocumentAttachment;
+import com.e_invoice.api.models.documents.DocumentCreateFromPdfParams;
+import com.e_invoice.api.models.documents.DocumentCreateFromPdfResponse;
import java.io.InputStream;
import java.net.URL;
-AttachmentAddParams params = AttachmentAddParams.builder()
- .documentId("document_id")
+DocumentCreateFromPdfParams params = DocumentCreateFromPdfParams.builder()
.file(MultipartField.builder()
.value(new URL("https://example.com//path/to/file").openStream())
.filename("/path/to/file")
.build())
.build();
-DocumentAttachment documentAttachment = client.documents().attachments().add(params);
+DocumentCreateFromPdfResponse response = client.documents().createFromPdf(params);
```
## Raw responses
@@ -402,13 +407,13 @@ The SDK uses the standard [OkHttp logging interceptor](https://github.com/square
Enable logging by setting the `E_INVOICE_LOG` environment variable to `info`:
```sh
-$ export E_INVOICE_LOG=info
+export E_INVOICE_LOG=info
```
Or to `debug` for more verbose logging:
```sh
-$ export E_INVOICE_LOG=debug
+export E_INVOICE_LOG=debug
```
## ProGuard and R8
@@ -428,6 +433,8 @@ If the SDK threw an exception, but you're _certain_ the version is compatible, t
> [!CAUTION]
> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.
+Also note that there are bugs in older Jackson versions that can affect the SDK. We don't work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead.
+
## Network options
### Retries
diff --git a/build.gradle.kts b/build.gradle.kts
index c57fa31..a545472 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -9,7 +9,7 @@ repositories {
allprojects {
group = "com.e_invoice.api"
- version = "0.1.0-alpha.12" // x-release-please-version
+ version = "0.1.0-alpha.13" // x-release-please-version
}
subprojects {
diff --git a/buildSrc/src/main/kotlin/e-invoice.kotlin.gradle.kts b/buildSrc/src/main/kotlin/e-invoice.kotlin.gradle.kts
index 8541ea6..16c0db2 100644
--- a/buildSrc/src/main/kotlin/e-invoice.kotlin.gradle.kts
+++ b/buildSrc/src/main/kotlin/e-invoice.kotlin.gradle.kts
@@ -33,6 +33,9 @@ kotlin {
tasks.withType().configureEach {
systemProperty("junit.jupiter.execution.parallel.enabled", true)
systemProperty("junit.jupiter.execution.parallel.mode.default", "concurrent")
+
+ // `SKIP_MOCK_TESTS` affects which tests run so it must be added as input for proper cache invalidation.
+ inputs.property("skipMockTests", System.getenv("SKIP_MOCK_TESTS")).optional(true)
}
val ktfmt by configurations.creating
diff --git a/buildSrc/src/main/kotlin/e-invoice.publish.gradle.kts b/buildSrc/src/main/kotlin/e-invoice.publish.gradle.kts
index dc41057..078189f 100644
--- a/buildSrc/src/main/kotlin/e-invoice.publish.gradle.kts
+++ b/buildSrc/src/main/kotlin/e-invoice.publish.gradle.kts
@@ -40,6 +40,14 @@ configure {
}
}
}
+ repositories {
+ if (project.hasProperty("publishLocal")) {
+ maven {
+ name = "LocalFileSystem"
+ url = uri("${rootProject.layout.buildDirectory.get()}/local-maven-repo")
+ }
+ }
+ }
}
signing {
diff --git a/e-invoice-java-client-okhttp/build.gradle.kts b/e-invoice-java-client-okhttp/build.gradle.kts
index 83540c1..20efb7d 100644
--- a/e-invoice-java-client-okhttp/build.gradle.kts
+++ b/e-invoice-java-client-okhttp/build.gradle.kts
@@ -10,5 +10,6 @@ dependencies {
implementation("com.squareup.okhttp3:logging-interceptor:4.12.0")
testImplementation(kotlin("test"))
- testImplementation("org.assertj:assertj-core:3.25.3")
+ testImplementation("org.assertj:assertj-core:3.27.7")
+ testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2")
}
diff --git a/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/EInvoiceOkHttpClient.kt b/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/EInvoiceOkHttpClient.kt
index f723839..4dbfcfc 100644
--- a/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/EInvoiceOkHttpClient.kt
+++ b/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/EInvoiceOkHttpClient.kt
@@ -18,6 +18,7 @@ import java.time.Clock
import java.time.Duration
import java.util.Optional
import java.util.concurrent.Executor
+import java.util.concurrent.ExecutorService
import javax.net.ssl.HostnameVerifier
import javax.net.ssl.SSLSocketFactory
import javax.net.ssl.X509TrustManager
@@ -46,11 +47,31 @@ class EInvoiceOkHttpClient private constructor() {
class Builder internal constructor() {
private var clientOptions: ClientOptions.Builder = ClientOptions.builder()
+ private var dispatcherExecutorService: ExecutorService? = null
private var proxy: Proxy? = null
private var sslSocketFactory: SSLSocketFactory? = null
private var trustManager: X509TrustManager? = null
private var hostnameVerifier: HostnameVerifier? = null
+ /**
+ * The executor service to use for running HTTP requests.
+ *
+ * Defaults to OkHttp's
+ * [default executor service](https://github.com/square/okhttp/blob/ace792f443b2ffb17974f5c0d1cecdf589309f26/okhttp/src/commonJvmAndroid/kotlin/okhttp3/Dispatcher.kt#L98-L104).
+ *
+ * This class takes ownership of the executor service and shuts it down when closed.
+ */
+ fun dispatcherExecutorService(dispatcherExecutorService: ExecutorService?) = apply {
+ this.dispatcherExecutorService = dispatcherExecutorService
+ }
+
+ /**
+ * Alias for calling [Builder.dispatcherExecutorService] with
+ * `dispatcherExecutorService.orElse(null)`.
+ */
+ fun dispatcherExecutorService(dispatcherExecutorService: Optional) =
+ dispatcherExecutorService(dispatcherExecutorService.getOrNull())
+
fun proxy(proxy: Proxy?) = apply { this.proxy = proxy }
/** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */
@@ -309,6 +330,7 @@ class EInvoiceOkHttpClient private constructor() {
OkHttpClient.builder()
.timeout(clientOptions.timeout())
.proxy(proxy)
+ .dispatcherExecutorService(dispatcherExecutorService)
.sslSocketFactory(sslSocketFactory)
.trustManager(trustManager)
.hostnameVerifier(hostnameVerifier)
diff --git a/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/EInvoiceOkHttpClientAsync.kt b/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/EInvoiceOkHttpClientAsync.kt
index 225db7f..2f4d1e2 100644
--- a/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/EInvoiceOkHttpClientAsync.kt
+++ b/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/EInvoiceOkHttpClientAsync.kt
@@ -18,6 +18,7 @@ import java.time.Clock
import java.time.Duration
import java.util.Optional
import java.util.concurrent.Executor
+import java.util.concurrent.ExecutorService
import javax.net.ssl.HostnameVerifier
import javax.net.ssl.SSLSocketFactory
import javax.net.ssl.X509TrustManager
@@ -46,11 +47,31 @@ class EInvoiceOkHttpClientAsync private constructor() {
class Builder internal constructor() {
private var clientOptions: ClientOptions.Builder = ClientOptions.builder()
+ private var dispatcherExecutorService: ExecutorService? = null
private var proxy: Proxy? = null
private var sslSocketFactory: SSLSocketFactory? = null
private var trustManager: X509TrustManager? = null
private var hostnameVerifier: HostnameVerifier? = null
+ /**
+ * The executor service to use for running HTTP requests.
+ *
+ * Defaults to OkHttp's
+ * [default executor service](https://github.com/square/okhttp/blob/ace792f443b2ffb17974f5c0d1cecdf589309f26/okhttp/src/commonJvmAndroid/kotlin/okhttp3/Dispatcher.kt#L98-L104).
+ *
+ * This class takes ownership of the executor service and shuts it down when closed.
+ */
+ fun dispatcherExecutorService(dispatcherExecutorService: ExecutorService?) = apply {
+ this.dispatcherExecutorService = dispatcherExecutorService
+ }
+
+ /**
+ * Alias for calling [Builder.dispatcherExecutorService] with
+ * `dispatcherExecutorService.orElse(null)`.
+ */
+ fun dispatcherExecutorService(dispatcherExecutorService: Optional) =
+ dispatcherExecutorService(dispatcherExecutorService.getOrNull())
+
fun proxy(proxy: Proxy?) = apply { this.proxy = proxy }
/** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */
@@ -309,6 +330,7 @@ class EInvoiceOkHttpClientAsync private constructor() {
OkHttpClient.builder()
.timeout(clientOptions.timeout())
.proxy(proxy)
+ .dispatcherExecutorService(dispatcherExecutorService)
.sslSocketFactory(sslSocketFactory)
.trustManager(trustManager)
.hostnameVerifier(hostnameVerifier)
diff --git a/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/OkHttpClient.kt b/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/OkHttpClient.kt
index f3c8245..9d16508 100644
--- a/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/OkHttpClient.kt
+++ b/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/OkHttpClient.kt
@@ -13,12 +13,15 @@ import java.io.IOException
import java.io.InputStream
import java.net.Proxy
import java.time.Duration
+import java.util.concurrent.CancellationException
import java.util.concurrent.CompletableFuture
+import java.util.concurrent.ExecutorService
import javax.net.ssl.HostnameVerifier
import javax.net.ssl.SSLSocketFactory
import javax.net.ssl.X509TrustManager
import okhttp3.Call
import okhttp3.Callback
+import okhttp3.Dispatcher
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.MediaType
import okhttp3.MediaType.Companion.toMediaType
@@ -29,8 +32,8 @@ import okhttp3.Response
import okhttp3.logging.HttpLoggingInterceptor
import okio.BufferedSink
-class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient) :
- HttpClient {
+class OkHttpClient
+private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClient) : HttpClient {
override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse {
val call = newCall(request, requestOptions)
@@ -50,20 +53,25 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC
): CompletableFuture {
val future = CompletableFuture()
- request.body?.run { future.whenComplete { _, _ -> close() } }
-
- newCall(request, requestOptions)
- .enqueue(
- object : Callback {
- override fun onResponse(call: Call, response: Response) {
- future.complete(response.toResponse())
- }
+ val call = newCall(request, requestOptions)
+ call.enqueue(
+ object : Callback {
+ override fun onResponse(call: Call, response: Response) {
+ future.complete(response.toResponse())
+ }
- override fun onFailure(call: Call, e: IOException) {
- future.completeExceptionally(EInvoiceIoException("Request failed", e))
- }
+ override fun onFailure(call: Call, e: IOException) {
+ future.completeExceptionally(EInvoiceIoException("Request failed", e))
}
- )
+ }
+ )
+
+ future.whenComplete { _, e ->
+ if (e is CancellationException) {
+ call.cancel()
+ }
+ request.body?.close()
+ }
return future
}
@@ -109,19 +117,19 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC
val builder = Request.Builder().url(toUrl()).method(method.name, body)
headers.names().forEach { name ->
- headers.values(name).forEach { builder.header(name, it) }
+ headers.values(name).forEach { builder.addHeader(name, it) }
}
if (
!headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0
) {
- builder.header(
+ builder.addHeader(
"X-Stainless-Read-Timeout",
Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString(),
)
}
if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) {
- builder.header(
+ builder.addHeader(
"X-Stainless-Timeout",
Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString(),
)
@@ -192,6 +200,7 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC
private var timeout: Timeout = Timeout.default()
private var proxy: Proxy? = null
+ private var dispatcherExecutorService: ExecutorService? = null
private var sslSocketFactory: SSLSocketFactory? = null
private var trustManager: X509TrustManager? = null
private var hostnameVerifier: HostnameVerifier? = null
@@ -202,6 +211,10 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC
fun proxy(proxy: Proxy?) = apply { this.proxy = proxy }
+ fun dispatcherExecutorService(dispatcherExecutorService: ExecutorService?) = apply {
+ this.dispatcherExecutorService = dispatcherExecutorService
+ }
+
fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply {
this.sslSocketFactory = sslSocketFactory
}
@@ -217,12 +230,16 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC
fun build(): OkHttpClient =
OkHttpClient(
okhttp3.OkHttpClient.Builder()
+ // `RetryingHttpClient` handles retries if the user enabled them.
+ .retryOnConnectionFailure(false)
.connectTimeout(timeout.connect())
.readTimeout(timeout.read())
.writeTimeout(timeout.write())
.callTimeout(timeout.request())
.proxy(proxy)
.apply {
+ dispatcherExecutorService?.let { dispatcher(Dispatcher(it)) }
+
val sslSocketFactory = sslSocketFactory
val trustManager = trustManager
if (sslSocketFactory != null && trustManager != null) {
diff --git a/e-invoice-java-client-okhttp/src/test/kotlin/com/e_invoice/api/client/okhttp/OkHttpClientTest.kt b/e-invoice-java-client-okhttp/src/test/kotlin/com/e_invoice/api/client/okhttp/OkHttpClientTest.kt
new file mode 100644
index 0000000..faec5b4
--- /dev/null
+++ b/e-invoice-java-client-okhttp/src/test/kotlin/com/e_invoice/api/client/okhttp/OkHttpClientTest.kt
@@ -0,0 +1,44 @@
+package com.e_invoice.api.client.okhttp
+
+import com.e_invoice.api.core.http.HttpMethod
+import com.e_invoice.api.core.http.HttpRequest
+import com.github.tomakehurst.wiremock.client.WireMock.*
+import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo
+import com.github.tomakehurst.wiremock.junit5.WireMockTest
+import org.assertj.core.api.Assertions.assertThat
+import org.junit.jupiter.api.BeforeEach
+import org.junit.jupiter.api.Test
+import org.junit.jupiter.api.parallel.ResourceLock
+
+@WireMockTest
+@ResourceLock("https://github.com/wiremock/wiremock/issues/169")
+internal class OkHttpClientTest {
+
+ private lateinit var baseUrl: String
+ private lateinit var httpClient: OkHttpClient
+
+ @BeforeEach
+ fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) {
+ baseUrl = wmRuntimeInfo.httpBaseUrl
+ httpClient = OkHttpClient.builder().build()
+ }
+
+ @Test
+ fun executeAsync_whenFutureCancelled_cancelsUnderlyingCall() {
+ stubFor(post(urlPathEqualTo("/something")).willReturn(ok()))
+ val responseFuture =
+ httpClient.executeAsync(
+ HttpRequest.builder()
+ .method(HttpMethod.POST)
+ .baseUrl(baseUrl)
+ .addPathSegment("something")
+ .build()
+ )
+ val call = httpClient.okHttpClient.dispatcher.runningCalls().single()
+
+ responseFuture.cancel(false)
+
+ // Should have cancelled the underlying call
+ assertThat(call.isCanceled()).isTrue()
+ }
+}
diff --git a/e-invoice-java-core/build.gradle.kts b/e-invoice-java-core/build.gradle.kts
index 50c3534..0465618 100644
--- a/e-invoice-java-core/build.gradle.kts
+++ b/e-invoice-java-core/build.gradle.kts
@@ -5,14 +5,16 @@ plugins {
configurations.all {
resolutionStrategy {
- // Compile and test against a lower Jackson version to ensure we're compatible with it.
- // We publish with a higher version (see below) to ensure users depend on a secure version by default.
- force("com.fasterxml.jackson.core:jackson-core:2.13.4")
- force("com.fasterxml.jackson.core:jackson-databind:2.13.4")
- force("com.fasterxml.jackson.core:jackson-annotations:2.13.4")
- force("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.13.4")
- force("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.4")
- force("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.4")
+ // Compile and test against a lower Jackson version to ensure we're compatible with it. Note that
+ // we generally support 2.13.4, but test against 2.14.0 because 2.13.4 has some annoying (but
+ // niche) bugs (users should upgrade if they encounter them). We publish with a higher version
+ // (see below) to ensure users depend on a secure version by default.
+ force("com.fasterxml.jackson.core:jackson-core:2.14.0")
+ force("com.fasterxml.jackson.core:jackson-databind:2.14.0")
+ force("com.fasterxml.jackson.core:jackson-annotations:2.14.0")
+ force("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.14.0")
+ force("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.0")
+ force("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.0")
}
}
@@ -31,7 +33,7 @@ dependencies {
testImplementation(kotlin("test"))
testImplementation(project(":e-invoice-java-client-okhttp"))
testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2")
- testImplementation("org.assertj:assertj-core:3.25.3")
+ testImplementation("org.assertj:assertj-core:3.27.7")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.3")
testImplementation("org.junit-pioneer:junit-pioneer:1.9.1")
diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClient.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClient.kt
index bdb63cf..a542ec7 100644
--- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClient.kt
+++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClient.kt
@@ -6,6 +6,7 @@ import com.e_invoice.api.core.ClientOptions
import com.e_invoice.api.services.blocking.DocumentService
import com.e_invoice.api.services.blocking.InboxService
import com.e_invoice.api.services.blocking.LookupService
+import com.e_invoice.api.services.blocking.MeService
import com.e_invoice.api.services.blocking.OutboxService
import com.e_invoice.api.services.blocking.ValidateService
import com.e_invoice.api.services.blocking.WebhookService
@@ -57,6 +58,8 @@ interface EInvoiceClient {
fun lookup(): LookupService
+ fun me(): MeService
+
fun webhooks(): WebhookService
/**
@@ -92,6 +95,8 @@ interface EInvoiceClient {
fun lookup(): LookupService.WithRawResponse
+ fun me(): MeService.WithRawResponse
+
fun webhooks(): WebhookService.WithRawResponse
}
}
diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClientAsync.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClientAsync.kt
index 41b20ab..5fed5d0 100644
--- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClientAsync.kt
+++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClientAsync.kt
@@ -6,6 +6,7 @@ import com.e_invoice.api.core.ClientOptions
import com.e_invoice.api.services.async.DocumentServiceAsync
import com.e_invoice.api.services.async.InboxServiceAsync
import com.e_invoice.api.services.async.LookupServiceAsync
+import com.e_invoice.api.services.async.MeServiceAsync
import com.e_invoice.api.services.async.OutboxServiceAsync
import com.e_invoice.api.services.async.ValidateServiceAsync
import com.e_invoice.api.services.async.WebhookServiceAsync
@@ -57,6 +58,8 @@ interface EInvoiceClientAsync {
fun lookup(): LookupServiceAsync
+ fun me(): MeServiceAsync
+
fun webhooks(): WebhookServiceAsync
/**
@@ -96,6 +99,8 @@ interface EInvoiceClientAsync {
fun lookup(): LookupServiceAsync.WithRawResponse
+ fun me(): MeServiceAsync.WithRawResponse
+
fun webhooks(): WebhookServiceAsync.WithRawResponse
}
}
diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClientAsyncImpl.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClientAsyncImpl.kt
index 68f8a26..4c1c28a 100644
--- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClientAsyncImpl.kt
+++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClientAsyncImpl.kt
@@ -10,6 +10,8 @@ import com.e_invoice.api.services.async.InboxServiceAsync
import com.e_invoice.api.services.async.InboxServiceAsyncImpl
import com.e_invoice.api.services.async.LookupServiceAsync
import com.e_invoice.api.services.async.LookupServiceAsyncImpl
+import com.e_invoice.api.services.async.MeServiceAsync
+import com.e_invoice.api.services.async.MeServiceAsyncImpl
import com.e_invoice.api.services.async.OutboxServiceAsync
import com.e_invoice.api.services.async.OutboxServiceAsyncImpl
import com.e_invoice.api.services.async.ValidateServiceAsync
@@ -55,6 +57,8 @@ class EInvoiceClientAsyncImpl(private val clientOptions: ClientOptions) : EInvoi
LookupServiceAsyncImpl(clientOptionsWithUserAgent)
}
+ private val me: MeServiceAsync by lazy { MeServiceAsyncImpl(clientOptionsWithUserAgent) }
+
private val webhooks: WebhookServiceAsync by lazy {
WebhookServiceAsyncImpl(clientOptionsWithUserAgent)
}
@@ -76,6 +80,8 @@ class EInvoiceClientAsyncImpl(private val clientOptions: ClientOptions) : EInvoi
override fun lookup(): LookupServiceAsync = lookup
+ override fun me(): MeServiceAsync = me
+
override fun webhooks(): WebhookServiceAsync = webhooks
override fun close() = clientOptions.close()
@@ -103,6 +109,10 @@ class EInvoiceClientAsyncImpl(private val clientOptions: ClientOptions) : EInvoi
LookupServiceAsyncImpl.WithRawResponseImpl(clientOptions)
}
+ private val me: MeServiceAsync.WithRawResponse by lazy {
+ MeServiceAsyncImpl.WithRawResponseImpl(clientOptions)
+ }
+
private val webhooks: WebhookServiceAsync.WithRawResponse by lazy {
WebhookServiceAsyncImpl.WithRawResponseImpl(clientOptions)
}
@@ -124,6 +134,8 @@ class EInvoiceClientAsyncImpl(private val clientOptions: ClientOptions) : EInvoi
override fun lookup(): LookupServiceAsync.WithRawResponse = lookup
+ override fun me(): MeServiceAsync.WithRawResponse = me
+
override fun webhooks(): WebhookServiceAsync.WithRawResponse = webhooks
}
}
diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClientImpl.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClientImpl.kt
index ecf0dc0..ff71e20 100644
--- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClientImpl.kt
+++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClientImpl.kt
@@ -10,6 +10,8 @@ import com.e_invoice.api.services.blocking.InboxService
import com.e_invoice.api.services.blocking.InboxServiceImpl
import com.e_invoice.api.services.blocking.LookupService
import com.e_invoice.api.services.blocking.LookupServiceImpl
+import com.e_invoice.api.services.blocking.MeService
+import com.e_invoice.api.services.blocking.MeServiceImpl
import com.e_invoice.api.services.blocking.OutboxService
import com.e_invoice.api.services.blocking.OutboxServiceImpl
import com.e_invoice.api.services.blocking.ValidateService
@@ -49,6 +51,8 @@ class EInvoiceClientImpl(private val clientOptions: ClientOptions) : EInvoiceCli
private val lookup: LookupService by lazy { LookupServiceImpl(clientOptionsWithUserAgent) }
+ private val me: MeService by lazy { MeServiceImpl(clientOptionsWithUserAgent) }
+
private val webhooks: WebhookService by lazy { WebhookServiceImpl(clientOptionsWithUserAgent) }
override fun async(): EInvoiceClientAsync = async
@@ -68,6 +72,8 @@ class EInvoiceClientImpl(private val clientOptions: ClientOptions) : EInvoiceCli
override fun lookup(): LookupService = lookup
+ override fun me(): MeService = me
+
override fun webhooks(): WebhookService = webhooks
override fun close() = clientOptions.close()
@@ -95,6 +101,10 @@ class EInvoiceClientImpl(private val clientOptions: ClientOptions) : EInvoiceCli
LookupServiceImpl.WithRawResponseImpl(clientOptions)
}
+ private val me: MeService.WithRawResponse by lazy {
+ MeServiceImpl.WithRawResponseImpl(clientOptions)
+ }
+
private val webhooks: WebhookService.WithRawResponse by lazy {
WebhookServiceImpl.WithRawResponseImpl(clientOptions)
}
@@ -116,6 +126,8 @@ class EInvoiceClientImpl(private val clientOptions: ClientOptions) : EInvoiceCli
override fun lookup(): LookupService.WithRawResponse = lookup
+ override fun me(): MeService.WithRawResponse = me
+
override fun webhooks(): WebhookService.WithRawResponse = webhooks
}
}
diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/ClientOptions.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/ClientOptions.kt
index 2586a9d..a29ecb3 100644
--- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/ClientOptions.kt
+++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/ClientOptions.kt
@@ -450,6 +450,7 @@ private constructor(
headers.put("X-Stainless-Package-Version", getPackageVersion())
headers.put("X-Stainless-Runtime", "JRE")
headers.put("X-Stainless-Runtime-Version", getJavaVersion())
+ headers.put("X-Stainless-Kotlin-Version", KotlinVersion.CURRENT.toString())
apiKey.let {
if (!it.isEmpty()) {
headers.put("Authorization", "Bearer $it")
diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/ObjectMappers.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/ObjectMappers.kt
index 50e9584..54ad6ad 100644
--- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/ObjectMappers.kt
+++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/ObjectMappers.kt
@@ -24,7 +24,8 @@ import java.io.InputStream
import java.time.DateTimeException
import java.time.LocalDate
import java.time.LocalDateTime
-import java.time.ZonedDateTime
+import java.time.OffsetDateTime
+import java.time.ZoneId
import java.time.format.DateTimeFormatter
import java.time.temporal.ChronoField
@@ -36,7 +37,7 @@ fun jsonMapper(): JsonMapper =
.addModule(
SimpleModule()
.addSerializer(InputStreamSerializer)
- .addDeserializer(LocalDateTime::class.java, LenientLocalDateTimeDeserializer())
+ .addDeserializer(OffsetDateTime::class.java, LenientOffsetDateTimeDeserializer())
)
.withCoercionConfig(LogicalType.Boolean) {
it.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail)
@@ -47,6 +48,7 @@ fun jsonMapper(): JsonMapper =
}
.withCoercionConfig(LogicalType.Integer) {
it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail)
+ .setCoercion(CoercionInputShape.Float, CoercionAction.Fail)
.setCoercion(CoercionInputShape.String, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Array, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Object, CoercionAction.Fail)
@@ -64,6 +66,12 @@ fun jsonMapper(): JsonMapper =
.setCoercion(CoercionInputShape.Array, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Object, CoercionAction.Fail)
}
+ .withCoercionConfig(LogicalType.DateTime) {
+ it.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail)
+ .setCoercion(CoercionInputShape.Float, CoercionAction.Fail)
+ .setCoercion(CoercionInputShape.Array, CoercionAction.Fail)
+ .setCoercion(CoercionInputShape.Object, CoercionAction.Fail)
+ }
.withCoercionConfig(LogicalType.Array) {
it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail)
.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail)
@@ -124,10 +132,10 @@ private object InputStreamSerializer : BaseSerializer(InputStream::
}
/**
- * A deserializer that can deserialize [LocalDateTime] from datetimes, dates, and zoned datetimes.
+ * A deserializer that can deserialize [OffsetDateTime] from datetimes, dates, and zoned datetimes.
*/
-private class LenientLocalDateTimeDeserializer :
- StdDeserializer(LocalDateTime::class.java) {
+private class LenientOffsetDateTimeDeserializer :
+ StdDeserializer(OffsetDateTime::class.java) {
companion object {
@@ -141,7 +149,7 @@ private class LenientLocalDateTimeDeserializer :
override fun logicalType(): LogicalType = LogicalType.DateTime
- override fun deserialize(p: JsonParser, context: DeserializationContext?): LocalDateTime {
+ override fun deserialize(p: JsonParser, context: DeserializationContext): OffsetDateTime {
val exceptions = mutableListOf()
for (formatter in DATE_TIME_FORMATTERS) {
@@ -150,17 +158,20 @@ private class LenientLocalDateTimeDeserializer :
return when {
!temporal.isSupported(ChronoField.HOUR_OF_DAY) ->
- LocalDate.from(temporal).atStartOfDay()
+ LocalDate.from(temporal)
+ .atStartOfDay()
+ .atZone(ZoneId.of("UTC"))
+ .toOffsetDateTime()
!temporal.isSupported(ChronoField.OFFSET_SECONDS) ->
- LocalDateTime.from(temporal)
- else -> ZonedDateTime.from(temporal).toLocalDateTime()
+ LocalDateTime.from(temporal).atZone(ZoneId.of("UTC")).toOffsetDateTime()
+ else -> OffsetDateTime.from(temporal)
}
} catch (e: DateTimeException) {
exceptions.add(e)
}
}
- throw JsonParseException(p, "Cannot parse `LocalDateTime` from value: ${p.text}").apply {
+ throw JsonParseException(p, "Cannot parse `OffsetDateTime` from value: ${p.text}").apply {
exceptions.forEach { addSuppressed(it) }
}
}
diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/http/HttpRequest.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/http/HttpRequest.kt
index 9a52e88..9a0db4d 100644
--- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/http/HttpRequest.kt
+++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/http/HttpRequest.kt
@@ -2,6 +2,7 @@ package com.e_invoice.api.core.http
import com.e_invoice.api.core.checkRequired
import com.e_invoice.api.core.toImmutable
+import java.net.URLEncoder
class HttpRequest
private constructor(
@@ -13,6 +14,35 @@ private constructor(
@get:JvmName("body") val body: HttpRequestBody?,
) {
+ fun url(): String = buildString {
+ append(baseUrl)
+
+ pathSegments.forEach { segment ->
+ if (!endsWith("/")) {
+ append("/")
+ }
+ append(URLEncoder.encode(segment, "UTF-8"))
+ }
+
+ if (queryParams.isEmpty()) {
+ return@buildString
+ }
+
+ append("?")
+ var isFirst = true
+ queryParams.keys().forEach { key ->
+ queryParams.values(key).forEach { value ->
+ if (!isFirst) {
+ append("&")
+ }
+ append(URLEncoder.encode(key, "UTF-8"))
+ append("=")
+ append(URLEncoder.encode(value, "UTF-8"))
+ isFirst = false
+ }
+ }
+ }
+
fun toBuilder(): Builder = Builder().from(this)
override fun toString(): String =
diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/http/RetryingHttpClient.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/http/RetryingHttpClient.kt
index be62ba9..db2fef5 100644
--- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/http/RetryingHttpClient.kt
+++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/http/RetryingHttpClient.kt
@@ -31,10 +31,6 @@ private constructor(
) : HttpClient {
override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse {
- if (!isRetryable(request) || maxRetries <= 0) {
- return httpClient.execute(request, requestOptions)
- }
-
var modifiedRequest = maybeAddIdempotencyHeader(request)
// Don't send the current retry count in the headers if the caller set their own value.
@@ -48,6 +44,10 @@ private constructor(
modifiedRequest = setRetryCountHeader(modifiedRequest, retries)
}
+ if (!isRetryable(modifiedRequest)) {
+ return httpClient.execute(modifiedRequest, requestOptions)
+ }
+
val response =
try {
val response = httpClient.execute(modifiedRequest, requestOptions)
@@ -75,10 +75,6 @@ private constructor(
request: HttpRequest,
requestOptions: RequestOptions,
): CompletableFuture {
- if (!isRetryable(request) || maxRetries <= 0) {
- return httpClient.executeAsync(request, requestOptions)
- }
-
val modifiedRequest = maybeAddIdempotencyHeader(request)
// Don't send the current retry count in the headers if the caller set their own value.
@@ -94,8 +90,12 @@ private constructor(
val requestWithRetryCount =
if (shouldSendRetryCount) setRetryCountHeader(request, retries) else request
- return httpClient
- .executeAsync(requestWithRetryCount, requestOptions)
+ val responseFuture = httpClient.executeAsync(requestWithRetryCount, requestOptions)
+ if (!isRetryable(requestWithRetryCount)) {
+ return responseFuture
+ }
+
+ return responseFuture
.handleAsync(
fun(
response: HttpResponse?,
diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Allowance.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Allowance.kt
new file mode 100644
index 0000000..0351698
--- /dev/null
+++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Allowance.kt
@@ -0,0 +1,845 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package com.e_invoice.api.models.documents
+
+import com.e_invoice.api.core.Enum
+import com.e_invoice.api.core.ExcludeMissing
+import com.e_invoice.api.core.JsonField
+import com.e_invoice.api.core.JsonMissing
+import com.e_invoice.api.core.JsonValue
+import com.e_invoice.api.errors.EInvoiceInvalidDataException
+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
+
+/** An allowance is a discount for example for early payment, volume discount, etc. */
+class Allowance
+@JsonCreator(mode = JsonCreator.Mode.DISABLED)
+private constructor(
+ private val amount: JsonField,
+ private val baseAmount: JsonField,
+ private val multiplierFactor: JsonField,
+ private val reason: JsonField,
+ private val reasonCode: JsonField,
+ private val taxCode: JsonField,
+ private val taxRate: JsonField,
+ private val additionalProperties: MutableMap,
+) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(),
+ @JsonProperty("base_amount")
+ @ExcludeMissing
+ baseAmount: JsonField = JsonMissing.of(),
+ @JsonProperty("multiplier_factor")
+ @ExcludeMissing
+ multiplierFactor: JsonField = JsonMissing.of(),
+ @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(),
+ @JsonProperty("reason_code")
+ @ExcludeMissing
+ reasonCode: JsonField = JsonMissing.of(),
+ @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(),
+ @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(),
+ ) : this(
+ amount,
+ baseAmount,
+ multiplierFactor,
+ reason,
+ reasonCode,
+ taxCode,
+ taxRate,
+ mutableMapOf(),
+ )
+
+ /**
+ * The allowance amount, without VAT. Must be rounded to maximum 2 decimals
+ *
+ * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun amount(): Optional = amount.getOptional("amount")
+
+ /**
+ * The base amount that may be used, in conjunction with the allowance percentage, to calculate
+ * the allowance amount. Must be rounded to maximum 2 decimals
+ *
+ * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun baseAmount(): Optional = baseAmount.getOptional("base_amount")
+
+ /**
+ * The percentage that may be used, in conjunction with the allowance base amount, to calculate
+ * the allowance amount. To state 20%, use value 20. Must be rounded to maximum 2 decimals
+ *
+ * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun multiplierFactor(): Optional = multiplierFactor.getOptional("multiplier_factor")
+
+ /**
+ * The reason for the allowance
+ *
+ * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun reason(): Optional = reason.getOptional("reason")
+
+ /**
+ * Allowance reason codes for invoice discounts and charges
+ *
+ * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun reasonCode(): Optional = reasonCode.getOptional("reason_code")
+
+ /**
+ * The VAT category code that applies to the allowance
+ *
+ * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun taxCode(): Optional = taxCode.getOptional("tax_code")
+
+ /**
+ * The VAT rate, represented as percentage that applies to the allowance. Must be rounded to
+ * maximum 2 decimals
+ *
+ * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun taxRate(): Optional = taxRate.getOptional("tax_rate")
+
+ /**
+ * 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 [baseAmount].
+ *
+ * Unlike [baseAmount], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("base_amount") @ExcludeMissing fun _baseAmount(): JsonField = baseAmount
+
+ /**
+ * Returns the raw JSON value of [multiplierFactor].
+ *
+ * Unlike [multiplierFactor], this method doesn't throw if the JSON field has an unexpected
+ * type.
+ */
+ @JsonProperty("multiplier_factor")
+ @ExcludeMissing
+ fun _multiplierFactor(): JsonField = multiplierFactor
+
+ /**
+ * Returns the raw JSON value of [reason].
+ *
+ * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason
+
+ /**
+ * Returns the raw JSON value of [reasonCode].
+ *
+ * Unlike [reasonCode], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("reason_code")
+ @ExcludeMissing
+ fun _reasonCode(): JsonField = reasonCode
+
+ /**
+ * Returns the raw JSON value of [taxCode].
+ *
+ * Unlike [taxCode], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("tax_code") @ExcludeMissing fun _taxCode(): JsonField = taxCode
+
+ /**
+ * Returns the raw JSON value of [taxRate].
+ *
+ * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate
+
+ @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 [Allowance]. */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [Allowance]. */
+ class Builder internal constructor() {
+
+ private var amount: JsonField = JsonMissing.of()
+ private var baseAmount: JsonField = JsonMissing.of()
+ private var multiplierFactor: JsonField = JsonMissing.of()
+ private var reason: JsonField = JsonMissing.of()
+ private var reasonCode: JsonField = JsonMissing.of()
+ private var taxCode: JsonField = JsonMissing.of()
+ private var taxRate: JsonField = JsonMissing.of()
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(allowance: Allowance) = apply {
+ amount = allowance.amount
+ baseAmount = allowance.baseAmount
+ multiplierFactor = allowance.multiplierFactor
+ reason = allowance.reason
+ reasonCode = allowance.reasonCode
+ taxCode = allowance.taxCode
+ taxRate = allowance.taxRate
+ additionalProperties = allowance.additionalProperties.toMutableMap()
+ }
+
+ /** The allowance amount, without VAT. Must be rounded to maximum 2 decimals */
+ fun amount(amount: String?) = amount(JsonField.ofNullable(amount))
+
+ /** 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 [String] 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 }
+
+ /**
+ * The base amount that may be used, in conjunction with the allowance percentage, to
+ * calculate the allowance amount. Must be rounded to maximum 2 decimals
+ */
+ fun baseAmount(baseAmount: String?) = baseAmount(JsonField.ofNullable(baseAmount))
+
+ /** Alias for calling [Builder.baseAmount] with `baseAmount.orElse(null)`. */
+ fun baseAmount(baseAmount: Optional) = baseAmount(baseAmount.getOrNull())
+
+ /**
+ * Sets [Builder.baseAmount] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.baseAmount] with a well-typed [String] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet supported
+ * value.
+ */
+ fun baseAmount(baseAmount: JsonField) = apply { this.baseAmount = baseAmount }
+
+ /**
+ * The percentage that may be used, in conjunction with the allowance base amount, to
+ * calculate the allowance amount. To state 20%, use value 20. Must be rounded to maximum 2
+ * decimals
+ */
+ fun multiplierFactor(multiplierFactor: String?) =
+ multiplierFactor(JsonField.ofNullable(multiplierFactor))
+
+ /** Alias for calling [Builder.multiplierFactor] with `multiplierFactor.orElse(null)`. */
+ fun multiplierFactor(multiplierFactor: Optional) =
+ multiplierFactor(multiplierFactor.getOrNull())
+
+ /**
+ * Sets [Builder.multiplierFactor] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.multiplierFactor] with a well-typed [String] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun multiplierFactor(multiplierFactor: JsonField) = apply {
+ this.multiplierFactor = multiplierFactor
+ }
+
+ /** The reason for the allowance */
+ fun reason(reason: String?) = reason(JsonField.ofNullable(reason))
+
+ /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */
+ fun reason(reason: Optional) = reason(reason.getOrNull())
+
+ /**
+ * Sets [Builder.reason] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.reason] with a well-typed [String] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun reason(reason: JsonField) = apply { this.reason = reason }
+
+ /** Allowance reason codes for invoice discounts and charges */
+ fun reasonCode(reasonCode: ReasonCode?) = reasonCode(JsonField.ofNullable(reasonCode))
+
+ /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */
+ fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull())
+
+ /**
+ * Sets [Builder.reasonCode] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.reasonCode] with a well-typed [ReasonCode] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode }
+
+ /** The VAT category code that applies to the allowance */
+ fun taxCode(taxCode: TaxCode) = taxCode(JsonField.of(taxCode))
+
+ /**
+ * Sets [Builder.taxCode] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.taxCode] with a well-typed [TaxCode] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode }
+
+ /**
+ * The VAT rate, represented as percentage that applies to the allowance. Must be rounded to
+ * maximum 2 decimals
+ */
+ fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate))
+
+ /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */
+ fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull())
+
+ /**
+ * Sets [Builder.taxRate] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.taxRate] with a well-typed [String] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate }
+
+ 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 [Allowance].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ */
+ fun build(): Allowance =
+ Allowance(
+ amount,
+ baseAmount,
+ multiplierFactor,
+ reason,
+ reasonCode,
+ taxCode,
+ taxRate,
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ fun validate(): Allowance = apply {
+ if (validated) {
+ return@apply
+ }
+
+ amount()
+ baseAmount()
+ multiplierFactor()
+ reason()
+ reasonCode().ifPresent { it.validate() }
+ taxCode().ifPresent { it.validate() }
+ taxRate()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: EInvoiceInvalidDataException) {
+ 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 (amount.asKnown().isPresent) 1 else 0) +
+ (if (baseAmount.asKnown().isPresent) 1 else 0) +
+ (if (multiplierFactor.asKnown().isPresent) 1 else 0) +
+ (if (reason.asKnown().isPresent) 1 else 0) +
+ (reasonCode.asKnown().getOrNull()?.validity() ?: 0) +
+ (taxCode.asKnown().getOrNull()?.validity() ?: 0) +
+ (if (taxRate.asKnown().isPresent) 1 else 0)
+
+ /** Allowance reason codes for invoice discounts and charges */
+ class ReasonCode @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 _41 = of("41")
+
+ @JvmField val _42 = of("42")
+
+ @JvmField val _60 = of("60")
+
+ @JvmField val _62 = of("62")
+
+ @JvmField val _63 = of("63")
+
+ @JvmField val _64 = of("64")
+
+ @JvmField val _65 = of("65")
+
+ @JvmField val _66 = of("66")
+
+ @JvmField val _67 = of("67")
+
+ @JvmField val _68 = of("68")
+
+ @JvmField val _70 = of("70")
+
+ @JvmField val _71 = of("71")
+
+ @JvmField val _88 = of("88")
+
+ @JvmField val _95 = of("95")
+
+ @JvmField val _100 = of("100")
+
+ @JvmField val _102 = of("102")
+
+ @JvmField val _103 = of("103")
+
+ @JvmField val _104 = of("104")
+
+ @JvmField val _105 = of("105")
+
+ @JvmStatic fun of(value: String) = ReasonCode(JsonField.of(value))
+ }
+
+ /** An enum containing [ReasonCode]'s known values. */
+ enum class Known {
+ _41,
+ _42,
+ _60,
+ _62,
+ _63,
+ _64,
+ _65,
+ _66,
+ _67,
+ _68,
+ _70,
+ _71,
+ _88,
+ _95,
+ _100,
+ _102,
+ _103,
+ _104,
+ _105,
+ }
+
+ /**
+ * An enum containing [ReasonCode]'s known values, as well as an [_UNKNOWN] member.
+ *
+ * An instance of [ReasonCode] 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 {
+ _41,
+ _42,
+ _60,
+ _62,
+ _63,
+ _64,
+ _65,
+ _66,
+ _67,
+ _68,
+ _70,
+ _71,
+ _88,
+ _95,
+ _100,
+ _102,
+ _103,
+ _104,
+ _105,
+ /**
+ * An enum member indicating that [ReasonCode] 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) {
+ _41 -> Value._41
+ _42 -> Value._42
+ _60 -> Value._60
+ _62 -> Value._62
+ _63 -> Value._63
+ _64 -> Value._64
+ _65 -> Value._65
+ _66 -> Value._66
+ _67 -> Value._67
+ _68 -> Value._68
+ _70 -> Value._70
+ _71 -> Value._71
+ _88 -> Value._88
+ _95 -> Value._95
+ _100 -> Value._100
+ _102 -> Value._102
+ _103 -> Value._103
+ _104 -> Value._104
+ _105 -> Value._105
+ 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 EInvoiceInvalidDataException if this class instance's value is a not a known
+ * member.
+ */
+ fun known(): Known =
+ when (this) {
+ _41 -> Known._41
+ _42 -> Known._42
+ _60 -> Known._60
+ _62 -> Known._62
+ _63 -> Known._63
+ _64 -> Known._64
+ _65 -> Known._65
+ _66 -> Known._66
+ _67 -> Known._67
+ _68 -> Known._68
+ _70 -> Known._70
+ _71 -> Known._71
+ _88 -> Known._88
+ _95 -> Known._95
+ _100 -> Known._100
+ _102 -> Known._102
+ _103 -> Known._103
+ _104 -> Known._104
+ _105 -> Known._105
+ else -> throw EInvoiceInvalidDataException("Unknown ReasonCode: $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 EInvoiceInvalidDataException if this class instance's value does not have the
+ * expected primitive type.
+ */
+ fun asString(): String =
+ _value().asString().orElseThrow {
+ EInvoiceInvalidDataException("Value is not a String")
+ }
+
+ private var validated: Boolean = false
+
+ fun validate(): ReasonCode = apply {
+ if (validated) {
+ return@apply
+ }
+
+ known()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: EInvoiceInvalidDataException) {
+ 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 ReasonCode && value == other.value
+ }
+
+ override fun hashCode() = value.hashCode()
+
+ override fun toString() = value.toString()
+ }
+
+ /** The VAT category code that applies to the allowance */
+ class TaxCode @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 AE = of("AE")
+
+ @JvmField val E = of("E")
+
+ @JvmField val S = of("S")
+
+ @JvmField val Z = of("Z")
+
+ @JvmField val G = of("G")
+
+ @JvmField val O = of("O")
+
+ @JvmField val K = of("K")
+
+ @JvmField val L = of("L")
+
+ @JvmField val M = of("M")
+
+ @JvmField val B = of("B")
+
+ @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value))
+ }
+
+ /** An enum containing [TaxCode]'s known values. */
+ enum class Known {
+ AE,
+ E,
+ S,
+ Z,
+ G,
+ O,
+ K,
+ L,
+ M,
+ B,
+ }
+
+ /**
+ * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member.
+ *
+ * An instance of [TaxCode] 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 {
+ AE,
+ E,
+ S,
+ Z,
+ G,
+ O,
+ K,
+ L,
+ M,
+ B,
+ /** An enum member indicating that [TaxCode] 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) {
+ AE -> Value.AE
+ E -> Value.E
+ S -> Value.S
+ Z -> Value.Z
+ G -> Value.G
+ O -> Value.O
+ K -> Value.K
+ L -> Value.L
+ M -> Value.M
+ B -> Value.B
+ 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 EInvoiceInvalidDataException if this class instance's value is a not a known
+ * member.
+ */
+ fun known(): Known =
+ when (this) {
+ AE -> Known.AE
+ E -> Known.E
+ S -> Known.S
+ Z -> Known.Z
+ G -> Known.G
+ O -> Known.O
+ K -> Known.K
+ L -> Known.L
+ M -> Known.M
+ B -> Known.B
+ else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $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 EInvoiceInvalidDataException if this class instance's value does not have the
+ * expected primitive type.
+ */
+ fun asString(): String =
+ _value().asString().orElseThrow {
+ EInvoiceInvalidDataException("Value is not a String")
+ }
+
+ private var validated: Boolean = false
+
+ fun validate(): TaxCode = apply {
+ if (validated) {
+ return@apply
+ }
+
+ known()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: EInvoiceInvalidDataException) {
+ 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 TaxCode && 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 Allowance &&
+ amount == other.amount &&
+ baseAmount == other.baseAmount &&
+ multiplierFactor == other.multiplierFactor &&
+ reason == other.reason &&
+ reasonCode == other.reasonCode &&
+ taxCode == other.taxCode &&
+ taxRate == other.taxRate &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy {
+ Objects.hash(
+ amount,
+ baseAmount,
+ multiplierFactor,
+ reason,
+ reasonCode,
+ taxCode,
+ taxRate,
+ additionalProperties,
+ )
+ }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "Allowance{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}"
+}
diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Charge.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Charge.kt
new file mode 100644
index 0000000..45e1ce7
--- /dev/null
+++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Charge.kt
@@ -0,0 +1,1807 @@
+// File generated from our OpenAPI spec by Stainless.
+
+package com.e_invoice.api.models.documents
+
+import com.e_invoice.api.core.Enum
+import com.e_invoice.api.core.ExcludeMissing
+import com.e_invoice.api.core.JsonField
+import com.e_invoice.api.core.JsonMissing
+import com.e_invoice.api.core.JsonValue
+import com.e_invoice.api.errors.EInvoiceInvalidDataException
+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
+
+/** A charge is an additional fee for example for late payment, late delivery, etc. */
+class Charge
+@JsonCreator(mode = JsonCreator.Mode.DISABLED)
+private constructor(
+ private val amount: JsonField,
+ private val baseAmount: JsonField,
+ private val multiplierFactor: JsonField,
+ private val reason: JsonField,
+ private val reasonCode: JsonField,
+ private val taxCode: JsonField,
+ private val taxRate: JsonField,
+ private val additionalProperties: MutableMap,
+) {
+
+ @JsonCreator
+ private constructor(
+ @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(),
+ @JsonProperty("base_amount")
+ @ExcludeMissing
+ baseAmount: JsonField = JsonMissing.of(),
+ @JsonProperty("multiplier_factor")
+ @ExcludeMissing
+ multiplierFactor: JsonField = JsonMissing.of(),
+ @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(),
+ @JsonProperty("reason_code")
+ @ExcludeMissing
+ reasonCode: JsonField = JsonMissing.of(),
+ @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(),
+ @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(),
+ ) : this(
+ amount,
+ baseAmount,
+ multiplierFactor,
+ reason,
+ reasonCode,
+ taxCode,
+ taxRate,
+ mutableMapOf(),
+ )
+
+ /**
+ * The charge amount, without VAT. Must be rounded to maximum 2 decimals
+ *
+ * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun amount(): Optional = amount.getOptional("amount")
+
+ /**
+ * The base amount that may be used, in conjunction with the charge percentage, to calculate the
+ * charge amount. Must be rounded to maximum 2 decimals
+ *
+ * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun baseAmount(): Optional = baseAmount.getOptional("base_amount")
+
+ /**
+ * The percentage that may be used, in conjunction with the charge base amount, to calculate the
+ * charge amount. To state 20%, use value 20
+ *
+ * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun multiplierFactor(): Optional = multiplierFactor.getOptional("multiplier_factor")
+
+ /**
+ * The reason for the charge
+ *
+ * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun reason(): Optional = reason.getOptional("reason")
+
+ /**
+ * Charge reason codes for invoice charges and fees
+ *
+ * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun reasonCode(): Optional = reasonCode.getOptional("reason_code")
+
+ /**
+ * Duty or tax or fee category codes (Subset of UNCL5305)
+ *
+ * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL
+ *
+ * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun taxCode(): Optional = taxCode.getOptional("tax_code")
+
+ /**
+ * The VAT rate, represented as percentage that applies to the charge
+ *
+ * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun taxRate(): Optional = taxRate.getOptional("tax_rate")
+
+ /**
+ * 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 [baseAmount].
+ *
+ * Unlike [baseAmount], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("base_amount") @ExcludeMissing fun _baseAmount(): JsonField = baseAmount
+
+ /**
+ * Returns the raw JSON value of [multiplierFactor].
+ *
+ * Unlike [multiplierFactor], this method doesn't throw if the JSON field has an unexpected
+ * type.
+ */
+ @JsonProperty("multiplier_factor")
+ @ExcludeMissing
+ fun _multiplierFactor(): JsonField = multiplierFactor
+
+ /**
+ * Returns the raw JSON value of [reason].
+ *
+ * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason
+
+ /**
+ * Returns the raw JSON value of [reasonCode].
+ *
+ * Unlike [reasonCode], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("reason_code")
+ @ExcludeMissing
+ fun _reasonCode(): JsonField = reasonCode
+
+ /**
+ * Returns the raw JSON value of [taxCode].
+ *
+ * Unlike [taxCode], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("tax_code") @ExcludeMissing fun _taxCode(): JsonField = taxCode
+
+ /**
+ * Returns the raw JSON value of [taxRate].
+ *
+ * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate
+
+ @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 [Charge]. */
+ @JvmStatic fun builder() = Builder()
+ }
+
+ /** A builder for [Charge]. */
+ class Builder internal constructor() {
+
+ private var amount: JsonField = JsonMissing.of()
+ private var baseAmount: JsonField = JsonMissing.of()
+ private var multiplierFactor: JsonField = JsonMissing.of()
+ private var reason: JsonField = JsonMissing.of()
+ private var reasonCode: JsonField = JsonMissing.of()
+ private var taxCode: JsonField = JsonMissing.of()
+ private var taxRate: JsonField = JsonMissing.of()
+ private var additionalProperties: MutableMap = mutableMapOf()
+
+ @JvmSynthetic
+ internal fun from(charge: Charge) = apply {
+ amount = charge.amount
+ baseAmount = charge.baseAmount
+ multiplierFactor = charge.multiplierFactor
+ reason = charge.reason
+ reasonCode = charge.reasonCode
+ taxCode = charge.taxCode
+ taxRate = charge.taxRate
+ additionalProperties = charge.additionalProperties.toMutableMap()
+ }
+
+ /** The charge amount, without VAT. Must be rounded to maximum 2 decimals */
+ fun amount(amount: String?) = amount(JsonField.ofNullable(amount))
+
+ /** 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 [String] 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 }
+
+ /**
+ * The base amount that may be used, in conjunction with the charge percentage, to calculate
+ * the charge amount. Must be rounded to maximum 2 decimals
+ */
+ fun baseAmount(baseAmount: String?) = baseAmount(JsonField.ofNullable(baseAmount))
+
+ /** Alias for calling [Builder.baseAmount] with `baseAmount.orElse(null)`. */
+ fun baseAmount(baseAmount: Optional) = baseAmount(baseAmount.getOrNull())
+
+ /**
+ * Sets [Builder.baseAmount] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.baseAmount] with a well-typed [String] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet supported
+ * value.
+ */
+ fun baseAmount(baseAmount: JsonField) = apply { this.baseAmount = baseAmount }
+
+ /**
+ * The percentage that may be used, in conjunction with the charge base amount, to calculate
+ * the charge amount. To state 20%, use value 20
+ */
+ fun multiplierFactor(multiplierFactor: String?) =
+ multiplierFactor(JsonField.ofNullable(multiplierFactor))
+
+ /** Alias for calling [Builder.multiplierFactor] with `multiplierFactor.orElse(null)`. */
+ fun multiplierFactor(multiplierFactor: Optional) =
+ multiplierFactor(multiplierFactor.getOrNull())
+
+ /**
+ * Sets [Builder.multiplierFactor] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.multiplierFactor] with a well-typed [String] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun multiplierFactor(multiplierFactor: JsonField) = apply {
+ this.multiplierFactor = multiplierFactor
+ }
+
+ /** The reason for the charge */
+ fun reason(reason: String?) = reason(JsonField.ofNullable(reason))
+
+ /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */
+ fun reason(reason: Optional) = reason(reason.getOrNull())
+
+ /**
+ * Sets [Builder.reason] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.reason] with a well-typed [String] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun reason(reason: JsonField) = apply { this.reason = reason }
+
+ /** Charge reason codes for invoice charges and fees */
+ fun reasonCode(reasonCode: ReasonCode?) = reasonCode(JsonField.ofNullable(reasonCode))
+
+ /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */
+ fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull())
+
+ /**
+ * Sets [Builder.reasonCode] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.reasonCode] with a well-typed [ReasonCode] value
+ * instead. This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode }
+
+ /**
+ * Duty or tax or fee category codes (Subset of UNCL5305)
+ *
+ * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL
+ */
+ fun taxCode(taxCode: TaxCode?) = taxCode(JsonField.ofNullable(taxCode))
+
+ /** Alias for calling [Builder.taxCode] with `taxCode.orElse(null)`. */
+ fun taxCode(taxCode: Optional) = taxCode(taxCode.getOrNull())
+
+ /**
+ * Sets [Builder.taxCode] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.taxCode] with a well-typed [TaxCode] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode }
+
+ /** The VAT rate, represented as percentage that applies to the charge */
+ fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate))
+
+ /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */
+ fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull())
+
+ /**
+ * Sets [Builder.taxRate] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.taxRate] with a well-typed [String] value instead. This
+ * method is primarily for setting the field to an undocumented or not yet supported value.
+ */
+ fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate }
+
+ 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 [Charge].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ */
+ fun build(): Charge =
+ Charge(
+ amount,
+ baseAmount,
+ multiplierFactor,
+ reason,
+ reasonCode,
+ taxCode,
+ taxRate,
+ additionalProperties.toMutableMap(),
+ )
+ }
+
+ private var validated: Boolean = false
+
+ fun validate(): Charge = apply {
+ if (validated) {
+ return@apply
+ }
+
+ amount()
+ baseAmount()
+ multiplierFactor()
+ reason()
+ reasonCode().ifPresent { it.validate() }
+ taxCode().ifPresent { it.validate() }
+ taxRate()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: EInvoiceInvalidDataException) {
+ 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 (amount.asKnown().isPresent) 1 else 0) +
+ (if (baseAmount.asKnown().isPresent) 1 else 0) +
+ (if (multiplierFactor.asKnown().isPresent) 1 else 0) +
+ (if (reason.asKnown().isPresent) 1 else 0) +
+ (reasonCode.asKnown().getOrNull()?.validity() ?: 0) +
+ (taxCode.asKnown().getOrNull()?.validity() ?: 0) +
+ (if (taxRate.asKnown().isPresent) 1 else 0)
+
+ /** Charge reason codes for invoice charges and fees */
+ class ReasonCode @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 AA = of("AA")
+
+ @JvmField val AAA = of("AAA")
+
+ @JvmField val AAC = of("AAC")
+
+ @JvmField val AAD = of("AAD")
+
+ @JvmField val AAE = of("AAE")
+
+ @JvmField val AAF = of("AAF")
+
+ @JvmField val AAH = of("AAH")
+
+ @JvmField val AAI = of("AAI")
+
+ @JvmField val AAS = of("AAS")
+
+ @JvmField val AAT = of("AAT")
+
+ @JvmField val AAV = of("AAV")
+
+ @JvmField val AAY = of("AAY")
+
+ @JvmField val AAZ = of("AAZ")
+
+ @JvmField val ABA = of("ABA")
+
+ @JvmField val ABB = of("ABB")
+
+ @JvmField val ABC = of("ABC")
+
+ @JvmField val ABD = of("ABD")
+
+ @JvmField val ABF = of("ABF")
+
+ @JvmField val ABK = of("ABK")
+
+ @JvmField val ABL = of("ABL")
+
+ @JvmField val ABN = of("ABN")
+
+ @JvmField val ABR = of("ABR")
+
+ @JvmField val ABS = of("ABS")
+
+ @JvmField val ABT = of("ABT")
+
+ @JvmField val ABU = of("ABU")
+
+ @JvmField val ACF = of("ACF")
+
+ @JvmField val ACG = of("ACG")
+
+ @JvmField val ACH = of("ACH")
+
+ @JvmField val ACI = of("ACI")
+
+ @JvmField val ACJ = of("ACJ")
+
+ @JvmField val ACK = of("ACK")
+
+ @JvmField val ACL = of("ACL")
+
+ @JvmField val ACM = of("ACM")
+
+ @JvmField val ACS = of("ACS")
+
+ @JvmField val ADC = of("ADC")
+
+ @JvmField val ADE = of("ADE")
+
+ @JvmField val ADJ = of("ADJ")
+
+ @JvmField val ADK = of("ADK")
+
+ @JvmField val ADL = of("ADL")
+
+ @JvmField val ADM = of("ADM")
+
+ @JvmField val ADN = of("ADN")
+
+ @JvmField val ADO = of("ADO")
+
+ @JvmField val ADP = of("ADP")
+
+ @JvmField val ADQ = of("ADQ")
+
+ @JvmField val ADR = of("ADR")
+
+ @JvmField val ADT = of("ADT")
+
+ @JvmField val ADW = of("ADW")
+
+ @JvmField val ADY = of("ADY")
+
+ @JvmField val ADZ = of("ADZ")
+
+ @JvmField val AEA = of("AEA")
+
+ @JvmField val AEB = of("AEB")
+
+ @JvmField val AEC = of("AEC")
+
+ @JvmField val AED = of("AED")
+
+ @JvmField val AEF = of("AEF")
+
+ @JvmField val AEH = of("AEH")
+
+ @JvmField val AEI = of("AEI")
+
+ @JvmField val AEJ = of("AEJ")
+
+ @JvmField val AEK = of("AEK")
+
+ @JvmField val AEL = of("AEL")
+
+ @JvmField val AEM = of("AEM")
+
+ @JvmField val AEN = of("AEN")
+
+ @JvmField val AEO = of("AEO")
+
+ @JvmField val AEP = of("AEP")
+
+ @JvmField val AES = of("AES")
+
+ @JvmField val AET = of("AET")
+
+ @JvmField val AEU = of("AEU")
+
+ @JvmField val AEV = of("AEV")
+
+ @JvmField val AEW = of("AEW")
+
+ @JvmField val AEX = of("AEX")
+
+ @JvmField val AEY = of("AEY")
+
+ @JvmField val AEZ = of("AEZ")
+
+ @JvmField val AJ = of("AJ")
+
+ @JvmField val AU = of("AU")
+
+ @JvmField val CA = of("CA")
+
+ @JvmField val CAB = of("CAB")
+
+ @JvmField val CAD = of("CAD")
+
+ @JvmField val CAE = of("CAE")
+
+ @JvmField val CAF = of("CAF")
+
+ @JvmField val CAI = of("CAI")
+
+ @JvmField val CAJ = of("CAJ")
+
+ @JvmField val CAK = of("CAK")
+
+ @JvmField val CAL = of("CAL")
+
+ @JvmField val CAM = of("CAM")
+
+ @JvmField val CAN = of("CAN")
+
+ @JvmField val CAO = of("CAO")
+
+ @JvmField val CAP = of("CAP")
+
+ @JvmField val CAQ = of("CAQ")
+
+ @JvmField val CAR = of("CAR")
+
+ @JvmField val CAS = of("CAS")
+
+ @JvmField val CAT = of("CAT")
+
+ @JvmField val CAU = of("CAU")
+
+ @JvmField val CAV = of("CAV")
+
+ @JvmField val CAW = of("CAW")
+
+ @JvmField val CAX = of("CAX")
+
+ @JvmField val CAY = of("CAY")
+
+ @JvmField val CAZ = of("CAZ")
+
+ @JvmField val CD = of("CD")
+
+ @JvmField val CG = of("CG")
+
+ @JvmField val CS = of("CS")
+
+ @JvmField val CT = of("CT")
+
+ @JvmField val DAB = of("DAB")
+
+ @JvmField val DAC = of("DAC")
+
+ @JvmField val DAD = of("DAD")
+
+ @JvmField val DAF = of("DAF")
+
+ @JvmField val DAG = of("DAG")
+
+ @JvmField val DAH = of("DAH")
+
+ @JvmField val DAI = of("DAI")
+
+ @JvmField val DAJ = of("DAJ")
+
+ @JvmField val DAK = of("DAK")
+
+ @JvmField val DAL = of("DAL")
+
+ @JvmField val DAM = of("DAM")
+
+ @JvmField val DAN = of("DAN")
+
+ @JvmField val DAO = of("DAO")
+
+ @JvmField val DAP = of("DAP")
+
+ @JvmField val DAQ = of("DAQ")
+
+ @JvmField val DL = of("DL")
+
+ @JvmField val EG = of("EG")
+
+ @JvmField val EP = of("EP")
+
+ @JvmField val ER = of("ER")
+
+ @JvmField val FAA = of("FAA")
+
+ @JvmField val FAB = of("FAB")
+
+ @JvmField val FAC = of("FAC")
+
+ @JvmField val FC = of("FC")
+
+ @JvmField val FH = of("FH")
+
+ @JvmField val FI = of("FI")
+
+ @JvmField val GAA = of("GAA")
+
+ @JvmField val HAA = of("HAA")
+
+ @JvmField val HD = of("HD")
+
+ @JvmField val HH = of("HH")
+
+ @JvmField val IAA = of("IAA")
+
+ @JvmField val IAB = of("IAB")
+
+ @JvmField val ID = of("ID")
+
+ @JvmField val IF = of("IF")
+
+ @JvmField val IR = of("IR")
+
+ @JvmField val IS = of("IS")
+
+ @JvmField val KO = of("KO")
+
+ @JvmField val L1 = of("L1")
+
+ @JvmField val LA = of("LA")
+
+ @JvmField val LAA = of("LAA")
+
+ @JvmField val LAB = of("LAB")
+
+ @JvmField val LF = of("LF")
+
+ @JvmField val MAE = of("MAE")
+
+ @JvmField val MI = of("MI")
+
+ @JvmField val ML = of("ML")
+
+ @JvmField val NAA = of("NAA")
+
+ @JvmField val OA = of("OA")
+
+ @JvmField val PA = of("PA")
+
+ @JvmField val PAA = of("PAA")
+
+ @JvmField val PC = of("PC")
+
+ @JvmField val PL = of("PL")
+
+ @JvmField val PRV = of("PRV")
+
+ @JvmField val RAB = of("RAB")
+
+ @JvmField val RAC = of("RAC")
+
+ @JvmField val RAD = of("RAD")
+
+ @JvmField val RAF = of("RAF")
+
+ @JvmField val RE = of("RE")
+
+ @JvmField val RF = of("RF")
+
+ @JvmField val RH = of("RH")
+
+ @JvmField val RV = of("RV")
+
+ @JvmField val SA = of("SA")
+
+ @JvmField val SAA = of("SAA")
+
+ @JvmField val SAD = of("SAD")
+
+ @JvmField val SAE = of("SAE")
+
+ @JvmField val SAI = of("SAI")
+
+ @JvmField val SG = of("SG")
+
+ @JvmField val SH = of("SH")
+
+ @JvmField val SM = of("SM")
+
+ @JvmField val SU = of("SU")
+
+ @JvmField val TAB = of("TAB")
+
+ @JvmField val TAC = of("TAC")
+
+ @JvmField val TT = of("TT")
+
+ @JvmField val TV = of("TV")
+
+ @JvmField val V1 = of("V1")
+
+ @JvmField val V2 = of("V2")
+
+ @JvmField val WH = of("WH")
+
+ @JvmField val XAA = of("XAA")
+
+ @JvmField val YY = of("YY")
+
+ @JvmField val ZZZ = of("ZZZ")
+
+ @JvmStatic fun of(value: String) = ReasonCode(JsonField.of(value))
+ }
+
+ /** An enum containing [ReasonCode]'s known values. */
+ enum class Known {
+ AA,
+ AAA,
+ AAC,
+ AAD,
+ AAE,
+ AAF,
+ AAH,
+ AAI,
+ AAS,
+ AAT,
+ AAV,
+ AAY,
+ AAZ,
+ ABA,
+ ABB,
+ ABC,
+ ABD,
+ ABF,
+ ABK,
+ ABL,
+ ABN,
+ ABR,
+ ABS,
+ ABT,
+ ABU,
+ ACF,
+ ACG,
+ ACH,
+ ACI,
+ ACJ,
+ ACK,
+ ACL,
+ ACM,
+ ACS,
+ ADC,
+ ADE,
+ ADJ,
+ ADK,
+ ADL,
+ ADM,
+ ADN,
+ ADO,
+ ADP,
+ ADQ,
+ ADR,
+ ADT,
+ ADW,
+ ADY,
+ ADZ,
+ AEA,
+ AEB,
+ AEC,
+ AED,
+ AEF,
+ AEH,
+ AEI,
+ AEJ,
+ AEK,
+ AEL,
+ AEM,
+ AEN,
+ AEO,
+ AEP,
+ AES,
+ AET,
+ AEU,
+ AEV,
+ AEW,
+ AEX,
+ AEY,
+ AEZ,
+ AJ,
+ AU,
+ CA,
+ CAB,
+ CAD,
+ CAE,
+ CAF,
+ CAI,
+ CAJ,
+ CAK,
+ CAL,
+ CAM,
+ CAN,
+ CAO,
+ CAP,
+ CAQ,
+ CAR,
+ CAS,
+ CAT,
+ CAU,
+ CAV,
+ CAW,
+ CAX,
+ CAY,
+ CAZ,
+ CD,
+ CG,
+ CS,
+ CT,
+ DAB,
+ DAC,
+ DAD,
+ DAF,
+ DAG,
+ DAH,
+ DAI,
+ DAJ,
+ DAK,
+ DAL,
+ DAM,
+ DAN,
+ DAO,
+ DAP,
+ DAQ,
+ DL,
+ EG,
+ EP,
+ ER,
+ FAA,
+ FAB,
+ FAC,
+ FC,
+ FH,
+ FI,
+ GAA,
+ HAA,
+ HD,
+ HH,
+ IAA,
+ IAB,
+ ID,
+ IF,
+ IR,
+ IS,
+ KO,
+ L1,
+ LA,
+ LAA,
+ LAB,
+ LF,
+ MAE,
+ MI,
+ ML,
+ NAA,
+ OA,
+ PA,
+ PAA,
+ PC,
+ PL,
+ PRV,
+ RAB,
+ RAC,
+ RAD,
+ RAF,
+ RE,
+ RF,
+ RH,
+ RV,
+ SA,
+ SAA,
+ SAD,
+ SAE,
+ SAI,
+ SG,
+ SH,
+ SM,
+ SU,
+ TAB,
+ TAC,
+ TT,
+ TV,
+ V1,
+ V2,
+ WH,
+ XAA,
+ YY,
+ ZZZ,
+ }
+
+ /**
+ * An enum containing [ReasonCode]'s known values, as well as an [_UNKNOWN] member.
+ *
+ * An instance of [ReasonCode] 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 {
+ AA,
+ AAA,
+ AAC,
+ AAD,
+ AAE,
+ AAF,
+ AAH,
+ AAI,
+ AAS,
+ AAT,
+ AAV,
+ AAY,
+ AAZ,
+ ABA,
+ ABB,
+ ABC,
+ ABD,
+ ABF,
+ ABK,
+ ABL,
+ ABN,
+ ABR,
+ ABS,
+ ABT,
+ ABU,
+ ACF,
+ ACG,
+ ACH,
+ ACI,
+ ACJ,
+ ACK,
+ ACL,
+ ACM,
+ ACS,
+ ADC,
+ ADE,
+ ADJ,
+ ADK,
+ ADL,
+ ADM,
+ ADN,
+ ADO,
+ ADP,
+ ADQ,
+ ADR,
+ ADT,
+ ADW,
+ ADY,
+ ADZ,
+ AEA,
+ AEB,
+ AEC,
+ AED,
+ AEF,
+ AEH,
+ AEI,
+ AEJ,
+ AEK,
+ AEL,
+ AEM,
+ AEN,
+ AEO,
+ AEP,
+ AES,
+ AET,
+ AEU,
+ AEV,
+ AEW,
+ AEX,
+ AEY,
+ AEZ,
+ AJ,
+ AU,
+ CA,
+ CAB,
+ CAD,
+ CAE,
+ CAF,
+ CAI,
+ CAJ,
+ CAK,
+ CAL,
+ CAM,
+ CAN,
+ CAO,
+ CAP,
+ CAQ,
+ CAR,
+ CAS,
+ CAT,
+ CAU,
+ CAV,
+ CAW,
+ CAX,
+ CAY,
+ CAZ,
+ CD,
+ CG,
+ CS,
+ CT,
+ DAB,
+ DAC,
+ DAD,
+ DAF,
+ DAG,
+ DAH,
+ DAI,
+ DAJ,
+ DAK,
+ DAL,
+ DAM,
+ DAN,
+ DAO,
+ DAP,
+ DAQ,
+ DL,
+ EG,
+ EP,
+ ER,
+ FAA,
+ FAB,
+ FAC,
+ FC,
+ FH,
+ FI,
+ GAA,
+ HAA,
+ HD,
+ HH,
+ IAA,
+ IAB,
+ ID,
+ IF,
+ IR,
+ IS,
+ KO,
+ L1,
+ LA,
+ LAA,
+ LAB,
+ LF,
+ MAE,
+ MI,
+ ML,
+ NAA,
+ OA,
+ PA,
+ PAA,
+ PC,
+ PL,
+ PRV,
+ RAB,
+ RAC,
+ RAD,
+ RAF,
+ RE,
+ RF,
+ RH,
+ RV,
+ SA,
+ SAA,
+ SAD,
+ SAE,
+ SAI,
+ SG,
+ SH,
+ SM,
+ SU,
+ TAB,
+ TAC,
+ TT,
+ TV,
+ V1,
+ V2,
+ WH,
+ XAA,
+ YY,
+ ZZZ,
+ /**
+ * An enum member indicating that [ReasonCode] 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) {
+ AA -> Value.AA
+ AAA -> Value.AAA
+ AAC -> Value.AAC
+ AAD -> Value.AAD
+ AAE -> Value.AAE
+ AAF -> Value.AAF
+ AAH -> Value.AAH
+ AAI -> Value.AAI
+ AAS -> Value.AAS
+ AAT -> Value.AAT
+ AAV -> Value.AAV
+ AAY -> Value.AAY
+ AAZ -> Value.AAZ
+ ABA -> Value.ABA
+ ABB -> Value.ABB
+ ABC -> Value.ABC
+ ABD -> Value.ABD
+ ABF -> Value.ABF
+ ABK -> Value.ABK
+ ABL -> Value.ABL
+ ABN -> Value.ABN
+ ABR -> Value.ABR
+ ABS -> Value.ABS
+ ABT -> Value.ABT
+ ABU -> Value.ABU
+ ACF -> Value.ACF
+ ACG -> Value.ACG
+ ACH -> Value.ACH
+ ACI -> Value.ACI
+ ACJ -> Value.ACJ
+ ACK -> Value.ACK
+ ACL -> Value.ACL
+ ACM -> Value.ACM
+ ACS -> Value.ACS
+ ADC -> Value.ADC
+ ADE -> Value.ADE
+ ADJ -> Value.ADJ
+ ADK -> Value.ADK
+ ADL -> Value.ADL
+ ADM -> Value.ADM
+ ADN -> Value.ADN
+ ADO -> Value.ADO
+ ADP -> Value.ADP
+ ADQ -> Value.ADQ
+ ADR -> Value.ADR
+ ADT -> Value.ADT
+ ADW -> Value.ADW
+ ADY -> Value.ADY
+ ADZ -> Value.ADZ
+ AEA -> Value.AEA
+ AEB -> Value.AEB
+ AEC -> Value.AEC
+ AED -> Value.AED
+ AEF -> Value.AEF
+ AEH -> Value.AEH
+ AEI -> Value.AEI
+ AEJ -> Value.AEJ
+ AEK -> Value.AEK
+ AEL -> Value.AEL
+ AEM -> Value.AEM
+ AEN -> Value.AEN
+ AEO -> Value.AEO
+ AEP -> Value.AEP
+ AES -> Value.AES
+ AET -> Value.AET
+ AEU -> Value.AEU
+ AEV -> Value.AEV
+ AEW -> Value.AEW
+ AEX -> Value.AEX
+ AEY -> Value.AEY
+ AEZ -> Value.AEZ
+ AJ -> Value.AJ
+ AU -> Value.AU
+ CA -> Value.CA
+ CAB -> Value.CAB
+ CAD -> Value.CAD
+ CAE -> Value.CAE
+ CAF -> Value.CAF
+ CAI -> Value.CAI
+ CAJ -> Value.CAJ
+ CAK -> Value.CAK
+ CAL -> Value.CAL
+ CAM -> Value.CAM
+ CAN -> Value.CAN
+ CAO -> Value.CAO
+ CAP -> Value.CAP
+ CAQ -> Value.CAQ
+ CAR -> Value.CAR
+ CAS -> Value.CAS
+ CAT -> Value.CAT
+ CAU -> Value.CAU
+ CAV -> Value.CAV
+ CAW -> Value.CAW
+ CAX -> Value.CAX
+ CAY -> Value.CAY
+ CAZ -> Value.CAZ
+ CD -> Value.CD
+ CG -> Value.CG
+ CS -> Value.CS
+ CT -> Value.CT
+ DAB -> Value.DAB
+ DAC -> Value.DAC
+ DAD -> Value.DAD
+ DAF -> Value.DAF
+ DAG -> Value.DAG
+ DAH -> Value.DAH
+ DAI -> Value.DAI
+ DAJ -> Value.DAJ
+ DAK -> Value.DAK
+ DAL -> Value.DAL
+ DAM -> Value.DAM
+ DAN -> Value.DAN
+ DAO -> Value.DAO
+ DAP -> Value.DAP
+ DAQ -> Value.DAQ
+ DL -> Value.DL
+ EG -> Value.EG
+ EP -> Value.EP
+ ER -> Value.ER
+ FAA -> Value.FAA
+ FAB -> Value.FAB
+ FAC -> Value.FAC
+ FC -> Value.FC
+ FH -> Value.FH
+ FI -> Value.FI
+ GAA -> Value.GAA
+ HAA -> Value.HAA
+ HD -> Value.HD
+ HH -> Value.HH
+ IAA -> Value.IAA
+ IAB -> Value.IAB
+ ID -> Value.ID
+ IF -> Value.IF
+ IR -> Value.IR
+ IS -> Value.IS
+ KO -> Value.KO
+ L1 -> Value.L1
+ LA -> Value.LA
+ LAA -> Value.LAA
+ LAB -> Value.LAB
+ LF -> Value.LF
+ MAE -> Value.MAE
+ MI -> Value.MI
+ ML -> Value.ML
+ NAA -> Value.NAA
+ OA -> Value.OA
+ PA -> Value.PA
+ PAA -> Value.PAA
+ PC -> Value.PC
+ PL -> Value.PL
+ PRV -> Value.PRV
+ RAB -> Value.RAB
+ RAC -> Value.RAC
+ RAD -> Value.RAD
+ RAF -> Value.RAF
+ RE -> Value.RE
+ RF -> Value.RF
+ RH -> Value.RH
+ RV -> Value.RV
+ SA -> Value.SA
+ SAA -> Value.SAA
+ SAD -> Value.SAD
+ SAE -> Value.SAE
+ SAI -> Value.SAI
+ SG -> Value.SG
+ SH -> Value.SH
+ SM -> Value.SM
+ SU -> Value.SU
+ TAB -> Value.TAB
+ TAC -> Value.TAC
+ TT -> Value.TT
+ TV -> Value.TV
+ V1 -> Value.V1
+ V2 -> Value.V2
+ WH -> Value.WH
+ XAA -> Value.XAA
+ YY -> Value.YY
+ ZZZ -> Value.ZZZ
+ 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 EInvoiceInvalidDataException if this class instance's value is a not a known
+ * member.
+ */
+ fun known(): Known =
+ when (this) {
+ AA -> Known.AA
+ AAA -> Known.AAA
+ AAC -> Known.AAC
+ AAD -> Known.AAD
+ AAE -> Known.AAE
+ AAF -> Known.AAF
+ AAH -> Known.AAH
+ AAI -> Known.AAI
+ AAS -> Known.AAS
+ AAT -> Known.AAT
+ AAV -> Known.AAV
+ AAY -> Known.AAY
+ AAZ -> Known.AAZ
+ ABA -> Known.ABA
+ ABB -> Known.ABB
+ ABC -> Known.ABC
+ ABD -> Known.ABD
+ ABF -> Known.ABF
+ ABK -> Known.ABK
+ ABL -> Known.ABL
+ ABN -> Known.ABN
+ ABR -> Known.ABR
+ ABS -> Known.ABS
+ ABT -> Known.ABT
+ ABU -> Known.ABU
+ ACF -> Known.ACF
+ ACG -> Known.ACG
+ ACH -> Known.ACH
+ ACI -> Known.ACI
+ ACJ -> Known.ACJ
+ ACK -> Known.ACK
+ ACL -> Known.ACL
+ ACM -> Known.ACM
+ ACS -> Known.ACS
+ ADC -> Known.ADC
+ ADE -> Known.ADE
+ ADJ -> Known.ADJ
+ ADK -> Known.ADK
+ ADL -> Known.ADL
+ ADM -> Known.ADM
+ ADN -> Known.ADN
+ ADO -> Known.ADO
+ ADP -> Known.ADP
+ ADQ -> Known.ADQ
+ ADR -> Known.ADR
+ ADT -> Known.ADT
+ ADW -> Known.ADW
+ ADY -> Known.ADY
+ ADZ -> Known.ADZ
+ AEA -> Known.AEA
+ AEB -> Known.AEB
+ AEC -> Known.AEC
+ AED -> Known.AED
+ AEF -> Known.AEF
+ AEH -> Known.AEH
+ AEI -> Known.AEI
+ AEJ -> Known.AEJ
+ AEK -> Known.AEK
+ AEL -> Known.AEL
+ AEM -> Known.AEM
+ AEN -> Known.AEN
+ AEO -> Known.AEO
+ AEP -> Known.AEP
+ AES -> Known.AES
+ AET -> Known.AET
+ AEU -> Known.AEU
+ AEV -> Known.AEV
+ AEW -> Known.AEW
+ AEX -> Known.AEX
+ AEY -> Known.AEY
+ AEZ -> Known.AEZ
+ AJ -> Known.AJ
+ AU -> Known.AU
+ CA -> Known.CA
+ CAB -> Known.CAB
+ CAD -> Known.CAD
+ CAE -> Known.CAE
+ CAF -> Known.CAF
+ CAI -> Known.CAI
+ CAJ -> Known.CAJ
+ CAK -> Known.CAK
+ CAL -> Known.CAL
+ CAM -> Known.CAM
+ CAN -> Known.CAN
+ CAO -> Known.CAO
+ CAP -> Known.CAP
+ CAQ -> Known.CAQ
+ CAR -> Known.CAR
+ CAS -> Known.CAS
+ CAT -> Known.CAT
+ CAU -> Known.CAU
+ CAV -> Known.CAV
+ CAW -> Known.CAW
+ CAX -> Known.CAX
+ CAY -> Known.CAY
+ CAZ -> Known.CAZ
+ CD -> Known.CD
+ CG -> Known.CG
+ CS -> Known.CS
+ CT -> Known.CT
+ DAB -> Known.DAB
+ DAC -> Known.DAC
+ DAD -> Known.DAD
+ DAF -> Known.DAF
+ DAG -> Known.DAG
+ DAH -> Known.DAH
+ DAI -> Known.DAI
+ DAJ -> Known.DAJ
+ DAK -> Known.DAK
+ DAL -> Known.DAL
+ DAM -> Known.DAM
+ DAN -> Known.DAN
+ DAO -> Known.DAO
+ DAP -> Known.DAP
+ DAQ -> Known.DAQ
+ DL -> Known.DL
+ EG -> Known.EG
+ EP -> Known.EP
+ ER -> Known.ER
+ FAA -> Known.FAA
+ FAB -> Known.FAB
+ FAC -> Known.FAC
+ FC -> Known.FC
+ FH -> Known.FH
+ FI -> Known.FI
+ GAA -> Known.GAA
+ HAA -> Known.HAA
+ HD -> Known.HD
+ HH -> Known.HH
+ IAA -> Known.IAA
+ IAB -> Known.IAB
+ ID -> Known.ID
+ IF -> Known.IF
+ IR -> Known.IR
+ IS -> Known.IS
+ KO -> Known.KO
+ L1 -> Known.L1
+ LA -> Known.LA
+ LAA -> Known.LAA
+ LAB -> Known.LAB
+ LF -> Known.LF
+ MAE -> Known.MAE
+ MI -> Known.MI
+ ML -> Known.ML
+ NAA -> Known.NAA
+ OA -> Known.OA
+ PA -> Known.PA
+ PAA -> Known.PAA
+ PC -> Known.PC
+ PL -> Known.PL
+ PRV -> Known.PRV
+ RAB -> Known.RAB
+ RAC -> Known.RAC
+ RAD -> Known.RAD
+ RAF -> Known.RAF
+ RE -> Known.RE
+ RF -> Known.RF
+ RH -> Known.RH
+ RV -> Known.RV
+ SA -> Known.SA
+ SAA -> Known.SAA
+ SAD -> Known.SAD
+ SAE -> Known.SAE
+ SAI -> Known.SAI
+ SG -> Known.SG
+ SH -> Known.SH
+ SM -> Known.SM
+ SU -> Known.SU
+ TAB -> Known.TAB
+ TAC -> Known.TAC
+ TT -> Known.TT
+ TV -> Known.TV
+ V1 -> Known.V1
+ V2 -> Known.V2
+ WH -> Known.WH
+ XAA -> Known.XAA
+ YY -> Known.YY
+ ZZZ -> Known.ZZZ
+ else -> throw EInvoiceInvalidDataException("Unknown ReasonCode: $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 EInvoiceInvalidDataException if this class instance's value does not have the
+ * expected primitive type.
+ */
+ fun asString(): String =
+ _value().asString().orElseThrow {
+ EInvoiceInvalidDataException("Value is not a String")
+ }
+
+ private var validated: Boolean = false
+
+ fun validate(): ReasonCode = apply {
+ if (validated) {
+ return@apply
+ }
+
+ known()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: EInvoiceInvalidDataException) {
+ 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 ReasonCode && value == other.value
+ }
+
+ override fun hashCode() = value.hashCode()
+
+ override fun toString() = value.toString()
+ }
+
+ /**
+ * Duty or tax or fee category codes (Subset of UNCL5305)
+ *
+ * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL
+ */
+ class TaxCode @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 AE = of("AE")
+
+ @JvmField val E = of("E")
+
+ @JvmField val S = of("S")
+
+ @JvmField val Z = of("Z")
+
+ @JvmField val G = of("G")
+
+ @JvmField val O = of("O")
+
+ @JvmField val K = of("K")
+
+ @JvmField val L = of("L")
+
+ @JvmField val M = of("M")
+
+ @JvmField val B = of("B")
+
+ @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value))
+ }
+
+ /** An enum containing [TaxCode]'s known values. */
+ enum class Known {
+ AE,
+ E,
+ S,
+ Z,
+ G,
+ O,
+ K,
+ L,
+ M,
+ B,
+ }
+
+ /**
+ * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member.
+ *
+ * An instance of [TaxCode] 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 {
+ AE,
+ E,
+ S,
+ Z,
+ G,
+ O,
+ K,
+ L,
+ M,
+ B,
+ /** An enum member indicating that [TaxCode] 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) {
+ AE -> Value.AE
+ E -> Value.E
+ S -> Value.S
+ Z -> Value.Z
+ G -> Value.G
+ O -> Value.O
+ K -> Value.K
+ L -> Value.L
+ M -> Value.M
+ B -> Value.B
+ 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 EInvoiceInvalidDataException if this class instance's value is a not a known
+ * member.
+ */
+ fun known(): Known =
+ when (this) {
+ AE -> Known.AE
+ E -> Known.E
+ S -> Known.S
+ Z -> Known.Z
+ G -> Known.G
+ O -> Known.O
+ K -> Known.K
+ L -> Known.L
+ M -> Known.M
+ B -> Known.B
+ else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $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 EInvoiceInvalidDataException if this class instance's value does not have the
+ * expected primitive type.
+ */
+ fun asString(): String =
+ _value().asString().orElseThrow {
+ EInvoiceInvalidDataException("Value is not a String")
+ }
+
+ private var validated: Boolean = false
+
+ fun validate(): TaxCode = apply {
+ if (validated) {
+ return@apply
+ }
+
+ known()
+ validated = true
+ }
+
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: EInvoiceInvalidDataException) {
+ 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 TaxCode && 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 Charge &&
+ amount == other.amount &&
+ baseAmount == other.baseAmount &&
+ multiplierFactor == other.multiplierFactor &&
+ reason == other.reason &&
+ reasonCode == other.reasonCode &&
+ taxCode == other.taxCode &&
+ taxRate == other.taxRate &&
+ additionalProperties == other.additionalProperties
+ }
+
+ private val hashCode: Int by lazy {
+ Objects.hash(
+ amount,
+ baseAmount,
+ multiplierFactor,
+ reason,
+ reasonCode,
+ taxCode,
+ taxRate,
+ additionalProperties,
+ )
+ }
+
+ override fun hashCode(): Int = hashCode
+
+ override fun toString() =
+ "Charge{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}"
+}
diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt
index 0c51e23..a713762 100644
--- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt
+++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt
@@ -4,6 +4,7 @@ package com.e_invoice.api.models.documents
import com.e_invoice.api.core.BaseDeserializer
import com.e_invoice.api.core.BaseSerializer
+import com.e_invoice.api.core.Enum
import com.e_invoice.api.core.ExcludeMissing
import com.e_invoice.api.core.JsonField
import com.e_invoice.api.core.JsonMissing
@@ -34,13 +35,16 @@ import kotlin.jvm.optionals.getOrNull
class DocumentCreate
@JsonCreator(mode = JsonCreator.Mode.DISABLED)
private constructor(
+ private val allowances: JsonField>,
private val amountDue: JsonField,
private val attachments: JsonField>,
private val billingAddress: JsonField,
private val billingAddressRecipient: JsonField,
+ private val charges: JsonField>,
private val currency: JsonField,
private val customerAddress: JsonField,
private val customerAddressRecipient: JsonField,
+ private val customerCompanyId: JsonField,
private val customerEmail: JsonField,
private val customerId: JsonField,
private val customerName: JsonField,
@@ -67,11 +71,15 @@ private constructor(
private val shippingAddressRecipient: JsonField,
private val state: JsonField,
private val subtotal: JsonField,
+ private val taxCode: JsonField,
private val taxDetails: JsonField>,
private val totalDiscount: JsonField,
private val totalTax: JsonField,
+ private val vatex: JsonField,
+ private val vatexNote: JsonField,
private val vendorAddress: JsonField,
private val vendorAddressRecipient: JsonField,
+ private val vendorCompanyId: JsonField,
private val vendorEmail: JsonField,
private val vendorName: JsonField,
private val vendorTaxId: JsonField,
@@ -80,6 +88,9 @@ private constructor(
@JsonCreator
private constructor(
+ @JsonProperty("allowances")
+ @ExcludeMissing
+ allowances: JsonField> = JsonMissing.of(),
@JsonProperty("amount_due")
@ExcludeMissing
amountDue: JsonField = JsonMissing.of(),
@@ -92,6 +103,9 @@ private constructor(
@JsonProperty("billing_address_recipient")
@ExcludeMissing
billingAddressRecipient: JsonField = JsonMissing.of(),
+ @JsonProperty("charges")
+ @ExcludeMissing
+ charges: JsonField> = JsonMissing.of(),
@JsonProperty("currency")
@ExcludeMissing
currency: JsonField = JsonMissing.of(),
@@ -101,6 +115,9 @@ private constructor(
@JsonProperty("customer_address_recipient")
@ExcludeMissing
customerAddressRecipient: JsonField = JsonMissing.of(),
+ @JsonProperty("customer_company_id")
+ @ExcludeMissing
+ customerCompanyId: JsonField = JsonMissing.of(),
@JsonProperty("customer_email")
@ExcludeMissing
customerEmail: JsonField = JsonMissing.of(),
@@ -167,6 +184,7 @@ private constructor(
shippingAddressRecipient: JsonField = JsonMissing.of(),
@JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(),
@JsonProperty("subtotal") @ExcludeMissing subtotal: JsonField = JsonMissing.of(),
+ @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(),
@JsonProperty("tax_details")
@ExcludeMissing
taxDetails: JsonField> = JsonMissing.of(),
@@ -174,12 +192,17 @@ private constructor(
@ExcludeMissing
totalDiscount: JsonField = JsonMissing.of(),
@JsonProperty("total_tax") @ExcludeMissing totalTax: JsonField = JsonMissing.of(),
+ @JsonProperty("vatex") @ExcludeMissing vatex: JsonField = JsonMissing.of(),
+ @JsonProperty("vatex_note") @ExcludeMissing vatexNote: JsonField = JsonMissing.of(),
@JsonProperty("vendor_address")
@ExcludeMissing
vendorAddress: JsonField = JsonMissing.of(),
@JsonProperty("vendor_address_recipient")
@ExcludeMissing
vendorAddressRecipient: JsonField = JsonMissing.of(),
+ @JsonProperty("vendor_company_id")
+ @ExcludeMissing
+ vendorCompanyId: JsonField = JsonMissing.of(),
@JsonProperty("vendor_email")
@ExcludeMissing
vendorEmail: JsonField = JsonMissing.of(),
@@ -190,13 +213,16 @@ private constructor(
@ExcludeMissing
vendorTaxId: JsonField = JsonMissing.of(),
) : this(
+ allowances,
amountDue,
attachments,
billingAddress,
billingAddressRecipient,
+ charges,
currency,
customerAddress,
customerAddressRecipient,
+ customerCompanyId,
customerEmail,
customerId,
customerName,
@@ -223,11 +249,15 @@ private constructor(
shippingAddressRecipient,
state,
subtotal,
+ taxCode,
taxDetails,
totalDiscount,
totalTax,
+ vatex,
+ vatexNote,
vendorAddress,
vendorAddressRecipient,
+ vendorCompanyId,
vendorEmail,
vendorName,
vendorTaxId,
@@ -238,6 +268,14 @@ private constructor(
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
+ fun allowances(): Optional> = allowances.getOptional("allowances")
+
+ /**
+ * The amount due for payment. Must be positive and rounded to maximum 2 decimals
+ *
+ * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
fun amountDue(): Optional = amountDue.getOptional("amount_due")
/**
@@ -248,12 +286,16 @@ private constructor(
attachments.getOptional("attachments")
/**
+ * The billing address (if different from customer address)
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun billingAddress(): Optional = billingAddress.getOptional("billing_address")
/**
+ * The recipient name at the billing address
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
@@ -261,7 +303,13 @@ private constructor(
billingAddressRecipient.getOptional("billing_address_recipient")
/**
- * Currency of the invoice
+ * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun charges(): Optional> = charges.getOptional("charges")
+
+ /**
+ * Currency of the invoice (ISO 4217 currency code)
*
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
@@ -269,12 +317,16 @@ private constructor(
fun currency(): Optional = currency.getOptional("currency")
/**
+ * The address of the customer/buyer
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun customerAddress(): Optional = customerAddress.getOptional("customer_address")
/**
+ * The recipient name at the customer address
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
@@ -282,72 +334,106 @@ private constructor(
customerAddressRecipient.getOptional("customer_address_recipient")
/**
+ * Customer company ID. For Belgium this is the CBE number or their EUID (European Unique
+ * Identifier) number. In the Netherlands this is the KVK number.
+ *
+ * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun customerCompanyId(): Optional = customerCompanyId.getOptional("customer_company_id")
+
+ /**
+ * The email address of the customer
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun customerEmail(): Optional = customerEmail.getOptional("customer_email")
/**
+ * The unique identifier for the customer in your system
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun customerId(): Optional = customerId.getOptional("customer_id")
/**
+ * The company name of the customer/buyer
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun customerName(): Optional = customerName.getOptional("customer_name")
/**
+ * Customer tax ID. For Belgium this is the VAT number. Must include the country prefix
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun customerTaxId(): Optional = customerTaxId.getOptional("customer_tax_id")
/**
+ * The direction of the document: INBOUND (purchases) or OUTBOUND (sales)
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun direction(): Optional = direction.getOptional("direction")
/**
+ * The type of document: INVOICE, CREDIT_NOTE, or DEBIT_NOTE
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun documentType(): Optional = documentType.getOptional("document_type")
/**
+ * The date when payment is due
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun dueDate(): Optional = dueDate.getOptional("due_date")
/**
+ * The date when the invoice was issued
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun invoiceDate(): Optional = invoiceDate.getOptional("invoice_date")
/**
+ * The unique invoice identifier/number
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun invoiceId(): Optional = invoiceId.getOptional("invoice_id")
/**
+ * The total amount of the invoice including tax (invoice_total = subtotal + total_tax +
+ * total_discount). Must be positive and rounded to maximum 2 decimals
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun invoiceTotal(): Optional = invoiceTotal.getOptional("invoice_total")
/**
+ * At least one line item is required
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun items(): Optional> = items.getOptional("items")
/**
+ * Additional notes or comments for the invoice
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
@@ -361,12 +447,17 @@ private constructor(
paymentDetails.getOptional("payment_details")
/**
+ * The payment terms (e.g., 'Net 30', 'Due on receipt', '2/10 Net 30')
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun paymentTerm(): Optional = paymentTerm.getOptional("payment_term")
/**
+ * The previous unpaid balance from prior invoices, if any. Must be positive and rounded to
+ * maximum 2 decimals
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
@@ -374,18 +465,24 @@ private constructor(
previousUnpaidBalance.getOptional("previous_unpaid_balance")
/**
+ * The purchase order reference number
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun purchaseOrder(): Optional = purchaseOrder.getOptional("purchase_order")
/**
+ * The address where payment should be sent or remitted to
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun remittanceAddress(): Optional = remittanceAddress.getOptional("remittance_address")
/**
+ * The recipient name at the remittance address
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
@@ -393,12 +490,16 @@ private constructor(
remittanceAddressRecipient.getOptional("remittance_address_recipient")
/**
+ * The address where services were performed or goods were delivered
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun serviceAddress(): Optional = serviceAddress.getOptional("service_address")
/**
+ * The recipient name at the service address
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
@@ -406,24 +507,32 @@ private constructor(
serviceAddressRecipient.getOptional("service_address_recipient")
/**
+ * The end date of the service period or delivery period
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun serviceEndDate(): Optional = serviceEndDate.getOptional("service_end_date")
/**
+ * The start date of the service period or delivery period
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun serviceStartDate(): Optional = serviceStartDate.getOptional("service_start_date")
/**
+ * The shipping/delivery address
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun shippingAddress(): Optional = shippingAddress.getOptional("shipping_address")
/**
+ * The recipient name at the shipping address
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
@@ -431,17 +540,31 @@ private constructor(
shippingAddressRecipient.getOptional("shipping_address_recipient")
/**
+ * The current state of the document: DRAFT, TRANSIT, FAILED, SENT, or RECEIVED
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun state(): Optional = state.getOptional("state")
/**
+ * The taxable base of the invoice. Should be the sum of all line items - allowances (for
+ * example commercial discounts) + charges with impact on VAT. Must be positive and rounded to
+ * maximum 2 decimals
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun subtotal(): Optional = subtotal.getOptional("subtotal")
+ /**
+ * Tax category code of the invoice (e.g., S for standard rate, Z for zero rate, E for exempt)
+ *
+ * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun taxCode(): Optional = taxCode.getOptional("tax_code")
+
/**
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
@@ -449,24 +572,52 @@ private constructor(
fun taxDetails(): Optional> = taxDetails.getOptional("tax_details")
/**
+ * The net financial discount/charge of the invoice (non-VAT charges minus non-VAT allowances).
+ * Can be positive (net charge), negative (net discount), or zero. Must be rounded to maximum 2
+ * decimals
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun totalDiscount(): Optional = totalDiscount.getOptional("total_discount")
/**
+ * The total tax amount of the invoice. Must be positive and rounded to maximum 2 decimals
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun totalTax(): Optional = totalTax.getOptional("total_tax")
/**
+ * VATEX code list for VAT exemption reasons
+ *
+ * Agency: CEF Identifier: vatex
+ *
+ * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun vatex(): Optional = vatex.getOptional("vatex")
+
+ /**
+ * Textual explanation for VAT exemption
+ *
+ * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun vatexNote(): Optional = vatexNote.getOptional("vatex_note")
+
+ /**
+ * The address of the vendor/seller
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun vendorAddress(): Optional = vendorAddress.getOptional("vendor_address")
/**
+ * The recipient name at the vendor address
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
@@ -474,23 +625,47 @@ private constructor(
vendorAddressRecipient.getOptional("vendor_address_recipient")
/**
+ * Vendor company ID. For Belgium this is the CBE number or their EUID (European Unique
+ * Identifier) number. In the Netherlands this is the KVK number.
+ *
+ * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
+ * server responded with an unexpected value).
+ */
+ fun vendorCompanyId(): Optional = vendorCompanyId.getOptional("vendor_company_id")
+
+ /**
+ * The email address of the vendor
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun vendorEmail(): Optional = vendorEmail.getOptional("vendor_email")
/**
+ * The name of the vendor/seller/supplier
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun vendorName(): Optional = vendorName.getOptional("vendor_name")
/**
+ * Vendor tax ID. For Belgium this is the VAT number. Must include the country prefix
+ *
* @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the
* server responded with an unexpected value).
*/
fun vendorTaxId(): Optional = vendorTaxId.getOptional("vendor_tax_id")
+ /**
+ * Returns the raw JSON value of [allowances].
+ *
+ * Unlike [allowances], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("allowances")
+ @ExcludeMissing
+ fun _allowances(): JsonField> = allowances
+
/**
* Returns the raw JSON value of [amountDue].
*
@@ -526,6 +701,13 @@ private constructor(
@ExcludeMissing
fun _billingAddressRecipient(): JsonField = billingAddressRecipient
+ /**
+ * Returns the raw JSON value of [charges].
+ *
+ * Unlike [charges], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("charges") @ExcludeMissing fun _charges(): JsonField> = charges
+
/**
* Returns the raw JSON value of [currency].
*
@@ -552,6 +734,16 @@ private constructor(
@ExcludeMissing
fun _customerAddressRecipient(): JsonField = customerAddressRecipient
+ /**
+ * Returns the raw JSON value of [customerCompanyId].
+ *
+ * Unlike [customerCompanyId], this method doesn't throw if the JSON field has an unexpected
+ * type.
+ */
+ @JsonProperty("customer_company_id")
+ @ExcludeMissing
+ fun _customerCompanyId(): JsonField = customerCompanyId
+
/**
* Returns the raw JSON value of [customerEmail].
*
@@ -778,6 +970,13 @@ private constructor(
*/
@JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal
+ /**
+ * Returns the raw JSON value of [taxCode].
+ *
+ * Unlike [taxCode], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("tax_code") @ExcludeMissing fun _taxCode(): JsonField = taxCode
+
/**
* Returns the raw JSON value of [taxDetails].
*
@@ -803,6 +1002,20 @@ private constructor(
*/
@JsonProperty("total_tax") @ExcludeMissing fun _totalTax(): JsonField = totalTax
+ /**
+ * Returns the raw JSON value of [vatex].
+ *
+ * Unlike [vatex], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("vatex") @ExcludeMissing fun _vatex(): JsonField = vatex
+
+ /**
+ * Returns the raw JSON value of [vatexNote].
+ *
+ * Unlike [vatexNote], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("vatex_note") @ExcludeMissing fun _vatexNote(): JsonField = vatexNote
+
/**
* Returns the raw JSON value of [vendorAddress].
*
@@ -822,6 +1035,15 @@ private constructor(
@ExcludeMissing
fun _vendorAddressRecipient(): JsonField = vendorAddressRecipient
+ /**
+ * Returns the raw JSON value of [vendorCompanyId].
+ *
+ * Unlike [vendorCompanyId], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("vendor_company_id")
+ @ExcludeMissing
+ fun _vendorCompanyId(): JsonField = vendorCompanyId
+
/**
* Returns the raw JSON value of [vendorEmail].
*
@@ -868,13 +1090,16 @@ private constructor(
/** A builder for [DocumentCreate]. */
class Builder internal constructor() {
+ private var allowances: JsonField>? = null
private var amountDue: JsonField = JsonMissing.of()
private var attachments: JsonField>? = null
private var billingAddress: JsonField = JsonMissing.of()
private var billingAddressRecipient: JsonField = JsonMissing.of()
+ private var charges: JsonField>? = null
private var currency: JsonField = JsonMissing.of()
private var customerAddress: JsonField = JsonMissing.of()
private var customerAddressRecipient: JsonField = JsonMissing.of()
+ private var customerCompanyId: JsonField = JsonMissing.of()
private var customerEmail: JsonField = JsonMissing.of()
private var customerId: JsonField = JsonMissing.of()
private var customerName: JsonField = JsonMissing.of()
@@ -901,11 +1126,15 @@ private constructor(
private var shippingAddressRecipient: JsonField = JsonMissing.of()
private var state: JsonField = JsonMissing.of()
private var subtotal: JsonField = JsonMissing.of()
+ private var taxCode: JsonField = JsonMissing.of()
private var taxDetails: JsonField>? = null
private var totalDiscount: JsonField = JsonMissing.of()
private var totalTax: JsonField = JsonMissing.of()
+ private var vatex: JsonField = JsonMissing.of()
+ private var vatexNote: JsonField = JsonMissing.of()
private var vendorAddress: JsonField = JsonMissing.of()
private var vendorAddressRecipient: JsonField = JsonMissing.of()
+ private var vendorCompanyId: JsonField = JsonMissing.of()
private var vendorEmail: JsonField