From 49b844478ec1c6e1bf34fa448e97d2b6ee91e625 Mon Sep 17 00:00:00 2001 From: Stainless Bot Date: Tue, 26 Nov 2024 15:40:14 +0000 Subject: [PATCH] chore(api): add backtest methods to AuthRules --- .stats.yml | 2 +- .../models/AuthRuleV2BacktestCreateParams.kt | 326 ++++++++ .../AuthRuleV2BacktestRetrieveParams.kt | 191 +++++ .../api/models/BacktestCreateResponse.kt | 108 +++ .../com/lithic/api/models/BacktestResults.kt | 727 ++++++++++++++++++ .../com/lithic/api/models/SettlementDetail.kt | 28 +- .../async/authRules/V2ServiceAsync.kt | 3 + .../async/authRules/V2ServiceAsyncImpl.kt | 6 + .../authRules/v2/BacktestServiceAsync.kt | 69 ++ .../authRules/v2/BacktestServiceAsyncImpl.kt | 132 ++++ .../services/blocking/authRules/V2Service.kt | 3 + .../blocking/authRules/V2ServiceImpl.kt | 6 + .../blocking/authRules/v2/BacktestService.kt | 68 ++ .../authRules/v2/BacktestServiceImpl.kt | 129 ++++ .../AuthRuleV2BacktestCreateParamsTest.kt | 57 ++ .../AuthRuleV2BacktestRetrieveParamsTest.kt | 34 + .../api/models/BacktestCreateResponseTest.kt | 20 + .../lithic/api/models/BacktestResultsTest.kt | 113 +++ .../lithic/api/models/SettlementDetailTest.kt | 3 + .../authRules/v2/BacktestServiceTest.kt | 53 ++ 20 files changed, 2074 insertions(+), 4 deletions(-) create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2BacktestCreateParams.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2BacktestRetrieveParams.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/BacktestCreateResponse.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/BacktestResults.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/v2/BacktestServiceAsync.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/v2/BacktestServiceAsyncImpl.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/v2/BacktestService.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/v2/BacktestServiceImpl.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2BacktestCreateParamsTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2BacktestRetrieveParamsTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/BacktestCreateResponseTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/BacktestResultsTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/authRules/v2/BacktestServiceTest.kt diff --git a/.stats.yml b/.stats.yml index db174bd64..d831e60eb 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 151 +configured_endpoints: 153 diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2BacktestCreateParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2BacktestCreateParams.kt new file mode 100644 index 000000000..1d835caeb --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2BacktestCreateParams.kt @@ -0,0 +1,326 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.http.Headers +import com.lithic.api.core.http.QueryParams +import com.lithic.api.core.toImmutable +import com.lithic.api.models.* +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +class AuthRuleV2BacktestCreateParams +constructor( + private val authRuleToken: String, + private val end: OffsetDateTime?, + private val start: OffsetDateTime?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) { + + fun authRuleToken(): String = authRuleToken + + fun end(): Optional = Optional.ofNullable(end) + + fun start(): Optional = Optional.ofNullable(start) + + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun _additionalBodyProperties(): Map = additionalBodyProperties + + @JvmSynthetic + internal fun getBody(): AuthRuleV2BacktestCreateBody { + return AuthRuleV2BacktestCreateBody( + end, + start, + additionalBodyProperties, + ) + } + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> authRuleToken + else -> "" + } + } + + @JsonDeserialize(builder = AuthRuleV2BacktestCreateBody.Builder::class) + @NoAutoDetect + class AuthRuleV2BacktestCreateBody + internal constructor( + private val end: OffsetDateTime?, + private val start: OffsetDateTime?, + private val additionalProperties: Map, + ) { + + /** The end time of the backtest. */ + @JsonProperty("end") fun end(): OffsetDateTime? = end + + /** The start time of the backtest. */ + @JsonProperty("start") fun start(): OffsetDateTime? = start + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var end: OffsetDateTime? = null + private var start: OffsetDateTime? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(authRuleV2BacktestCreateBody: AuthRuleV2BacktestCreateBody) = apply { + this.end = authRuleV2BacktestCreateBody.end + this.start = authRuleV2BacktestCreateBody.start + additionalProperties(authRuleV2BacktestCreateBody.additionalProperties) + } + + /** The end time of the backtest. */ + @JsonProperty("end") fun end(end: OffsetDateTime) = apply { this.end = end } + + /** The start time of the backtest. */ + @JsonProperty("start") fun start(start: OffsetDateTime) = apply { this.start = start } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): AuthRuleV2BacktestCreateBody = + AuthRuleV2BacktestCreateBody( + end, + start, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AuthRuleV2BacktestCreateBody && end == other.end && start == other.start && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(end, start, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AuthRuleV2BacktestCreateBody{end=$end, start=$start, additionalProperties=$additionalProperties}" + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var authRuleToken: String? = null + private var end: OffsetDateTime? = null + private var start: OffsetDateTime? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(authRuleV2BacktestCreateParams: AuthRuleV2BacktestCreateParams) = apply { + authRuleToken = authRuleV2BacktestCreateParams.authRuleToken + end = authRuleV2BacktestCreateParams.end + start = authRuleV2BacktestCreateParams.start + additionalHeaders = authRuleV2BacktestCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = authRuleV2BacktestCreateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + authRuleV2BacktestCreateParams.additionalBodyProperties.toMutableMap() + } + + fun authRuleToken(authRuleToken: String) = apply { this.authRuleToken = authRuleToken } + + /** The end time of the backtest. */ + fun end(end: OffsetDateTime) = apply { this.end = end } + + /** The start time of the backtest. */ + fun start(start: OffsetDateTime) = apply { this.start = start } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + fun build(): AuthRuleV2BacktestCreateParams = + AuthRuleV2BacktestCreateParams( + checkNotNull(authRuleToken) { "`authRuleToken` is required but was not set" }, + end, + start, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AuthRuleV2BacktestCreateParams && authRuleToken == other.authRuleToken && end == other.end && start == other.start && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams && additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(authRuleToken, end, start, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + + override fun toString() = + "AuthRuleV2BacktestCreateParams{authRuleToken=$authRuleToken, end=$end, start=$start, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2BacktestRetrieveParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2BacktestRetrieveParams.kt new file mode 100644 index 000000000..0f329b93d --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2BacktestRetrieveParams.kt @@ -0,0 +1,191 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.http.Headers +import com.lithic.api.core.http.QueryParams +import com.lithic.api.models.* +import java.util.Objects + +class AuthRuleV2BacktestRetrieveParams +constructor( + private val authRuleToken: String, + private val authRuleBacktestToken: String, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) { + + fun authRuleToken(): String = authRuleToken + + fun authRuleBacktestToken(): String = authRuleBacktestToken + + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + + @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams + + fun getPathParam(index: Int): String { + return when (index) { + 0 -> authRuleToken + 1 -> authRuleBacktestToken + else -> "" + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + @NoAutoDetect + class Builder { + + private var authRuleToken: String? = null + private var authRuleBacktestToken: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(authRuleV2BacktestRetrieveParams: AuthRuleV2BacktestRetrieveParams) = + apply { + authRuleToken = authRuleV2BacktestRetrieveParams.authRuleToken + authRuleBacktestToken = authRuleV2BacktestRetrieveParams.authRuleBacktestToken + additionalHeaders = authRuleV2BacktestRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = + authRuleV2BacktestRetrieveParams.additionalQueryParams.toBuilder() + } + + fun authRuleToken(authRuleToken: String) = apply { this.authRuleToken = authRuleToken } + + fun authRuleBacktestToken(authRuleBacktestToken: String) = apply { + this.authRuleBacktestToken = authRuleBacktestToken + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun build(): AuthRuleV2BacktestRetrieveParams = + AuthRuleV2BacktestRetrieveParams( + checkNotNull(authRuleToken) { "`authRuleToken` is required but was not set" }, + checkNotNull(authRuleBacktestToken) { + "`authRuleBacktestToken` is required but was not set" + }, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is AuthRuleV2BacktestRetrieveParams && authRuleToken == other.authRuleToken && authRuleBacktestToken == other.authRuleBacktestToken && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(authRuleToken, authRuleBacktestToken, additionalHeaders, additionalQueryParams) /* spotless:on */ + + override fun toString() = + "AuthRuleV2BacktestRetrieveParams{authRuleToken=$authRuleToken, authRuleBacktestToken=$authRuleBacktestToken, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/BacktestCreateResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/BacktestCreateResponse.kt new file mode 100644 index 000000000..25937e2c4 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/BacktestCreateResponse.kt @@ -0,0 +1,108 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.toImmutable +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(builder = BacktestCreateResponse.Builder::class) +@NoAutoDetect +class BacktestCreateResponse +private constructor( + private val backtestToken: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + /** Auth Rule Backtest Token */ + fun backtestToken(): Optional = + Optional.ofNullable(backtestToken.getNullable("backtest_token")) + + /** Auth Rule Backtest Token */ + @JsonProperty("backtest_token") @ExcludeMissing fun _backtestToken() = backtestToken + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): BacktestCreateResponse = apply { + if (!validated) { + backtestToken() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var backtestToken: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(backtestCreateResponse: BacktestCreateResponse) = apply { + this.backtestToken = backtestCreateResponse.backtestToken + additionalProperties(backtestCreateResponse.additionalProperties) + } + + /** Auth Rule Backtest Token */ + fun backtestToken(backtestToken: String) = backtestToken(JsonField.of(backtestToken)) + + /** Auth Rule Backtest Token */ + @JsonProperty("backtest_token") + @ExcludeMissing + fun backtestToken(backtestToken: JsonField) = apply { + this.backtestToken = backtestToken + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): BacktestCreateResponse = + BacktestCreateResponse(backtestToken, additionalProperties.toImmutable()) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BacktestCreateResponse && backtestToken == other.backtestToken && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(backtestToken, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BacktestCreateResponse{backtestToken=$backtestToken, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/BacktestResults.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/BacktestResults.kt new file mode 100644 index 000000000..c25377c81 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/BacktestResults.kt @@ -0,0 +1,727 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.NoAutoDetect +import com.lithic.api.core.toImmutable +import java.time.OffsetDateTime +import java.util.Objects +import java.util.Optional + +@JsonDeserialize(builder = BacktestResults.Builder::class) +@NoAutoDetect +class BacktestResults +private constructor( + private val backtestToken: JsonField, + private val simulationParameters: JsonField, + private val results: JsonField, + private val additionalProperties: Map, +) { + + private var validated: Boolean = false + + /** Auth Rule Backtest Token */ + fun backtestToken(): String = backtestToken.getRequired("backtest_token") + + fun simulationParameters(): SimulationParameters = + simulationParameters.getRequired("simulation_parameters") + + fun results(): Results = results.getRequired("results") + + /** Auth Rule Backtest Token */ + @JsonProperty("backtest_token") @ExcludeMissing fun _backtestToken() = backtestToken + + @JsonProperty("simulation_parameters") + @ExcludeMissing + fun _simulationParameters() = simulationParameters + + @JsonProperty("results") @ExcludeMissing fun _results() = results + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): BacktestResults = apply { + if (!validated) { + backtestToken() + simulationParameters().validate() + results().validate() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var backtestToken: JsonField = JsonMissing.of() + private var simulationParameters: JsonField = JsonMissing.of() + private var results: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(backtestResults: BacktestResults) = apply { + this.backtestToken = backtestResults.backtestToken + this.simulationParameters = backtestResults.simulationParameters + this.results = backtestResults.results + additionalProperties(backtestResults.additionalProperties) + } + + /** Auth Rule Backtest Token */ + fun backtestToken(backtestToken: String) = backtestToken(JsonField.of(backtestToken)) + + /** Auth Rule Backtest Token */ + @JsonProperty("backtest_token") + @ExcludeMissing + fun backtestToken(backtestToken: JsonField) = apply { + this.backtestToken = backtestToken + } + + fun simulationParameters(simulationParameters: SimulationParameters) = + simulationParameters(JsonField.of(simulationParameters)) + + @JsonProperty("simulation_parameters") + @ExcludeMissing + fun simulationParameters(simulationParameters: JsonField) = apply { + this.simulationParameters = simulationParameters + } + + fun results(results: Results) = results(JsonField.of(results)) + + @JsonProperty("results") + @ExcludeMissing + fun results(results: JsonField) = apply { this.results = results } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): BacktestResults = + BacktestResults( + backtestToken, + simulationParameters, + results, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = Results.Builder::class) + @NoAutoDetect + class Results + private constructor( + private val currentVersion: JsonField, + private val draftVersion: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + fun currentVersion(): Optional = + Optional.ofNullable(currentVersion.getNullable("current_version")) + + fun draftVersion(): Optional = + Optional.ofNullable(draftVersion.getNullable("draft_version")) + + @JsonProperty("current_version") @ExcludeMissing fun _currentVersion() = currentVersion + + @JsonProperty("draft_version") @ExcludeMissing fun _draftVersion() = draftVersion + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Results = apply { + if (!validated) { + currentVersion().map { it.validate() } + draftVersion().map { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var currentVersion: JsonField = JsonMissing.of() + private var draftVersion: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(results: Results) = apply { + this.currentVersion = results.currentVersion + this.draftVersion = results.draftVersion + additionalProperties(results.additionalProperties) + } + + fun currentVersion(currentVersion: RuleStats) = + currentVersion(JsonField.of(currentVersion)) + + @JsonProperty("current_version") + @ExcludeMissing + fun currentVersion(currentVersion: JsonField) = apply { + this.currentVersion = currentVersion + } + + fun draftVersion(draftVersion: RuleStats) = draftVersion(JsonField.of(draftVersion)) + + @JsonProperty("draft_version") + @ExcludeMissing + fun draftVersion(draftVersion: JsonField) = apply { + this.draftVersion = draftVersion + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Results = + Results( + currentVersion, + draftVersion, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = RuleStats.Builder::class) + @NoAutoDetect + class RuleStats + private constructor( + private val version: JsonField, + private val approved: JsonField, + private val declined: JsonField, + private val examples: JsonField>, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + fun version(): Optional = Optional.ofNullable(version.getNullable("version")) + + /** + * The total number of historical transactions approved by this rule during the backtest + * period, or the number of transactions that would have been approved if the rule was + * evaluated in shadow mode. + */ + fun approved(): Optional = Optional.ofNullable(approved.getNullable("approved")) + + /** + * The total number of historical transactions declined by this rule during the backtest + * period, or the number of transactions that would have been declined if the rule was + * evaluated in shadow mode. + */ + fun declined(): Optional = Optional.ofNullable(declined.getNullable("declined")) + + /** Example authorization request events that would have been approved or declined. */ + fun examples(): Optional> = + Optional.ofNullable(examples.getNullable("examples")) + + /** + * The version of the rule, this is incremented whenever the rule's parameters change. + */ + @JsonProperty("version") @ExcludeMissing fun _version() = version + + /** + * The total number of historical transactions approved by this rule during the backtest + * period, or the number of transactions that would have been approved if the rule was + * evaluated in shadow mode. + */ + @JsonProperty("approved") @ExcludeMissing fun _approved() = approved + + /** + * The total number of historical transactions declined by this rule during the backtest + * period, or the number of transactions that would have been declined if the rule was + * evaluated in shadow mode. + */ + @JsonProperty("declined") @ExcludeMissing fun _declined() = declined + + /** Example authorization request events that would have been approved or declined. */ + @JsonProperty("examples") @ExcludeMissing fun _examples() = examples + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): RuleStats = apply { + if (!validated) { + version() + approved() + declined() + examples().map { it.forEach { it.validate() } } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var version: JsonField = JsonMissing.of() + private var approved: JsonField = JsonMissing.of() + private var declined: JsonField = JsonMissing.of() + private var examples: JsonField> = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(ruleStats: RuleStats) = apply { + this.version = ruleStats.version + this.approved = ruleStats.approved + this.declined = ruleStats.declined + this.examples = ruleStats.examples + additionalProperties(ruleStats.additionalProperties) + } + + /** + * The version of the rule, this is incremented whenever the rule's parameters + * change. + */ + fun version(version: Long) = version(JsonField.of(version)) + + /** + * The version of the rule, this is incremented whenever the rule's parameters + * change. + */ + @JsonProperty("version") + @ExcludeMissing + fun version(version: JsonField) = apply { this.version = version } + + /** + * The total number of historical transactions approved by this rule during the + * backtest period, or the number of transactions that would have been approved if + * the rule was evaluated in shadow mode. + */ + fun approved(approved: Long) = approved(JsonField.of(approved)) + + /** + * The total number of historical transactions approved by this rule during the + * backtest period, or the number of transactions that would have been approved if + * the rule was evaluated in shadow mode. + */ + @JsonProperty("approved") + @ExcludeMissing + fun approved(approved: JsonField) = apply { this.approved = approved } + + /** + * The total number of historical transactions declined by this rule during the + * backtest period, or the number of transactions that would have been declined if + * the rule was evaluated in shadow mode. + */ + fun declined(declined: Long) = declined(JsonField.of(declined)) + + /** + * The total number of historical transactions declined by this rule during the + * backtest period, or the number of transactions that would have been declined if + * the rule was evaluated in shadow mode. + */ + @JsonProperty("declined") + @ExcludeMissing + fun declined(declined: JsonField) = apply { this.declined = declined } + + /** + * Example authorization request events that would have been approved or declined. + */ + fun examples(examples: List) = examples(JsonField.of(examples)) + + /** + * Example authorization request events that would have been approved or declined. + */ + @JsonProperty("examples") + @ExcludeMissing + fun examples(examples: JsonField>) = apply { + this.examples = examples + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): RuleStats = + RuleStats( + version, + approved, + declined, + examples.map { it.toImmutable() }, + additionalProperties.toImmutable(), + ) + } + + @JsonDeserialize(builder = Example.Builder::class) + @NoAutoDetect + class Example + private constructor( + private val eventToken: JsonField, + private val timestamp: JsonField, + private val approved: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** The authorization request event token. */ + fun eventToken(): Optional = + Optional.ofNullable(eventToken.getNullable("event_token")) + + /** The timestamp of the authorization request event. */ + fun timestamp(): Optional = + Optional.ofNullable(timestamp.getNullable("timestamp")) + + /** Whether the rule would have approved the authorization request. */ + fun approved(): Optional = + Optional.ofNullable(approved.getNullable("approved")) + + /** The authorization request event token. */ + @JsonProperty("event_token") @ExcludeMissing fun _eventToken() = eventToken + + /** The timestamp of the authorization request event. */ + @JsonProperty("timestamp") @ExcludeMissing fun _timestamp() = timestamp + + /** Whether the rule would have approved the authorization request. */ + @JsonProperty("approved") @ExcludeMissing fun _approved() = approved + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): Example = apply { + if (!validated) { + eventToken() + timestamp() + approved() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var eventToken: JsonField = JsonMissing.of() + private var timestamp: JsonField = JsonMissing.of() + private var approved: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(example: Example) = apply { + this.eventToken = example.eventToken + this.timestamp = example.timestamp + this.approved = example.approved + additionalProperties(example.additionalProperties) + } + + /** The authorization request event token. */ + fun eventToken(eventToken: String) = eventToken(JsonField.of(eventToken)) + + /** The authorization request event token. */ + @JsonProperty("event_token") + @ExcludeMissing + fun eventToken(eventToken: JsonField) = apply { + this.eventToken = eventToken + } + + /** The timestamp of the authorization request event. */ + fun timestamp(timestamp: OffsetDateTime) = timestamp(JsonField.of(timestamp)) + + /** The timestamp of the authorization request event. */ + @JsonProperty("timestamp") + @ExcludeMissing + fun timestamp(timestamp: JsonField) = apply { + this.timestamp = timestamp + } + + /** Whether the rule would have approved the authorization request. */ + fun approved(approved: Boolean) = approved(JsonField.of(approved)) + + /** Whether the rule would have approved the authorization request. */ + @JsonProperty("approved") + @ExcludeMissing + fun approved(approved: JsonField) = apply { this.approved = approved } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): Example = + Example( + eventToken, + timestamp, + approved, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Example && eventToken == other.eventToken && timestamp == other.timestamp && approved == other.approved && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(eventToken, timestamp, approved, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Example{eventToken=$eventToken, timestamp=$timestamp, approved=$approved, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is RuleStats && version == other.version && approved == other.approved && declined == other.declined && examples == other.examples && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(version, approved, declined, examples, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RuleStats{version=$version, approved=$approved, declined=$declined, examples=$examples, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Results && currentVersion == other.currentVersion && draftVersion == other.draftVersion && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(currentVersion, draftVersion, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Results{currentVersion=$currentVersion, draftVersion=$draftVersion, additionalProperties=$additionalProperties}" + } + + @JsonDeserialize(builder = SimulationParameters.Builder::class) + @NoAutoDetect + class SimulationParameters + private constructor( + private val authRuleToken: JsonField, + private val start: JsonField, + private val end: JsonField, + private val additionalProperties: Map, + ) { + + private var validated: Boolean = false + + /** Auth Rule Token */ + fun authRuleToken(): Optional = + Optional.ofNullable(authRuleToken.getNullable("auth_rule_token")) + + /** The start time of the simulation. */ + fun start(): Optional = Optional.ofNullable(start.getNullable("start")) + + /** The end time of the simulation. */ + fun end(): Optional = Optional.ofNullable(end.getNullable("end")) + + /** Auth Rule Token */ + @JsonProperty("auth_rule_token") @ExcludeMissing fun _authRuleToken() = authRuleToken + + /** The start time of the simulation. */ + @JsonProperty("start") @ExcludeMissing fun _start() = start + + /** The end time of the simulation. */ + @JsonProperty("end") @ExcludeMissing fun _end() = end + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun validate(): SimulationParameters = apply { + if (!validated) { + authRuleToken() + start() + end() + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var authRuleToken: JsonField = JsonMissing.of() + private var start: JsonField = JsonMissing.of() + private var end: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(simulationParameters: SimulationParameters) = apply { + this.authRuleToken = simulationParameters.authRuleToken + this.start = simulationParameters.start + this.end = simulationParameters.end + additionalProperties(simulationParameters.additionalProperties) + } + + /** Auth Rule Token */ + fun authRuleToken(authRuleToken: String) = authRuleToken(JsonField.of(authRuleToken)) + + /** Auth Rule Token */ + @JsonProperty("auth_rule_token") + @ExcludeMissing + fun authRuleToken(authRuleToken: JsonField) = apply { + this.authRuleToken = authRuleToken + } + + /** The start time of the simulation. */ + fun start(start: OffsetDateTime) = start(JsonField.of(start)) + + /** The start time of the simulation. */ + @JsonProperty("start") + @ExcludeMissing + fun start(start: JsonField) = apply { this.start = start } + + /** The end time of the simulation. */ + fun end(end: OffsetDateTime) = end(JsonField.of(end)) + + /** The end time of the simulation. */ + @JsonProperty("end") + @ExcludeMissing + fun end(end: JsonField) = apply { this.end = end } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + this.additionalProperties.putAll(additionalProperties) + } + + @JsonAnySetter + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + this.additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun build(): SimulationParameters = + SimulationParameters( + authRuleToken, + start, + end, + additionalProperties.toImmutable(), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is SimulationParameters && authRuleToken == other.authRuleToken && start == other.start && end == other.end && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(authRuleToken, start, end, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SimulationParameters{authRuleToken=$authRuleToken, start=$start, end=$end, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BacktestResults && backtestToken == other.backtestToken && simulationParameters == other.simulationParameters && results == other.results && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(backtestToken, simulationParameters, results, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BacktestResults{backtestToken=$backtestToken, simulationParameters=$simulationParameters, results=$results, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/SettlementDetail.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/SettlementDetail.kt index 158a2b8a6..1120e6a46 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/SettlementDetail.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/SettlementDetail.kt @@ -30,6 +30,7 @@ private constructor( private val currency: JsonField, private val disputesGrossAmount: JsonField, private val eventTokens: JsonField>, + private val feeDescription: JsonField, private val institution: JsonField, private val interchangeFeeExtendedPrecision: JsonField, private val interchangeGrossAmount: JsonField, @@ -72,6 +73,10 @@ private constructor( /** Globally unique identifiers denoting the Events associated with this settlement. */ fun eventTokens(): List = eventTokens.getRequired("event_tokens") + /** Network's description of a fee, only present on records with type `FEE`. */ + fun feeDescription(): Optional = + Optional.ofNullable(feeDescription.getNullable("fee_description")) + /** The most granular ID the network settles with (e.g., ICA for Mastercard, FTSRE for Visa). */ fun institution(): String = institution.getRequired("institution") @@ -143,6 +148,9 @@ private constructor( /** Globally unique identifiers denoting the Events associated with this settlement. */ @JsonProperty("event_tokens") @ExcludeMissing fun _eventTokens() = eventTokens + /** Network's description of a fee, only present on records with type `FEE`. */ + @JsonProperty("fee_description") @ExcludeMissing fun _feeDescription() = feeDescription + /** The most granular ID the network settles with (e.g., ICA for Mastercard, FTSRE for Visa). */ @JsonProperty("institution") @ExcludeMissing fun _institution() = institution @@ -206,6 +214,7 @@ private constructor( currency() disputesGrossAmount() eventTokens() + feeDescription() institution() interchangeFeeExtendedPrecision() interchangeGrossAmount() @@ -239,6 +248,7 @@ private constructor( private var currency: JsonField = JsonMissing.of() private var disputesGrossAmount: JsonField = JsonMissing.of() private var eventTokens: JsonField> = JsonMissing.of() + private var feeDescription: JsonField = JsonMissing.of() private var institution: JsonField = JsonMissing.of() private var interchangeFeeExtendedPrecision: JsonField = JsonMissing.of() private var interchangeGrossAmount: JsonField = JsonMissing.of() @@ -263,6 +273,7 @@ private constructor( this.currency = settlementDetail.currency this.disputesGrossAmount = settlementDetail.disputesGrossAmount this.eventTokens = settlementDetail.eventTokens + this.feeDescription = settlementDetail.feeDescription this.institution = settlementDetail.institution this.interchangeFeeExtendedPrecision = settlementDetail.interchangeFeeExtendedPrecision this.interchangeGrossAmount = settlementDetail.interchangeGrossAmount @@ -359,6 +370,16 @@ private constructor( this.eventTokens = eventTokens } + /** Network's description of a fee, only present on records with type `FEE`. */ + fun feeDescription(feeDescription: String) = feeDescription(JsonField.of(feeDescription)) + + /** Network's description of a fee, only present on records with type `FEE`. */ + @JsonProperty("fee_description") + @ExcludeMissing + fun feeDescription(feeDescription: JsonField) = apply { + this.feeDescription = feeDescription + } + /** * The most granular ID the network settles with (e.g., ICA for Mastercard, FTSRE for Visa). */ @@ -517,6 +538,7 @@ private constructor( currency, disputesGrossAmount, eventTokens.map { it.toImmutable() }, + feeDescription, institution, interchangeFeeExtendedPrecision, interchangeGrossAmount, @@ -799,15 +821,15 @@ private constructor( return true } - return /* spotless:off */ other is SettlementDetail && accountToken == other.accountToken && cardProgramToken == other.cardProgramToken && cardToken == other.cardToken && created == other.created && currency == other.currency && disputesGrossAmount == other.disputesGrossAmount && eventTokens == other.eventTokens && institution == other.institution && interchangeFeeExtendedPrecision == other.interchangeFeeExtendedPrecision && interchangeGrossAmount == other.interchangeGrossAmount && network == other.network && otherFeesDetails == other.otherFeesDetails && otherFeesGrossAmount == other.otherFeesGrossAmount && reportDate == other.reportDate && settlementDate == other.settlementDate && token == other.token && transactionToken == other.transactionToken && transactionsGrossAmount == other.transactionsGrossAmount && type == other.type && updated == other.updated && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SettlementDetail && accountToken == other.accountToken && cardProgramToken == other.cardProgramToken && cardToken == other.cardToken && created == other.created && currency == other.currency && disputesGrossAmount == other.disputesGrossAmount && eventTokens == other.eventTokens && feeDescription == other.feeDescription && institution == other.institution && interchangeFeeExtendedPrecision == other.interchangeFeeExtendedPrecision && interchangeGrossAmount == other.interchangeGrossAmount && network == other.network && otherFeesDetails == other.otherFeesDetails && otherFeesGrossAmount == other.otherFeesGrossAmount && reportDate == other.reportDate && settlementDate == other.settlementDate && token == other.token && transactionToken == other.transactionToken && transactionsGrossAmount == other.transactionsGrossAmount && type == other.type && updated == other.updated && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(accountToken, cardProgramToken, cardToken, created, currency, disputesGrossAmount, eventTokens, institution, interchangeFeeExtendedPrecision, interchangeGrossAmount, network, otherFeesDetails, otherFeesGrossAmount, reportDate, settlementDate, token, transactionToken, transactionsGrossAmount, type, updated, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(accountToken, cardProgramToken, cardToken, created, currency, disputesGrossAmount, eventTokens, feeDescription, institution, interchangeFeeExtendedPrecision, interchangeGrossAmount, network, otherFeesDetails, otherFeesGrossAmount, reportDate, settlementDate, token, transactionToken, transactionsGrossAmount, type, updated, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "SettlementDetail{accountToken=$accountToken, cardProgramToken=$cardProgramToken, cardToken=$cardToken, created=$created, currency=$currency, disputesGrossAmount=$disputesGrossAmount, eventTokens=$eventTokens, institution=$institution, interchangeFeeExtendedPrecision=$interchangeFeeExtendedPrecision, interchangeGrossAmount=$interchangeGrossAmount, network=$network, otherFeesDetails=$otherFeesDetails, otherFeesGrossAmount=$otherFeesGrossAmount, reportDate=$reportDate, settlementDate=$settlementDate, token=$token, transactionToken=$transactionToken, transactionsGrossAmount=$transactionsGrossAmount, type=$type, updated=$updated, additionalProperties=$additionalProperties}" + "SettlementDetail{accountToken=$accountToken, cardProgramToken=$cardProgramToken, cardToken=$cardToken, created=$created, currency=$currency, disputesGrossAmount=$disputesGrossAmount, eventTokens=$eventTokens, feeDescription=$feeDescription, institution=$institution, interchangeFeeExtendedPrecision=$interchangeFeeExtendedPrecision, interchangeGrossAmount=$interchangeGrossAmount, network=$network, otherFeesDetails=$otherFeesDetails, otherFeesGrossAmount=$otherFeesGrossAmount, reportDate=$reportDate, settlementDate=$settlementDate, token=$token, transactionToken=$transactionToken, transactionsGrossAmount=$transactionsGrossAmount, type=$type, updated=$updated, additionalProperties=$additionalProperties}" } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsync.kt index 87ff8988b..91e5e368d 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsync.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsync.kt @@ -21,10 +21,13 @@ import com.lithic.api.models.V2PromoteResponse import com.lithic.api.models.V2ReportResponse import com.lithic.api.models.V2RetrieveResponse import com.lithic.api.models.V2UpdateResponse +import com.lithic.api.services.async.authRules.v2.BacktestServiceAsync import java.util.concurrent.CompletableFuture interface V2ServiceAsync { + fun backtests(): BacktestServiceAsync + /** Creates a new V2 authorization rule in draft mode */ @JvmOverloads fun create( diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsyncImpl.kt index 6ef1029ff..e49069d9b 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/V2ServiceAsyncImpl.kt @@ -28,6 +28,8 @@ import com.lithic.api.models.V2PromoteResponse import com.lithic.api.models.V2ReportResponse import com.lithic.api.models.V2RetrieveResponse import com.lithic.api.models.V2UpdateResponse +import com.lithic.api.services.async.authRules.v2.BacktestServiceAsync +import com.lithic.api.services.async.authRules.v2.BacktestServiceAsyncImpl import java.util.concurrent.CompletableFuture class V2ServiceAsyncImpl @@ -37,6 +39,10 @@ constructor( private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val backtests: BacktestServiceAsync by lazy { BacktestServiceAsyncImpl(clientOptions) } + + override fun backtests(): BacktestServiceAsync = backtests + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/v2/BacktestServiceAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/v2/BacktestServiceAsync.kt new file mode 100644 index 000000000..d2ef5149c --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/v2/BacktestServiceAsync.kt @@ -0,0 +1,69 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package com.lithic.api.services.async.authRules.v2 + +import com.lithic.api.core.RequestOptions +import com.lithic.api.models.AuthRuleV2BacktestCreateParams +import com.lithic.api.models.AuthRuleV2BacktestRetrieveParams +import com.lithic.api.models.BacktestCreateResponse +import com.lithic.api.models.BacktestResults +import java.util.concurrent.CompletableFuture + +interface BacktestServiceAsync { + + /** + * Initiates a request to asynchronously generate a backtest for an authorization rule. During + * backtesting, both the active version (if one exists) and the draft version of the + * Authorization Rule are evaluated by replaying historical transaction data against the rule's + * conditions. This process allows customers to simulate and understand the effects of proposed + * rule changes before deployment. The generated backtest report provides detailed results + * showing whether the draft version of the Auth Rule would have approved or declined historical + * transactions which were processed during the backtest period. These reports help evaluate how + * changes to rule configurations might affect overall transaction approval rates. + * + * The generated backtest report will be delivered asynchronously through a webhook with + * `event_type` = `auth_rules.backtest_report.created`. See the docs on setting up + * [webhook subscriptions](https://docs.lithic.com/docs/events-api). It is also possible to + * request backtest reports on-demand through the + * `/v2/auth_rules/{auth_rule_token}/backtests/{auth_rule_backtest_token}` endpoint. + * + * Lithic currently supports backtesting for `CONDITIONAL_BLOCK` rules. Backtesting for + * `VELOCITY_LIMIT` rules is generally not supported. In specific cases (i.e. where Lithic has + * pre-calculated the requested velocity metrics for historical transactions), a backtest may be + * feasible. However, such cases are uncommon and customers should not anticipate support for + * velocity backtests under most configurations. If a historical transaction does not feature + * the required inputs to evaluate the rule, then it will not be included in the final backtest + * report. + */ + @JvmOverloads + fun create( + params: AuthRuleV2BacktestCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture + + /** + * Returns the backtest results of an authorization rule (if available). + * + * Backtesting is an asynchronous process that requires time to complete. If a customer + * retrieves the backtest results using this endpoint before the report is fully generated, the + * response will return null for `results.current_version` and `results.draft_version`. + * Customers are advised to wait for the backtest creation process to complete (as indicated by + * the webhook event auth_rules.backtest_report.created) before retrieving results from this + * endpoint. + * + * Backtesting is an asynchronous process, while the backtest is being processed, results will + * not be available which will cause `results.current_version` and `results.draft_version` + * objects to contain `null`. The entries in `results` will also always represent the + * configuration of the rule at the time requests are made to this endpoint. For example, the + * results for `current_version` in the served backtest report will be consistent with which + * version of the rule is currently activated in the Auth Stream, regardless of which version of + * the rule was active in the Auth Stream at the time a backtest is requested. + */ + @JvmOverloads + fun retrieve( + params: AuthRuleV2BacktestRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): CompletableFuture +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/v2/BacktestServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/v2/BacktestServiceAsyncImpl.kt new file mode 100644 index 000000000..9d00bebc6 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/authRules/v2/BacktestServiceAsyncImpl.kt @@ -0,0 +1,132 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.async.authRules.v2 + +import com.lithic.api.core.ClientOptions +import com.lithic.api.core.RequestOptions +import com.lithic.api.core.handlers.errorHandler +import com.lithic.api.core.handlers.jsonHandler +import com.lithic.api.core.handlers.withErrorHandler +import com.lithic.api.core.http.HttpMethod +import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse.Handler +import com.lithic.api.core.json +import com.lithic.api.errors.LithicError +import com.lithic.api.models.AuthRuleV2BacktestCreateParams +import com.lithic.api.models.AuthRuleV2BacktestRetrieveParams +import com.lithic.api.models.BacktestCreateResponse +import com.lithic.api.models.BacktestResults +import java.util.concurrent.CompletableFuture + +class BacktestServiceAsyncImpl +constructor( + private val clientOptions: ClientOptions, +) : BacktestServiceAsync { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** + * Initiates a request to asynchronously generate a backtest for an authorization rule. During + * backtesting, both the active version (if one exists) and the draft version of the + * Authorization Rule are evaluated by replaying historical transaction data against the rule's + * conditions. This process allows customers to simulate and understand the effects of proposed + * rule changes before deployment. The generated backtest report provides detailed results + * showing whether the draft version of the Auth Rule would have approved or declined historical + * transactions which were processed during the backtest period. These reports help evaluate how + * changes to rule configurations might affect overall transaction approval rates. + * + * The generated backtest report will be delivered asynchronously through a webhook with + * `event_type` = `auth_rules.backtest_report.created`. See the docs on setting up + * [webhook subscriptions](https://docs.lithic.com/docs/events-api). It is also possible to + * request backtest reports on-demand through the + * `/v2/auth_rules/{auth_rule_token}/backtests/{auth_rule_backtest_token}` endpoint. + * + * Lithic currently supports backtesting for `CONDITIONAL_BLOCK` rules. Backtesting for + * `VELOCITY_LIMIT` rules is generally not supported. In specific cases (i.e. where Lithic has + * pre-calculated the requested velocity metrics for historical transactions), a backtest may be + * feasible. However, such cases are uncommon and customers should not anticipate support for + * velocity backtests under most configurations. If a historical transaction does not feature + * the required inputs to evaluate the rule, then it will not be included in the final backtest + * report. + */ + override fun create( + params: AuthRuleV2BacktestCreateParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v2", "auth_rules", params.getPathParam(0), "backtests") + .putAllQueryParams(clientOptions.queryParams) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .replaceAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** + * Returns the backtest results of an authorization rule (if available). + * + * Backtesting is an asynchronous process that requires time to complete. If a customer + * retrieves the backtest results using this endpoint before the report is fully generated, the + * response will return null for `results.current_version` and `results.draft_version`. + * Customers are advised to wait for the backtest creation process to complete (as indicated by + * the webhook event auth_rules.backtest_report.created) before retrieving results from this + * endpoint. + * + * Backtesting is an asynchronous process, while the backtest is being processed, results will + * not be available which will cause `results.current_version` and `results.draft_version` + * objects to contain `null`. The entries in `results` will also always represent the + * configuration of the rule at the time requests are made to this endpoint. For example, the + * results for `current_version` in the served backtest report will be consistent with which + * version of the rule is currently activated in the Auth Stream, regardless of which version of + * the rule was active in the Auth Stream at the time a backtest is requested. + */ + override fun retrieve( + params: AuthRuleV2BacktestRetrieveParams, + requestOptions: RequestOptions + ): CompletableFuture { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "v2", + "auth_rules", + params.getPathParam(0), + "backtests", + params.getPathParam(1) + ) + .putAllQueryParams(clientOptions.queryParams) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .replaceAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.executeAsync(request, requestOptions).thenApply { response + -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/V2Service.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/V2Service.kt index 482293821..244ba4681 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/V2Service.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/V2Service.kt @@ -21,9 +21,12 @@ import com.lithic.api.models.V2PromoteResponse import com.lithic.api.models.V2ReportResponse import com.lithic.api.models.V2RetrieveResponse import com.lithic.api.models.V2UpdateResponse +import com.lithic.api.services.blocking.authRules.v2.BacktestService interface V2Service { + fun backtests(): BacktestService + /** Creates a new V2 authorization rule in draft mode */ @JvmOverloads fun create( diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/V2ServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/V2ServiceImpl.kt index d26882edb..8d63e849a 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/V2ServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/V2ServiceImpl.kt @@ -28,6 +28,8 @@ import com.lithic.api.models.V2PromoteResponse import com.lithic.api.models.V2ReportResponse import com.lithic.api.models.V2RetrieveResponse import com.lithic.api.models.V2UpdateResponse +import com.lithic.api.services.blocking.authRules.v2.BacktestService +import com.lithic.api.services.blocking.authRules.v2.BacktestServiceImpl class V2ServiceImpl constructor( @@ -36,6 +38,10 @@ constructor( private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + private val backtests: BacktestService by lazy { BacktestServiceImpl(clientOptions) } + + override fun backtests(): BacktestService = backtests + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/v2/BacktestService.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/v2/BacktestService.kt new file mode 100644 index 000000000..2d6050ecc --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/v2/BacktestService.kt @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +@file:Suppress("OVERLOADS_INTERFACE") // See https://youtrack.jetbrains.com/issue/KT-36102 + +package com.lithic.api.services.blocking.authRules.v2 + +import com.lithic.api.core.RequestOptions +import com.lithic.api.models.AuthRuleV2BacktestCreateParams +import com.lithic.api.models.AuthRuleV2BacktestRetrieveParams +import com.lithic.api.models.BacktestCreateResponse +import com.lithic.api.models.BacktestResults + +interface BacktestService { + + /** + * Initiates a request to asynchronously generate a backtest for an authorization rule. During + * backtesting, both the active version (if one exists) and the draft version of the + * Authorization Rule are evaluated by replaying historical transaction data against the rule's + * conditions. This process allows customers to simulate and understand the effects of proposed + * rule changes before deployment. The generated backtest report provides detailed results + * showing whether the draft version of the Auth Rule would have approved or declined historical + * transactions which were processed during the backtest period. These reports help evaluate how + * changes to rule configurations might affect overall transaction approval rates. + * + * The generated backtest report will be delivered asynchronously through a webhook with + * `event_type` = `auth_rules.backtest_report.created`. See the docs on setting up + * [webhook subscriptions](https://docs.lithic.com/docs/events-api). It is also possible to + * request backtest reports on-demand through the + * `/v2/auth_rules/{auth_rule_token}/backtests/{auth_rule_backtest_token}` endpoint. + * + * Lithic currently supports backtesting for `CONDITIONAL_BLOCK` rules. Backtesting for + * `VELOCITY_LIMIT` rules is generally not supported. In specific cases (i.e. where Lithic has + * pre-calculated the requested velocity metrics for historical transactions), a backtest may be + * feasible. However, such cases are uncommon and customers should not anticipate support for + * velocity backtests under most configurations. If a historical transaction does not feature + * the required inputs to evaluate the rule, then it will not be included in the final backtest + * report. + */ + @JvmOverloads + fun create( + params: AuthRuleV2BacktestCreateParams, + requestOptions: RequestOptions = RequestOptions.none() + ): BacktestCreateResponse + + /** + * Returns the backtest results of an authorization rule (if available). + * + * Backtesting is an asynchronous process that requires time to complete. If a customer + * retrieves the backtest results using this endpoint before the report is fully generated, the + * response will return null for `results.current_version` and `results.draft_version`. + * Customers are advised to wait for the backtest creation process to complete (as indicated by + * the webhook event auth_rules.backtest_report.created) before retrieving results from this + * endpoint. + * + * Backtesting is an asynchronous process, while the backtest is being processed, results will + * not be available which will cause `results.current_version` and `results.draft_version` + * objects to contain `null`. The entries in `results` will also always represent the + * configuration of the rule at the time requests are made to this endpoint. For example, the + * results for `current_version` in the served backtest report will be consistent with which + * version of the rule is currently activated in the Auth Stream, regardless of which version of + * the rule was active in the Auth Stream at the time a backtest is requested. + */ + @JvmOverloads + fun retrieve( + params: AuthRuleV2BacktestRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none() + ): BacktestResults +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/v2/BacktestServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/v2/BacktestServiceImpl.kt new file mode 100644 index 000000000..dc4014b4e --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/authRules/v2/BacktestServiceImpl.kt @@ -0,0 +1,129 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking.authRules.v2 + +import com.lithic.api.core.ClientOptions +import com.lithic.api.core.RequestOptions +import com.lithic.api.core.handlers.errorHandler +import com.lithic.api.core.handlers.jsonHandler +import com.lithic.api.core.handlers.withErrorHandler +import com.lithic.api.core.http.HttpMethod +import com.lithic.api.core.http.HttpRequest +import com.lithic.api.core.http.HttpResponse.Handler +import com.lithic.api.core.json +import com.lithic.api.errors.LithicError +import com.lithic.api.models.AuthRuleV2BacktestCreateParams +import com.lithic.api.models.AuthRuleV2BacktestRetrieveParams +import com.lithic.api.models.BacktestCreateResponse +import com.lithic.api.models.BacktestResults + +class BacktestServiceImpl +constructor( + private val clientOptions: ClientOptions, +) : BacktestService { + + private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** + * Initiates a request to asynchronously generate a backtest for an authorization rule. During + * backtesting, both the active version (if one exists) and the draft version of the + * Authorization Rule are evaluated by replaying historical transaction data against the rule's + * conditions. This process allows customers to simulate and understand the effects of proposed + * rule changes before deployment. The generated backtest report provides detailed results + * showing whether the draft version of the Auth Rule would have approved or declined historical + * transactions which were processed during the backtest period. These reports help evaluate how + * changes to rule configurations might affect overall transaction approval rates. + * + * The generated backtest report will be delivered asynchronously through a webhook with + * `event_type` = `auth_rules.backtest_report.created`. See the docs on setting up + * [webhook subscriptions](https://docs.lithic.com/docs/events-api). It is also possible to + * request backtest reports on-demand through the + * `/v2/auth_rules/{auth_rule_token}/backtests/{auth_rule_backtest_token}` endpoint. + * + * Lithic currently supports backtesting for `CONDITIONAL_BLOCK` rules. Backtesting for + * `VELOCITY_LIMIT` rules is generally not supported. In specific cases (i.e. where Lithic has + * pre-calculated the requested velocity metrics for historical transactions), a backtest may be + * feasible. However, such cases are uncommon and customers should not anticipate support for + * velocity backtests under most configurations. If a historical transaction does not feature + * the required inputs to evaluate the rule, then it will not be included in the final backtest + * report. + */ + override fun create( + params: AuthRuleV2BacktestCreateParams, + requestOptions: RequestOptions + ): BacktestCreateResponse { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .addPathSegments("v2", "auth_rules", params.getPathParam(0), "backtests") + .putAllQueryParams(clientOptions.queryParams) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .replaceAllHeaders(params.getHeaders()) + .body(json(clientOptions.jsonMapper, params.getBody())) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { createHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) + + /** + * Returns the backtest results of an authorization rule (if available). + * + * Backtesting is an asynchronous process that requires time to complete. If a customer + * retrieves the backtest results using this endpoint before the report is fully generated, the + * response will return null for `results.current_version` and `results.draft_version`. + * Customers are advised to wait for the backtest creation process to complete (as indicated by + * the webhook event auth_rules.backtest_report.created) before retrieving results from this + * endpoint. + * + * Backtesting is an asynchronous process, while the backtest is being processed, results will + * not be available which will cause `results.current_version` and `results.draft_version` + * objects to contain `null`. The entries in `results` will also always represent the + * configuration of the rule at the time requests are made to this endpoint. For example, the + * results for `current_version` in the served backtest report will be consistent with which + * version of the rule is currently activated in the Auth Stream, regardless of which version of + * the rule was active in the Auth Stream at the time a backtest is requested. + */ + override fun retrieve( + params: AuthRuleV2BacktestRetrieveParams, + requestOptions: RequestOptions + ): BacktestResults { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .addPathSegments( + "v2", + "auth_rules", + params.getPathParam(0), + "backtests", + params.getPathParam(1) + ) + .putAllQueryParams(clientOptions.queryParams) + .replaceAllQueryParams(params.getQueryParams()) + .putAllHeaders(clientOptions.headers) + .replaceAllHeaders(params.getHeaders()) + .build() + return clientOptions.httpClient.execute(request, requestOptions).let { response -> + response + .use { retrieveHandler.handle(it) } + .apply { + if (requestOptions.responseValidation ?: clientOptions.responseValidation) { + validate() + } + } + } + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2BacktestCreateParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2BacktestCreateParamsTest.kt new file mode 100644 index 000000000..f0ea50f7c --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2BacktestCreateParamsTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.models.* +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class AuthRuleV2BacktestCreateParamsTest { + + @Test + fun createAuthRuleV2BacktestCreateParams() { + AuthRuleV2BacktestCreateParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .end(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .start(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + } + + @Test + fun getBody() { + val params = + AuthRuleV2BacktestCreateParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .end(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .start(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + val body = params.getBody() + assertThat(body).isNotNull + assertThat(body.end()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(body.start()).isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun getBodyWithoutOptionalFields() { + val params = + AuthRuleV2BacktestCreateParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + val body = params.getBody() + assertThat(body).isNotNull + } + + @Test + fun getPathParam() { + val params = + AuthRuleV2BacktestCreateParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "authRuleToken" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(1)).isEqualTo("") + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2BacktestRetrieveParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2BacktestRetrieveParamsTest.kt new file mode 100644 index 000000000..389c4d8db --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleV2BacktestRetrieveParamsTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.lithic.api.models.* +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class AuthRuleV2BacktestRetrieveParamsTest { + + @Test + fun createAuthRuleV2BacktestRetrieveParams() { + AuthRuleV2BacktestRetrieveParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .authRuleBacktestToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun getPathParam() { + val params = + AuthRuleV2BacktestRetrieveParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .authRuleBacktestToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(params).isNotNull + // path param "authRuleToken" + assertThat(params.getPathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // path param "authRuleBacktestToken" + assertThat(params.getPathParam(1)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params.getPathParam(2)).isEqualTo("") + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/BacktestCreateResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/BacktestCreateResponseTest.kt new file mode 100644 index 000000000..aabf7e459 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/BacktestCreateResponseTest.kt @@ -0,0 +1,20 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class BacktestCreateResponseTest { + + @Test + fun createBacktestCreateResponse() { + val backtestCreateResponse = + BacktestCreateResponse.builder() + .backtestToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + assertThat(backtestCreateResponse).isNotNull + assertThat(backtestCreateResponse.backtestToken()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/BacktestResultsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/BacktestResultsTest.kt new file mode 100644 index 000000000..3cc2d902f --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/BacktestResultsTest.kt @@ -0,0 +1,113 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +class BacktestResultsTest { + + @Test + fun createBacktestResults() { + val backtestResults = + BacktestResults.builder() + .backtestToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .results( + BacktestResults.Results.builder() + .currentVersion( + BacktestResults.Results.RuleStats.builder() + .approved(0L) + .declined(0L) + .examples( + listOf( + BacktestResults.Results.RuleStats.Example.builder() + .approved(true) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .timestamp( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + ) + .version(0L) + .build() + ) + .draftVersion( + BacktestResults.Results.RuleStats.builder() + .approved(0L) + .declined(0L) + .examples( + listOf( + BacktestResults.Results.RuleStats.Example.builder() + .approved(true) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .timestamp( + OffsetDateTime.parse("2019-12-27T18:11:19.117Z") + ) + .build() + ) + ) + .version(0L) + .build() + ) + .build() + ) + .simulationParameters( + BacktestResults.SimulationParameters.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .end(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .start(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + assertThat(backtestResults).isNotNull + assertThat(backtestResults.backtestToken()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(backtestResults.results()) + .isEqualTo( + BacktestResults.Results.builder() + .currentVersion( + BacktestResults.Results.RuleStats.builder() + .approved(0L) + .declined(0L) + .examples( + listOf( + BacktestResults.Results.RuleStats.Example.builder() + .approved(true) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + .version(0L) + .build() + ) + .draftVersion( + BacktestResults.Results.RuleStats.builder() + .approved(0L) + .declined(0L) + .examples( + listOf( + BacktestResults.Results.RuleStats.Example.builder() + .approved(true) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .timestamp(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + ) + .version(0L) + .build() + ) + .build() + ) + assertThat(backtestResults.simulationParameters()) + .isEqualTo( + BacktestResults.SimulationParameters.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .end(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .start(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/SettlementDetailTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/SettlementDetailTest.kt index ee616ba86..3e2da1cae 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/SettlementDetailTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/SettlementDetailTest.kt @@ -32,6 +32,7 @@ class SettlementDetailTest { .transactionsGrossAmount(1900L) .type(SettlementDetail.Type.ADJUSTMENT) .updated(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + .feeDescription("INTERCHANGE COMPLIANCE ADJUSTMENT FOR : 11/12/24") .build() assertThat(settlementDetail).isNotNull assertThat(settlementDetail.token()).isEqualTo("e34a817f-119d-4976-9fb3-8b020b8bbec3") @@ -60,5 +61,7 @@ class SettlementDetailTest { assertThat(settlementDetail.type()).isEqualTo(SettlementDetail.Type.ADJUSTMENT) assertThat(settlementDetail.updated()) .isEqualTo(OffsetDateTime.parse("2023-06-01T00:00:00Z")) + assertThat(settlementDetail.feeDescription()) + .contains("INTERCHANGE COMPLIANCE ADJUSTMENT FOR : 11/12/24") } } diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/authRules/v2/BacktestServiceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/authRules/v2/BacktestServiceTest.kt new file mode 100644 index 000000000..875faba32 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/authRules/v2/BacktestServiceTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.services.blocking.authRules.v2 + +import com.lithic.api.TestServerExtension +import com.lithic.api.client.okhttp.LithicOkHttpClient +import com.lithic.api.models.* +import java.time.OffsetDateTime +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +class BacktestServiceTest { + + @Test + fun callCreate() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val backtestService = client.authRules().v2().backtests() + val backtestCreateResponse = + backtestService.create( + AuthRuleV2BacktestCreateParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .end(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .start(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + println(backtestCreateResponse) + backtestCreateResponse.validate() + } + + @Test + fun callRetrieve() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val backtestService = client.authRules().v2().backtests() + val backtestResults = + backtestService.retrieve( + AuthRuleV2BacktestRetrieveParams.builder() + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .authRuleBacktestToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + println(backtestResults) + backtestResults.validate() + } +}