From b943cf3d7ac31090a55eb93194197c2b701e0d00 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 13 Dec 2024 03:19:01 +0000 Subject: [PATCH] chore(internal): codegen related update (#15) --- README.md | 2 +- .../sdk/models/VerificationCheckParams.kt | 26 ++++---- .../sdk/models/VerificationCheckResponse.kt | 30 +++++----- .../sdk/models/VerificationCreateParams.kt | 60 +++++++++---------- .../sdk/models/VerificationCreateResponse.kt | 52 ++++++++-------- .../prelude/sdk/models/WatchFeedBackParams.kt | 52 ++++++++-------- .../prelude/sdk/models/WatchPredictParams.kt | 26 ++++---- .../sdk/models/WatchPredictResponse.kt | 60 +++++++++---------- .../sdk/models/TransactionalSendParamsTest.kt | 20 ++++++- .../models/TransactionalSendResponseTest.kt | 13 +++- .../blocking/TransactionalServiceTest.kt | 7 ++- 11 files changed, 188 insertions(+), 160 deletions(-) diff --git a/README.md b/README.md index 878d71c..5f521ab 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ import so.prelude.sdk.models.VerificationCreateResponse; VerificationCreateParams params = VerificationCreateParams.builder() .target(VerificationCreateParams.Target.builder() - .type(VerificationCreateParams.Target.Type.phone_number) + .type(VerificationCreateParams.Target.Type.PHONE_NUMBER) .value("+30123456789") .build()) .build(); diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationCheckParams.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationCheckParams.kt index 5918c22..5c8297a 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationCheckParams.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationCheckParams.kt @@ -374,21 +374,9 @@ constructor( @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val PHONE_NUMBER = Type(JsonField.of("phone_number")) + @JvmField val PHONE_NUMBER = of("phone_number") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } @@ -415,6 +403,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationCheckResponse.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationCheckResponse.kt index 3293106..409c318 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationCheckResponse.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationCheckResponse.kt @@ -151,25 +151,13 @@ private constructor( @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val SUCCESS = Status(JsonField.of("success")) + @JvmField val SUCCESS = of("success") - @JvmField val FAILURE = Status(JsonField.of("failure")) + @JvmField val FAILURE = of("failure") - @JvmField val EXPIRED_OR_NOT_FOUND = Status(JsonField.of("expired_or_not_found")) + @JvmField val EXPIRED_OR_NOT_FOUND = of("expired_or_not_found") @JvmStatic fun of(value: String) = Status(JsonField.of(value)) } @@ -204,6 +192,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } /** The metadata for this verification. */ diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationCreateParams.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationCreateParams.kt index 07b5ca2..670552e 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationCreateParams.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationCreateParams.kt @@ -427,21 +427,9 @@ constructor( @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val PHONE_NUMBER = Type(JsonField.of("phone_number")) + @JvmField val PHONE_NUMBER = of("phone_number") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } @@ -468,6 +456,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -860,29 +860,17 @@ constructor( @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is DevicePlatform && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val ANDROID = DevicePlatform(JsonField.of("android")) + @JvmField val ANDROID = of("android") - @JvmField val IOS = DevicePlatform(JsonField.of("ios")) + @JvmField val IOS = of("ios") - @JvmField val IPADOS = DevicePlatform(JsonField.of("ipados")) + @JvmField val IPADOS = of("ipados") - @JvmField val TVOS = DevicePlatform(JsonField.of("tvos")) + @JvmField val TVOS = of("tvos") - @JvmField val WEB = DevicePlatform(JsonField.of("web")) + @JvmField val WEB = of("web") @JvmStatic fun of(value: String) = DevicePlatform(JsonField.of(value)) } @@ -925,6 +913,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is DevicePlatform && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationCreateResponse.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationCreateResponse.kt index ccec22f..9256686 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationCreateResponse.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/VerificationCreateResponse.kt @@ -170,21 +170,9 @@ private constructor( @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Method && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val MESSAGE = Method(JsonField.of("message")) + @JvmField val MESSAGE = of("message") @JvmStatic fun of(value: String) = Method(JsonField.of(value)) } @@ -211,35 +199,35 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() - } - - class Status - @JsonCreator - private constructor( - private val value: JsonField, - ) : Enum { - - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + return /* spotless:off */ other is Method && value == other.value /* spotless:on */ } override fun hashCode() = value.hashCode() override fun toString() = value.toString() + } + + class Status + @JsonCreator + private constructor( + private val value: JsonField, + ) : Enum { + + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { - @JvmField val SUCCESS = Status(JsonField.of("success")) + @JvmField val SUCCESS = of("success") - @JvmField val RETRY = Status(JsonField.of("retry")) + @JvmField val RETRY = of("retry") - @JvmField val BLOCKED = Status(JsonField.of("blocked")) + @JvmField val BLOCKED = of("blocked") @JvmStatic fun of(value: String) = Status(JsonField.of(value)) } @@ -274,6 +262,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Status && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } /** The metadata for this verification. */ diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchFeedBackParams.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchFeedBackParams.kt index 384f1bf..c5cbcb5 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchFeedBackParams.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchFeedBackParams.kt @@ -382,21 +382,9 @@ constructor( @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val CONFIRM_TARGET = Type(JsonField.of("CONFIRM_TARGET")) + @JvmField val CONFIRM_TARGET = of("CONFIRM_TARGET") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } @@ -423,6 +411,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -518,21 +518,9 @@ constructor( @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val PHONE_NUMBER = Type(JsonField.of("phone_number")) + @JvmField val PHONE_NUMBER = of("phone_number") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } @@ -559,6 +547,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchPredictParams.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchPredictParams.kt index 87649e8..782d631 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchPredictParams.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchPredictParams.kt @@ -382,21 +382,9 @@ constructor( @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val PHONE_NUMBER = Type(JsonField.of("phone_number")) + @JvmField val PHONE_NUMBER = of("phone_number") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } @@ -423,6 +411,18 @@ constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { diff --git a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchPredictResponse.kt b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchPredictResponse.kt index a65b35b..7ae0145 100644 --- a/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchPredictResponse.kt +++ b/prelude-java-core/src/main/kotlin/so/prelude/sdk/models/WatchPredictResponse.kt @@ -132,23 +132,11 @@ private constructor( @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Prediction && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val ALLOW = Prediction(JsonField.of("allow")) + @JvmField val ALLOW = of("allow") - @JvmField val BLOCK = Prediction(JsonField.of("block")) + @JvmField val BLOCK = of("block") @JvmStatic fun of(value: String) = Prediction(JsonField.of(value)) } @@ -179,6 +167,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Prediction && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } @JsonDeserialize(builder = Reasoning.Builder::class) @@ -294,27 +294,15 @@ private constructor( @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Cause && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - companion object { - @JvmField val NONE = Cause(JsonField.of("none")) + @JvmField val NONE = of("none") - @JvmField val SMART_ANTIFRAUD = Cause(JsonField.of("smart_antifraud")) + @JvmField val SMART_ANTIFRAUD = of("smart_antifraud") - @JvmField val REPEAT_NUMBER = Cause(JsonField.of("repeat_number")) + @JvmField val REPEAT_NUMBER = of("repeat_number") - @JvmField val INVALID_LINE = Cause(JsonField.of("invalid_line")) + @JvmField val INVALID_LINE = of("invalid_line") @JvmStatic fun of(value: String) = Cause(JsonField.of(value)) } @@ -353,6 +341,18 @@ private constructor( } fun asString(): String = _value().asStringOrThrow() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Cause && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/TransactionalSendParamsTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/TransactionalSendParamsTest.kt index d4f03ce..f8b21e0 100644 --- a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/TransactionalSendParamsTest.kt +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/TransactionalSendParamsTest.kt @@ -4,6 +4,7 @@ package so.prelude.sdk.models import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import so.prelude.sdk.core.JsonValue import so.prelude.sdk.models.* class TransactionalSendParamsTest { @@ -17,7 +18,11 @@ class TransactionalSendParamsTest { .correlationId("correlation_id") .expiresAt("expires_at") .from("from") - .variables(TransactionalSendParams.Variables.builder().build()) + .variables( + TransactionalSendParams.Variables.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() } @@ -31,7 +36,11 @@ class TransactionalSendParamsTest { .correlationId("correlation_id") .expiresAt("expires_at") .from("from") - .variables(TransactionalSendParams.Variables.builder().build()) + .variables( + TransactionalSendParams.Variables.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() val body = params.getBody() assertThat(body).isNotNull @@ -41,7 +50,12 @@ class TransactionalSendParamsTest { assertThat(body.correlationId()).isEqualTo("correlation_id") assertThat(body.expiresAt()).isEqualTo("expires_at") assertThat(body.from()).isEqualTo("from") - assertThat(body.variables()).isEqualTo(TransactionalSendParams.Variables.builder().build()) + assertThat(body.variables()) + .isEqualTo( + TransactionalSendParams.Variables.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) } @Test diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/TransactionalSendResponseTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/TransactionalSendResponseTest.kt index 3a2e67b..b9a4e2e 100644 --- a/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/TransactionalSendResponseTest.kt +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/models/TransactionalSendResponseTest.kt @@ -5,6 +5,7 @@ package so.prelude.sdk.models import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import so.prelude.sdk.core.JsonValue class TransactionalSendResponseTest { @@ -17,7 +18,11 @@ class TransactionalSendResponseTest { .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .templateId("template_id") .to("to") - .variables(TransactionalSendResponse.Variables.builder().build()) + .variables( + TransactionalSendResponse.Variables.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) .callbackUrl("callback_url") .correlationId("correlation_id") .from("from") @@ -31,7 +36,11 @@ class TransactionalSendResponseTest { assertThat(transactionalSendResponse.templateId()).isEqualTo("template_id") assertThat(transactionalSendResponse.to()).isEqualTo("to") assertThat(transactionalSendResponse.variables()) - .isEqualTo(TransactionalSendResponse.Variables.builder().build()) + .isEqualTo( + TransactionalSendResponse.Variables.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) assertThat(transactionalSendResponse.callbackUrl()).contains("callback_url") assertThat(transactionalSendResponse.correlationId()).contains("correlation_id") assertThat(transactionalSendResponse.from()).contains("from") diff --git a/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/blocking/TransactionalServiceTest.kt b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/blocking/TransactionalServiceTest.kt index f63716a..d2d1612 100644 --- a/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/blocking/TransactionalServiceTest.kt +++ b/prelude-java-core/src/test/kotlin/so/prelude/sdk/services/blocking/TransactionalServiceTest.kt @@ -7,6 +7,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith import so.prelude.sdk.TestServerExtension import so.prelude.sdk.client.okhttp.PreludeOkHttpClient +import so.prelude.sdk.core.JsonValue import so.prelude.sdk.models.* @ExtendWith(TestServerExtension::class) @@ -32,7 +33,11 @@ class TransactionalServiceTest { .correlationId("correlation_id") .expiresAt("expires_at") .from("from") - .variables(TransactionalSendParams.Variables.builder().build()) + .variables( + TransactionalSendParams.Variables.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) .build() ) println(transactionalSendResponse)