From 9d519f9b26fda4ccce522097d98400f83475352d Mon Sep 17 00:00:00 2001 From: Jean-Pierre Portier Date: Fri, 9 Aug 2024 12:15:06 +0200 Subject: [PATCH] feature (Conversation/ContactMessage): Synch ContactMessage with updated specs --- .../api/v1/adapters/ConversationService.java | 2 + .../adapters/messages/AppMessageMapper.java | 27 +- .../messages/ContactMessageMapper.java | 92 +- .../models/v1/messages/AppMessage.java | 9 +- .../models/v1/messages/AppMessageImpl.java | 4 +- .../models/v1/messages/ContactMessage.java | 56 +- .../v1/messages/ContactMessageBody.java | 3 + .../v1/messages/ContactMessageImpl.java | 57 ++ .../ContactMessageInternalMapper.java | 153 +++ .../api/v1/adapters/MessagesServiceTest.java | 2 +- .../models/v1/messages/ReplyTo.java | 59 ++ .../models/v1/messages/ReplyToImpl.java | 165 ++++ .../internal/ContactMessageInternal.java | 179 +++- .../internal/ContactMessageInternalImpl.java | 879 ++++++------------ ...sageInternal.java => ReplyToInternal.java} | 10 +- ...rnalImpl.java => ReplyToInternalImpl.java} | 22 +- .../ChannelSpecificContactMessage.java | 2 +- .../ChannelSpecificContactMessageImpl.java | 2 +- .../choiceresponse/ChoiceResponseMessage.java | 2 +- .../ChoiceResponseMessageImpl.java | 2 +- .../types/fallback/FallbackMessage.java | 2 +- .../types/fallback/FallbackMessageImpl.java | 2 +- .../types/location/LocationMessage.java | 2 +- .../types/location/LocationMessageImpl.java | 2 +- .../v1/messages/types/media/MediaMessage.java | 2 +- .../types/media/MediaMessageImpl.java | 2 +- .../types/mediacard/MediaCardMessage.java | 2 +- .../types/mediacard/MediaCardMessageImpl.java | 2 +- .../ProductResponseMessage.java | 2 +- .../ProductResponseMessageImpl.java | 2 +- .../v1/messages/types/text/TextMessage.java | 2 +- .../messages/types/text/TextMessageImpl.java | 2 +- .../models/v1/messages/AppMessageDtoTest.java | 18 +- .../v1/messages/ContactMessageDtoTest.java | 172 +++- .../ConversationMessageDtoTest.java | 5 +- .../models/v1/messages/ReplyToDtoTest.java | 33 + .../types/replyto/ReplyToMessageDtoTest.java | 31 - .../message/MessageInboundEventDtoTest.java | 4 +- ...martConversationRedactionEventDtoTest.java | 4 +- ...MessageChannelSpecificContactNfmReply.json | 16 + .../ContactMessageChoiceResponseDto.json | 9 + .../messages/ContactMessageFallbackDto.json | 13 + .../messages/ContactMessageLocationDto.json | 13 + .../messages/ContactMessageMediaCardDto.json | 9 + .../v1/messages/ContactMessageMediaDto.json | 10 + .../ContactMessageProductResponseDto.json | 18 + .../v1/messages/ContactMessageTextDto.json | 8 + .../ContactMessageTextNoReplyToDto.json | 5 + .../ContactMessageTextNullReplyToDto.json | 6 + ...ConversationMessageContactLocationDto.json | 3 + ...ReplyToMessageDto.json => ReplyToDto.json} | 0 .../message/MessageInboundEventDto.json | 3 + ...undSmartConversationRedactionEventDto.json | 7 +- .../sample/conversation/messages/Send.java | 4 +- 54 files changed, 1389 insertions(+), 753 deletions(-) create mode 100644 client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/ContactMessageBody.java create mode 100644 client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/ContactMessageImpl.java create mode 100644 client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/internal/ContactMessageInternalMapper.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/ReplyTo.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/ReplyToImpl.java rename openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/internal/{ReplyToMessageInternal.java => ReplyToInternal.java} (85%) rename openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/internal/{ReplyToMessageInternalImpl.java => ReplyToInternalImpl.java} (74%) rename openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/{response => messages}/ConversationMessageDtoTest.java (92%) create mode 100644 openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/messages/ReplyToDtoTest.java delete mode 100644 openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/messages/types/replyto/ReplyToMessageDtoTest.java create mode 100644 openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageChannelSpecificContactNfmReply.json create mode 100644 openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageChoiceResponseDto.json create mode 100644 openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageFallbackDto.json create mode 100644 openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageLocationDto.json create mode 100644 openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageMediaCardDto.json create mode 100644 openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageMediaDto.json create mode 100644 openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageProductResponseDto.json create mode 100644 openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageTextDto.json create mode 100644 openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageTextNoReplyToDto.json create mode 100644 openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageTextNullReplyToDto.json rename openapi-contracts/src/test/resources/domains/conversation/v1/messages/{types/replyto/ReplyToMessageDto.json => ReplyToDto.json} (100%) diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/ConversationService.java b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/ConversationService.java index 3796de63e..8d58084cc 100644 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/ConversationService.java +++ b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/ConversationService.java @@ -19,6 +19,7 @@ import com.sinch.sdk.domains.conversation.api.v1.adapters.messages.WhatsAppInteractiveHeaderMapper; import com.sinch.sdk.domains.conversation.models.v1.messages.internal.AppMessageInternalMapper; import com.sinch.sdk.domains.conversation.models.v1.messages.internal.ChannelSpecificMessageInternalMapper; +import com.sinch.sdk.domains.conversation.models.v1.messages.internal.ContactMessageInternalMapper; import com.sinch.sdk.domains.conversation.models.v1.messages.types.carousel.CarouselMessageMapper; import com.sinch.sdk.domains.conversation.models.v1.messages.types.internal.ChoiceMessageMapper; import com.sinch.sdk.domains.conversation.models.v1.messages.types.template.TemplateMessageMapper; @@ -127,6 +128,7 @@ private LocalLazyInit() { ContactEventMapper.initMapper(); ContactMessageEventMapper.initMapper(); ContactMessageMapper.initMapper(); + ContactMessageInternalMapper.initMapper(); ConversationMessageMapper.initMapper(); ListSectionMapper.initMapper(); OmniMessageOverrideMapper.initMapper(); diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/messages/AppMessageMapper.java b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/messages/AppMessageMapper.java index 2d2d5f804..27025a59a 100644 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/messages/AppMessageMapper.java +++ b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/messages/AppMessageMapper.java @@ -9,6 +9,8 @@ import com.fasterxml.jackson.databind.ser.std.StdSerializer; import com.sinch.sdk.core.utils.databind.Mapper; import com.sinch.sdk.domains.conversation.models.v1.messages.AppMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.AppMessage.Builder; +import com.sinch.sdk.domains.conversation.models.v1.messages.AppMessageBody; import com.sinch.sdk.domains.conversation.models.v1.messages.AppMessageImpl; import com.sinch.sdk.domains.conversation.models.v1.messages.internal.AppMessageInternal; import com.sinch.sdk.domains.conversation.models.v1.messages.internal.AppMessageInternalImpl; @@ -29,6 +31,7 @@ public class AppMessageMapper { private static final Logger LOGGER = Logger.getLogger(AppMessageMapper.class.getName()); public static void initMapper() { + SimpleModule module = new SimpleModule() .addSerializer(AppMessage.class, new Serializer()) @@ -36,7 +39,7 @@ public static void initMapper() { Mapper.getInstance().registerModule(module); } - static class Deserializer extends StdDeserializer> { + static class Deserializer extends StdDeserializer { public Deserializer() { this(null); @@ -53,20 +56,20 @@ public AppMessage deserialize(JsonParser jp, DeserializationContext ctxt) AppMessageInternalImpl deserialized = (AppMessageInternalImpl) jp.readValueAs(AppMessageInternal.class); - AppMessage.Builder internal = AppMessage.builder(); + Builder internal = AppMessage.builder(); deserialized.explicitChannelMessage().ifPresent(internal::setExplicitChannelMessage); deserialized.explicitChannelOmniMessage().ifPresent(internal::setExplicitChannelOmniMessage); deserialized.channelSpecificMessage().ifPresent(internal::setChannelSpecificMessage); deserialized.agent().ifPresent(internal::setAgent); - deserialized.cardMessage().ifPresent(internal::setMessage); - deserialized.carouselMessage().ifPresent(internal::setMessage); - deserialized.choiceMessage().ifPresent(internal::setMessage); - deserialized.contactInfoMessage().ifPresent(internal::setMessage); - deserialized.listMessage().ifPresent(internal::setMessage); - deserialized.locationMessage().ifPresent(internal::setMessage); - deserialized.mediaMessage().ifPresent(internal::setMessage); - deserialized.templateMessage().ifPresent(internal::setMessage); - deserialized.textMessage().ifPresent(internal::setMessage); + deserialized.cardMessage().ifPresent(internal::setBody); + deserialized.carouselMessage().ifPresent(internal::setBody); + deserialized.choiceMessage().ifPresent(internal::setBody); + deserialized.contactInfoMessage().ifPresent(internal::setBody); + deserialized.listMessage().ifPresent(internal::setBody); + deserialized.locationMessage().ifPresent(internal::setBody); + deserialized.mediaMessage().ifPresent(internal::setBody); + deserialized.templateMessage().ifPresent(internal::setBody); + deserialized.textMessage().ifPresent(internal::setBody); return internal.build(); } } @@ -93,7 +96,7 @@ public void serialize(AppMessage raw, JsonGenerator jgen, SerializerProvider pro value.channelSpecificMessage().ifPresent(internal::setChannelSpecificMessage); value.agent().ifPresent(internal::setAgent); value - .message() + .body() .ifPresent( message -> { if (message instanceof CardMessage) { diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/messages/ContactMessageMapper.java b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/messages/ContactMessageMapper.java index a1831ce69..75722bc47 100644 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/messages/ContactMessageMapper.java +++ b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/messages/ContactMessageMapper.java @@ -1,38 +1,118 @@ package com.sinch.sdk.domains.conversation.api.v1.adapters.messages; +import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.deser.std.StdDeserializer; import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; import com.sinch.sdk.core.utils.databind.Mapper; import com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessage.Builder; +import com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessageBody; +import com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessageImpl; +import com.sinch.sdk.domains.conversation.models.v1.messages.internal.ContactMessageInternal; import com.sinch.sdk.domains.conversation.models.v1.messages.internal.ContactMessageInternalImpl; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.channelspecific.ChannelSpecificContactMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.choiceresponse.ChoiceResponseMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.fallback.FallbackMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.location.LocationMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.media.MediaMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.mediacard.MediaCardMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.productresponse.ProductResponseMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.text.TextMessage; import java.io.IOException; +import java.util.logging.Logger; public class ContactMessageMapper { + private static final Logger LOGGER = Logger.getLogger(ContactMessageMapper.class.getName()); + public static void initMapper() { SimpleModule module = - new SimpleModule().addDeserializer(ContactMessage.class, new Deserializer()); + new SimpleModule() + .addSerializer(ContactMessage.class, new Serializer()) + .addDeserializer(ContactMessage.class, new Deserializer()); Mapper.getInstance().registerModule(module); } - static class Deserializer extends StdDeserializer { + static class Deserializer extends StdDeserializer> { public Deserializer() { this(null); } - public Deserializer(Class vc) { + public Deserializer(Class> vc) { super(vc); } @Override - public ContactMessage deserialize(JsonParser jp, DeserializationContext ctxt) + public ContactMessage deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { - Object deserialized = jp.readValueAs(ContactMessageInternalImpl.class).getActualInstance(); - return (ContactMessage) deserialized; + ContactMessageInternalImpl deserialized = + (ContactMessageInternalImpl) jp.readValueAs(ContactMessageInternal.class); + Builder internal = ContactMessage.builder(); + + deserialized.channelSpecificMessage().ifPresent(internal::setBody); + deserialized.choiceResponseMessage().ifPresent(internal::setBody); + deserialized.fallbackMessage().ifPresent(internal::setBody); + deserialized.locationMessage().ifPresent(internal::setBody); + deserialized.mediaCardMessage().ifPresent(internal::setBody); + deserialized.mediaMessage().ifPresent(internal::setBody); + deserialized.productResponseMessage().ifPresent(internal::setBody); + deserialized.textMessage().ifPresent(internal::setBody); + deserialized.replyTo().ifPresent(internal::setReplyTo); + + return internal.build(); + } + } + + static class Serializer extends StdSerializer { + + public Serializer() { + this(null); + } + + public Serializer(Class t) { + super(t); + } + + @Override + public void serialize(ContactMessage raw, JsonGenerator jgen, SerializerProvider provider) + throws IOException { + + ContactMessageImpl value = (ContactMessageImpl) raw; + ContactMessageInternal.Builder internal = ContactMessageInternal.builder(); + + value.replyTo().ifPresent(internal::setReplyTo); + value + .body() + .ifPresent( + message -> { + if (message instanceof ChannelSpecificContactMessage) { + internal.setChannelSpecificMessage((ChannelSpecificContactMessage) message); + } else if (message instanceof ChoiceResponseMessage) { + internal.setChoiceResponseMessage((ChoiceResponseMessage) message); + } else if (message instanceof FallbackMessage) { + internal.setFallbackMessage((FallbackMessage) message); + } else if (message instanceof LocationMessage) { + internal.setLocationMessage((LocationMessage) message); + } else if (message instanceof MediaCardMessage) { + internal.setMediaCardMessage((MediaCardMessage) message); + } else if (message instanceof MediaMessage) { + internal.setMediaMessage((MediaMessage) message); + } else if (message instanceof ProductResponseMessage) { + internal.setProductResponseMessage((ProductResponseMessage) message); + } else if (message instanceof TextMessage) { + internal.setTextMessage((TextMessage) message); + } else { + LOGGER.severe("Unexpected class '" + message.getClass() + "'"); + } + }); + + jgen.writeObject(internal.build()); } } } diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/AppMessage.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/AppMessage.java index 57928c206..012048e2c 100644 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/AppMessage.java +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/AppMessage.java @@ -69,7 +69,14 @@ static Builder builder() { /** Dedicated Builder */ interface Builder { - Builder setMessage(T message); + /** + * see getter + * + * @param message see getter + * @return Current builder + * @see #getBody() + */ + Builder setBody(T message); /** * see getter diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/AppMessageImpl.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/AppMessageImpl.java index c5b2cc175..7d22dbbda 100644 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/AppMessageImpl.java +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/AppMessageImpl.java @@ -34,7 +34,7 @@ public T getBody() { return message.orElse(null); } - public OptionalValue message() { + public OptionalValue body() { return message; } @@ -99,7 +99,7 @@ static class Builder implements AppMessage.Builder OptionalValue.empty(); OptionalValue agent = OptionalValue.empty(); - public Builder setMessage(T message) { + public Builder setBody(T message) { this.message = OptionalValue.of(message); return this; } diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/ContactMessage.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/ContactMessage.java index 230575f5f..1845a9388 100644 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/ContactMessage.java +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/ContactMessage.java @@ -1,3 +1,57 @@ package com.sinch.sdk.domains.conversation.models.v1.messages; -public interface ContactMessage extends ConversationMessageBody {} +/** + * Message originating from a Contact + * + * @param Body type for message + * @since _NEXT_VERSION_ + */ +public interface ContactMessage extends ConversationMessageBody { + + /** + * Get message body + * + * @return Message body + */ + T getBody(); + + /** + * @see ReplyTo + * @return reply to + */ + ReplyTo getReplyTo(); + + /** + * Getting Builder + * + * @return New Builder instance + * @since 1.0 + */ + static Builder builder() { + return new ContactMessageImpl.Builder<>(); + } + + /** Dedicated Builder */ + interface Builder { + + /** + * see getter + * + * @param message see getter + * @return Current builder + * @see #getBody() + */ + Builder setBody(T message); + + /** + * see getter + * + * @param replyTo see getter + * @return Current builder + * @see #getReplyTo() + */ + Builder setReplyTo(ReplyTo replyTo); + + ContactMessage build(); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/ContactMessageBody.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/ContactMessageBody.java new file mode 100644 index 000000000..1379a3938 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/ContactMessageBody.java @@ -0,0 +1,3 @@ +package com.sinch.sdk.domains.conversation.models.v1.messages; + +public interface ContactMessageBody {} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/ContactMessageImpl.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/ContactMessageImpl.java new file mode 100644 index 000000000..dc481d537 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/ContactMessageImpl.java @@ -0,0 +1,57 @@ +package com.sinch.sdk.domains.conversation.models.v1.messages; + +import com.sinch.sdk.core.models.OptionalValue; + +public class ContactMessageImpl implements ContactMessage { + + private final OptionalValue message; + + private final OptionalValue replyTo; + + public ContactMessageImpl(OptionalValue message, OptionalValue replyTo) { + this.message = message; + this.replyTo = replyTo; + } + + public T getBody() { + return message.orElse(null); + } + + public OptionalValue body() { + return message; + } + + public ReplyTo getReplyTo() { + return replyTo.orElse(null); + } + + public OptionalValue replyTo() { + return replyTo; + } + + @Override + public String toString() { + return "ContactMessageImpl{" + "message=" + message + ", replyTo=" + replyTo + '}'; + } + + /** Dedicated Builder */ + static class Builder implements ContactMessage.Builder { + + OptionalValue message = OptionalValue.empty(); + OptionalValue replyTo = OptionalValue.empty(); + + public Builder setBody(T message) { + this.message = OptionalValue.of(message); + return this; + } + + public Builder setReplyTo(ReplyTo replyTo) { + this.replyTo = OptionalValue.of(replyTo); + return this; + } + + public ContactMessage build() { + return new ContactMessageImpl<>(message, replyTo); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/internal/ContactMessageInternalMapper.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/internal/ContactMessageInternalMapper.java new file mode 100644 index 000000000..2a22435d5 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/internal/ContactMessageInternalMapper.java @@ -0,0 +1,153 @@ +package com.sinch.sdk.domains.conversation.models.v1.messages.internal; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.sinch.sdk.core.models.OptionalValue; +import com.sinch.sdk.core.utils.databind.Mapper; +import com.sinch.sdk.domains.conversation.models.v1.messages.ReplyTo; +import com.sinch.sdk.domains.conversation.models.v1.messages.ReplyToImpl; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.channelspecific.ChannelSpecificContactMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.channelspecific.ChannelSpecificContactMessageImpl; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.choiceresponse.ChoiceResponseMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.choiceresponse.ChoiceResponseMessageImpl; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.fallback.FallbackMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.fallback.FallbackMessageImpl; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.location.LocationMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.location.LocationMessageImpl; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.media.MediaMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.media.MediaMessageImpl; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.mediacard.MediaCardMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.mediacard.MediaCardMessageImpl; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.productresponse.ProductResponseMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.productresponse.ProductResponseMessageImpl; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.text.TextMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.text.TextMessageImpl; + +public class ContactMessageInternalMapper { + + public static void initMapper() { + + Mapper.getInstance() + .addMixIn(ContactMessageInternal.class, ContactMessageInternalMapperMixinSerializer.class) + .addMixIn( + ContactMessageInternal.Builder.class, ContactMessageInternalBuilderMapperMixin.class); + } + + static class ContactMessageInternalMapperMixinSerializer extends ContactMessageInternalImpl { + + @Override + @JsonSerialize(using = ChannelSpecificContactMessageImpl.DelegatedSerializer.class) + public OptionalValue channelSpecificMessage() { + return super.channelSpecificMessage(); + } + + @Override + @JsonSerialize(using = ChoiceResponseMessageImpl.DelegatedSerializer.class) + public OptionalValue choiceResponseMessage() { + return super.choiceResponseMessage(); + } + + @Override + @JsonSerialize(using = FallbackMessageImpl.DelegatedSerializer.class) + public OptionalValue fallbackMessage() { + return super.fallbackMessage(); + } + + @Override + @JsonSerialize(using = LocationMessageImpl.DelegatedSerializer.class) + public OptionalValue locationMessage() { + return super.locationMessage(); + } + + @Override + @JsonSerialize(using = MediaCardMessageImpl.DelegatedSerializer.class) + public OptionalValue mediaCardMessage() { + return super.mediaCardMessage(); + } + + @Override + @JsonSerialize(using = MediaMessageImpl.DelegatedSerializer.class) + public OptionalValue mediaMessage() { + return super.mediaMessage(); + } + + @Override + @JsonSerialize(using = ProductResponseMessageImpl.DelegatedSerializer.class) + public OptionalValue productResponseMessage() { + return super.productResponseMessage(); + } + + @Override + @JsonSerialize(using = TextMessageImpl.DelegatedSerializer.class) + public OptionalValue textMessage() { + return super.textMessage(); + } + + @Override + @JsonSerialize(using = ReplyToImpl.DelegatedSerializer.class) + public OptionalValue replyTo() { + return super.replyTo(); + } + } + + static class ContactMessageInternalBuilderMapperMixin extends ContactMessageInternalImpl.Builder { + + @Override + @JsonDeserialize(using = ChannelSpecificContactMessageImpl.DelegatedDeSerializer.class) + public ContactMessageInternalImpl.Builder setChannelSpecificMessage( + ChannelSpecificContactMessage channelSpecificMessage) { + return super.setChannelSpecificMessage(channelSpecificMessage); + } + + @Override + @JsonDeserialize(using = ChoiceResponseMessageImpl.DelegatedDeSerializer.class) + public ContactMessageInternalImpl.Builder setChoiceResponseMessage( + ChoiceResponseMessage choiceResponseMessage) { + return super.setChoiceResponseMessage(choiceResponseMessage); + } + + @Override + @JsonDeserialize(using = FallbackMessageImpl.DelegatedDeSerializer.class) + public ContactMessageInternalImpl.Builder setFallbackMessage(FallbackMessage fallbackMessage) { + return super.setFallbackMessage(fallbackMessage); + } + + @Override + @JsonDeserialize(using = LocationMessageImpl.DelegatedDeSerializer.class) + public ContactMessageInternalImpl.Builder setLocationMessage(LocationMessage locationMessage) { + return super.setLocationMessage(locationMessage); + } + + @Override + @JsonDeserialize(using = MediaCardMessageImpl.DelegatedDeSerializer.class) + public ContactMessageInternalImpl.Builder setMediaCardMessage( + MediaCardMessage mediaCardMessage) { + return super.setMediaCardMessage(mediaCardMessage); + } + + @Override + @JsonDeserialize(using = MediaMessageImpl.DelegatedDeSerializer.class) + public ContactMessageInternalImpl.Builder setMediaMessage(MediaMessage mediaMessage) { + return super.setMediaMessage(mediaMessage); + } + + @Override + @JsonDeserialize(using = ProductResponseMessageImpl.DelegatedDeSerializer.class) + public ContactMessageInternalImpl.Builder setProductResponseMessage( + ProductResponseMessage productResponseMessage) { + return super.setProductResponseMessage(productResponseMessage); + } + + @Override + @JsonDeserialize(using = TextMessageImpl.DelegatedDeSerializer.class) + public ContactMessageInternalImpl.Builder setTextMessage(TextMessage textMessage) { + return super.setTextMessage(textMessage); + } + + @Override + @JsonDeserialize(using = ReplyToImpl.DelegatedDeSerializer.class) + public ContactMessageInternalImpl.Builder setReplyTo(ReplyTo replyTo) { + return super.setReplyTo(replyTo); + } + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/MessagesServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/MessagesServiceTest.java index 29954189f..f5e551388 100644 --- a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/MessagesServiceTest.java +++ b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/MessagesServiceTest.java @@ -18,13 +18,13 @@ import com.sinch.sdk.domains.conversation.api.v1.internal.MessagesApi; import com.sinch.sdk.domains.conversation.models.v1.internal.ConversationMessageInternal; import com.sinch.sdk.domains.conversation.models.v1.messages.ConversationMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.ConversationMessageDtoTest; import com.sinch.sdk.domains.conversation.models.v1.messages.internal.ListMessagesResponseInternal; import com.sinch.sdk.domains.conversation.models.v1.messages.request.MessageUpdateRequest; import com.sinch.sdk.domains.conversation.models.v1.messages.request.MessagesListRequest; import com.sinch.sdk.domains.conversation.models.v1.messages.request.SendMessageDtoTest; import com.sinch.sdk.domains.conversation.models.v1.messages.response.MessagesListResponse; import com.sinch.sdk.domains.conversation.models.v1.messages.response.SendMessageResponse; -import com.sinch.sdk.domains.conversation.models.v1.response.ConversationMessageDtoTest; import com.sinch.sdk.models.ConversationContext; import java.time.Instant; import java.util.Map; diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/ReplyTo.java b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/ReplyTo.java new file mode 100644 index 000000000..b66c1a830 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/ReplyTo.java @@ -0,0 +1,59 @@ +/* + * Conversation API | Sinch + * Send and receive messages globally over SMS, RCS, WhatsApp, Viber Business, Facebook messenger and other popular channels using the Sinch Conversation API. The Conversation API endpoint uses built-in transcoding to give you the power of conversation across all supported channels and, if required, full control over channel specific features. + * + * The version of the OpenAPI document: 1.0 + * Contact: support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.conversation.models.v1.messages; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +/** + * If the contact message was a response to a previous App message then this field contains + * information about that. + */ +@JsonDeserialize(builder = ReplyToImpl.Builder.class) +public interface ReplyTo { + + /** + * Required. The Id of the message that this is a response to + * + * @return messageId + */ + String getMessageId(); + + /** + * Getting builder + * + * @return New Builder instance + */ + static Builder builder() { + return new ReplyToImpl.Builder(); + } + + /** Dedicated Builder */ + interface Builder { + + /** + * see getter + * + * @param messageId see getter + * @return Current builder + * @see #getMessageId + */ + Builder setMessageId(String messageId); + + /** + * Create instance + * + * @return The instance build with current builder values + */ + ReplyTo build(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/ReplyToImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/ReplyToImpl.java new file mode 100644 index 000000000..de80f02ac --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/ReplyToImpl.java @@ -0,0 +1,165 @@ +package com.sinch.sdk.domains.conversation.models.v1.messages; + +import com.fasterxml.jackson.annotation.JsonFilter; +import com.fasterxml.jackson.annotation.JsonIgnore; +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.conversation.models.v1.messages.internal.ReplyToInternal; +import com.sinch.sdk.domains.conversation.models.v1.messages.internal.ReplyToInternalImpl; +import java.io.IOException; +import java.util.Objects; +import java.util.Optional; + +@JsonPropertyOrder({ReplyToImpl.JSON_PROPERTY_REPLY_TO}) +@JsonFilter("uninitializedFilter") +@JsonInclude(value = JsonInclude.Include.CUSTOM) +public class ReplyToImpl implements ReplyTo { + private static final long serialVersionUID = 1L; + + public static final String JSON_PROPERTY_REPLY_TO = "reply_to"; + + private OptionalValue replyTo; + + public ReplyToImpl() {} + + protected ReplyToImpl(OptionalValue replyTo) { + this.replyTo = replyTo; + } + + @JsonIgnore + public ReplyToInternal getReplyTo() { + return replyTo.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_REPLY_TO) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue replyTo() { + return replyTo; + } + + @JsonIgnore + public String getMessageId() { + if (null == replyTo || !replyTo.isPresent() || null == replyTo.get().getMessageId()) { + return null; + } + return replyTo.get().getMessageId(); + } + + public OptionalValue messageId() { + return null != replyTo && replyTo.isPresent() + ? replyTo.map(f -> ((ReplyToInternalImpl) f).messageId()).orElse(OptionalValue.empty()) + : OptionalValue.empty(); + } + + /** Return true if this ReplyToField object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReplyToImpl replyToField = (ReplyToImpl) o; + return Objects.equals(this.replyTo, replyToField.replyTo); + } + + @Override + public int hashCode() { + return Objects.hash(replyTo); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ReplyToImpl {\n"); + sb.append(" replyTo: ").append(toIndentedString(replyTo)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + @JsonPOJOBuilder(withPrefix = "set") + static class Builder implements ReplyTo.Builder { + OptionalValue replyTo = OptionalValue.empty(); + + ReplyToInternal.Builder _delegatedBuilder = null; + + @JsonProperty(value = JSON_PROPERTY_REPLY_TO, required = true) + public Builder setReplyTo(ReplyToInternal replyTo) { + this.replyTo = OptionalValue.of(replyTo); + return this; + } + + @JsonIgnore + public Builder setMessageId(String messageId) { + getDelegatedBuilder().setMessageId(messageId); + return this; + } + + private ReplyToInternal.Builder getDelegatedBuilder() { + if (null == _delegatedBuilder) { + this._delegatedBuilder = ReplyToInternal.builder(); + } + return this._delegatedBuilder; + } + + public ReplyTo build() { + // delegated builder was used: filling the related source of delegation field + if (null != this._delegatedBuilder) { + this.replyTo = OptionalValue.of(this._delegatedBuilder.build()); + } + return new ReplyToImpl(replyTo); + } + } + + public static class DelegatedSerializer extends JsonSerializer> { + @Override + public void serialize( + OptionalValue value, JsonGenerator jgen, SerializerProvider provider) + throws IOException { + + if (!value.isPresent()) { + return; + } + ReplyToImpl impl = (ReplyToImpl) value.get(); + jgen.writeObject(null != impl ? impl.getReplyTo() : null); + } + } + + public static class DelegatedDeSerializer extends JsonDeserializer { + @Override + public ReplyTo deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { + + ReplyToImpl.Builder builder = new ReplyToImpl.Builder(); + ReplyToInternalImpl deserialized = jp.readValueAs(ReplyToInternalImpl.class); + builder.setReplyTo(deserialized); + return builder.build(); + } + } + + public static Optional delegatedConverter(ReplyToInternal internal) { + if (null == internal) { + return Optional.empty(); + } + return Optional.of(new Builder().setReplyTo(internal).build()); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/internal/ContactMessageInternal.java b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/internal/ContactMessageInternal.java index 773e45549..812abd750 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/internal/ContactMessageInternal.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/internal/ContactMessageInternal.java @@ -13,6 +13,181 @@ package com.sinch.sdk.domains.conversation.models.v1.messages.internal; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.sinch.sdk.domains.conversation.models.v1.messages.ReplyTo; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.channelspecific.ChannelSpecificContactMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.choiceresponse.ChoiceResponseMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.fallback.FallbackMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.location.LocationMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.media.MediaMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.mediacard.MediaCardMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.productresponse.ProductResponseMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.text.TextMessage; -@JsonDeserialize(using = ContactMessageInternalImpl.ContactMessageInternalImplDeserializer.class) -public interface ContactMessageInternal {} +/** Message originating from a contact */ +@JsonDeserialize(builder = ContactMessageInternalImpl.Builder.class) +public interface ContactMessageInternal { + + /** + * Get channelSpecificMessage + * + * @return channelSpecificMessage + */ + ChannelSpecificContactMessage getChannelSpecificMessage(); + + /** + * Get choiceResponseMessage + * + * @return choiceResponseMessage + */ + ChoiceResponseMessage getChoiceResponseMessage(); + + /** + * Get fallbackMessage + * + * @return fallbackMessage + */ + FallbackMessage getFallbackMessage(); + + /** + * Get locationMessage + * + * @return locationMessage + */ + LocationMessage getLocationMessage(); + + /** + * Get mediaCardMessage + * + * @return mediaCardMessage + */ + MediaCardMessage getMediaCardMessage(); + + /** + * Get mediaMessage + * + * @return mediaMessage + */ + MediaMessage getMediaMessage(); + + /** + * Get productResponseMessage + * + * @return productResponseMessage + */ + ProductResponseMessage getProductResponseMessage(); + + /** + * Get textMessage + * + * @return textMessage + */ + TextMessage getTextMessage(); + + /** + * Get replyTo + * + * @return replyTo + */ + ReplyTo getReplyTo(); + + /** + * Getting builder + * + * @return New Builder instance + */ + static Builder builder() { + return new ContactMessageInternalImpl.Builder(); + } + + /** Dedicated Builder */ + interface Builder { + + /** + * see getter + * + * @param channelSpecificMessage see getter + * @return Current builder + * @see #getChannelSpecificMessage + */ + Builder setChannelSpecificMessage(ChannelSpecificContactMessage channelSpecificMessage); + + /** + * see getter + * + * @param choiceResponseMessage see getter + * @return Current builder + * @see #getChoiceResponseMessage + */ + Builder setChoiceResponseMessage(ChoiceResponseMessage choiceResponseMessage); + + /** + * see getter + * + * @param fallbackMessage see getter + * @return Current builder + * @see #getFallbackMessage + */ + Builder setFallbackMessage(FallbackMessage fallbackMessage); + + /** + * see getter + * + * @param locationMessage see getter + * @return Current builder + * @see #getLocationMessage + */ + Builder setLocationMessage(LocationMessage locationMessage); + + /** + * see getter + * + * @param mediaCardMessage see getter + * @return Current builder + * @see #getMediaCardMessage + */ + Builder setMediaCardMessage(MediaCardMessage mediaCardMessage); + + /** + * see getter + * + * @param mediaMessage see getter + * @return Current builder + * @see #getMediaMessage + */ + Builder setMediaMessage(MediaMessage mediaMessage); + + /** + * see getter + * + * @param productResponseMessage see getter + * @return Current builder + * @see #getProductResponseMessage + */ + Builder setProductResponseMessage(ProductResponseMessage productResponseMessage); + + /** + * see getter + * + * @param textMessage see getter + * @return Current builder + * @see #getTextMessage + */ + Builder setTextMessage(TextMessage textMessage); + + /** + * see getter + * + * @param replyTo see getter + * @return Current builder + * @see #getReplyTo + */ + Builder setReplyTo(ReplyTo replyTo); + + /** + * Create instance + * + * @return The instance build with current builder values + */ + ContactMessageInternal build(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/internal/ContactMessageInternalImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/internal/ContactMessageInternalImpl.java index 4eb038593..aed6b38f4 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/internal/ContactMessageInternalImpl.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/internal/ContactMessageInternalImpl.java @@ -1,655 +1,342 @@ package com.sinch.sdk.domains.conversation.models.v1.messages.internal; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.JsonToken; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.MapperFeature; -import com.fasterxml.jackson.databind.SerializerProvider; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.databind.deser.std.StdDeserializer; -import com.fasterxml.jackson.databind.ser.std.StdSerializer; -import com.sinch.sdk.core.models.AbstractOpenApiSchema; -import com.sinch.sdk.core.utils.databind.JSONNavigator; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.channelspecific.ChannelSpecificContactMessageImpl; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.choiceresponse.ChoiceResponseMessageImpl; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.fallback.FallbackMessageImpl; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.location.LocationMessageImpl; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.media.MediaMessageImpl; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.mediacard.MediaCardMessageImpl; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.productresponse.ProductResponseMessageImpl; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.text.TextMessageImpl; -import java.io.IOException; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; - -@JsonDeserialize(using = ContactMessageInternalImpl.ContactMessageInternalImplDeserializer.class) -@JsonSerialize(using = ContactMessageInternalImpl.ContactMessageInternalImplSerializer.class) -public class ContactMessageInternalImpl extends AbstractOpenApiSchema - implements ContactMessageInternal { - private static final Logger log = Logger.getLogger(ContactMessageInternalImpl.class.getName()); - - public static final class ContactMessageInternalImplSerializer - extends StdSerializer { - private static final long serialVersionUID = 1L; - - public ContactMessageInternalImplSerializer(Class t) { - super(t); - } +import com.fasterxml.jackson.annotation.JsonFilter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.sinch.sdk.core.models.OptionalValue; +import com.sinch.sdk.domains.conversation.models.v1.messages.ReplyTo; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.channelspecific.ChannelSpecificContactMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.choiceresponse.ChoiceResponseMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.fallback.FallbackMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.location.LocationMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.media.MediaMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.mediacard.MediaCardMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.productresponse.ProductResponseMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.text.TextMessage; +import java.util.Objects; + +@JsonPropertyOrder({ + ContactMessageInternalImpl.JSON_PROPERTY_CHANNEL_SPECIFIC_MESSAGE, + ContactMessageInternalImpl.JSON_PROPERTY_CHOICE_RESPONSE_MESSAGE, + ContactMessageInternalImpl.JSON_PROPERTY_FALLBACK_MESSAGE, + ContactMessageInternalImpl.JSON_PROPERTY_LOCATION_MESSAGE, + ContactMessageInternalImpl.JSON_PROPERTY_MEDIA_CARD_MESSAGE, + ContactMessageInternalImpl.JSON_PROPERTY_MEDIA_MESSAGE, + ContactMessageInternalImpl.JSON_PROPERTY_PRODUCT_RESPONSE_MESSAGE, + ContactMessageInternalImpl.JSON_PROPERTY_TEXT_MESSAGE, + ContactMessageInternalImpl.JSON_PROPERTY_REPLY_TO +}) +@JsonFilter("uninitializedFilter") +@JsonInclude(value = JsonInclude.Include.CUSTOM) +public class ContactMessageInternalImpl implements ContactMessageInternal { + private static final long serialVersionUID = 1L; + + public static final String JSON_PROPERTY_CHANNEL_SPECIFIC_MESSAGE = "channel_specific_message"; + + private OptionalValue channelSpecificMessage; + + public static final String JSON_PROPERTY_CHOICE_RESPONSE_MESSAGE = "choice_response_message"; + + private OptionalValue choiceResponseMessage; + + public static final String JSON_PROPERTY_FALLBACK_MESSAGE = "fallback_message"; + + private OptionalValue fallbackMessage; + + public static final String JSON_PROPERTY_LOCATION_MESSAGE = "location_message"; + + private OptionalValue locationMessage; + + public static final String JSON_PROPERTY_MEDIA_CARD_MESSAGE = "media_card_message"; + + private OptionalValue mediaCardMessage; + + public static final String JSON_PROPERTY_MEDIA_MESSAGE = "media_message"; + + private OptionalValue mediaMessage; + + public static final String JSON_PROPERTY_PRODUCT_RESPONSE_MESSAGE = "product_response_message"; + + private OptionalValue productResponseMessage; + + public static final String JSON_PROPERTY_TEXT_MESSAGE = "text_message"; + + private OptionalValue textMessage; + + public static final String JSON_PROPERTY_REPLY_TO = "reply_to"; + + private OptionalValue replyTo; + + public ContactMessageInternalImpl() {} + + protected ContactMessageInternalImpl( + OptionalValue channelSpecificMessage, + OptionalValue choiceResponseMessage, + OptionalValue fallbackMessage, + OptionalValue locationMessage, + OptionalValue mediaCardMessage, + OptionalValue mediaMessage, + OptionalValue productResponseMessage, + OptionalValue textMessage, + OptionalValue replyTo) { + this.channelSpecificMessage = channelSpecificMessage; + this.choiceResponseMessage = choiceResponseMessage; + this.fallbackMessage = fallbackMessage; + this.locationMessage = locationMessage; + this.mediaCardMessage = mediaCardMessage; + this.mediaMessage = mediaMessage; + this.productResponseMessage = productResponseMessage; + this.textMessage = textMessage; + this.replyTo = replyTo; + } - public ContactMessageInternalImplSerializer() { - this(null); - } + @JsonIgnore + public ChannelSpecificContactMessage getChannelSpecificMessage() { + return channelSpecificMessage.orElse(null); + } - @Override - public void serialize( - ContactMessageInternalImpl value, JsonGenerator jgen, SerializerProvider provider) - throws IOException, JsonProcessingException { - jgen.writeObject(value.getActualInstance()); - } + @JsonProperty(JSON_PROPERTY_CHANNEL_SPECIFIC_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue channelSpecificMessage() { + return channelSpecificMessage; } - public static final class ContactMessageInternalImplDeserializer - extends StdDeserializer { + @JsonIgnore + public ChoiceResponseMessage getChoiceResponseMessage() { + return choiceResponseMessage.orElse(null); + } - private static final long serialVersionUID = 1L; + @JsonProperty(JSON_PROPERTY_CHOICE_RESPONSE_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue choiceResponseMessage() { + return choiceResponseMessage; + } - public ContactMessageInternalImplDeserializer() { - this(ContactMessageInternalImpl.class); - } + @JsonIgnore + public FallbackMessage getFallbackMessage() { + return fallbackMessage.orElse(null); + } - public ContactMessageInternalImplDeserializer(Class vc) { - super(vc); - } + @JsonProperty(JSON_PROPERTY_FALLBACK_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue fallbackMessage() { + return fallbackMessage; + } - @Override - public ContactMessageInternalImpl deserialize(JsonParser jp, DeserializationContext ctxt) - throws IOException, JsonProcessingException { - JsonNode tree = jp.readValueAsTree(); - Object deserialized = null; - boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); - int match = 0; - JsonToken token = tree.traverse(jp.getCodec()).nextToken(); - // deserialize ChannelSpecificContactMessageImpl - try { - boolean attemptParsing = true; - // ensure that we respect type coercion as set on the client ObjectMapper - if (ChannelSpecificContactMessageImpl.class.equals(Integer.class) - || ChannelSpecificContactMessageImpl.class.equals(Long.class) - || ChannelSpecificContactMessageImpl.class.equals(Float.class) - || ChannelSpecificContactMessageImpl.class.equals(Double.class) - || ChannelSpecificContactMessageImpl.class.equals(Boolean.class) - || ChannelSpecificContactMessageImpl.class.equals(String.class)) { - attemptParsing = typeCoercion; - if (!attemptParsing) { - attemptParsing |= - ((ChannelSpecificContactMessageImpl.class.equals(Integer.class) - || ChannelSpecificContactMessageImpl.class.equals(Long.class)) - && token == JsonToken.VALUE_NUMBER_INT); - attemptParsing |= - ((ChannelSpecificContactMessageImpl.class.equals(Float.class) - || ChannelSpecificContactMessageImpl.class.equals(Double.class)) - && token == JsonToken.VALUE_NUMBER_FLOAT); - attemptParsing |= - (ChannelSpecificContactMessageImpl.class.equals(Boolean.class) - && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); - attemptParsing |= - (ChannelSpecificContactMessageImpl.class.equals(String.class) - && token == JsonToken.VALUE_STRING); - } - } - if (attemptParsing) { - deserialized = - tree.traverse(jp.getCodec()).readValueAs(ChannelSpecificContactMessageImpl.class); - // TODO: there is no validation against JSON schema constraints - // (min, max, enum, pattern...), this does not perform a strict JSON - // validation, which means the 'match' count may be higher than it should be. - match++; - log.log(Level.FINER, "Input data matches schema 'ChannelSpecificContactMessageImpl'"); - } - } catch (Exception e) { - // deserialization failed, continue - log.log( - Level.FINER, "Input data does not match schema 'ChannelSpecificContactMessageImpl'", e); - } - - // deserialize ChoiceResponseMessageImpl - try { - boolean attemptParsing = true; - // ensure that we respect type coercion as set on the client ObjectMapper - if (ChoiceResponseMessageImpl.class.equals(Integer.class) - || ChoiceResponseMessageImpl.class.equals(Long.class) - || ChoiceResponseMessageImpl.class.equals(Float.class) - || ChoiceResponseMessageImpl.class.equals(Double.class) - || ChoiceResponseMessageImpl.class.equals(Boolean.class) - || ChoiceResponseMessageImpl.class.equals(String.class)) { - attemptParsing = typeCoercion; - if (!attemptParsing) { - attemptParsing |= - ((ChoiceResponseMessageImpl.class.equals(Integer.class) - || ChoiceResponseMessageImpl.class.equals(Long.class)) - && token == JsonToken.VALUE_NUMBER_INT); - attemptParsing |= - ((ChoiceResponseMessageImpl.class.equals(Float.class) - || ChoiceResponseMessageImpl.class.equals(Double.class)) - && token == JsonToken.VALUE_NUMBER_FLOAT); - attemptParsing |= - (ChoiceResponseMessageImpl.class.equals(Boolean.class) - && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); - attemptParsing |= - (ChoiceResponseMessageImpl.class.equals(String.class) - && token == JsonToken.VALUE_STRING); - } - } - if (attemptParsing) { - deserialized = tree.traverse(jp.getCodec()).readValueAs(ChoiceResponseMessageImpl.class); - // TODO: there is no validation against JSON schema constraints - // (min, max, enum, pattern...), this does not perform a strict JSON - // validation, which means the 'match' count may be higher than it should be. - match++; - log.log(Level.FINER, "Input data matches schema 'ChoiceResponseMessageImpl'"); - } - } catch (Exception e) { - // deserialization failed, continue - log.log(Level.FINER, "Input data does not match schema 'ChoiceResponseMessageImpl'", e); - } - - // deserialize FallbackMessageImpl - try { - boolean attemptParsing = true; - // ensure that we respect type coercion as set on the client ObjectMapper - if (FallbackMessageImpl.class.equals(Integer.class) - || FallbackMessageImpl.class.equals(Long.class) - || FallbackMessageImpl.class.equals(Float.class) - || FallbackMessageImpl.class.equals(Double.class) - || FallbackMessageImpl.class.equals(Boolean.class) - || FallbackMessageImpl.class.equals(String.class)) { - attemptParsing = typeCoercion; - if (!attemptParsing) { - attemptParsing |= - ((FallbackMessageImpl.class.equals(Integer.class) - || FallbackMessageImpl.class.equals(Long.class)) - && token == JsonToken.VALUE_NUMBER_INT); - attemptParsing |= - ((FallbackMessageImpl.class.equals(Float.class) - || FallbackMessageImpl.class.equals(Double.class)) - && token == JsonToken.VALUE_NUMBER_FLOAT); - attemptParsing |= - (FallbackMessageImpl.class.equals(Boolean.class) - && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); - attemptParsing |= - (FallbackMessageImpl.class.equals(String.class) && token == JsonToken.VALUE_STRING); - } - } - if (attemptParsing) { - deserialized = tree.traverse(jp.getCodec()).readValueAs(FallbackMessageImpl.class); - // TODO: there is no validation against JSON schema constraints - // (min, max, enum, pattern...), this does not perform a strict JSON - // validation, which means the 'match' count may be higher than it should be. - match++; - log.log(Level.FINER, "Input data matches schema 'FallbackMessageImpl'"); - } - } catch (Exception e) { - // deserialization failed, continue - log.log(Level.FINER, "Input data does not match schema 'FallbackMessageImpl'", e); - } - - // deserialize LocationMessageImpl - try { - boolean attemptParsing = true; - // ensure that we respect type coercion as set on the client ObjectMapper - if (LocationMessageImpl.class.equals(Integer.class) - || LocationMessageImpl.class.equals(Long.class) - || LocationMessageImpl.class.equals(Float.class) - || LocationMessageImpl.class.equals(Double.class) - || LocationMessageImpl.class.equals(Boolean.class) - || LocationMessageImpl.class.equals(String.class)) { - attemptParsing = typeCoercion; - if (!attemptParsing) { - attemptParsing |= - ((LocationMessageImpl.class.equals(Integer.class) - || LocationMessageImpl.class.equals(Long.class)) - && token == JsonToken.VALUE_NUMBER_INT); - attemptParsing |= - ((LocationMessageImpl.class.equals(Float.class) - || LocationMessageImpl.class.equals(Double.class)) - && token == JsonToken.VALUE_NUMBER_FLOAT); - attemptParsing |= - (LocationMessageImpl.class.equals(Boolean.class) - && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); - attemptParsing |= - (LocationMessageImpl.class.equals(String.class) && token == JsonToken.VALUE_STRING); - } - } - if (attemptParsing) { - deserialized = tree.traverse(jp.getCodec()).readValueAs(LocationMessageImpl.class); - // TODO: there is no validation against JSON schema constraints - // (min, max, enum, pattern...), this does not perform a strict JSON - // validation, which means the 'match' count may be higher than it should be. - match++; - log.log(Level.FINER, "Input data matches schema 'LocationMessageImpl'"); - } - } catch (Exception e) { - // deserialization failed, continue - log.log(Level.FINER, "Input data does not match schema 'LocationMessageImpl'", e); - } - - // deserialize MediaCardMessageImpl - try { - boolean attemptParsing = true; - // ensure that we respect type coercion as set on the client ObjectMapper - if (MediaCardMessageImpl.class.equals(Integer.class) - || MediaCardMessageImpl.class.equals(Long.class) - || MediaCardMessageImpl.class.equals(Float.class) - || MediaCardMessageImpl.class.equals(Double.class) - || MediaCardMessageImpl.class.equals(Boolean.class) - || MediaCardMessageImpl.class.equals(String.class)) { - attemptParsing = typeCoercion; - if (!attemptParsing) { - attemptParsing |= - ((MediaCardMessageImpl.class.equals(Integer.class) - || MediaCardMessageImpl.class.equals(Long.class)) - && token == JsonToken.VALUE_NUMBER_INT); - attemptParsing |= - ((MediaCardMessageImpl.class.equals(Float.class) - || MediaCardMessageImpl.class.equals(Double.class)) - && token == JsonToken.VALUE_NUMBER_FLOAT); - attemptParsing |= - (MediaCardMessageImpl.class.equals(Boolean.class) - && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); - attemptParsing |= - (MediaCardMessageImpl.class.equals(String.class) - && token == JsonToken.VALUE_STRING); - } - } - if (attemptParsing) { - deserialized = tree.traverse(jp.getCodec()).readValueAs(MediaCardMessageImpl.class); - // TODO: there is no validation against JSON schema constraints - // (min, max, enum, pattern...), this does not perform a strict JSON - // validation, which means the 'match' count may be higher than it should be. - match++; - log.log(Level.FINER, "Input data matches schema 'MediaCardMessageImpl'"); - } - } catch (Exception e) { - // deserialization failed, continue - log.log(Level.FINER, "Input data does not match schema 'MediaCardMessageImpl'", e); - } - - // deserialize MediaMessageImpl - try { - boolean attemptParsing = true; - // ensure that we respect type coercion as set on the client ObjectMapper - if (MediaMessageImpl.class.equals(Integer.class) - || MediaMessageImpl.class.equals(Long.class) - || MediaMessageImpl.class.equals(Float.class) - || MediaMessageImpl.class.equals(Double.class) - || MediaMessageImpl.class.equals(Boolean.class) - || MediaMessageImpl.class.equals(String.class)) { - attemptParsing = typeCoercion; - if (!attemptParsing) { - attemptParsing |= - ((MediaMessageImpl.class.equals(Integer.class) - || MediaMessageImpl.class.equals(Long.class)) - && token == JsonToken.VALUE_NUMBER_INT); - attemptParsing |= - ((MediaMessageImpl.class.equals(Float.class) - || MediaMessageImpl.class.equals(Double.class)) - && token == JsonToken.VALUE_NUMBER_FLOAT); - attemptParsing |= - (MediaMessageImpl.class.equals(Boolean.class) - && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); - attemptParsing |= - (MediaMessageImpl.class.equals(String.class) && token == JsonToken.VALUE_STRING); - } - } - if (attemptParsing) { - deserialized = tree.traverse(jp.getCodec()).readValueAs(MediaMessageImpl.class); - // TODO: there is no validation against JSON schema constraints - // (min, max, enum, pattern...), this does not perform a strict JSON - // validation, which means the 'match' count may be higher than it should be. - match++; - log.log(Level.FINER, "Input data matches schema 'MediaMessageImpl'"); - } - } catch (Exception e) { - // deserialization failed, continue - log.log(Level.FINER, "Input data does not match schema 'MediaMessageImpl'", e); - } - - // deserialize ProductResponseMessageImpl - try { - boolean attemptParsing = true; - // ensure that we respect type coercion as set on the client ObjectMapper - if (ProductResponseMessageImpl.class.equals(Integer.class) - || ProductResponseMessageImpl.class.equals(Long.class) - || ProductResponseMessageImpl.class.equals(Float.class) - || ProductResponseMessageImpl.class.equals(Double.class) - || ProductResponseMessageImpl.class.equals(Boolean.class) - || ProductResponseMessageImpl.class.equals(String.class)) { - attemptParsing = typeCoercion; - if (!attemptParsing) { - attemptParsing |= - ((ProductResponseMessageImpl.class.equals(Integer.class) - || ProductResponseMessageImpl.class.equals(Long.class)) - && token == JsonToken.VALUE_NUMBER_INT); - attemptParsing |= - ((ProductResponseMessageImpl.class.equals(Float.class) - || ProductResponseMessageImpl.class.equals(Double.class)) - && token == JsonToken.VALUE_NUMBER_FLOAT); - attemptParsing |= - (ProductResponseMessageImpl.class.equals(Boolean.class) - && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); - attemptParsing |= - (ProductResponseMessageImpl.class.equals(String.class) - && token == JsonToken.VALUE_STRING); - } - } - if (attemptParsing) { - deserialized = tree.traverse(jp.getCodec()).readValueAs(ProductResponseMessageImpl.class); - // TODO: there is no validation against JSON schema constraints - // (min, max, enum, pattern...), this does not perform a strict JSON - // validation, which means the 'match' count may be higher than it should be. - match++; - log.log(Level.FINER, "Input data matches schema 'ProductResponseMessageImpl'"); - } - } catch (Exception e) { - // deserialization failed, continue - log.log(Level.FINER, "Input data does not match schema 'ProductResponseMessageImpl'", e); - } - - // deserialize TextMessageImpl - try { - boolean attemptParsing = true; - // ensure that we respect type coercion as set on the client ObjectMapper - if (TextMessageImpl.class.equals(Integer.class) - || TextMessageImpl.class.equals(Long.class) - || TextMessageImpl.class.equals(Float.class) - || TextMessageImpl.class.equals(Double.class) - || TextMessageImpl.class.equals(Boolean.class) - || TextMessageImpl.class.equals(String.class)) { - attemptParsing = typeCoercion; - if (!attemptParsing) { - attemptParsing |= - ((TextMessageImpl.class.equals(Integer.class) - || TextMessageImpl.class.equals(Long.class)) - && token == JsonToken.VALUE_NUMBER_INT); - attemptParsing |= - ((TextMessageImpl.class.equals(Float.class) - || TextMessageImpl.class.equals(Double.class)) - && token == JsonToken.VALUE_NUMBER_FLOAT); - attemptParsing |= - (TextMessageImpl.class.equals(Boolean.class) - && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); - attemptParsing |= - (TextMessageImpl.class.equals(String.class) && token == JsonToken.VALUE_STRING); - } - } - if (attemptParsing) { - deserialized = tree.traverse(jp.getCodec()).readValueAs(TextMessageImpl.class); - // TODO: there is no validation against JSON schema constraints - // (min, max, enum, pattern...), this does not perform a strict JSON - // validation, which means the 'match' count may be higher than it should be. - match++; - log.log(Level.FINER, "Input data matches schema 'TextMessageImpl'"); - } - } catch (Exception e) { - // deserialization failed, continue - log.log(Level.FINER, "Input data does not match schema 'TextMessageImpl'", e); - } - - if (match == 1) { - ContactMessageInternalImpl ret = new ContactMessageInternalImpl(); - ret.setActualInstance(deserialized); - return ret; - } - throw new IOException( - String.format( - "Failed deserialization for ContactMessageInternalImpl: %d classes match result," - + " expected 1", - match)); - } + @JsonIgnore + public LocationMessage getLocationMessage() { + return locationMessage.orElse(null); + } - /** Handle deserialization of the 'null' value. */ - @Override - public ContactMessageInternalImpl getNullValue(DeserializationContext ctxt) - throws JsonMappingException { - throw new JsonMappingException(ctxt.getParser(), "ContactMessageInternalImpl cannot be null"); - } + @JsonProperty(JSON_PROPERTY_LOCATION_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue locationMessage() { + return locationMessage; } - // store a list of schema names defined in oneOf - public static final Map> schemas = new HashMap<>(); + @JsonIgnore + public MediaCardMessage getMediaCardMessage() { + return mediaCardMessage.orElse(null); + } - public ContactMessageInternalImpl() { - super("oneOf", Boolean.FALSE); + @JsonProperty(JSON_PROPERTY_MEDIA_CARD_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue mediaCardMessage() { + return mediaCardMessage; } - public ContactMessageInternalImpl(ChannelSpecificContactMessageImpl o) { - super("oneOf", Boolean.FALSE); - setActualInstance(o); + @JsonIgnore + public MediaMessage getMediaMessage() { + return mediaMessage.orElse(null); } - public ContactMessageInternalImpl(ChoiceResponseMessageImpl o) { - super("oneOf", Boolean.FALSE); - setActualInstance(o); + @JsonProperty(JSON_PROPERTY_MEDIA_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue mediaMessage() { + return mediaMessage; } - public ContactMessageInternalImpl(FallbackMessageImpl o) { - super("oneOf", Boolean.FALSE); - setActualInstance(o); + @JsonIgnore + public ProductResponseMessage getProductResponseMessage() { + return productResponseMessage.orElse(null); } - public ContactMessageInternalImpl(LocationMessageImpl o) { - super("oneOf", Boolean.FALSE); - setActualInstance(o); + @JsonProperty(JSON_PROPERTY_PRODUCT_RESPONSE_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue productResponseMessage() { + return productResponseMessage; } - public ContactMessageInternalImpl(MediaCardMessageImpl o) { - super("oneOf", Boolean.FALSE); - setActualInstance(o); + @JsonIgnore + public TextMessage getTextMessage() { + return textMessage.orElse(null); } - public ContactMessageInternalImpl(MediaMessageImpl o) { - super("oneOf", Boolean.FALSE); - setActualInstance(o); + @JsonProperty(JSON_PROPERTY_TEXT_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue textMessage() { + return textMessage; } - public ContactMessageInternalImpl(ProductResponseMessageImpl o) { - super("oneOf", Boolean.FALSE); - setActualInstance(o); + @JsonIgnore + public ReplyTo getReplyTo() { + return replyTo.orElse(null); } - public ContactMessageInternalImpl(TextMessageImpl o) { - super("oneOf", Boolean.FALSE); - setActualInstance(o); + @JsonProperty(JSON_PROPERTY_REPLY_TO) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue replyTo() { + return replyTo; } - static { - schemas.put("ChannelSpecificContactMessageImpl", ChannelSpecificContactMessageImpl.class); - schemas.put("ChoiceResponseMessageImpl", ChoiceResponseMessageImpl.class); - schemas.put("FallbackMessageImpl", FallbackMessageImpl.class); - schemas.put("LocationMessageImpl", LocationMessageImpl.class); - schemas.put("MediaCardMessageImpl", MediaCardMessageImpl.class); - schemas.put("MediaMessageImpl", MediaMessageImpl.class); - schemas.put("ProductResponseMessageImpl", ProductResponseMessageImpl.class); - schemas.put("TextMessageImpl", TextMessageImpl.class); - JSONNavigator.registerDescendants( - ContactMessageInternalImpl.class, Collections.unmodifiableMap(schemas)); + /** Return true if this ContactMessage object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ContactMessageInternalImpl contactMessage = (ContactMessageInternalImpl) o; + return Objects.equals(this.channelSpecificMessage, contactMessage.channelSpecificMessage) + && Objects.equals(this.choiceResponseMessage, contactMessage.choiceResponseMessage) + && Objects.equals(this.fallbackMessage, contactMessage.fallbackMessage) + && Objects.equals(this.locationMessage, contactMessage.locationMessage) + && Objects.equals(this.mediaCardMessage, contactMessage.mediaCardMessage) + && Objects.equals(this.mediaMessage, contactMessage.mediaMessage) + && Objects.equals(this.productResponseMessage, contactMessage.productResponseMessage) + && Objects.equals(this.textMessage, contactMessage.textMessage) + && Objects.equals(this.replyTo, contactMessage.replyTo); + } + + @Override + public int hashCode() { + return Objects.hash( + channelSpecificMessage, + choiceResponseMessage, + fallbackMessage, + locationMessage, + mediaCardMessage, + mediaMessage, + productResponseMessage, + textMessage, + replyTo); } @Override - public Map> getSchemas() { - return ContactMessageInternalImpl.schemas; + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ContactMessageInternalImpl {\n"); + sb.append(" channelSpecificMessage: ") + .append(toIndentedString(channelSpecificMessage)) + .append("\n"); + sb.append(" choiceResponseMessage: ") + .append(toIndentedString(choiceResponseMessage)) + .append("\n"); + sb.append(" fallbackMessage: ").append(toIndentedString(fallbackMessage)).append("\n"); + sb.append(" locationMessage: ").append(toIndentedString(locationMessage)).append("\n"); + sb.append(" mediaCardMessage: ").append(toIndentedString(mediaCardMessage)).append("\n"); + sb.append(" mediaMessage: ").append(toIndentedString(mediaMessage)).append("\n"); + sb.append(" productResponseMessage: ") + .append(toIndentedString(productResponseMessage)) + .append("\n"); + sb.append(" textMessage: ").append(toIndentedString(textMessage)).append("\n"); + sb.append(" replyTo: ").append(toIndentedString(replyTo)).append("\n"); + sb.append("}"); + return sb.toString(); } /** - * Set the instance that matches the oneOf child schema, check the instance parameter is valid - * against the oneOf child schemas: ChannelSpecificContactMessageImpl, ChoiceResponseMessageImpl, - * FallbackMessageImpl, LocationMessageImpl, MediaCardMessageImpl, MediaMessageImpl, - * ProductResponseMessageImpl, TextMessageImpl - * - *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a - * composed schema (allOf, anyOf, oneOf). + * Convert the given object to string with each line indented by 4 spaces (except the first line). */ - @Override - public void setActualInstance(Object instance) { - if (JSONNavigator.isInstanceOf( - ChannelSpecificContactMessageImpl.class, instance, new HashSet>())) { - super.setActualInstance(instance); - return; + private String toIndentedString(Object o) { + if (o == null) { + return "null"; } + return o.toString().replace("\n", "\n "); + } - if (JSONNavigator.isInstanceOf( - ChoiceResponseMessageImpl.class, instance, new HashSet>())) { - super.setActualInstance(instance); - return; + @JsonPOJOBuilder(withPrefix = "set") + static class Builder implements ContactMessageInternal.Builder { + OptionalValue channelSpecificMessage = OptionalValue.empty(); + OptionalValue choiceResponseMessage = OptionalValue.empty(); + OptionalValue fallbackMessage = OptionalValue.empty(); + OptionalValue locationMessage = OptionalValue.empty(); + OptionalValue mediaCardMessage = OptionalValue.empty(); + OptionalValue mediaMessage = OptionalValue.empty(); + OptionalValue productResponseMessage = OptionalValue.empty(); + OptionalValue textMessage = OptionalValue.empty(); + OptionalValue replyTo = OptionalValue.empty(); + + @JsonProperty(JSON_PROPERTY_CHANNEL_SPECIFIC_MESSAGE) + public Builder setChannelSpecificMessage(ChannelSpecificContactMessage channelSpecificMessage) { + this.channelSpecificMessage = OptionalValue.of(channelSpecificMessage); + return this; } - if (JSONNavigator.isInstanceOf(FallbackMessageImpl.class, instance, new HashSet>())) { - super.setActualInstance(instance); - return; + @JsonProperty(JSON_PROPERTY_CHOICE_RESPONSE_MESSAGE) + public Builder setChoiceResponseMessage(ChoiceResponseMessage choiceResponseMessage) { + this.choiceResponseMessage = OptionalValue.of(choiceResponseMessage); + return this; } - if (JSONNavigator.isInstanceOf(LocationMessageImpl.class, instance, new HashSet>())) { - super.setActualInstance(instance); - return; + @JsonProperty(JSON_PROPERTY_FALLBACK_MESSAGE) + public Builder setFallbackMessage(FallbackMessage fallbackMessage) { + this.fallbackMessage = OptionalValue.of(fallbackMessage); + return this; } - if (JSONNavigator.isInstanceOf(MediaCardMessageImpl.class, instance, new HashSet>())) { - super.setActualInstance(instance); - return; + @JsonProperty(JSON_PROPERTY_LOCATION_MESSAGE) + public Builder setLocationMessage(LocationMessage locationMessage) { + this.locationMessage = OptionalValue.of(locationMessage); + return this; } - if (JSONNavigator.isInstanceOf(MediaMessageImpl.class, instance, new HashSet>())) { - super.setActualInstance(instance); - return; + @JsonProperty(JSON_PROPERTY_MEDIA_CARD_MESSAGE) + public Builder setMediaCardMessage(MediaCardMessage mediaCardMessage) { + this.mediaCardMessage = OptionalValue.of(mediaCardMessage); + return this; } - if (JSONNavigator.isInstanceOf( - ProductResponseMessageImpl.class, instance, new HashSet>())) { - super.setActualInstance(instance); - return; + @JsonProperty(JSON_PROPERTY_MEDIA_MESSAGE) + public Builder setMediaMessage(MediaMessage mediaMessage) { + this.mediaMessage = OptionalValue.of(mediaMessage); + return this; } - if (JSONNavigator.isInstanceOf(TextMessageImpl.class, instance, new HashSet>())) { - super.setActualInstance(instance); - return; + @JsonProperty(JSON_PROPERTY_PRODUCT_RESPONSE_MESSAGE) + public Builder setProductResponseMessage(ProductResponseMessage productResponseMessage) { + this.productResponseMessage = OptionalValue.of(productResponseMessage); + return this; } - throw new RuntimeException( - "Invalid instance type. Must be ChannelSpecificContactMessageImpl," - + " ChoiceResponseMessageImpl, FallbackMessageImpl, LocationMessageImpl," - + " MediaCardMessageImpl, MediaMessageImpl, ProductResponseMessageImpl," - + " TextMessageImpl"); - } - - /** - * Get the actual instance, which can be the following: ChannelSpecificContactMessageImpl, - * ChoiceResponseMessageImpl, FallbackMessageImpl, LocationMessageImpl, MediaCardMessageImpl, - * MediaMessageImpl, ProductResponseMessageImpl, TextMessageImpl - * - * @return The actual instance (ChannelSpecificContactMessageImpl, ChoiceResponseMessageImpl, - * FallbackMessageImpl, LocationMessageImpl, MediaCardMessageImpl, MediaMessageImpl, - * ProductResponseMessageImpl, TextMessageImpl) - */ - @Override - public Object getActualInstance() { - return super.getActualInstance(); - } - - /** - * Get the actual instance of `ChannelSpecificContactMessageImpl`. If the actual instance is not - * `ChannelSpecificContactMessageImpl`, the ClassCastException will be thrown. - * - * @return The actual instance of `ChannelSpecificContactMessageImpl` - * @throws ClassCastException if the instance is not `ChannelSpecificContactMessageImpl` - */ - public ChannelSpecificContactMessageImpl getChannelSpecificContactMessageImpl() - throws ClassCastException { - return (ChannelSpecificContactMessageImpl) super.getActualInstance(); - } - - /** - * Get the actual instance of `ChoiceResponseMessageImpl`. If the actual instance is not - * `ChoiceResponseMessageImpl`, the ClassCastException will be thrown. - * - * @return The actual instance of `ChoiceResponseMessageImpl` - * @throws ClassCastException if the instance is not `ChoiceResponseMessageImpl` - */ - public ChoiceResponseMessageImpl getChoiceResponseMessageImpl() throws ClassCastException { - return (ChoiceResponseMessageImpl) super.getActualInstance(); - } - - /** - * Get the actual instance of `FallbackMessageImpl`. If the actual instance is not - * `FallbackMessageImpl`, the ClassCastException will be thrown. - * - * @return The actual instance of `FallbackMessageImpl` - * @throws ClassCastException if the instance is not `FallbackMessageImpl` - */ - public FallbackMessageImpl getFallbackMessageImpl() throws ClassCastException { - return (FallbackMessageImpl) super.getActualInstance(); - } - - /** - * Get the actual instance of `LocationMessageImpl`. If the actual instance is not - * `LocationMessageImpl`, the ClassCastException will be thrown. - * - * @return The actual instance of `LocationMessageImpl` - * @throws ClassCastException if the instance is not `LocationMessageImpl` - */ - public LocationMessageImpl getLocationMessageImpl() throws ClassCastException { - return (LocationMessageImpl) super.getActualInstance(); - } - - /** - * Get the actual instance of `MediaCardMessageImpl`. If the actual instance is not - * `MediaCardMessageImpl`, the ClassCastException will be thrown. - * - * @return The actual instance of `MediaCardMessageImpl` - * @throws ClassCastException if the instance is not `MediaCardMessageImpl` - */ - public MediaCardMessageImpl getMediaCardMessageImpl() throws ClassCastException { - return (MediaCardMessageImpl) super.getActualInstance(); - } - - /** - * Get the actual instance of `MediaMessageImpl`. If the actual instance is not - * `MediaMessageImpl`, the ClassCastException will be thrown. - * - * @return The actual instance of `MediaMessageImpl` - * @throws ClassCastException if the instance is not `MediaMessageImpl` - */ - public MediaMessageImpl getMediaMessageImpl() throws ClassCastException { - return (MediaMessageImpl) super.getActualInstance(); - } + @JsonProperty(JSON_PROPERTY_TEXT_MESSAGE) + public Builder setTextMessage(TextMessage textMessage) { + this.textMessage = OptionalValue.of(textMessage); + return this; + } - /** - * Get the actual instance of `ProductResponseMessageImpl`. If the actual instance is not - * `ProductResponseMessageImpl`, the ClassCastException will be thrown. - * - * @return The actual instance of `ProductResponseMessageImpl` - * @throws ClassCastException if the instance is not `ProductResponseMessageImpl` - */ - public ProductResponseMessageImpl getProductResponseMessageImpl() throws ClassCastException { - return (ProductResponseMessageImpl) super.getActualInstance(); - } + @JsonProperty(JSON_PROPERTY_REPLY_TO) + public Builder setReplyTo(ReplyTo replyTo) { + this.replyTo = OptionalValue.of(replyTo); + return this; + } - /** - * Get the actual instance of `TextMessageImpl`. If the actual instance is not `TextMessageImpl`, - * the ClassCastException will be thrown. - * - * @return The actual instance of `TextMessageImpl` - * @throws ClassCastException if the instance is not `TextMessageImpl` - */ - public TextMessageImpl getTextMessageImpl() throws ClassCastException { - return (TextMessageImpl) super.getActualInstance(); + public ContactMessageInternal build() { + return new ContactMessageInternalImpl( + channelSpecificMessage, + choiceResponseMessage, + fallbackMessage, + locationMessage, + mediaCardMessage, + mediaMessage, + productResponseMessage, + textMessage, + replyTo); + } } } diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/internal/ReplyToMessageInternal.java b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/internal/ReplyToInternal.java similarity index 85% rename from openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/internal/ReplyToMessageInternal.java rename to openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/internal/ReplyToInternal.java index f810951ee..e7dcf76a4 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/internal/ReplyToMessageInternal.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/internal/ReplyToInternal.java @@ -14,9 +14,9 @@ import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -/** Reply To Message */ -@JsonDeserialize(builder = ReplyToMessageInternalImpl.Builder.class) -public interface ReplyToMessageInternal { +/** Reply To */ +@JsonDeserialize(builder = ReplyToInternalImpl.Builder.class) +public interface ReplyToInternal { /** * Required. The Id of the message that this is a response to @@ -31,7 +31,7 @@ public interface ReplyToMessageInternal { * @return New Builder instance */ static Builder builder() { - return new ReplyToMessageInternalImpl.Builder(); + return new ReplyToInternalImpl.Builder(); } /** Dedicated Builder */ @@ -51,6 +51,6 @@ interface Builder { * * @return The instance build with current builder values */ - ReplyToMessageInternal build(); + ReplyToInternal build(); } } diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/internal/ReplyToMessageInternalImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/internal/ReplyToInternalImpl.java similarity index 74% rename from openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/internal/ReplyToMessageInternalImpl.java rename to openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/internal/ReplyToInternalImpl.java index 4b75ad802..e1cb3df1c 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/internal/ReplyToMessageInternalImpl.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/internal/ReplyToInternalImpl.java @@ -9,19 +9,19 @@ import com.sinch.sdk.core.models.OptionalValue; import java.util.Objects; -@JsonPropertyOrder({ReplyToMessageInternalImpl.JSON_PROPERTY_MESSAGE_ID}) +@JsonPropertyOrder({ReplyToInternalImpl.JSON_PROPERTY_MESSAGE_ID}) @JsonFilter("uninitializedFilter") @JsonInclude(value = JsonInclude.Include.CUSTOM) -public class ReplyToMessageInternalImpl implements ReplyToMessageInternal { +public class ReplyToInternalImpl implements ReplyToInternal { private static final long serialVersionUID = 1L; public static final String JSON_PROPERTY_MESSAGE_ID = "message_id"; private OptionalValue messageId; - public ReplyToMessageInternalImpl() {} + public ReplyToInternalImpl() {} - protected ReplyToMessageInternalImpl(OptionalValue messageId) { + protected ReplyToInternalImpl(OptionalValue messageId) { this.messageId = messageId; } @@ -36,7 +36,7 @@ public OptionalValue messageId() { return messageId; } - /** Return true if this Reply_To_Message object is equal to o. */ + /** Return true if this Reply_To object is equal to o. */ @Override public boolean equals(Object o) { if (this == o) { @@ -45,8 +45,8 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - ReplyToMessageInternalImpl replyToMessage = (ReplyToMessageInternalImpl) o; - return Objects.equals(this.messageId, replyToMessage.messageId); + ReplyToInternalImpl replyTo = (ReplyToInternalImpl) o; + return Objects.equals(this.messageId, replyTo.messageId); } @Override @@ -57,7 +57,7 @@ public int hashCode() { @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class ReplyToMessageInternalImpl {\n"); + sb.append("class ReplyToInternalImpl {\n"); sb.append(" messageId: ").append(toIndentedString(messageId)).append("\n"); sb.append("}"); return sb.toString(); @@ -74,7 +74,7 @@ private String toIndentedString(Object o) { } @JsonPOJOBuilder(withPrefix = "set") - static class Builder implements ReplyToMessageInternal.Builder { + static class Builder implements ReplyToInternal.Builder { OptionalValue messageId = OptionalValue.empty(); @JsonProperty(JSON_PROPERTY_MESSAGE_ID) @@ -83,8 +83,8 @@ public Builder setMessageId(String messageId) { return this; } - public ReplyToMessageInternal build() { - return new ReplyToMessageInternalImpl(messageId); + public ReplyToInternal build() { + return new ReplyToInternalImpl(messageId); } } } diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/ChannelSpecificContactMessage.java b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/ChannelSpecificContactMessage.java index e2ae86b75..56a8ba5e4 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/ChannelSpecificContactMessage.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/ChannelSpecificContactMessage.java @@ -21,7 +21,7 @@ /** A contact message containing a channel specific message (not supported by OMNI types). */ @JsonDeserialize(builder = ChannelSpecificContactMessageImpl.Builder.class) public interface ChannelSpecificContactMessage - extends com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessage { + extends com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessageBody { /** The message type. */ public class MessageTypeEnum extends EnumDynamic { diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/ChannelSpecificContactMessageImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/ChannelSpecificContactMessageImpl.java index cb094945b..f1ca5b11a 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/ChannelSpecificContactMessageImpl.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/ChannelSpecificContactMessageImpl.java @@ -24,7 +24,7 @@ @JsonInclude(value = JsonInclude.Include.CUSTOM) public class ChannelSpecificContactMessageImpl implements ChannelSpecificContactMessage, - com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessage { + com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessageBody { private static final long serialVersionUID = 1L; public static final String JSON_PROPERTY_CHANNEL_SPECIFIC_MESSAGE = "channel_specific_message"; diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/choiceresponse/ChoiceResponseMessage.java b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/choiceresponse/ChoiceResponseMessage.java index 08ca54e39..b5959968c 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/choiceresponse/ChoiceResponseMessage.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/choiceresponse/ChoiceResponseMessage.java @@ -17,7 +17,7 @@ /** Represents a response to a choice message. */ @JsonDeserialize(builder = ChoiceResponseMessageImpl.Builder.class) public interface ChoiceResponseMessage - extends com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessage { + extends com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessageBody { /** * The message id containing the choice. diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/choiceresponse/ChoiceResponseMessageImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/choiceresponse/ChoiceResponseMessageImpl.java index 51e73cfe1..c999bf0b0 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/choiceresponse/ChoiceResponseMessageImpl.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/choiceresponse/ChoiceResponseMessageImpl.java @@ -24,7 +24,7 @@ @JsonInclude(value = JsonInclude.Include.CUSTOM) public class ChoiceResponseMessageImpl implements ChoiceResponseMessage, - com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessage { + com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessageBody { private static final long serialVersionUID = 1L; public static final String JSON_PROPERTY_CHOICE_RESPONSE_MESSAGE = "choice_response_message"; diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/fallback/FallbackMessage.java b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/fallback/FallbackMessage.java index 949bc76cd..549e802d3 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/fallback/FallbackMessage.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/fallback/FallbackMessage.java @@ -18,7 +18,7 @@ /** Fallback message. Used when original contact message can not be handled. */ @JsonDeserialize(builder = FallbackMessageImpl.Builder.class) public interface FallbackMessage - extends com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessage { + extends com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessageBody { /** * Optional. The raw fallback message if provided by the channel. diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/fallback/FallbackMessageImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/fallback/FallbackMessageImpl.java index 202a0ac6d..6b2344659 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/fallback/FallbackMessageImpl.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/fallback/FallbackMessageImpl.java @@ -25,7 +25,7 @@ @JsonInclude(value = JsonInclude.Include.CUSTOM) public class FallbackMessageImpl implements FallbackMessage, - com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessage { + com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessageBody { private static final long serialVersionUID = 1L; public static final String JSON_PROPERTY_FALLBACK_MESSAGE = "fallback_message"; diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/location/LocationMessage.java b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/location/LocationMessage.java index c58729297..786b8a11b 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/location/LocationMessage.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/location/LocationMessage.java @@ -19,7 +19,7 @@ public interface LocationMessage extends com.sinch.sdk.domains.conversation.models.v1.messages.OmniMessageOverride, com.sinch.sdk.domains.conversation.models.v1.messages.AppMessageBody, - com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessage, + com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessageBody, com.sinch.sdk.domains.conversation.models.v1.messages.types.choice.ChoiceMessageType { /** diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/location/LocationMessageImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/location/LocationMessageImpl.java index 9a502de9f..f7393ae83 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/location/LocationMessageImpl.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/location/LocationMessageImpl.java @@ -26,7 +26,7 @@ public class LocationMessageImpl implements LocationMessage, com.sinch.sdk.domains.conversation.models.v1.messages.OmniMessageOverride, com.sinch.sdk.domains.conversation.models.v1.messages.AppMessageBody, - com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessage, + com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessageBody, com.sinch.sdk.domains.conversation.models.v1.messages.types.choice.ChoiceMessageType { private static final long serialVersionUID = 1L; diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/media/MediaMessage.java b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/media/MediaMessage.java index af7269cb7..0eae616f7 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/media/MediaMessage.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/media/MediaMessage.java @@ -19,7 +19,7 @@ public interface MediaMessage extends com.sinch.sdk.domains.conversation.models.v1.messages.OmniMessageOverride, com.sinch.sdk.domains.conversation.models.v1.messages.AppMessageBody, - com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessage { + com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessageBody { /** * An optional parameter. Will be used where it is natively supported. diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/media/MediaMessageImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/media/MediaMessageImpl.java index f38cf1d1c..b5bdb4b0f 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/media/MediaMessageImpl.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/media/MediaMessageImpl.java @@ -26,7 +26,7 @@ public class MediaMessageImpl implements MediaMessage, com.sinch.sdk.domains.conversation.models.v1.messages.OmniMessageOverride, com.sinch.sdk.domains.conversation.models.v1.messages.AppMessageBody, - com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessage { + com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessageBody { private static final long serialVersionUID = 1L; public static final String JSON_PROPERTY_MEDIA_MESSAGE = "media_message"; diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/mediacard/MediaCardMessage.java b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/mediacard/MediaCardMessage.java index 6ae48cbfe..164167e4a 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/mediacard/MediaCardMessage.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/mediacard/MediaCardMessage.java @@ -17,7 +17,7 @@ /** A message containing a media component, such as an image or video. */ @JsonDeserialize(builder = MediaCardMessageImpl.Builder.class) public interface MediaCardMessage - extends com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessage { + extends com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessageBody { /** * Caption for the media on supported channels. diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/mediacard/MediaCardMessageImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/mediacard/MediaCardMessageImpl.java index 77218d927..4a21179d6 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/mediacard/MediaCardMessageImpl.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/mediacard/MediaCardMessageImpl.java @@ -24,7 +24,7 @@ @JsonInclude(value = JsonInclude.Include.CUSTOM) public class MediaCardMessageImpl implements MediaCardMessage, - com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessage { + com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessageBody { private static final long serialVersionUID = 1L; public static final String JSON_PROPERTY_MEDIA_CARD_MESSAGE = "media_card_message"; diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/productresponse/ProductResponseMessage.java b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/productresponse/ProductResponseMessage.java index fce594379..00e37691d 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/productresponse/ProductResponseMessage.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/productresponse/ProductResponseMessage.java @@ -19,7 +19,7 @@ /** Represents an interactive WhatsApp message containing ProductItem objects */ @JsonDeserialize(builder = ProductResponseMessageImpl.Builder.class) public interface ProductResponseMessage - extends com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessage { + extends com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessageBody { /** * The selected products. diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/productresponse/ProductResponseMessageImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/productresponse/ProductResponseMessageImpl.java index f9976f171..df5db5e57 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/productresponse/ProductResponseMessageImpl.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/productresponse/ProductResponseMessageImpl.java @@ -26,7 +26,7 @@ @JsonInclude(value = JsonInclude.Include.CUSTOM) public class ProductResponseMessageImpl implements ProductResponseMessage, - com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessage { + com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessageBody { private static final long serialVersionUID = 1L; public static final String JSON_PROPERTY_PRODUCT_RESPONSE_MESSAGE = "product_response_message"; diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/text/TextMessage.java b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/text/TextMessage.java index 37ab7ce47..b7c90baac 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/text/TextMessage.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/text/TextMessage.java @@ -19,7 +19,7 @@ public interface TextMessage extends com.sinch.sdk.domains.conversation.models.v1.messages.OmniMessageOverride, com.sinch.sdk.domains.conversation.models.v1.messages.AppMessageBody, - com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessage, + com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessageBody, com.sinch.sdk.domains.conversation.models.v1.messages.types.choice.ChoiceMessageType { /** diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/text/TextMessageImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/text/TextMessageImpl.java index 0820685ba..76e9358c9 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/text/TextMessageImpl.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/text/TextMessageImpl.java @@ -26,7 +26,7 @@ public class TextMessageImpl implements TextMessage, com.sinch.sdk.domains.conversation.models.v1.messages.OmniMessageOverride, com.sinch.sdk.domains.conversation.models.v1.messages.AppMessageBody, - com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessage, + com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessageBody, com.sinch.sdk.domains.conversation.models.v1.messages.types.choice.ChoiceMessageType { private static final long serialVersionUID = 1L; diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/messages/AppMessageDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/messages/AppMessageDtoTest.java index 6f2409c7d..ad08d8ef8 100644 --- a/openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/messages/AppMessageDtoTest.java +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/messages/AppMessageDtoTest.java @@ -40,7 +40,7 @@ public class AppMessageDtoTest extends ConversationBaseTest { public static AppMessage appCardMessageDto = AppMessage.builder() - .setMessage(CardMessageDtoTest.cardMessageDto) + .setBody(CardMessageDtoTest.cardMessageDto) .setExplicitChannelMessage(createExplicitChannelMessage()) .setExplicitChannelOmniMessage(createExplicitChannelOmniMessage()) .setChannelSpecificMessage(createChannelSpecificMessage()) @@ -49,7 +49,7 @@ public class AppMessageDtoTest extends ConversationBaseTest { public static AppMessage appCarouselMessageDto = AppMessage.builder() - .setMessage(CarouselMessageDtoTest.carouselMessageDto) + .setBody(CarouselMessageDtoTest.carouselMessageDto) .setExplicitChannelMessage(createExplicitChannelMessage()) .setExplicitChannelOmniMessage(createExplicitChannelOmniMessage()) .setChannelSpecificMessage(createChannelSpecificMessage()) @@ -58,7 +58,7 @@ public class AppMessageDtoTest extends ConversationBaseTest { public static AppMessage appChoiceMessageDto = AppMessage.builder() - .setMessage(ChoiceMessageDtoTest.choiceMessageDto) + .setBody(ChoiceMessageDtoTest.choiceMessageDto) .setExplicitChannelMessage(createExplicitChannelMessage()) .setExplicitChannelOmniMessage(createExplicitChannelOmniMessage()) .setChannelSpecificMessage(createChannelSpecificMessage()) @@ -66,7 +66,7 @@ public class AppMessageDtoTest extends ConversationBaseTest { .build(); public static AppMessage appContactInfoMessageDto = AppMessage.builder() - .setMessage(ContactInfoMessageDtoTest.contactInfoMessageDto) + .setBody(ContactInfoMessageDtoTest.contactInfoMessageDto) .setExplicitChannelMessage(createExplicitChannelMessage()) .setExplicitChannelOmniMessage(createExplicitChannelOmniMessage()) .setChannelSpecificMessage(createChannelSpecificMessage()) @@ -75,7 +75,7 @@ public class AppMessageDtoTest extends ConversationBaseTest { public static AppMessage appListMessageDto = AppMessage.builder() - .setMessage(ListMessageDtoTest.listMessageChoiceDto) + .setBody(ListMessageDtoTest.listMessageChoiceDto) .setExplicitChannelMessage(createExplicitChannelMessage()) .setExplicitChannelOmniMessage(createExplicitChannelOmniMessage()) .setChannelSpecificMessage(createChannelSpecificMessage()) @@ -84,7 +84,7 @@ public class AppMessageDtoTest extends ConversationBaseTest { public static AppMessage appLocationMessageDto = AppMessage.builder() - .setMessage(LocationMessageDtoTest.locationMessageDto) + .setBody(LocationMessageDtoTest.locationMessageDto) .setExplicitChannelMessage(createExplicitChannelMessage()) .setExplicitChannelOmniMessage(createExplicitChannelOmniMessage()) .setChannelSpecificMessage(createChannelSpecificMessage()) @@ -92,7 +92,7 @@ public class AppMessageDtoTest extends ConversationBaseTest { .build(); public static AppMessage appMediaMessageDto = AppMessage.builder() - .setMessage(MediaMessageDtoTest.mediaMessageDto) + .setBody(MediaMessageDtoTest.mediaMessageDto) .setExplicitChannelMessage(createExplicitChannelMessage()) .setExplicitChannelOmniMessage(createExplicitChannelOmniMessage()) .setChannelSpecificMessage(createChannelSpecificMessage()) @@ -101,7 +101,7 @@ public class AppMessageDtoTest extends ConversationBaseTest { public static AppMessage appTemplateMessageDto = AppMessage.builder() - .setMessage(TemplateMessageDtoTest.templateMessageDto) + .setBody(TemplateMessageDtoTest.templateMessageDto) .setExplicitChannelMessage(createExplicitChannelMessage()) .setExplicitChannelOmniMessage(createExplicitChannelOmniMessage()) .setChannelSpecificMessage(createChannelSpecificMessage()) @@ -109,7 +109,7 @@ public class AppMessageDtoTest extends ConversationBaseTest { .build(); public static AppMessage appTextMessageDto = AppMessage.builder() - .setMessage(TextMessageDtoTest.textMessageDto) + .setBody(TextMessageDtoTest.textMessageDto) .setExplicitChannelMessage(createExplicitChannelMessage()) .setExplicitChannelOmniMessage(createExplicitChannelOmniMessage()) .setChannelSpecificMessage(createChannelSpecificMessage()) diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/messages/ContactMessageDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/messages/ContactMessageDtoTest.java index d040bfc49..feef45d19 100644 --- a/openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/messages/ContactMessageDtoTest.java +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/messages/ContactMessageDtoTest.java @@ -4,12 +4,21 @@ import com.adelean.inject.resources.junit.jupiter.TestWithResources; import com.fasterxml.jackson.core.JsonProcessingException; import com.sinch.sdk.domains.conversation.api.v1.adapters.ConversationBaseTest; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.channelspecific.ChannelSpecificContactMessage; import com.sinch.sdk.domains.conversation.models.v1.messages.types.channelspecific.ChannelSpecificContactMessageDtoTest; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.choiceresponse.ChoiceResponseMessage; import com.sinch.sdk.domains.conversation.models.v1.messages.types.choiceresponse.ChoiceResponseMessageDtoTest; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.fallback.FallbackMessage; import com.sinch.sdk.domains.conversation.models.v1.messages.types.fallback.FallbackMessageDtoTest; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.location.LocationMessage; import com.sinch.sdk.domains.conversation.models.v1.messages.types.location.LocationMessageDtoTest; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.media.MediaMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.media.MediaMessageDtoTest; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.mediacard.MediaCardMessage; import com.sinch.sdk.domains.conversation.models.v1.messages.types.mediacard.MediaCardMessageDtoTest; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.productresponse.ProductResponseMessage; import com.sinch.sdk.domains.conversation.models.v1.messages.types.productresponse.ProductResponseMessageDtoTest; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.text.TextMessage; import com.sinch.sdk.domains.conversation.models.v1.messages.types.text.TextMessageDtoTest; import org.assertj.core.api.Assertions; import org.json.JSONException; @@ -19,54 +28,93 @@ @TestWithResources public class ContactMessageDtoTest extends ConversationBaseTest { - public static ContactMessage channelSpecificContactMessageDto = - ChannelSpecificContactMessageDtoTest.channelSpecificContactMessageNfmReply; - public static ContactMessage choiceResponseContactMessageDto = - ChoiceResponseMessageDtoTest.choiceResponseMessageDto; - - public static ContactMessage fallbackContactMessageDto = - FallbackMessageDtoTest.choiceFallbackMessageDto; - - public static ContactMessage locationContactMessageDto = - LocationMessageDtoTest.locationMessageDto; - - public static ContactMessage mediaCardContactMessageDto = - MediaCardMessageDtoTest.mediaCardMessageDto; - - /* - TODO Temporary removed: waiting for https://tickets.sinch.com/browse/CACORE-2200 status - public static ContactMessage replyToContactMessageDto = ReplyToMessageDtoTest.replyToMessageDto; - */ - public static ContactMessage textContactMessageDto = TextMessageDtoTest.textMessageDto; - public static ContactMessage productResponseContactMessageDto = - ProductResponseMessageDtoTest.productResponseMessageDto; + public static ContactMessage channelSpecificContactMessageDto = + ContactMessage.builder() + .setBody(ChannelSpecificContactMessageDtoTest.channelSpecificContactMessageNfmReply) + .setReplyTo(ReplyToDtoTest.replyToDto) + .build(); + + public static ContactMessage choiceResponseContactMessageDto = + ContactMessage.builder() + .setBody(ChoiceResponseMessageDtoTest.choiceResponseMessageDto) + .setReplyTo(ReplyToDtoTest.replyToDto) + .build(); + + public static ContactMessage fallbackContactMessageDto = + ContactMessage.builder() + .setBody(FallbackMessageDtoTest.choiceFallbackMessageDto) + .setReplyTo(ReplyToDtoTest.replyToDto) + .build(); + + public static ContactMessage locationContactMessageDto = + ContactMessage.builder() + .setBody(LocationMessageDtoTest.locationMessageDto) + .setReplyTo(ReplyToDtoTest.replyToDto) + .build(); + + public static ContactMessage mediaCardContactMessageDto = + ContactMessage.builder() + .setBody(MediaCardMessageDtoTest.mediaCardMessageDto) + .setReplyTo(ReplyToDtoTest.replyToDto) + .build(); + + public static ContactMessage mediaContactMessageDto = + ContactMessage.builder() + .setBody(MediaMessageDtoTest.mediaMessageDto) + .setReplyTo(ReplyToDtoTest.replyToDto) + .build(); + + public static ContactMessage productResponseContactMessageDto = + ContactMessage.builder() + .setBody(ProductResponseMessageDtoTest.productResponseMessageDto) + .setReplyTo(ReplyToDtoTest.replyToDto) + .build(); + + public static ContactMessage textContactMessageDto = + ContactMessage.builder() + .setBody(TextMessageDtoTest.textMessageDto) + .setReplyTo(ReplyToDtoTest.replyToDto) + .build(); + + public static ContactMessage textContactMessageNoReplyToDto = + ContactMessage.builder().setBody(TextMessageDtoTest.textMessageDto).build(); + + public static ContactMessage textContactMessageNullReplyToDto = + ContactMessage.builder() + .setBody(TextMessageDtoTest.textMessageDto) + .setReplyTo(null) + .build(); @GivenTextResource( - "/domains/conversation/v1/messages/types/channelspecific/whatsapp/nfmreply/ChannelSpecificContactMessageNfmReply.json") + "/domains/conversation/v1/messages/ContactMessageChannelSpecificContactNfmReply.json") static String jsonChannelSpecificContactMessageDto; - @GivenTextResource( - "/domains/conversation/v1/messages/types/choiceresponse/ChoiceResponseMessageDto.json") + @GivenTextResource("/domains/conversation/v1/messages/ContactMessageChoiceResponseDto.json") static String jsonChoiceResponseContactMessageDto; - @GivenTextResource("/domains/conversation/v1/messages/types/fallback/FallbackMessageDto.json") + @GivenTextResource("/domains/conversation/v1/messages/ContactMessageFallbackDto.json") static String jsonFallbackContactMessageDto; - @GivenTextResource("/domains/conversation/v1/messages/types/location/LocationMessageDto.json") + @GivenTextResource("/domains/conversation/v1/messages/ContactMessageLocationDto.json") static String jsonLocationContactMessageDto; - @GivenTextResource("/domains/conversation/v1/messages/types/mediacard/MediaCardMessageDto.json") + @GivenTextResource("/domains/conversation/v1/messages/ContactMessageMediaCardDto.json") static String jsonMediaCardContactMessageDto; - @GivenTextResource("/domains/conversation/v1/messages/types/replyto/ReplyToMessageDto.json") - static String jsonReplyToContactMessageDto; + @GivenTextResource("/domains/conversation/v1/messages/ContactMessageMediaDto.json") + static String jsonMediaContactMessageDto; - @GivenTextResource("/domains/conversation/v1/messages/types/text/TextMessageDto.json") + @GivenTextResource("/domains/conversation/v1/messages/ContactMessageProductResponseDto.json") + static String jsonProductResponseContactMessageDto; + + @GivenTextResource("/domains/conversation/v1/messages/ContactMessageTextDto.json") static String jsonTextMessageDto; - @GivenTextResource( - "/domains/conversation/v1/messages/types/productresponse/ProductResponseMessageDto.json") - static String jsonProductResponseContactMessageDto; + @GivenTextResource("/domains/conversation/v1/messages/ContactMessageTextNoReplyToDto.json") + static String jsonTextMessageNoReplyToDto; + + @GivenTextResource("/domains/conversation/v1/messages/ContactMessageTextNullReplyToDto.json") + static String jsonTextMessageNullReplyToDto; @Test void serializeChannelSpecificContactMessageDto() throws JsonProcessingException, JSONException { @@ -153,27 +201,39 @@ void deserializeMediaCardContactMessageDto() throws JsonProcessingException { .isEqualTo(mediaCardContactMessageDto); } - /* - TODO Temporary removed: waiting for https://tickets.sinch.com/browse/CACORE-2200 status + @Test + void serializeMediaContactMessageDto() throws JsonProcessingException, JSONException { + String serializedString = objectMapper.writeValueAsString(mediaContactMessageDto); + + JSONAssert.assertEquals(jsonMediaContactMessageDto, serializedString, true); + } @Test - void serializeReplyToContactMessageDto() throws JsonProcessingException, JSONException { - String serializedString = objectMapper.writeValueAsString(replyToContactMessageDto); + void deserializeMediaContactMessageDto() throws JsonProcessingException { + Object deserialized = objectMapper.readValue(jsonMediaContactMessageDto, ContactMessage.class); - JSONAssert.assertEquals(jsonReplyToContactMessageDto, serializedString, true); + Assertions.assertThat(deserialized) + .usingRecursiveComparison() + .isEqualTo(mediaContactMessageDto); } @Test - void deserializeReplyToContactMessageDto() throws JsonProcessingException { + void serializeProductResponseContactMessageDto() throws JsonProcessingException, JSONException { + String serializedString = objectMapper.writeValueAsString(productResponseContactMessageDto); + + JSONAssert.assertEquals(jsonProductResponseContactMessageDto, serializedString, true); + } + + @Test + void deserializeProductResponseContactMessageDto() throws JsonProcessingException { Object deserialized = - objectMapper.readValue(jsonReplyToContactMessageDto, ContactMessage.class); + objectMapper.readValue(jsonProductResponseContactMessageDto, ContactMessage.class); Assertions.assertThat(deserialized) .usingRecursiveComparison() - .isEqualTo(replyToContactMessageDto); + .isEqualTo(productResponseContactMessageDto); } - */ @Test void serializeTextContactMessageDto() throws JsonProcessingException, JSONException { String serializedString = objectMapper.writeValueAsString(textContactMessageDto); @@ -189,19 +249,35 @@ void deserializeTextContactMessageDto() throws JsonProcessingException { } @Test - void serializeProductResponseContactMessageDto() throws JsonProcessingException, JSONException { - String serializedString = objectMapper.writeValueAsString(productResponseContactMessageDto); + void serializeTextNoReplyToContactMessageDto() throws JsonProcessingException, JSONException { + String serializedString = objectMapper.writeValueAsString(textContactMessageNoReplyToDto); - JSONAssert.assertEquals(jsonProductResponseContactMessageDto, serializedString, true); + JSONAssert.assertEquals(jsonTextMessageNoReplyToDto, serializedString, true); } @Test - void deserializeProductResponseContactMessageDto() throws JsonProcessingException { + void deserializeNoReplyTextContactMessageDto() throws JsonProcessingException { + Object deserialized = objectMapper.readValue(jsonTextMessageNoReplyToDto, ContactMessage.class); + + Assertions.assertThat(deserialized) + .usingRecursiveComparison() + .isEqualTo(textContactMessageNoReplyToDto); + } + + @Test + void serializeTextNullReplyToContactMessageDto() throws JsonProcessingException, JSONException { + String serializedString = objectMapper.writeValueAsString(textContactMessageNullReplyToDto); + + JSONAssert.assertEquals(jsonTextMessageNullReplyToDto, serializedString, true); + } + + @Test + void deserializeNullReplyTextContactMessageDto() throws JsonProcessingException { Object deserialized = - objectMapper.readValue(jsonProductResponseContactMessageDto, ContactMessage.class); + objectMapper.readValue(jsonTextMessageNullReplyToDto, ContactMessage.class); Assertions.assertThat(deserialized) .usingRecursiveComparison() - .isEqualTo(productResponseContactMessageDto); + .isEqualTo(textContactMessageNullReplyToDto); } } diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/response/ConversationMessageDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/messages/ConversationMessageDtoTest.java similarity index 92% rename from openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/response/ConversationMessageDtoTest.java rename to openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/messages/ConversationMessageDtoTest.java index ed0c0d5a7..9b7028d75 100644 --- a/openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/response/ConversationMessageDtoTest.java +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/messages/ConversationMessageDtoTest.java @@ -1,4 +1,4 @@ -package com.sinch.sdk.domains.conversation.models.v1.response; +package com.sinch.sdk.domains.conversation.models.v1.messages; import com.adelean.inject.resources.junit.jupiter.GivenTextResource; import com.adelean.inject.resources.junit.jupiter.TestWithResources; @@ -7,9 +7,6 @@ import com.sinch.sdk.domains.conversation.models.v1.ChannelIdentityDtoTest; import com.sinch.sdk.domains.conversation.models.v1.ConversationDirection; import com.sinch.sdk.domains.conversation.models.v1.ProcessingMode; -import com.sinch.sdk.domains.conversation.models.v1.messages.AppMessageDtoTest; -import com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessageDtoTest; -import com.sinch.sdk.domains.conversation.models.v1.messages.ConversationMessage; import java.time.Instant; import org.assertj.core.api.Assertions; import org.json.JSONException; diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/messages/ReplyToDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/messages/ReplyToDtoTest.java new file mode 100644 index 000000000..8ad04da66 --- /dev/null +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/messages/ReplyToDtoTest.java @@ -0,0 +1,33 @@ +package com.sinch.sdk.domains.conversation.models.v1.messages; + +import com.adelean.inject.resources.junit.jupiter.GivenTextResource; +import com.adelean.inject.resources.junit.jupiter.TestWithResources; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.sinch.sdk.BaseTest; +import org.assertj.core.api.Assertions; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.skyscreamer.jsonassert.JSONAssert; + +@TestWithResources +public class ReplyToDtoTest extends BaseTest { + + public static ReplyTo replyToDto = ReplyTo.builder().setMessageId("message id value").build(); + + @GivenTextResource("/domains/conversation/v1/messages/ReplyToDto.json") + String jsonReplyToMessageDto; + + @Test + void serializeMessageDto() throws JsonProcessingException, JSONException { + String serializedString = objectMapper.writeValueAsString(replyToDto); + + JSONAssert.assertEquals(jsonReplyToMessageDto, serializedString, true); + } + + @Test + void deserializeMessageDto() throws JsonProcessingException { + Object deserialized = objectMapper.readValue(jsonReplyToMessageDto, ReplyTo.class); + + Assertions.assertThat(deserialized).usingRecursiveComparison().isEqualTo(replyToDto); + } +} diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/messages/types/replyto/ReplyToMessageDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/messages/types/replyto/ReplyToMessageDtoTest.java deleted file mode 100644 index dabd53659..000000000 --- a/openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/messages/types/replyto/ReplyToMessageDtoTest.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.sinch.sdk.domains.conversation.models.v1.messages.types.replyto; - -import com.adelean.inject.resources.junit.jupiter.TestWithResources; -import com.sinch.sdk.BaseTest; - -@TestWithResources -public class ReplyToMessageDtoTest extends BaseTest { - - /* - TODO Temporary removed: waiting for https://tickets.sinch.com/browse/CACORE-2200 status - - public static ReplyToMessage replyToMessageDto = - ReplyToMessage.builder().setMessageId("message id value").build(); - - @GivenTextResource("/domains/conversation/v1/messages/types/replyto/ReplyToMessageDto.json") - String jsonReplyToMessageDto; - - @Test - void serializeMessageDto() throws JsonProcessingException, JSONException { - String serializedString = objectMapper.writeValueAsString(replyToMessageDto); - - JSONAssert.assertEquals(jsonReplyToMessageDto, serializedString, true); - } - - @Test - void deserializeMessageDto() throws JsonProcessingException { - Object deserialized = objectMapper.readValue(jsonReplyToMessageDto, ReplyToMessage.class); - - Assertions.assertThat(deserialized).usingRecursiveComparison().isEqualTo(replyToMessageDto); - }*/ -} diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/message/MessageInboundEventDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/message/MessageInboundEventDtoTest.java index fd3ded4d1..bcd2c870a 100644 --- a/openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/message/MessageInboundEventDtoTest.java +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/message/MessageInboundEventDtoTest.java @@ -8,7 +8,7 @@ import com.sinch.sdk.domains.conversation.api.v1.adapters.ConversationBaseTest; import com.sinch.sdk.domains.conversation.models.v1.ChannelIdentityDtoTest; import com.sinch.sdk.domains.conversation.models.v1.ProcessingMode; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.text.TextMessageDtoTest; +import com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessageDtoTest; import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.message.MessageInboundEventMessage.DirectionEnum; import java.time.Instant; import org.json.JSONException; @@ -36,7 +36,7 @@ public class MessageInboundEventDtoTest extends ConversationBaseTest { MessageInboundEventMessage.builder() .setId("event id") .setDirection(DirectionEnum.TO_APP) - .setContactMessage(TextMessageDtoTest.textMessageDto) + .setContactMessage(ContactMessageDtoTest.textContactMessageDto) .setChannelIdentity(ChannelIdentityDtoTest.expectedDto) .setConversationId("conversation id") .setContactId("contact ID") diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/smartconversations/MessageInboundSmartConversationRedactionEventDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/smartconversations/MessageInboundSmartConversationRedactionEventDtoTest.java index 55bbe0342..b85e090a7 100644 --- a/openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/smartconversations/MessageInboundSmartConversationRedactionEventDtoTest.java +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/smartconversations/MessageInboundSmartConversationRedactionEventDtoTest.java @@ -8,7 +8,7 @@ import com.sinch.sdk.domains.conversation.api.v1.adapters.ConversationBaseTest; import com.sinch.sdk.domains.conversation.models.v1.ChannelIdentityDtoTest; import com.sinch.sdk.domains.conversation.models.v1.ProcessingMode; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.media.MediaMessageDtoTest; +import com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessageDtoTest; import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.message.MessageInboundEventMessage; import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.message.MessageInboundEventMessage.DirectionEnum; import java.time.Instant; @@ -23,7 +23,7 @@ public class MessageInboundSmartConversationRedactionEventDtoTest extends Conver MessageInboundEventMessage.builder() .setId("id") .setDirection(DirectionEnum.TO_APP) - .setContactMessage(MediaMessageDtoTest.mediaMessageDto) + .setContactMessage(ContactMessageDtoTest.mediaContactMessageDto) .setChannelIdentity(ChannelIdentityDtoTest.expectedDto) .setConversationId("conversation id") .setContactId("contact id") diff --git a/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageChannelSpecificContactNfmReply.json b/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageChannelSpecificContactNfmReply.json new file mode 100644 index 000000000..4b0c21622 --- /dev/null +++ b/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageChannelSpecificContactNfmReply.json @@ -0,0 +1,16 @@ +{ + "channel_specific_message": { + "message_type": "nfm_reply", + "message": { + "type": "nfm_reply", + "nfm_reply": { + "name": "address_message", + "response_json": "{\"key\": \"value\"}", + "body": "nfm reply body value" + } + } + }, + "reply_to": { + "message_id": "message id value" + } +} diff --git a/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageChoiceResponseDto.json b/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageChoiceResponseDto.json new file mode 100644 index 000000000..fd5a9071f --- /dev/null +++ b/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageChoiceResponseDto.json @@ -0,0 +1,9 @@ +{ + "choice_response_message": { + "message_id": "message id value", + "postback_data": "postback data value" + }, + "reply_to": { + "message_id": "message id value" + } +} diff --git a/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageFallbackDto.json b/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageFallbackDto.json new file mode 100644 index 000000000..23ef68fd5 --- /dev/null +++ b/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageFallbackDto.json @@ -0,0 +1,13 @@ +{ + "fallback_message": { + "raw_message": "raw message value", + "reason": { + "code": "RECIPIENT_NOT_OPTED_IN", + "description": "reason description", + "sub_code": "UNSPECIFIED_SUB_CODE" + } + }, + "reply_to": { + "message_id": "message id value" + } +} diff --git a/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageLocationDto.json b/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageLocationDto.json new file mode 100644 index 000000000..93fd62130 --- /dev/null +++ b/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageLocationDto.json @@ -0,0 +1,13 @@ +{ + "location_message": { + "coordinates": { + "latitude": 47.62798, + "longitude": -2.822915 + }, + "label": "label value", + "title": "title value" + }, + "reply_to": { + "message_id": "message id value" + } +} diff --git a/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageMediaCardDto.json b/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageMediaCardDto.json new file mode 100644 index 000000000..cc51d7587 --- /dev/null +++ b/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageMediaCardDto.json @@ -0,0 +1,9 @@ +{ + "media_card_message": { + "caption": "caption value", + "url": "an url value" + }, + "reply_to": { + "message_id": "message id value" + } +} diff --git a/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageMediaDto.json b/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageMediaDto.json new file mode 100644 index 000000000..f1e2a8564 --- /dev/null +++ b/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageMediaDto.json @@ -0,0 +1,10 @@ +{ + "media_message": { + "thumbnail_url": "another url", + "url": "an url value", + "filename_override": "filename override value" + }, + "reply_to": { + "message_id": "message id value" + } +} diff --git a/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageProductResponseDto.json b/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageProductResponseDto.json new file mode 100644 index 000000000..07c45d5ba --- /dev/null +++ b/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageProductResponseDto.json @@ -0,0 +1,18 @@ +{ + "product_response_message": { + "products": [ + { + "id": "product ID value", + "marketplace": "marketplace value", + "quantity": 4, + "item_price": 3.14159, + "currency": "currency value" + } + ], + "title": "a product response message title value", + "catalog_id": "catalog id value" + }, + "reply_to": { + "message_id": "message id value" + } +} diff --git a/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageTextDto.json b/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageTextDto.json new file mode 100644 index 000000000..b82d9ddb9 --- /dev/null +++ b/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageTextDto.json @@ -0,0 +1,8 @@ +{ + "text_message": { + "text": "This is a text message." + }, + "reply_to": { + "message_id": "message id value" + } +} diff --git a/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageTextNoReplyToDto.json b/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageTextNoReplyToDto.json new file mode 100644 index 000000000..243856ad2 --- /dev/null +++ b/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageTextNoReplyToDto.json @@ -0,0 +1,5 @@ +{ + "text_message": { + "text": "This is a text message." + } +} diff --git a/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageTextNullReplyToDto.json b/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageTextNullReplyToDto.json new file mode 100644 index 000000000..aca37e42c --- /dev/null +++ b/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ContactMessageTextNullReplyToDto.json @@ -0,0 +1,6 @@ +{ + "text_message": { + "text": "This is a text message." + }, + "reply_to": null +} diff --git a/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ConversationMessageContactLocationDto.json b/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ConversationMessageContactLocationDto.json index a6bbe7424..2e997bcd9 100644 --- a/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ConversationMessageContactLocationDto.json +++ b/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ConversationMessageContactLocationDto.json @@ -21,6 +21,9 @@ }, "title": "title value", "label": "label value" + }, + "reply_to": { + "message_id": "message id value" } } } diff --git a/openapi-contracts/src/test/resources/domains/conversation/v1/messages/types/replyto/ReplyToMessageDto.json b/openapi-contracts/src/test/resources/domains/conversation/v1/messages/ReplyToDto.json similarity index 100% rename from openapi-contracts/src/test/resources/domains/conversation/v1/messages/types/replyto/ReplyToMessageDto.json rename to openapi-contracts/src/test/resources/domains/conversation/v1/messages/ReplyToDto.json diff --git a/openapi-contracts/src/test/resources/domains/conversation/v1/webhooks/events/message/MessageInboundEventDto.json b/openapi-contracts/src/test/resources/domains/conversation/v1/webhooks/events/message/MessageInboundEventDto.json index 4a245249b..fa0198d79 100644 --- a/openapi-contracts/src/test/resources/domains/conversation/v1/webhooks/events/message/MessageInboundEventDto.json +++ b/openapi-contracts/src/test/resources/domains/conversation/v1/webhooks/events/message/MessageInboundEventDto.json @@ -23,6 +23,9 @@ "contact_message": { "text_message": { "text": "This is a text message." + }, + "reply_to": { + "message_id": "message id value" } } } diff --git a/openapi-contracts/src/test/resources/domains/conversation/v1/webhooks/events/smartconversations/MessageInboundSmartConversationRedactionEventDto.json b/openapi-contracts/src/test/resources/domains/conversation/v1/webhooks/events/smartconversations/MessageInboundSmartConversationRedactionEventDto.json index 4ed1c6294..6de8150eb 100644 --- a/openapi-contracts/src/test/resources/domains/conversation/v1/webhooks/events/smartconversations/MessageInboundSmartConversationRedactionEventDto.json +++ b/openapi-contracts/src/test/resources/domains/conversation/v1/webhooks/events/smartconversations/MessageInboundSmartConversationRedactionEventDto.json @@ -8,14 +8,17 @@ "message_redaction": { "id": "id", "direction": "TO_APP", - "contact_message":{ + "contact_message": { "media_message": { "url": "an url value", "thumbnail_url": "another url", "filename_override": "filename override value" + }, + "reply_to": { + "message_id": "message id value" } }, - "channel_identity":{ + "channel_identity": { "app_id": "an app id", "channel": "MESSENGER", "identity": "an identity" diff --git a/sample-app/src/main/java/com/sinch/sample/conversation/messages/Send.java b/sample-app/src/main/java/com/sinch/sample/conversation/messages/Send.java index 542bb82c7..9fa0bdc31 100644 --- a/sample-app/src/main/java/com/sinch/sample/conversation/messages/Send.java +++ b/sample-app/src/main/java/com/sinch/sample/conversation/messages/Send.java @@ -84,7 +84,7 @@ SendMessageRequest createRCSSendMessage() { .setAppId(conversationAppId) .setMessage( AppMessage.builder() - .setMessage( + .setBody( ChoiceMessage.builder().setChoices(choices).setTextMessage(textMessage).build()) .setAgent( Agent.builder().setType(AgentType.HUMAN).setDisplayName("Agent Name").build()) @@ -104,7 +104,7 @@ SendMessageRequest createSMSSendMessage() { .setAppId(conversationAppId) .setMessage( AppMessage.builder() - .setMessage( + .setBody( TextMessage.builder() .setText("[Java SDK: Conversation Message] Sample text message") .build())