diff --git a/.fern/metadata.json b/.fern/metadata.json index 6a918934..189279f9 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -8,5 +8,5 @@ "client-class-name": "Vital", "enable-forward-compatible-enums": false }, - "sdkVersion": "1.2.601" + "sdkVersion": "1.2.605" } \ No newline at end of file diff --git a/build.gradle b/build.gradle index 7d719024..a36120f5 100644 --- a/build.gradle +++ b/build.gradle @@ -47,7 +47,7 @@ java { group = 'io.tryvital' -version = '1.2.601' +version = '1.2.605' jar { dependsOn(":generatePomFileForMavenPublication") @@ -78,7 +78,7 @@ publishing { maven(MavenPublication) { groupId = 'io.tryvital' artifactId = 'vital-java' - version = '1.2.601' + version = '1.2.605' from components.java pom { name = 'vital' diff --git a/reference.md b/reference.md index bec83aea..ab88a1cb 100644 --- a/reference.md +++ b/reference.md @@ -13258,6 +13258,7 @@ client.labTests().bookPscAppointment( .build() ) .idempotencyKey("x-idempotency-key") + .idempotencyError("no-cache") .build() ); ``` @@ -13290,6 +13291,14 @@ client.labTests().bookPscAppointment(
+**idempotencyError:** `Optional` — If `no-cache`, applies idempotency only to successful outcomes. + +
+
+ +
+
+ **request:** `AppointmentBookingRequest`
@@ -14303,6 +14312,127 @@ client.labTests().validateIcdCodes(
+ + + + +## OrderTransaction +
client.orderTransaction.getTransaction(transactionId) -> GetOrderTransactionResponse +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.orderTransaction().getTransaction("transaction_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**transactionId:** `String` + +
+
+
+
+ + +
+
+
+ +
client.orderTransaction.getTransactionResult(transactionId) -> LabResultsRaw +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.orderTransaction().getTransactionResult("transaction_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**transactionId:** `String` + +
+
+
+
+ + +
+
+
+ +
client.orderTransaction.getTransactionResultPdf(transactionId) -> InputStream +
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```java +client.orderTransaction().getTransactionResultPdf("transaction_id"); +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**transactionId:** `String` + +
+
+
+
+ +
diff --git a/src/main/java/com/vital/api/AsyncVital.java b/src/main/java/com/vital/api/AsyncVital.java index d7fc86ab..263529b6 100644 --- a/src/main/java/com/vital/api/AsyncVital.java +++ b/src/main/java/com/vital/api/AsyncVital.java @@ -18,6 +18,7 @@ import com.vital.api.resources.meal.AsyncMealClient; import com.vital.api.resources.menstrualcycle.AsyncMenstrualCycleClient; import com.vital.api.resources.order.AsyncOrderClient; +import com.vital.api.resources.ordertransaction.AsyncOrderTransactionClient; import com.vital.api.resources.payor.AsyncPayorClient; import com.vital.api.resources.profile.AsyncProfileClient; import com.vital.api.resources.providers.AsyncProvidersClient; @@ -67,6 +68,8 @@ public class AsyncVital { protected final Supplier labTestsClient; + protected final Supplier orderTransactionClient; + protected final Supplier testkitClient; protected final Supplier orderClient; @@ -98,6 +101,7 @@ public AsyncVital(ClientOptions clientOptions) { this.providersClient = Suppliers.memoize(() -> new AsyncProvidersClient(clientOptions)); this.introspectClient = Suppliers.memoize(() -> new AsyncIntrospectClient(clientOptions)); this.labTestsClient = Suppliers.memoize(() -> new AsyncLabTestsClient(clientOptions)); + this.orderTransactionClient = Suppliers.memoize(() -> new AsyncOrderTransactionClient(clientOptions)); this.testkitClient = Suppliers.memoize(() -> new AsyncTestkitClient(clientOptions)); this.orderClient = Suppliers.memoize(() -> new AsyncOrderClient(clientOptions)); this.insuranceClient = Suppliers.memoize(() -> new AsyncInsuranceClient(clientOptions)); @@ -174,6 +178,10 @@ public AsyncLabTestsClient labTests() { return this.labTestsClient.get(); } + public AsyncOrderTransactionClient orderTransaction() { + return this.orderTransactionClient.get(); + } + public AsyncTestkitClient testkit() { return this.testkitClient.get(); } diff --git a/src/main/java/com/vital/api/Vital.java b/src/main/java/com/vital/api/Vital.java index 9ef917b7..40499d3b 100644 --- a/src/main/java/com/vital/api/Vital.java +++ b/src/main/java/com/vital/api/Vital.java @@ -18,6 +18,7 @@ import com.vital.api.resources.meal.MealClient; import com.vital.api.resources.menstrualcycle.MenstrualCycleClient; import com.vital.api.resources.order.OrderClient; +import com.vital.api.resources.ordertransaction.OrderTransactionClient; import com.vital.api.resources.payor.PayorClient; import com.vital.api.resources.profile.ProfileClient; import com.vital.api.resources.providers.ProvidersClient; @@ -67,6 +68,8 @@ public class Vital { protected final Supplier labTestsClient; + protected final Supplier orderTransactionClient; + protected final Supplier testkitClient; protected final Supplier orderClient; @@ -98,6 +101,7 @@ public Vital(ClientOptions clientOptions) { this.providersClient = Suppliers.memoize(() -> new ProvidersClient(clientOptions)); this.introspectClient = Suppliers.memoize(() -> new IntrospectClient(clientOptions)); this.labTestsClient = Suppliers.memoize(() -> new LabTestsClient(clientOptions)); + this.orderTransactionClient = Suppliers.memoize(() -> new OrderTransactionClient(clientOptions)); this.testkitClient = Suppliers.memoize(() -> new TestkitClient(clientOptions)); this.orderClient = Suppliers.memoize(() -> new OrderClient(clientOptions)); this.insuranceClient = Suppliers.memoize(() -> new InsuranceClient(clientOptions)); @@ -174,6 +178,10 @@ public LabTestsClient labTests() { return this.labTestsClient.get(); } + public OrderTransactionClient orderTransaction() { + return this.orderTransactionClient.get(); + } + public TestkitClient testkit() { return this.testkitClient.get(); } diff --git a/src/main/java/com/vital/api/core/ClientOptions.java b/src/main/java/com/vital/api/core/ClientOptions.java index 43c4b250..6a476e01 100644 --- a/src/main/java/com/vital/api/core/ClientOptions.java +++ b/src/main/java/com/vital/api/core/ClientOptions.java @@ -35,10 +35,10 @@ private ClientOptions( this.headers.putAll(headers); this.headers.putAll(new HashMap() { { - put("User-Agent", "io.tryvital:vital-java/1.2.601"); + put("User-Agent", "io.tryvital:vital-java/1.2.605"); put("X-Fern-Language", "JAVA"); put("X-Fern-SDK-Name", "com.vital.fern:api-sdk"); - put("X-Fern-SDK-Version", "1.2.601"); + put("X-Fern-SDK-Version", "1.2.605"); } }); this.headerSuppliers = headerSuppliers; diff --git a/src/main/java/com/vital/api/resources/labtests/AsyncRawLabTestsClient.java b/src/main/java/com/vital/api/resources/labtests/AsyncRawLabTestsClient.java index 897e71b6..8ef51371 100644 --- a/src/main/java/com/vital/api/resources/labtests/AsyncRawLabTestsClient.java +++ b/src/main/java/com/vital/api/resources/labtests/AsyncRawLabTestsClient.java @@ -2513,6 +2513,10 @@ public CompletableFuture> bookPscAppo _requestBuilder.addHeader( "x-idempotency-key", request.getIdempotencyKey().get()); } + if (request.getIdempotencyError().isPresent()) { + _requestBuilder.addHeader( + "x-idempotency-error", request.getIdempotencyError().get()); + } Request okhttpRequest = _requestBuilder.build(); OkHttpClient client = clientOptions.httpClient(); if (requestOptions != null && requestOptions.getTimeout().isPresent()) { diff --git a/src/main/java/com/vital/api/resources/labtests/RawLabTestsClient.java b/src/main/java/com/vital/api/resources/labtests/RawLabTestsClient.java index ce9792f0..26ff8924 100644 --- a/src/main/java/com/vital/api/resources/labtests/RawLabTestsClient.java +++ b/src/main/java/com/vital/api/resources/labtests/RawLabTestsClient.java @@ -2071,6 +2071,10 @@ public VitalHttpResponse bookPscAppointment( _requestBuilder.addHeader( "x-idempotency-key", request.getIdempotencyKey().get()); } + if (request.getIdempotencyError().isPresent()) { + _requestBuilder.addHeader( + "x-idempotency-error", request.getIdempotencyError().get()); + } Request okhttpRequest = _requestBuilder.build(); OkHttpClient client = clientOptions.httpClient(); if (requestOptions != null && requestOptions.getTimeout().isPresent()) { diff --git a/src/main/java/com/vital/api/resources/labtests/requests/LabTestsBookPscAppointmentRequest.java b/src/main/java/com/vital/api/resources/labtests/requests/LabTestsBookPscAppointmentRequest.java index c80ca240..687181d6 100644 --- a/src/main/java/com/vital/api/resources/labtests/requests/LabTestsBookPscAppointmentRequest.java +++ b/src/main/java/com/vital/api/resources/labtests/requests/LabTestsBookPscAppointmentRequest.java @@ -24,13 +24,19 @@ public final class LabTestsBookPscAppointmentRequest { private final Optional idempotencyKey; + private final Optional idempotencyError; + private final AppointmentBookingRequest body; private final Map additionalProperties; private LabTestsBookPscAppointmentRequest( - Optional idempotencyKey, AppointmentBookingRequest body, Map additionalProperties) { + Optional idempotencyKey, + Optional idempotencyError, + AppointmentBookingRequest body, + Map additionalProperties) { this.idempotencyKey = idempotencyKey; + this.idempotencyError = idempotencyError; this.body = body; this.additionalProperties = additionalProperties; } @@ -43,6 +49,14 @@ public Optional getIdempotencyKey() { return idempotencyKey; } + /** + * @return If no-cache, applies idempotency only to successful outcomes. + */ + @JsonIgnore + public Optional getIdempotencyError() { + return idempotencyError; + } + @JsonProperty("body") public AppointmentBookingRequest getBody() { return body; @@ -60,12 +74,14 @@ public Map getAdditionalProperties() { } private boolean equalTo(LabTestsBookPscAppointmentRequest other) { - return idempotencyKey.equals(other.idempotencyKey) && body.equals(other.body); + return idempotencyKey.equals(other.idempotencyKey) + && idempotencyError.equals(other.idempotencyError) + && body.equals(other.body); } @java.lang.Override public int hashCode() { - return Objects.hash(this.idempotencyKey, this.body); + return Objects.hash(this.idempotencyKey, this.idempotencyError, this.body); } @java.lang.Override @@ -92,12 +108,21 @@ public interface _FinalStage { _FinalStage idempotencyKey(Optional idempotencyKey); _FinalStage idempotencyKey(String idempotencyKey); + + /** + *

If no-cache, applies idempotency only to successful outcomes.

+ */ + _FinalStage idempotencyError(Optional idempotencyError); + + _FinalStage idempotencyError(String idempotencyError); } @JsonIgnoreProperties(ignoreUnknown = true) public static final class Builder implements BodyStage, _FinalStage { private AppointmentBookingRequest body; + private Optional idempotencyError = Optional.empty(); + private Optional idempotencyKey = Optional.empty(); @JsonAnySetter @@ -108,6 +133,7 @@ private Builder() {} @java.lang.Override public Builder from(LabTestsBookPscAppointmentRequest other) { idempotencyKey(other.getIdempotencyKey()); + idempotencyError(other.getIdempotencyError()); body(other.getBody()); return this; } @@ -119,6 +145,25 @@ public _FinalStage body(@NotNull AppointmentBookingRequest body) { return this; } + /** + *

If no-cache, applies idempotency only to successful outcomes.

+ * @return Reference to {@code this} so that method calls can be chained together. + */ + @java.lang.Override + public _FinalStage idempotencyError(String idempotencyError) { + this.idempotencyError = Optional.ofNullable(idempotencyError); + return this; + } + + /** + *

If no-cache, applies idempotency only to successful outcomes.

+ */ + @java.lang.Override + public _FinalStage idempotencyError(Optional idempotencyError) { + this.idempotencyError = idempotencyError; + return this; + } + /** *

[!] This feature (Idempotency Key) is under closed beta. Idempotency Key support for booking PSC appointment.

* @return Reference to {@code this} so that method calls can be chained together. @@ -140,7 +185,7 @@ public _FinalStage idempotencyKey(Optional idempotencyKey) { @java.lang.Override public LabTestsBookPscAppointmentRequest build() { - return new LabTestsBookPscAppointmentRequest(idempotencyKey, body, additionalProperties); + return new LabTestsBookPscAppointmentRequest(idempotencyKey, idempotencyError, body, additionalProperties); } } } diff --git a/src/main/java/com/vital/api/resources/ordertransaction/AsyncOrderTransactionClient.java b/src/main/java/com/vital/api/resources/ordertransaction/AsyncOrderTransactionClient.java new file mode 100644 index 00000000..bd5bf075 --- /dev/null +++ b/src/main/java/com/vital/api/resources/ordertransaction/AsyncOrderTransactionClient.java @@ -0,0 +1,58 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.vital.api.resources.ordertransaction; + +import com.vital.api.core.ClientOptions; +import com.vital.api.core.RequestOptions; +import com.vital.api.types.GetOrderTransactionResponse; +import com.vital.api.types.LabResultsRaw; +import java.io.InputStream; +import java.util.concurrent.CompletableFuture; + +public class AsyncOrderTransactionClient { + protected final ClientOptions clientOptions; + + private final AsyncRawOrderTransactionClient rawClient; + + public AsyncOrderTransactionClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new AsyncRawOrderTransactionClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public AsyncRawOrderTransactionClient withRawResponse() { + return this.rawClient; + } + + public CompletableFuture getTransaction(String transactionId) { + return this.rawClient.getTransaction(transactionId).thenApply(response -> response.body()); + } + + public CompletableFuture getTransaction( + String transactionId, RequestOptions requestOptions) { + return this.rawClient.getTransaction(transactionId, requestOptions).thenApply(response -> response.body()); + } + + public CompletableFuture getTransactionResult(String transactionId) { + return this.rawClient.getTransactionResult(transactionId).thenApply(response -> response.body()); + } + + public CompletableFuture getTransactionResult(String transactionId, RequestOptions requestOptions) { + return this.rawClient + .getTransactionResult(transactionId, requestOptions) + .thenApply(response -> response.body()); + } + + public CompletableFuture getTransactionResultPdf(String transactionId) { + return this.rawClient.getTransactionResultPdf(transactionId).thenApply(response -> response.body()); + } + + public CompletableFuture getTransactionResultPdf(String transactionId, RequestOptions requestOptions) { + return this.rawClient + .getTransactionResultPdf(transactionId, requestOptions) + .thenApply(response -> response.body()); + } +} diff --git a/src/main/java/com/vital/api/resources/ordertransaction/AsyncRawOrderTransactionClient.java b/src/main/java/com/vital/api/resources/ordertransaction/AsyncRawOrderTransactionClient.java new file mode 100644 index 00000000..ef17b535 --- /dev/null +++ b/src/main/java/com/vital/api/resources/ordertransaction/AsyncRawOrderTransactionClient.java @@ -0,0 +1,232 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.vital.api.resources.ordertransaction; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.vital.api.core.ApiError; +import com.vital.api.core.ClientOptions; +import com.vital.api.core.ObjectMappers; +import com.vital.api.core.RequestOptions; +import com.vital.api.core.ResponseBodyInputStream; +import com.vital.api.core.VitalException; +import com.vital.api.core.VitalHttpResponse; +import com.vital.api.errors.UnprocessableEntityError; +import com.vital.api.types.GetOrderTransactionResponse; +import com.vital.api.types.HttpValidationError; +import com.vital.api.types.LabResultsRaw; +import java.io.IOException; +import java.io.InputStream; +import java.util.concurrent.CompletableFuture; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.jetbrains.annotations.NotNull; + +public class AsyncRawOrderTransactionClient { + protected final ClientOptions clientOptions; + + public AsyncRawOrderTransactionClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public CompletableFuture> getTransaction(String transactionId) { + return getTransaction(transactionId, null); + } + + public CompletableFuture> getTransaction( + String transactionId, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v3/order_transaction") + .addPathSegment(transactionId); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((key, value) -> { + httpUrl.addQueryParameter(key, value); + }); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new VitalHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue( + responseBodyString, GetOrderTransactionResponse.class), + response)); + return; + } + try { + if (response.code() == 422) { + future.completeExceptionally(new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, HttpValidationError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), response.code(), errorBody, response)); + return; + } catch (IOException e) { + future.completeExceptionally(new VitalException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new VitalException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getTransactionResult(String transactionId) { + return getTransactionResult(transactionId, null); + } + + public CompletableFuture> getTransactionResult( + String transactionId, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v3/order_transaction") + .addPathSegment(transactionId) + .addPathSegments("result"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((key, value) -> { + httpUrl.addQueryParameter(key, value); + }); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody responseBody = response.body()) { + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + future.complete(new VitalHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, LabResultsRaw.class), + response)); + return; + } + try { + if (response.code() == 422) { + future.completeExceptionally(new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, HttpValidationError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), response.code(), errorBody, response)); + return; + } catch (IOException e) { + future.completeExceptionally(new VitalException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new VitalException("Network error executing HTTP request", e)); + } + }); + return future; + } + + public CompletableFuture> getTransactionResultPdf(String transactionId) { + return getTransactionResultPdf(transactionId, null); + } + + public CompletableFuture> getTransactionResultPdf( + String transactionId, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v3/order_transaction") + .addPathSegment(transactionId) + .addPathSegments("result") + .addPathSegments("pdf"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((key, value) -> { + httpUrl.addQueryParameter(key, value); + }); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + CompletableFuture> future = new CompletableFuture<>(); + client.newCall(okhttpRequest).enqueue(new Callback() { + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try { + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + future.complete(new VitalHttpResponse<>(new ResponseBodyInputStream(response), response)); + return; + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 422) { + future.completeExceptionally(new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, HttpValidationError.class), + response)); + return; + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + future.completeExceptionally(new ApiError( + "Error with status code " + response.code(), response.code(), errorBody, response)); + return; + } catch (IOException e) { + future.completeExceptionally(new VitalException("Network error executing HTTP request", e)); + } + } + + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + future.completeExceptionally(new VitalException("Network error executing HTTP request", e)); + } + }); + return future; + } +} diff --git a/src/main/java/com/vital/api/resources/ordertransaction/OrderTransactionClient.java b/src/main/java/com/vital/api/resources/ordertransaction/OrderTransactionClient.java new file mode 100644 index 00000000..f428f74f --- /dev/null +++ b/src/main/java/com/vital/api/resources/ordertransaction/OrderTransactionClient.java @@ -0,0 +1,56 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.vital.api.resources.ordertransaction; + +import com.vital.api.core.ClientOptions; +import com.vital.api.core.RequestOptions; +import com.vital.api.types.GetOrderTransactionResponse; +import com.vital.api.types.LabResultsRaw; +import java.io.InputStream; + +public class OrderTransactionClient { + protected final ClientOptions clientOptions; + + private final RawOrderTransactionClient rawClient; + + public OrderTransactionClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + this.rawClient = new RawOrderTransactionClient(clientOptions); + } + + /** + * Get responses with HTTP metadata like headers + */ + public RawOrderTransactionClient withRawResponse() { + return this.rawClient; + } + + public GetOrderTransactionResponse getTransaction(String transactionId) { + return this.rawClient.getTransaction(transactionId).body(); + } + + public GetOrderTransactionResponse getTransaction(String transactionId, RequestOptions requestOptions) { + return this.rawClient.getTransaction(transactionId, requestOptions).body(); + } + + public LabResultsRaw getTransactionResult(String transactionId) { + return this.rawClient.getTransactionResult(transactionId).body(); + } + + public LabResultsRaw getTransactionResult(String transactionId, RequestOptions requestOptions) { + return this.rawClient + .getTransactionResult(transactionId, requestOptions) + .body(); + } + + public InputStream getTransactionResultPdf(String transactionId) { + return this.rawClient.getTransactionResultPdf(transactionId).body(); + } + + public InputStream getTransactionResultPdf(String transactionId, RequestOptions requestOptions) { + return this.rawClient + .getTransactionResultPdf(transactionId, requestOptions) + .body(); + } +} diff --git a/src/main/java/com/vital/api/resources/ordertransaction/RawOrderTransactionClient.java b/src/main/java/com/vital/api/resources/ordertransaction/RawOrderTransactionClient.java new file mode 100644 index 00000000..cc0bb86f --- /dev/null +++ b/src/main/java/com/vital/api/resources/ordertransaction/RawOrderTransactionClient.java @@ -0,0 +1,179 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.vital.api.resources.ordertransaction; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.vital.api.core.ApiError; +import com.vital.api.core.ClientOptions; +import com.vital.api.core.ObjectMappers; +import com.vital.api.core.RequestOptions; +import com.vital.api.core.ResponseBodyInputStream; +import com.vital.api.core.VitalException; +import com.vital.api.core.VitalHttpResponse; +import com.vital.api.errors.UnprocessableEntityError; +import com.vital.api.types.GetOrderTransactionResponse; +import com.vital.api.types.HttpValidationError; +import com.vital.api.types.LabResultsRaw; +import java.io.IOException; +import java.io.InputStream; +import okhttp3.Headers; +import okhttp3.HttpUrl; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import okhttp3.ResponseBody; + +public class RawOrderTransactionClient { + protected final ClientOptions clientOptions; + + public RawOrderTransactionClient(ClientOptions clientOptions) { + this.clientOptions = clientOptions; + } + + public VitalHttpResponse getTransaction(String transactionId) { + return getTransaction(transactionId, null); + } + + public VitalHttpResponse getTransaction( + String transactionId, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v3/order_transaction") + .addPathSegment(transactionId); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((key, value) -> { + httpUrl.addQueryParameter(key, value); + }); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new VitalHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, GetOrderTransactionResponse.class), + response); + } + try { + if (response.code() == 422) { + throw new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, HttpValidationError.class), + response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new ApiError("Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new VitalException("Network error executing HTTP request", e); + } + } + + public VitalHttpResponse getTransactionResult(String transactionId) { + return getTransactionResult(transactionId, null); + } + + public VitalHttpResponse getTransactionResult(String transactionId, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v3/order_transaction") + .addPathSegment(transactionId) + .addPathSegments("result"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((key, value) -> { + httpUrl.addQueryParameter(key, value); + }); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try (Response response = client.newCall(okhttpRequest).execute()) { + ResponseBody responseBody = response.body(); + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + if (response.isSuccessful()) { + return new VitalHttpResponse<>( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, LabResultsRaw.class), response); + } + try { + if (response.code() == 422) { + throw new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, HttpValidationError.class), + response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new ApiError("Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new VitalException("Network error executing HTTP request", e); + } + } + + public VitalHttpResponse getTransactionResultPdf(String transactionId) { + return getTransactionResultPdf(transactionId, null); + } + + public VitalHttpResponse getTransactionResultPdf(String transactionId, RequestOptions requestOptions) { + HttpUrl.Builder httpUrl = HttpUrl.parse(this.clientOptions.environment().getUrl()) + .newBuilder() + .addPathSegments("v3/order_transaction") + .addPathSegment(transactionId) + .addPathSegments("result") + .addPathSegments("pdf"); + if (requestOptions != null) { + requestOptions.getQueryParameters().forEach((key, value) -> { + httpUrl.addQueryParameter(key, value); + }); + } + Request okhttpRequest = new Request.Builder() + .url(httpUrl.build()) + .method("GET", null) + .headers(Headers.of(clientOptions.headers(requestOptions))) + .addHeader("Accept", "application/json") + .build(); + OkHttpClient client = clientOptions.httpClient(); + if (requestOptions != null && requestOptions.getTimeout().isPresent()) { + client = clientOptions.httpClientWithTimeout(requestOptions); + } + try { + Response response = client.newCall(okhttpRequest).execute(); + ResponseBody responseBody = response.body(); + if (response.isSuccessful()) { + return new VitalHttpResponse<>(new ResponseBodyInputStream(response), response); + } + String responseBodyString = responseBody != null ? responseBody.string() : "{}"; + try { + if (response.code() == 422) { + throw new UnprocessableEntityError( + ObjectMappers.JSON_MAPPER.readValue(responseBodyString, HttpValidationError.class), + response); + } + } catch (JsonProcessingException ignored) { + // unable to map error response, throwing generic error + } + Object errorBody = ObjectMappers.parseErrorBody(responseBodyString); + throw new ApiError("Error with status code " + response.code(), response.code(), errorBody, response); + } catch (IOException e) { + throw new VitalException("Network error executing HTTP request", e); + } + } +} diff --git a/src/main/java/com/vital/api/types/ClientFacingOrderInTransaction.java b/src/main/java/com/vital/api/types/ClientFacingOrderInTransaction.java index 4585d6c8..cf1f736b 100644 --- a/src/main/java/com/vital/api/types/ClientFacingOrderInTransaction.java +++ b/src/main/java/com/vital/api/types/ClientFacingOrderInTransaction.java @@ -24,9 +24,9 @@ public final class ClientFacingOrderInTransaction { private final String id; - private final Optional status; + private final Optional lowLevelStatus; - private final Optional statusCreatedAt; + private final Optional lowLevelStatusCreatedAt; private final Optional origin; @@ -40,16 +40,16 @@ public final class ClientFacingOrderInTransaction { private ClientFacingOrderInTransaction( String id, - Optional status, - Optional statusCreatedAt, + Optional lowLevelStatus, + Optional lowLevelStatusCreatedAt, Optional origin, Optional parentId, OffsetDateTime createdAt, OffsetDateTime updatedAt, Map additionalProperties) { this.id = id; - this.status = status; - this.statusCreatedAt = statusCreatedAt; + this.lowLevelStatus = lowLevelStatus; + this.lowLevelStatusCreatedAt = lowLevelStatusCreatedAt; this.origin = origin; this.parentId = parentId; this.createdAt = createdAt; @@ -62,14 +62,14 @@ public String getId() { return id; } - @JsonProperty("status") - public Optional getStatus() { - return status; + @JsonProperty("low_level_status") + public Optional getLowLevelStatus() { + return lowLevelStatus; } - @JsonProperty("status_created_at") - public Optional getStatusCreatedAt() { - return statusCreatedAt; + @JsonProperty("low_level_status_created_at") + public Optional getLowLevelStatusCreatedAt() { + return lowLevelStatusCreatedAt; } @JsonProperty("origin") @@ -105,8 +105,8 @@ public Map getAdditionalProperties() { private boolean equalTo(ClientFacingOrderInTransaction other) { return id.equals(other.id) - && status.equals(other.status) - && statusCreatedAt.equals(other.statusCreatedAt) + && lowLevelStatus.equals(other.lowLevelStatus) + && lowLevelStatusCreatedAt.equals(other.lowLevelStatusCreatedAt) && origin.equals(other.origin) && parentId.equals(other.parentId) && createdAt.equals(other.createdAt) @@ -116,7 +116,13 @@ private boolean equalTo(ClientFacingOrderInTransaction other) { @java.lang.Override public int hashCode() { return Objects.hash( - this.id, this.status, this.statusCreatedAt, this.origin, this.parentId, this.createdAt, this.updatedAt); + this.id, + this.lowLevelStatus, + this.lowLevelStatusCreatedAt, + this.origin, + this.parentId, + this.createdAt, + this.updatedAt); } @java.lang.Override @@ -145,13 +151,13 @@ public interface UpdatedAtStage { public interface _FinalStage { ClientFacingOrderInTransaction build(); - _FinalStage status(Optional status); + _FinalStage lowLevelStatus(Optional lowLevelStatus); - _FinalStage status(OrderTopLevelStatus status); + _FinalStage lowLevelStatus(OrderLowLevelStatus lowLevelStatus); - _FinalStage statusCreatedAt(Optional statusCreatedAt); + _FinalStage lowLevelStatusCreatedAt(Optional lowLevelStatusCreatedAt); - _FinalStage statusCreatedAt(OffsetDateTime statusCreatedAt); + _FinalStage lowLevelStatusCreatedAt(OffsetDateTime lowLevelStatusCreatedAt); _FinalStage origin(Optional origin); @@ -174,9 +180,9 @@ public static final class Builder implements IdStage, CreatedAtStage, UpdatedAtS private Optional origin = Optional.empty(); - private Optional statusCreatedAt = Optional.empty(); + private Optional lowLevelStatusCreatedAt = Optional.empty(); - private Optional status = Optional.empty(); + private Optional lowLevelStatus = Optional.empty(); @JsonAnySetter private Map additionalProperties = new HashMap<>(); @@ -186,8 +192,8 @@ private Builder() {} @java.lang.Override public Builder from(ClientFacingOrderInTransaction other) { id(other.getId()); - status(other.getStatus()); - statusCreatedAt(other.getStatusCreatedAt()); + lowLevelStatus(other.getLowLevelStatus()); + lowLevelStatusCreatedAt(other.getLowLevelStatusCreatedAt()); origin(other.getOrigin()); parentId(other.getParentId()); createdAt(other.getCreatedAt()); @@ -243,35 +249,42 @@ public _FinalStage origin(Optional origin) { } @java.lang.Override - public _FinalStage statusCreatedAt(OffsetDateTime statusCreatedAt) { - this.statusCreatedAt = Optional.ofNullable(statusCreatedAt); + public _FinalStage lowLevelStatusCreatedAt(OffsetDateTime lowLevelStatusCreatedAt) { + this.lowLevelStatusCreatedAt = Optional.ofNullable(lowLevelStatusCreatedAt); return this; } @java.lang.Override - @JsonSetter(value = "status_created_at", nulls = Nulls.SKIP) - public _FinalStage statusCreatedAt(Optional statusCreatedAt) { - this.statusCreatedAt = statusCreatedAt; + @JsonSetter(value = "low_level_status_created_at", nulls = Nulls.SKIP) + public _FinalStage lowLevelStatusCreatedAt(Optional lowLevelStatusCreatedAt) { + this.lowLevelStatusCreatedAt = lowLevelStatusCreatedAt; return this; } @java.lang.Override - public _FinalStage status(OrderTopLevelStatus status) { - this.status = Optional.ofNullable(status); + public _FinalStage lowLevelStatus(OrderLowLevelStatus lowLevelStatus) { + this.lowLevelStatus = Optional.ofNullable(lowLevelStatus); return this; } @java.lang.Override - @JsonSetter(value = "status", nulls = Nulls.SKIP) - public _FinalStage status(Optional status) { - this.status = status; + @JsonSetter(value = "low_level_status", nulls = Nulls.SKIP) + public _FinalStage lowLevelStatus(Optional lowLevelStatus) { + this.lowLevelStatus = lowLevelStatus; return this; } @java.lang.Override public ClientFacingOrderInTransaction build() { return new ClientFacingOrderInTransaction( - id, status, statusCreatedAt, origin, parentId, createdAt, updatedAt, additionalProperties); + id, + lowLevelStatus, + lowLevelStatusCreatedAt, + origin, + parentId, + createdAt, + updatedAt, + additionalProperties); } } } diff --git a/src/main/java/com/vital/api/types/GetOrderTransactionResponse.java b/src/main/java/com/vital/api/types/GetOrderTransactionResponse.java new file mode 100644 index 00000000..c8493a36 --- /dev/null +++ b/src/main/java/com/vital/api/types/GetOrderTransactionResponse.java @@ -0,0 +1,185 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.vital.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.vital.api.core.ObjectMappers; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = GetOrderTransactionResponse.Builder.class) +public final class GetOrderTransactionResponse { + private final String id; + + private final String teamId; + + private final String status; + + private final Optional> orders; + + private final Map additionalProperties; + + private GetOrderTransactionResponse( + String id, + String teamId, + String status, + Optional> orders, + Map additionalProperties) { + this.id = id; + this.teamId = teamId; + this.status = status; + this.orders = orders; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("team_id") + public String getTeamId() { + return teamId; + } + + @JsonProperty("status") + public String getStatus() { + return status; + } + + @JsonProperty("orders") + public Optional> getOrders() { + return orders; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof GetOrderTransactionResponse && equalTo((GetOrderTransactionResponse) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(GetOrderTransactionResponse other) { + return id.equals(other.id) + && teamId.equals(other.teamId) + && status.equals(other.status) + && orders.equals(other.orders); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash(this.id, this.teamId, this.status, this.orders); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + TeamIdStage id(@NotNull String id); + + Builder from(GetOrderTransactionResponse other); + } + + public interface TeamIdStage { + StatusStage teamId(@NotNull String teamId); + } + + public interface StatusStage { + _FinalStage status(@NotNull String status); + } + + public interface _FinalStage { + GetOrderTransactionResponse build(); + + _FinalStage orders(Optional> orders); + + _FinalStage orders(List orders); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder implements IdStage, TeamIdStage, StatusStage, _FinalStage { + private String id; + + private String teamId; + + private String status; + + private Optional> orders = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(GetOrderTransactionResponse other) { + id(other.getId()); + teamId(other.getTeamId()); + status(other.getStatus()); + orders(other.getOrders()); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public TeamIdStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("team_id") + public StatusStage teamId(@NotNull String teamId) { + this.teamId = Objects.requireNonNull(teamId, "teamId must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("status") + public _FinalStage status(@NotNull String status) { + this.status = Objects.requireNonNull(status, "status must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage orders(List orders) { + this.orders = Optional.ofNullable(orders); + return this; + } + + @java.lang.Override + @JsonSetter(value = "orders", nulls = Nulls.SKIP) + public _FinalStage orders(Optional> orders) { + this.orders = orders; + return this; + } + + @java.lang.Override + public GetOrderTransactionResponse build() { + return new GetOrderTransactionResponse(id, teamId, status, orders, additionalProperties); + } + } +} diff --git a/src/main/java/com/vital/api/types/OrderSummary.java b/src/main/java/com/vital/api/types/OrderSummary.java new file mode 100644 index 00000000..582da2b7 --- /dev/null +++ b/src/main/java/com/vital/api/types/OrderSummary.java @@ -0,0 +1,273 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ +package com.vital.api.types; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonSetter; +import com.fasterxml.jackson.annotation.Nulls; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.vital.api.core.ObjectMappers; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import org.jetbrains.annotations.NotNull; + +@JsonInclude(JsonInclude.Include.NON_ABSENT) +@JsonDeserialize(builder = OrderSummary.Builder.class) +public final class OrderSummary { + private final String id; + + private final Optional origin; + + private final Optional parentId; + + private final OrderLowLevelStatus lastStatus; + + private final OffsetDateTime lastStatusCreatedAt; + + private final OffsetDateTime updatedAt; + + private final OffsetDateTime createdAt; + + private final Map additionalProperties; + + private OrderSummary( + String id, + Optional origin, + Optional parentId, + OrderLowLevelStatus lastStatus, + OffsetDateTime lastStatusCreatedAt, + OffsetDateTime updatedAt, + OffsetDateTime createdAt, + Map additionalProperties) { + this.id = id; + this.origin = origin; + this.parentId = parentId; + this.lastStatus = lastStatus; + this.lastStatusCreatedAt = lastStatusCreatedAt; + this.updatedAt = updatedAt; + this.createdAt = createdAt; + this.additionalProperties = additionalProperties; + } + + @JsonProperty("id") + public String getId() { + return id; + } + + @JsonProperty("origin") + public Optional getOrigin() { + return origin; + } + + @JsonProperty("parent_id") + public Optional getParentId() { + return parentId; + } + + @JsonProperty("last_status") + public OrderLowLevelStatus getLastStatus() { + return lastStatus; + } + + @JsonProperty("last_status_created_at") + public OffsetDateTime getLastStatusCreatedAt() { + return lastStatusCreatedAt; + } + + @JsonProperty("updated_at") + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + @JsonProperty("created_at") + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + @java.lang.Override + public boolean equals(Object other) { + if (this == other) return true; + return other instanceof OrderSummary && equalTo((OrderSummary) other); + } + + @JsonAnyGetter + public Map getAdditionalProperties() { + return this.additionalProperties; + } + + private boolean equalTo(OrderSummary other) { + return id.equals(other.id) + && origin.equals(other.origin) + && parentId.equals(other.parentId) + && lastStatus.equals(other.lastStatus) + && lastStatusCreatedAt.equals(other.lastStatusCreatedAt) + && updatedAt.equals(other.updatedAt) + && createdAt.equals(other.createdAt); + } + + @java.lang.Override + public int hashCode() { + return Objects.hash( + this.id, + this.origin, + this.parentId, + this.lastStatus, + this.lastStatusCreatedAt, + this.updatedAt, + this.createdAt); + } + + @java.lang.Override + public String toString() { + return ObjectMappers.stringify(this); + } + + public static IdStage builder() { + return new Builder(); + } + + public interface IdStage { + LastStatusStage id(@NotNull String id); + + Builder from(OrderSummary other); + } + + public interface LastStatusStage { + LastStatusCreatedAtStage lastStatus(@NotNull OrderLowLevelStatus lastStatus); + } + + public interface LastStatusCreatedAtStage { + UpdatedAtStage lastStatusCreatedAt(@NotNull OffsetDateTime lastStatusCreatedAt); + } + + public interface UpdatedAtStage { + CreatedAtStage updatedAt(@NotNull OffsetDateTime updatedAt); + } + + public interface CreatedAtStage { + _FinalStage createdAt(@NotNull OffsetDateTime createdAt); + } + + public interface _FinalStage { + OrderSummary build(); + + _FinalStage origin(Optional origin); + + _FinalStage origin(OrderOrigin origin); + + _FinalStage parentId(Optional parentId); + + _FinalStage parentId(String parentId); + } + + @JsonIgnoreProperties(ignoreUnknown = true) + public static final class Builder + implements IdStage, LastStatusStage, LastStatusCreatedAtStage, UpdatedAtStage, CreatedAtStage, _FinalStage { + private String id; + + private OrderLowLevelStatus lastStatus; + + private OffsetDateTime lastStatusCreatedAt; + + private OffsetDateTime updatedAt; + + private OffsetDateTime createdAt; + + private Optional parentId = Optional.empty(); + + private Optional origin = Optional.empty(); + + @JsonAnySetter + private Map additionalProperties = new HashMap<>(); + + private Builder() {} + + @java.lang.Override + public Builder from(OrderSummary other) { + id(other.getId()); + origin(other.getOrigin()); + parentId(other.getParentId()); + lastStatus(other.getLastStatus()); + lastStatusCreatedAt(other.getLastStatusCreatedAt()); + updatedAt(other.getUpdatedAt()); + createdAt(other.getCreatedAt()); + return this; + } + + @java.lang.Override + @JsonSetter("id") + public LastStatusStage id(@NotNull String id) { + this.id = Objects.requireNonNull(id, "id must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("last_status") + public LastStatusCreatedAtStage lastStatus(@NotNull OrderLowLevelStatus lastStatus) { + this.lastStatus = Objects.requireNonNull(lastStatus, "lastStatus must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("last_status_created_at") + public UpdatedAtStage lastStatusCreatedAt(@NotNull OffsetDateTime lastStatusCreatedAt) { + this.lastStatusCreatedAt = + Objects.requireNonNull(lastStatusCreatedAt, "lastStatusCreatedAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("updated_at") + public CreatedAtStage updatedAt(@NotNull OffsetDateTime updatedAt) { + this.updatedAt = Objects.requireNonNull(updatedAt, "updatedAt must not be null"); + return this; + } + + @java.lang.Override + @JsonSetter("created_at") + public _FinalStage createdAt(@NotNull OffsetDateTime createdAt) { + this.createdAt = Objects.requireNonNull(createdAt, "createdAt must not be null"); + return this; + } + + @java.lang.Override + public _FinalStage parentId(String parentId) { + this.parentId = Optional.ofNullable(parentId); + return this; + } + + @java.lang.Override + @JsonSetter(value = "parent_id", nulls = Nulls.SKIP) + public _FinalStage parentId(Optional parentId) { + this.parentId = parentId; + return this; + } + + @java.lang.Override + public _FinalStage origin(OrderOrigin origin) { + this.origin = Optional.ofNullable(origin); + return this; + } + + @java.lang.Override + @JsonSetter(value = "origin", nulls = Nulls.SKIP) + public _FinalStage origin(Optional origin) { + this.origin = origin; + return this; + } + + @java.lang.Override + public OrderSummary build() { + return new OrderSummary( + id, origin, parentId, lastStatus, lastStatusCreatedAt, updatedAt, createdAt, additionalProperties); + } + } +}