From 8cdeef188088565990a0057332df5cd0f4846f92 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Portier Date: Fri, 9 Aug 2024 14:34:24 +0200 Subject: [PATCH] fix (Verification): Generated sources with guard against null for DelegatedSerializer --- ...erificationReportRequestFlashCallImpl.java | 56 +++++++++++++- ...erificationReportRequestPhoneCallImpl.java | 56 +++++++++++++- .../VerificationReportRequestSmsImpl.java | 58 ++++++++++++++- ...VerificationStartRequestFlashCallImpl.java | 56 +++++++++++++- ...VerificationStartRequestPhoneCallImpl.java | 56 +++++++++++++- .../VerificationStartRequestSmsImpl.java | 67 +++++++++++++++-- .../VerificationStartResponseDataImpl.java | 55 +++++++++++++- ...erificationStartResponseFlashCallImpl.java | 74 +++++++++++++++++-- .../VerificationStartResponseSmsImpl.java | 58 ++++++++++++++- ...tionRequestEventResponseFlashCallImpl.java | 62 +++++++++++++++- ...tionRequestEventResponsePhoneCallImpl.java | 62 +++++++++++++++- ...rificationRequestEventResponseSmsImpl.java | 60 ++++++++++++++- 12 files changed, 675 insertions(+), 45 deletions(-) diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/report/request/VerificationReportRequestFlashCallImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/report/request/VerificationReportRequestFlashCallImpl.java index 9f65012c7..894250caf 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/report/request/VerificationReportRequestFlashCallImpl.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/report/request/VerificationReportRequestFlashCallImpl.java @@ -5,10 +5,19 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; import com.sinch.sdk.core.models.OptionalValue; import com.sinch.sdk.domains.verification.models.v1.report.request.internal.VerificationReportRequestFlashCallOptions; +import com.sinch.sdk.domains.verification.models.v1.report.request.internal.VerificationReportRequestFlashCallOptionsImpl; +import java.io.IOException; import java.util.Objects; +import java.util.Optional; @JsonPropertyOrder({ VerificationReportRequestFlashCallImpl.JSON_PROPERTY_METHOD, @@ -69,8 +78,10 @@ public String getCli() { } public OptionalValue cli() { - return null != flashCall - ? flashCall.map(VerificationReportRequestFlashCallOptions::getCli) + return null != flashCall && flashCall.isPresent() + ? flashCall + .map(f -> ((VerificationReportRequestFlashCallOptionsImpl) f).cli()) + .orElse(OptionalValue.empty()) : OptionalValue.empty(); } @@ -148,4 +159,45 @@ public VerificationReportRequestFlashCall build() { return new VerificationReportRequestFlashCallImpl(method, flashCall); } } + + public static class DelegatedSerializer + extends JsonSerializer> { + @Override + public void serialize( + OptionalValue value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException { + + if (!value.isPresent()) { + return; + } + VerificationReportRequestFlashCallImpl impl = + (VerificationReportRequestFlashCallImpl) value.get(); + jgen.writeObject(null != impl ? impl.getFlashCall() : null); + } + } + + public static class DelegatedDeSerializer + extends JsonDeserializer { + @Override + public VerificationReportRequestFlashCall deserialize( + JsonParser jp, DeserializationContext ctxt) throws IOException { + + VerificationReportRequestFlashCallImpl.Builder builder = + new VerificationReportRequestFlashCallImpl.Builder(); + VerificationReportRequestFlashCallOptionsImpl deserialized = + jp.readValueAs(VerificationReportRequestFlashCallOptionsImpl.class); + builder.setFlashCall(deserialized); + return builder.build(); + } + } + + public static Optional delegatedConverter( + VerificationReportRequestFlashCallOptions internal) { + if (null == internal) { + return Optional.empty(); + } + return Optional.of(new Builder().setFlashCall(internal).build()); + } } diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/report/request/VerificationReportRequestPhoneCallImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/report/request/VerificationReportRequestPhoneCallImpl.java index 1c0620bee..3c62c717e 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/report/request/VerificationReportRequestPhoneCallImpl.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/report/request/VerificationReportRequestPhoneCallImpl.java @@ -5,10 +5,19 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; import com.sinch.sdk.core.models.OptionalValue; import com.sinch.sdk.domains.verification.models.v1.report.request.internal.VerificationReportRequestPhoneCallOptions; +import com.sinch.sdk.domains.verification.models.v1.report.request.internal.VerificationReportRequestPhoneCallOptionsImpl; +import java.io.IOException; import java.util.Objects; +import java.util.Optional; @JsonPropertyOrder({ VerificationReportRequestPhoneCallImpl.JSON_PROPERTY_METHOD, @@ -69,8 +78,10 @@ public String getCode() { } public OptionalValue code() { - return null != callout - ? callout.map(VerificationReportRequestPhoneCallOptions::getCode) + return null != callout && callout.isPresent() + ? callout + .map(f -> ((VerificationReportRequestPhoneCallOptionsImpl) f).code()) + .orElse(OptionalValue.empty()) : OptionalValue.empty(); } @@ -148,4 +159,45 @@ public VerificationReportRequestPhoneCall build() { return new VerificationReportRequestPhoneCallImpl(method, callout); } } + + public static class DelegatedSerializer + extends JsonSerializer> { + @Override + public void serialize( + OptionalValue value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException { + + if (!value.isPresent()) { + return; + } + VerificationReportRequestPhoneCallImpl impl = + (VerificationReportRequestPhoneCallImpl) value.get(); + jgen.writeObject(null != impl ? impl.getCallout() : null); + } + } + + public static class DelegatedDeSerializer + extends JsonDeserializer { + @Override + public VerificationReportRequestPhoneCall deserialize( + JsonParser jp, DeserializationContext ctxt) throws IOException { + + VerificationReportRequestPhoneCallImpl.Builder builder = + new VerificationReportRequestPhoneCallImpl.Builder(); + VerificationReportRequestPhoneCallOptionsImpl deserialized = + jp.readValueAs(VerificationReportRequestPhoneCallOptionsImpl.class); + builder.setCallout(deserialized); + return builder.build(); + } + } + + public static Optional delegatedConverter( + VerificationReportRequestPhoneCallOptions internal) { + if (null == internal) { + return Optional.empty(); + } + return Optional.of(new Builder().setCallout(internal).build()); + } } diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/report/request/VerificationReportRequestSmsImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/report/request/VerificationReportRequestSmsImpl.java index 65fa0a9d0..a632f7390 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/report/request/VerificationReportRequestSmsImpl.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/report/request/VerificationReportRequestSmsImpl.java @@ -5,10 +5,19 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; import com.sinch.sdk.core.models.OptionalValue; import com.sinch.sdk.domains.verification.models.v1.report.request.internal.VerificationReportRequestSmsOptions; +import com.sinch.sdk.domains.verification.models.v1.report.request.internal.VerificationReportRequestSmsOptionsImpl; +import java.io.IOException; import java.util.Objects; +import java.util.Optional; @JsonPropertyOrder({ VerificationReportRequestSmsImpl.JSON_PROPERTY_METHOD, @@ -68,8 +77,9 @@ public String getCode() { } public OptionalValue code() { - return null != sms - ? sms.map(VerificationReportRequestSmsOptions::getCode) + return null != sms && sms.isPresent() + ? sms.map(f -> ((VerificationReportRequestSmsOptionsImpl) f).code()) + .orElse(OptionalValue.empty()) : OptionalValue.empty(); } @@ -82,8 +92,9 @@ public String getCli() { } public OptionalValue cli() { - return null != sms - ? sms.map(VerificationReportRequestSmsOptions::getCli) + return null != sms && sms.isPresent() + ? sms.map(f -> ((VerificationReportRequestSmsOptionsImpl) f).cli()) + .orElse(OptionalValue.empty()) : OptionalValue.empty(); } @@ -167,4 +178,43 @@ public VerificationReportRequestSms build() { return new VerificationReportRequestSmsImpl(method, sms); } } + + public static class DelegatedSerializer + extends JsonSerializer> { + @Override + public void serialize( + OptionalValue value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException { + + if (!value.isPresent()) { + return; + } + VerificationReportRequestSmsImpl impl = (VerificationReportRequestSmsImpl) value.get(); + jgen.writeObject(null != impl ? impl.getSms() : null); + } + } + + public static class DelegatedDeSerializer extends JsonDeserializer { + @Override + public VerificationReportRequestSms deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException { + + VerificationReportRequestSmsImpl.Builder builder = + new VerificationReportRequestSmsImpl.Builder(); + VerificationReportRequestSmsOptionsImpl deserialized = + jp.readValueAs(VerificationReportRequestSmsOptionsImpl.class); + builder.setSms(deserialized); + return builder.build(); + } + } + + public static Optional delegatedConverter( + VerificationReportRequestSmsOptions internal) { + if (null == internal) { + return Optional.empty(); + } + return Optional.of(new Builder().setSms(internal).build()); + } } diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/start/request/VerificationStartRequestFlashCallImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/start/request/VerificationStartRequestFlashCallImpl.java index 365f709f3..d0b1af32e 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/start/request/VerificationStartRequestFlashCallImpl.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/start/request/VerificationStartRequestFlashCallImpl.java @@ -5,12 +5,21 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; import com.sinch.sdk.core.models.OptionalValue; import com.sinch.sdk.domains.verification.models.v1.Identity; import com.sinch.sdk.domains.verification.models.v1.VerificationMethod; import com.sinch.sdk.domains.verification.models.v1.start.request.internal.VerificationStartFlashCallOptions; +import com.sinch.sdk.domains.verification.models.v1.start.request.internal.VerificationStartFlashCallOptionsImpl; +import java.io.IOException; import java.util.Objects; +import java.util.Optional; @JsonPropertyOrder({ VerificationStartRequestFlashCallImpl.JSON_PROPERTY_IDENTITY, @@ -127,8 +136,10 @@ public Integer getDialTimeout() { } public OptionalValue dialTimeout() { - return null != flashCallOptions - ? flashCallOptions.map(VerificationStartFlashCallOptions::getDialTimeout) + return null != flashCallOptions && flashCallOptions.isPresent() + ? flashCallOptions + .map(f -> ((VerificationStartFlashCallOptionsImpl) f).dialTimeout()) + .orElse(OptionalValue.empty()) : OptionalValue.empty(); } @@ -235,4 +246,45 @@ public VerificationStartRequestFlashCall build() { identity, method, reference, custom, flashCallOptions); } } + + public static class DelegatedSerializer + extends JsonSerializer> { + @Override + public void serialize( + OptionalValue value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException { + + if (!value.isPresent()) { + return; + } + VerificationStartRequestFlashCallImpl impl = + (VerificationStartRequestFlashCallImpl) value.get(); + jgen.writeObject(null != impl ? impl.getFlashCallOptions() : null); + } + } + + public static class DelegatedDeSerializer + extends JsonDeserializer { + @Override + public VerificationStartRequestFlashCall deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException { + + VerificationStartRequestFlashCallImpl.Builder builder = + new VerificationStartRequestFlashCallImpl.Builder(); + VerificationStartFlashCallOptionsImpl deserialized = + jp.readValueAs(VerificationStartFlashCallOptionsImpl.class); + builder.setFlashCallOptions(deserialized); + return builder.build(); + } + } + + public static Optional delegatedConverter( + VerificationStartFlashCallOptions internal) { + if (null == internal) { + return Optional.empty(); + } + return Optional.of(new Builder().setFlashCallOptions(internal).build()); + } } diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/start/request/VerificationStartRequestPhoneCallImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/start/request/VerificationStartRequestPhoneCallImpl.java index 00094261c..1bd3e3431 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/start/request/VerificationStartRequestPhoneCallImpl.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/start/request/VerificationStartRequestPhoneCallImpl.java @@ -5,12 +5,21 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; import com.sinch.sdk.core.models.OptionalValue; import com.sinch.sdk.domains.verification.models.v1.Identity; import com.sinch.sdk.domains.verification.models.v1.VerificationMethod; import com.sinch.sdk.domains.verification.models.v1.start.request.internal.VerificationStartPhoneCallOptions; +import com.sinch.sdk.domains.verification.models.v1.start.request.internal.VerificationStartPhoneCallOptionsImpl; +import java.io.IOException; import java.util.Objects; +import java.util.Optional; @JsonPropertyOrder({ VerificationStartRequestPhoneCallImpl.JSON_PROPERTY_IDENTITY, @@ -127,8 +136,10 @@ public PhoneCallSpeech getSpeech() { } public OptionalValue speech() { - return null != calloutOptions - ? calloutOptions.map(VerificationStartPhoneCallOptions::getSpeech) + return null != calloutOptions && calloutOptions.isPresent() + ? calloutOptions + .map(f -> ((VerificationStartPhoneCallOptionsImpl) f).speech()) + .orElse(OptionalValue.empty()) : OptionalValue.empty(); } @@ -234,4 +245,45 @@ public VerificationStartRequestPhoneCall build() { identity, method, reference, custom, calloutOptions); } } + + public static class DelegatedSerializer + extends JsonSerializer> { + @Override + public void serialize( + OptionalValue value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException { + + if (!value.isPresent()) { + return; + } + VerificationStartRequestPhoneCallImpl impl = + (VerificationStartRequestPhoneCallImpl) value.get(); + jgen.writeObject(null != impl ? impl.getCalloutOptions() : null); + } + } + + public static class DelegatedDeSerializer + extends JsonDeserializer { + @Override + public VerificationStartRequestPhoneCall deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException { + + VerificationStartRequestPhoneCallImpl.Builder builder = + new VerificationStartRequestPhoneCallImpl.Builder(); + VerificationStartPhoneCallOptionsImpl deserialized = + jp.readValueAs(VerificationStartPhoneCallOptionsImpl.class); + builder.setCalloutOptions(deserialized); + return builder.build(); + } + } + + public static Optional delegatedConverter( + VerificationStartPhoneCallOptions internal) { + if (null == internal) { + return Optional.empty(); + } + return Optional.of(new Builder().setCalloutOptions(internal).build()); + } } diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/start/request/VerificationStartRequestSmsImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/start/request/VerificationStartRequestSmsImpl.java index ba80837ee..c6e508771 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/start/request/VerificationStartRequestSmsImpl.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/start/request/VerificationStartRequestSmsImpl.java @@ -5,13 +5,21 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; import com.sinch.sdk.core.models.OptionalValue; import com.sinch.sdk.domains.verification.models.v1.Identity; import com.sinch.sdk.domains.verification.models.v1.VerificationMethod; import com.sinch.sdk.domains.verification.models.v1.start.request.internal.VerificationStartSmsOptions; import com.sinch.sdk.domains.verification.models.v1.start.request.internal.VerificationStartSmsOptionsImpl; +import java.io.IOException; import java.util.Objects; +import java.util.Optional; @JsonPropertyOrder({ VerificationStartRequestSmsImpl.JSON_PROPERTY_IDENTITY, @@ -126,8 +134,10 @@ public String getExpiry() { } public OptionalValue expiry() { - return null != smsOptions - ? smsOptions.map(VerificationStartSmsOptions::getExpiry) + return null != smsOptions && smsOptions.isPresent() + ? smsOptions + .map(f -> ((VerificationStartSmsOptionsImpl) f).expiry()) + .orElse(OptionalValue.empty()) : OptionalValue.empty(); } @@ -140,7 +150,7 @@ public CodeTypeEnum getCodeType() { } public OptionalValue codeType() { - return null != smsOptions + return null != smsOptions && smsOptions.isPresent() ? smsOptions.map(f -> CodeTypeEnum.from(smsOptions.get().getCodeType().value())) : OptionalValue.empty(); } @@ -154,8 +164,10 @@ public String getTemplate() { } public OptionalValue template() { - return null != smsOptions - ? smsOptions.map(VerificationStartSmsOptions::getTemplate) + return null != smsOptions && smsOptions.isPresent() + ? smsOptions + .map(f -> ((VerificationStartSmsOptionsImpl) f).template()) + .orElse(OptionalValue.empty()) : OptionalValue.empty(); } @@ -170,8 +182,10 @@ public String getAcceptLanguage() { } public OptionalValue acceptLanguage() { - return null != smsOptions - ? smsOptions.map(VerificationStartSmsOptions::getAcceptLanguage) + return null != smsOptions && smsOptions.isPresent() + ? smsOptions + .map(f -> ((VerificationStartSmsOptionsImpl) f).acceptLanguage()) + .orElse(OptionalValue.empty()) : OptionalValue.empty(); } @@ -298,4 +312,43 @@ public VerificationStartRequestSms build() { return new VerificationStartRequestSmsImpl(identity, method, reference, custom, smsOptions); } } + + public static class DelegatedSerializer + extends JsonSerializer> { + @Override + public void serialize( + OptionalValue value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException { + + if (!value.isPresent()) { + return; + } + VerificationStartRequestSmsImpl impl = (VerificationStartRequestSmsImpl) value.get(); + jgen.writeObject(null != impl ? impl.getSmsOptions() : null); + } + } + + public static class DelegatedDeSerializer extends JsonDeserializer { + @Override + public VerificationStartRequestSms deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException { + + VerificationStartRequestSmsImpl.Builder builder = + new VerificationStartRequestSmsImpl.Builder(); + VerificationStartSmsOptionsImpl deserialized = + jp.readValueAs(VerificationStartSmsOptionsImpl.class); + builder.setSmsOptions(deserialized); + return builder.build(); + } + } + + public static Optional delegatedConverter( + VerificationStartSmsOptions internal) { + if (null == internal) { + return Optional.empty(); + } + return Optional.of(new Builder().setSmsOptions(internal).build()); + } } diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/start/response/VerificationStartResponseDataImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/start/response/VerificationStartResponseDataImpl.java index 3ee42909f..400050676 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/start/response/VerificationStartResponseDataImpl.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/start/response/VerificationStartResponseDataImpl.java @@ -5,12 +5,21 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; import com.sinch.sdk.core.models.OptionalValue; import com.sinch.sdk.domains.verification.models.v1.VerificationMethod; import com.sinch.sdk.domains.verification.models.v1.start.response.internal.VerificationStartResponseDataContent; +import com.sinch.sdk.domains.verification.models.v1.start.response.internal.VerificationStartResponseDataContentImpl; +import java.io.IOException; import java.util.List; import java.util.Objects; +import java.util.Optional; @JsonPropertyOrder({ VerificationStartResponseDataImpl.JSON_PROPERTY_ID, @@ -107,8 +116,10 @@ public String getTargetUri() { } public OptionalValue targetUri() { - return null != seamless - ? seamless.map(VerificationStartResponseDataContent::getTargetUri) + return null != seamless && seamless.isPresent() + ? seamless + .map(f -> ((VerificationStartResponseDataContentImpl) f).targetUri()) + .orElse(OptionalValue.empty()) : OptionalValue.empty(); } @@ -204,4 +215,44 @@ public VerificationStartResponseData build() { return new VerificationStartResponseDataImpl(id, method, links, seamless); } } + + public static class DelegatedSerializer + extends JsonSerializer> { + @Override + public void serialize( + OptionalValue value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException { + + if (!value.isPresent()) { + return; + } + VerificationStartResponseDataImpl impl = (VerificationStartResponseDataImpl) value.get(); + jgen.writeObject(null != impl ? impl.getSeamless() : null); + } + } + + public static class DelegatedDeSerializer + extends JsonDeserializer { + @Override + public VerificationStartResponseData deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException { + + VerificationStartResponseDataImpl.Builder builder = + new VerificationStartResponseDataImpl.Builder(); + VerificationStartResponseDataContentImpl deserialized = + jp.readValueAs(VerificationStartResponseDataContentImpl.class); + builder.setSeamless(deserialized); + return builder.build(); + } + } + + public static Optional delegatedConverter( + VerificationStartResponseDataContent internal) { + if (null == internal) { + return Optional.empty(); + } + return Optional.of(new Builder().setSeamless(internal).build()); + } } diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/start/response/VerificationStartResponseFlashCallImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/start/response/VerificationStartResponseFlashCallImpl.java index a6a7fbea3..adcbde246 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/start/response/VerificationStartResponseFlashCallImpl.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/start/response/VerificationStartResponseFlashCallImpl.java @@ -5,12 +5,21 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; import com.sinch.sdk.core.models.OptionalValue; import com.sinch.sdk.domains.verification.models.v1.VerificationMethod; import com.sinch.sdk.domains.verification.models.v1.start.response.internal.VerificationStartResponseFlashCallContent; +import com.sinch.sdk.domains.verification.models.v1.start.response.internal.VerificationStartResponseFlashCallContentImpl; +import java.io.IOException; import java.util.List; import java.util.Objects; +import java.util.Optional; @JsonPropertyOrder({ VerificationStartResponseFlashCallImpl.JSON_PROPERTY_ID, @@ -107,8 +116,10 @@ public String getCliFilter() { } public OptionalValue cliFilter() { - return null != flashCall - ? flashCall.map(VerificationStartResponseFlashCallContent::getCliFilter) + return null != flashCall && flashCall.isPresent() + ? flashCall + .map(f -> ((VerificationStartResponseFlashCallContentImpl) f).cliFilter()) + .orElse(OptionalValue.empty()) : OptionalValue.empty(); } @@ -123,8 +134,10 @@ public Integer getInterceptionTimeout() { } public OptionalValue interceptionTimeout() { - return null != flashCall - ? flashCall.map(VerificationStartResponseFlashCallContent::getInterceptionTimeout) + return null != flashCall && flashCall.isPresent() + ? flashCall + .map(f -> ((VerificationStartResponseFlashCallContentImpl) f).interceptionTimeout()) + .orElse(OptionalValue.empty()) : OptionalValue.empty(); } @@ -137,8 +150,10 @@ public Integer getReportTimeout() { } public OptionalValue reportTimeout() { - return null != flashCall - ? flashCall.map(VerificationStartResponseFlashCallContent::getReportTimeout) + return null != flashCall && flashCall.isPresent() + ? flashCall + .map(f -> ((VerificationStartResponseFlashCallContentImpl) f).reportTimeout()) + .orElse(OptionalValue.empty()) : OptionalValue.empty(); } @@ -151,8 +166,10 @@ public Integer getDenyCallAfter() { } public OptionalValue denyCallAfter() { - return null != flashCall - ? flashCall.map(VerificationStartResponseFlashCallContent::getDenyCallAfter) + return null != flashCall && flashCall.isPresent() + ? flashCall + .map(f -> ((VerificationStartResponseFlashCallContentImpl) f).denyCallAfter()) + .orElse(OptionalValue.empty()) : OptionalValue.empty(); } @@ -266,4 +283,45 @@ public VerificationStartResponseFlashCall build() { return new VerificationStartResponseFlashCallImpl(id, method, links, flashCall); } } + + public static class DelegatedSerializer + extends JsonSerializer> { + @Override + public void serialize( + OptionalValue value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException { + + if (!value.isPresent()) { + return; + } + VerificationStartResponseFlashCallImpl impl = + (VerificationStartResponseFlashCallImpl) value.get(); + jgen.writeObject(null != impl ? impl.getFlashCall() : null); + } + } + + public static class DelegatedDeSerializer + extends JsonDeserializer { + @Override + public VerificationStartResponseFlashCall deserialize( + JsonParser jp, DeserializationContext ctxt) throws IOException { + + VerificationStartResponseFlashCallImpl.Builder builder = + new VerificationStartResponseFlashCallImpl.Builder(); + VerificationStartResponseFlashCallContentImpl deserialized = + jp.readValueAs(VerificationStartResponseFlashCallContentImpl.class); + builder.setFlashCall(deserialized); + return builder.build(); + } + } + + public static Optional delegatedConverter( + VerificationStartResponseFlashCallContent internal) { + if (null == internal) { + return Optional.empty(); + } + return Optional.of(new Builder().setFlashCall(internal).build()); + } } diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/start/response/VerificationStartResponseSmsImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/start/response/VerificationStartResponseSmsImpl.java index b6e4690d0..3e198e1af 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/start/response/VerificationStartResponseSmsImpl.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/start/response/VerificationStartResponseSmsImpl.java @@ -5,12 +5,21 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; import com.sinch.sdk.core.models.OptionalValue; import com.sinch.sdk.domains.verification.models.v1.VerificationMethod; import com.sinch.sdk.domains.verification.models.v1.start.response.internal.VerificationStartResponseSmsContent; +import com.sinch.sdk.domains.verification.models.v1.start.response.internal.VerificationStartResponseSmsContentImpl; +import java.io.IOException; import java.util.List; import java.util.Objects; +import java.util.Optional; @JsonPropertyOrder({ VerificationStartResponseSmsImpl.JSON_PROPERTY_ID, @@ -107,8 +116,9 @@ public String getTemplate() { } public OptionalValue template() { - return null != sms - ? sms.map(VerificationStartResponseSmsContent::getTemplate) + return null != sms && sms.isPresent() + ? sms.map(f -> ((VerificationStartResponseSmsContentImpl) f).template()) + .orElse(OptionalValue.empty()) : OptionalValue.empty(); } @@ -121,8 +131,9 @@ public Integer getInterceptionTimeout() { } public OptionalValue interceptionTimeout() { - return null != sms - ? sms.map(VerificationStartResponseSmsContent::getInterceptionTimeout) + return null != sms && sms.isPresent() + ? sms.map(f -> ((VerificationStartResponseSmsContentImpl) f).interceptionTimeout()) + .orElse(OptionalValue.empty()) : OptionalValue.empty(); } @@ -224,4 +235,43 @@ public VerificationStartResponseSms build() { return new VerificationStartResponseSmsImpl(id, method, links, sms); } } + + public static class DelegatedSerializer + extends JsonSerializer> { + @Override + public void serialize( + OptionalValue value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException { + + if (!value.isPresent()) { + return; + } + VerificationStartResponseSmsImpl impl = (VerificationStartResponseSmsImpl) value.get(); + jgen.writeObject(null != impl ? impl.getSms() : null); + } + } + + public static class DelegatedDeSerializer extends JsonDeserializer { + @Override + public VerificationStartResponseSms deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException { + + VerificationStartResponseSmsImpl.Builder builder = + new VerificationStartResponseSmsImpl.Builder(); + VerificationStartResponseSmsContentImpl deserialized = + jp.readValueAs(VerificationStartResponseSmsContentImpl.class); + builder.setSms(deserialized); + return builder.build(); + } + } + + public static Optional delegatedConverter( + VerificationStartResponseSmsContent internal) { + if (null == internal) { + return Optional.empty(); + } + return Optional.of(new Builder().setSms(internal).build()); + } } diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/webhooks/VerificationRequestEventResponseFlashCallImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/webhooks/VerificationRequestEventResponseFlashCallImpl.java index 0ee6f37eb..888443bdf 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/webhooks/VerificationRequestEventResponseFlashCallImpl.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/webhooks/VerificationRequestEventResponseFlashCallImpl.java @@ -5,10 +5,19 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; import com.sinch.sdk.core.models.OptionalValue; import com.sinch.sdk.domains.verification.models.v1.webhooks.internal.VerificationRequestEventResponseFlashCallContent; +import com.sinch.sdk.domains.verification.models.v1.webhooks.internal.VerificationRequestEventResponseFlashCallContentImpl; +import java.io.IOException; import java.util.Objects; +import java.util.Optional; @JsonPropertyOrder({ VerificationRequestEventResponseFlashCallImpl.JSON_PROPERTY_ACTION, @@ -69,8 +78,10 @@ public String getCli() { } public OptionalValue cli() { - return null != flashCall - ? flashCall.map(VerificationRequestEventResponseFlashCallContent::getCli) + return null != flashCall && flashCall.isPresent() + ? flashCall + .map(f -> ((VerificationRequestEventResponseFlashCallContentImpl) f).cli()) + .orElse(OptionalValue.empty()) : OptionalValue.empty(); } @@ -83,8 +94,10 @@ public Integer getDialTimeout() { } public OptionalValue dialTimeout() { - return null != flashCall - ? flashCall.map(VerificationRequestEventResponseFlashCallContent::getDialTimeout) + return null != flashCall && flashCall.isPresent() + ? flashCall + .map(f -> ((VerificationRequestEventResponseFlashCallContentImpl) f).dialTimeout()) + .orElse(OptionalValue.empty()) : OptionalValue.empty(); } @@ -175,4 +188,45 @@ public VerificationRequestEventResponseFlashCall build() { return new VerificationRequestEventResponseFlashCallImpl(action, flashCall); } } + + public static class DelegatedSerializer + extends JsonSerializer> { + @Override + public void serialize( + OptionalValue value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException { + + if (!value.isPresent()) { + return; + } + VerificationRequestEventResponseFlashCallImpl impl = + (VerificationRequestEventResponseFlashCallImpl) value.get(); + jgen.writeObject(null != impl ? impl.getFlashCall() : null); + } + } + + public static class DelegatedDeSerializer + extends JsonDeserializer { + @Override + public VerificationRequestEventResponseFlashCall deserialize( + JsonParser jp, DeserializationContext ctxt) throws IOException { + + VerificationRequestEventResponseFlashCallImpl.Builder builder = + new VerificationRequestEventResponseFlashCallImpl.Builder(); + VerificationRequestEventResponseFlashCallContentImpl deserialized = + jp.readValueAs(VerificationRequestEventResponseFlashCallContentImpl.class); + builder.setFlashCall(deserialized); + return builder.build(); + } + } + + public static Optional delegatedConverter( + VerificationRequestEventResponseFlashCallContent internal) { + if (null == internal) { + return Optional.empty(); + } + return Optional.of(new Builder().setFlashCall(internal).build()); + } } diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/webhooks/VerificationRequestEventResponsePhoneCallImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/webhooks/VerificationRequestEventResponsePhoneCallImpl.java index f2bade6b8..3f8057ef1 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/webhooks/VerificationRequestEventResponsePhoneCallImpl.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/webhooks/VerificationRequestEventResponsePhoneCallImpl.java @@ -5,11 +5,20 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; import com.sinch.sdk.core.models.OptionalValue; import com.sinch.sdk.domains.verification.models.v1.start.request.PhoneCallSpeech; import com.sinch.sdk.domains.verification.models.v1.webhooks.internal.VerificationRequestEventResponsePhoneCallContent; +import com.sinch.sdk.domains.verification.models.v1.webhooks.internal.VerificationRequestEventResponsePhoneCallContentImpl; +import java.io.IOException; import java.util.Objects; +import java.util.Optional; @JsonPropertyOrder({ VerificationRequestEventResponsePhoneCallImpl.JSON_PROPERTY_ACTION, @@ -70,8 +79,10 @@ public String getCode() { } public OptionalValue code() { - return null != callout - ? callout.map(VerificationRequestEventResponsePhoneCallContent::getCode) + return null != callout && callout.isPresent() + ? callout + .map(f -> ((VerificationRequestEventResponsePhoneCallContentImpl) f).code()) + .orElse(OptionalValue.empty()) : OptionalValue.empty(); } @@ -84,8 +95,10 @@ public PhoneCallSpeech getSpeech() { } public OptionalValue speech() { - return null != callout - ? callout.map(VerificationRequestEventResponsePhoneCallContent::getSpeech) + return null != callout && callout.isPresent() + ? callout + .map(f -> ((VerificationRequestEventResponsePhoneCallContentImpl) f).speech()) + .orElse(OptionalValue.empty()) : OptionalValue.empty(); } @@ -175,4 +188,45 @@ public VerificationRequestEventResponsePhoneCall build() { return new VerificationRequestEventResponsePhoneCallImpl(action, callout); } } + + public static class DelegatedSerializer + extends JsonSerializer> { + @Override + public void serialize( + OptionalValue value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException { + + if (!value.isPresent()) { + return; + } + VerificationRequestEventResponsePhoneCallImpl impl = + (VerificationRequestEventResponsePhoneCallImpl) value.get(); + jgen.writeObject(null != impl ? impl.getCallout() : null); + } + } + + public static class DelegatedDeSerializer + extends JsonDeserializer { + @Override + public VerificationRequestEventResponsePhoneCall deserialize( + JsonParser jp, DeserializationContext ctxt) throws IOException { + + VerificationRequestEventResponsePhoneCallImpl.Builder builder = + new VerificationRequestEventResponsePhoneCallImpl.Builder(); + VerificationRequestEventResponsePhoneCallContentImpl deserialized = + jp.readValueAs(VerificationRequestEventResponsePhoneCallContentImpl.class); + builder.setCallout(deserialized); + return builder.build(); + } + } + + public static Optional delegatedConverter( + VerificationRequestEventResponsePhoneCallContent internal) { + if (null == internal) { + return Optional.empty(); + } + return Optional.of(new Builder().setCallout(internal).build()); + } } diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/webhooks/VerificationRequestEventResponseSmsImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/webhooks/VerificationRequestEventResponseSmsImpl.java index fd336bfed..f9b07d8a4 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/webhooks/VerificationRequestEventResponseSmsImpl.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/v1/webhooks/VerificationRequestEventResponseSmsImpl.java @@ -5,11 +5,20 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; import com.sinch.sdk.core.models.OptionalValue; import com.sinch.sdk.domains.verification.models.v1.webhooks.internal.VerificationRequestEventResponseSmsContent; +import com.sinch.sdk.domains.verification.models.v1.webhooks.internal.VerificationRequestEventResponseSmsContentImpl; +import java.io.IOException; import java.util.List; import java.util.Objects; +import java.util.Optional; @JsonPropertyOrder({ VerificationRequestEventResponseSmsImpl.JSON_PROPERTY_ACTION, @@ -70,8 +79,9 @@ public String getCode() { } public OptionalValue code() { - return null != sms - ? sms.map(VerificationRequestEventResponseSmsContent::getCode) + return null != sms && sms.isPresent() + ? sms.map(f -> ((VerificationRequestEventResponseSmsContentImpl) f).code()) + .orElse(OptionalValue.empty()) : OptionalValue.empty(); } @@ -84,8 +94,9 @@ public List getAcceptLanguage() { } public OptionalValue> acceptLanguage() { - return null != sms - ? sms.map(VerificationRequestEventResponseSmsContent::getAcceptLanguage) + return null != sms && sms.isPresent() + ? sms.map(f -> ((VerificationRequestEventResponseSmsContentImpl) f).acceptLanguage()) + .orElse(OptionalValue.empty()) : OptionalValue.empty(); } @@ -175,4 +186,45 @@ public VerificationRequestEventResponseSms build() { return new VerificationRequestEventResponseSmsImpl(action, sms); } } + + public static class DelegatedSerializer + extends JsonSerializer> { + @Override + public void serialize( + OptionalValue value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException { + + if (!value.isPresent()) { + return; + } + VerificationRequestEventResponseSmsImpl impl = + (VerificationRequestEventResponseSmsImpl) value.get(); + jgen.writeObject(null != impl ? impl.getSms() : null); + } + } + + public static class DelegatedDeSerializer + extends JsonDeserializer { + @Override + public VerificationRequestEventResponseSms deserialize( + JsonParser jp, DeserializationContext ctxt) throws IOException { + + VerificationRequestEventResponseSmsImpl.Builder builder = + new VerificationRequestEventResponseSmsImpl.Builder(); + VerificationRequestEventResponseSmsContentImpl deserialized = + jp.readValueAs(VerificationRequestEventResponseSmsContentImpl.class); + builder.setSms(deserialized); + return builder.build(); + } + } + + public static Optional delegatedConverter( + VerificationRequestEventResponseSmsContent internal) { + if (null == internal) { + return Optional.empty(); + } + return Optional.of(new Builder().setSms(internal).build()); + } }