001// Generated by delombok at Sun Apr 14 14:59:49 CEST 2024
002/*
003 * Copyright (c) 2010-2024 Mark Allen, Norbert Bartels.
004 *
005 * Permission is hereby granted, free of charge, to any person obtaining a copy
006 * of this software and associated documentation files (the "Software"), to deal
007 * in the Software without restriction, including without limitation the rights
008 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
009 * copies of the Software, and to permit persons to whom the Software is
010 * furnished to do so, subject to the following conditions:
011 *
012 * The above copyright notice and this permission notice shall be included in
013 * all copies or substantial portions of the Software.
014 *
015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
016 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
017 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
018 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
019 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
020 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
021 * THE SOFTWARE.
022 */
023package com.restfb.types.webhook.messaging;
024
025import java.util.ArrayList;
026import java.util.List;
027import com.restfb.Facebook;
028
029/**
030 * Represents the
031 * <a href=" https://developers.facebook.com/docs/messenger-platform/webhook-reference/message-received">Message</a>
032 * Callback
033 */
034public class MessageItem implements InnerMessagingItem {
035  /**
036   * Message ID
037   */
038  @Facebook
039  private String mid;
040  /**
041   * Text of message
042   */
043  @Facebook
044  private String text;
045  @Facebook("is_deleted")
046  private Boolean isDeleted;
047  /**
048   * not included if message is supported
049   */
050  @Facebook("is_unsupported")
051  private Boolean isUnsupported;
052  /**
053   * Indicates the message sent from the page itself
054   */
055  @Facebook("is_echo")
056  private boolean isEcho;
057  /**
058   * ID of the app from which the message was sent
059   */
060  @Facebook("app_id")
061  private String appId;
062  /**
063   * Custom string passed to the Send API as the metadata field
064   */
065  @Facebook
066  private String metadata;
067  @Facebook("quick_reply")
068  private QuickReplyItem quickReply;
069  @Facebook("sticker_id")
070  private String stickerId;
071  /**
072   * Array containing attachment data
073   */
074  @Facebook
075  private List<MessagingAttachment> attachments = new ArrayList<>();
076  @Facebook
077  private NlpResult nlp;
078  @Facebook("reply_to")
079  private ReplyTo replyTo;
080
081  /**
082   * The user may send a like and this method can be used to discover the three know versions of the sticker
083   *
084   * @return {@code true} if the user sent a like (thumb up sticker), {@code false} otherwise
085   */
086  public boolean isLike() {
087    return  // small like (thumb up) sticker
088    // medium size sticker
089    "369239263222822".equals(stickerId) || "369239343222814".equals(stickerId) || "369239383222810".equals(stickerId); // large size sticker
090  }
091
092  /**
093   * Returns whether the message contains an attachment.
094   *
095   * @return {@code true} if the message contains a attachment, {@code false} otherwise
096   */
097  public boolean hasAttachment() {
098    return attachments != null && !attachments.isEmpty();
099  }
100
101  /**
102   * Returns whether the message contains a quick reply.
103   *
104   * @return {@code true} if the message contains a quick reply, {@code false} otherwise
105   */
106  public boolean hasQuickReply() {
107    return quickReply != null;
108  }
109
110  /**
111   * Returns whether the message contains a NLP result.
112   *
113   * @return {@code true} if the message contains a NLP result, {@code false} otherwise
114   */
115  public boolean hasNlp() {
116    return nlp != null;
117  }
118
119  /**
120   * Returns wether the message is a reply to another message
121   *
122   * @return {@code true} if the message is a reply of another message, {@code false} otherwise
123   */
124  public boolean isReply() {
125    return replyTo != null;
126  }
127
128  @java.lang.Override
129  @java.lang.SuppressWarnings("all")
130  public java.lang.String toString() {
131    return "MessageItem(mid=" + this.getMid() + ", text=" + this.getText() + ", isDeleted=" + this.getIsDeleted() + ", isUnsupported=" + this.getIsUnsupported() + ", isEcho=" + this.isEcho() + ", appId=" + this.getAppId() + ", metadata=" + this.getMetadata() + ", quickReply=" + this.getQuickReply() + ", stickerId=" + this.getStickerId() + ", attachments=" + this.getAttachments() + ", nlp=" + this.getNlp() + ", replyTo=" + this.getReplyTo() + ")";
132  }
133
134  /**
135   * Message ID
136   */
137  @java.lang.SuppressWarnings("all")
138  public String getMid() {
139    return this.mid;
140  }
141
142  /**
143   * Message ID
144   */
145  @java.lang.SuppressWarnings("all")
146  public void setMid(final String mid) {
147    this.mid = mid;
148  }
149
150  /**
151   * Text of message
152   */
153  @java.lang.SuppressWarnings("all")
154  public String getText() {
155    return this.text;
156  }
157
158  /**
159   * Text of message
160   */
161  @java.lang.SuppressWarnings("all")
162  public void setText(final String text) {
163    this.text = text;
164  }
165
166  @java.lang.SuppressWarnings("all")
167  public Boolean getIsDeleted() {
168    return this.isDeleted;
169  }
170
171  @java.lang.SuppressWarnings("all")
172  public void setIsDeleted(final Boolean isDeleted) {
173    this.isDeleted = isDeleted;
174  }
175
176  /**
177   * not included if message is supported
178   */
179  @java.lang.SuppressWarnings("all")
180  public Boolean getIsUnsupported() {
181    return this.isUnsupported;
182  }
183
184  /**
185   * not included if message is supported
186   */
187  @java.lang.SuppressWarnings("all")
188  public void setIsUnsupported(final Boolean isUnsupported) {
189    this.isUnsupported = isUnsupported;
190  }
191
192  /**
193   * Indicates the message sent from the page itself
194   */
195  @java.lang.SuppressWarnings("all")
196  public boolean isEcho() {
197    return this.isEcho;
198  }
199
200  /**
201   * Indicates the message sent from the page itself
202   */
203  @java.lang.SuppressWarnings("all")
204  public void setEcho(final boolean isEcho) {
205    this.isEcho = isEcho;
206  }
207
208  /**
209   * ID of the app from which the message was sent
210   */
211  @java.lang.SuppressWarnings("all")
212  public String getAppId() {
213    return this.appId;
214  }
215
216  /**
217   * ID of the app from which the message was sent
218   */
219  @java.lang.SuppressWarnings("all")
220  public void setAppId(final String appId) {
221    this.appId = appId;
222  }
223
224  /**
225   * Custom string passed to the Send API as the metadata field
226   */
227  @java.lang.SuppressWarnings("all")
228  public String getMetadata() {
229    return this.metadata;
230  }
231
232  /**
233   * Custom string passed to the Send API as the metadata field
234   */
235  @java.lang.SuppressWarnings("all")
236  public void setMetadata(final String metadata) {
237    this.metadata = metadata;
238  }
239
240  @java.lang.SuppressWarnings("all")
241  public QuickReplyItem getQuickReply() {
242    return this.quickReply;
243  }
244
245  @java.lang.SuppressWarnings("all")
246  public void setQuickReply(final QuickReplyItem quickReply) {
247    this.quickReply = quickReply;
248  }
249
250  @java.lang.SuppressWarnings("all")
251  public String getStickerId() {
252    return this.stickerId;
253  }
254
255  @java.lang.SuppressWarnings("all")
256  public void setStickerId(final String stickerId) {
257    this.stickerId = stickerId;
258  }
259
260  /**
261   * Array containing attachment data
262   */
263  @java.lang.SuppressWarnings("all")
264  public List<MessagingAttachment> getAttachments() {
265    return this.attachments;
266  }
267
268  /**
269   * Array containing attachment data
270   */
271  @java.lang.SuppressWarnings("all")
272  public void setAttachments(final List<MessagingAttachment> attachments) {
273    this.attachments = attachments;
274  }
275
276  @java.lang.SuppressWarnings("all")
277  public NlpResult getNlp() {
278    return this.nlp;
279  }
280
281  @java.lang.SuppressWarnings("all")
282  public ReplyTo getReplyTo() {
283    return this.replyTo;
284  }
285}