001/*
002 *   Copyright 2024 Vonage
003 *
004 *   Licensed under the Apache License, Version 2.0 (the "License");
005 *   you may not use this file except in compliance with the License.
006 *   You may obtain a copy of the License at
007 *
008 *        http://www.apache.org/licenses/LICENSE-2.0
009 *
010 *   Unless required by applicable law or agreed to in writing, software
011 *   distributed under the License is distributed on an "AS IS" BASIS,
012 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 *   See the License for the specific language governing permissions and
014 *   limitations under the License.
015 */
016package com.vonage.client.messages.whatsapp;
017
018import com.fasterxml.jackson.annotation.JsonProperty;
019import com.vonage.client.JsonableBaseObject;
020import com.vonage.client.messages.InboundMessage;
021import com.vonage.client.messages.MessageType;
022import java.net.URI;
023
024/**
025 * This is only present for situations where a user has clicked on a 'WhatsApp' button embedded in an advertisement
026 * or post on Facebook. Clicking on the button directs the user to the WhatsApp app from where they can send a message.
027 * The inbound message will contain this object which includes details of the Facebook advertisement or post which
028 * contained the embedded button. This is used in {@link InboundMessage#getWhatsappReferral()}.
029 *
030 * @since 8.1.0
031 */
032public final class Referral extends JsonableBaseObject {
033        private String body, headline, sourceId, sourceType, clickId;
034        private URI sourceUrl, imageUrl, videoUrl, thumbnailUrl;
035        private MessageType mediaType;
036
037        Referral() {}
038
039        /**
040         * Body text of the referring advertisement or post.
041         *
042         * @return The referral body.
043         */
044        @JsonProperty("body")
045        public String getBody() {
046                return body;
047        }
048
049        /**
050         * Headline text of the referring advertisement or post.
051         *
052         * @return The referral headline.
053         */
054        @JsonProperty("headline")
055        public String getHeadline() {
056                return headline;
057        }
058
059        /**
060         * The click ID of the advertisement or post.
061         *
062         * @return The {@code ctwa_clid}, or {@code null} if absent / unknown / not applicable.
063         * @since 8.11.0
064         */
065        @JsonProperty("ctwa_clid")
066        public String getClickId() {
067                return clickId;
068        }
069
070        /**
071         * Meta/WhatsApp ID of the referring advertisement or post.
072         *
073         * @return The source referral ID as a String.
074         */
075        @JsonProperty("source_id")
076        public String getSourceId() {
077                return sourceId;
078        }
079
080        /**
081         * The type of the referring advertisement or post.
082         *
083         * @return The source referral type as a String.
084         */
085        @JsonProperty("source_type")
086        public String getSourceType() {
087                return sourceType;
088        }
089
090        /**
091         * The type of media shown in the advertisement or post. Either {@linkplain MessageType#IMAGE}
092         * or {@linkplain MessageType#VIDEO}.
093         *
094         * @return The media type as an enum, or {@code null} if absent / not applicable.
095         * @since 8.11.0
096         */
097        @JsonProperty("media_type")
098        public MessageType getMediaType() {
099                return mediaType;
100        }
101
102        /**
103         * A URL referencing the content of the media shown in the advertisement when the user clicked to send a message.
104         *
105         * @return Link to the advertised content.
106         */
107        @JsonProperty("source_url")
108        public URI getSourceUrl() {
109                return sourceUrl;
110        }
111
112        /**
113         * URL of the image shown in the advertisement or post.
114         *
115         * @return The image URL, or {@code null} if absent / not applicable.
116         * @since 8.11.0
117         */
118        @JsonProperty("image_url")
119        public URI getImageUrl() {
120                return imageUrl;
121        }
122
123        /**
124         * URL of the video shown in the advertisement or post.
125         *
126         * @return The video URL, or {@code null} if absent / not applicable.
127         * @since 8.11.0
128         */
129        @JsonProperty("video_url")
130        public URI getVideoUrl() {
131                return videoUrl;
132        }
133
134
135        /**
136         * URL of the thumbnail image shown in the advertisement or post.
137         *
138         * @return The thumbnail URL, or {@code null} if absent / not applicable.
139         * @since 8.11.0
140         */
141        @JsonProperty("thumbnail_url")
142        public URI getThumbnailUrl() {
143                return thumbnailUrl;
144        }
145}