001// Generated by delombok at Fri Nov 22 22:30:55 CET 2019
002/**
003 * Copyright (c) 2010-2019 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   * Message sequence number
042   *
043   * @deprecated https://messengerblog.com/platform-updates/introducing-messenger-platform-v1-3-and-new-ways-to-drive-the-conversation/
044   *             "Developers who previously relied on using seq ID for deduping can use mid instead, and those who were
045   *             using it for ordering purposes can use timestamp instead."
046   */
047  @Deprecated
048  @Facebook
049  private Long seq;
050  /**
051   * Text of message
052   */
053  @Facebook
054  private String text;
055  /**
056   * Indicates the message sent from the page itself
057   */
058  @Facebook("is_echo")
059  private boolean isEcho;
060  /**
061   * ID of the app from which the message was sent
062   */
063  @Facebook("app_id")
064  private String appId;
065  /**
066   * Custom string passed to the Send API as the metadata field
067   */
068  @Facebook
069  private String metadata;
070  @Facebook("quick_reply")
071  private QuickReplyItem quickReply;
072  @Facebook("sticker_id")
073  private String stickerId;
074  /**
075   * Array containing attachment data
076   */
077  @Facebook
078  private List<MessagingAttachment> attachments = new ArrayList<>();
079  @Facebook
080  private NlpResult nlp;
081  @Facebook("reply_to")
082  private ReplyTo replyTo;
083
084  /**
085   * The user may send a like and this method can be used to discover the three know versions of the sticker
086   *
087   * @return {@code true} if the user sent a like (thumb up sticker), {@code false} otherwise
088   */
089  public boolean isLike() {
090    return  // small like (thumb up) sticker
091    // medium size sticker
092    "369239263222822".equals(stickerId) || "369239343222814".equals(stickerId) || "369239383222810".equals(stickerId); // large size sticker
093  }
094
095  /**
096   * Returns whether the message contains an attachment.
097   *
098   * @return {@code true} if the message contains a attachment, {@code false} otherwise
099   */
100  public boolean hasAttachment() {
101    return attachments != null && !attachments.isEmpty();
102  }
103
104  /**
105   * Returns whether the message contains a quick reply.
106   *
107   * @return {@code true} if the message contains a quick reply, {@code false} otherwise
108   */
109  public boolean hasQuickReply() {
110    return quickReply != null;
111  }
112
113  /**
114   * Returns whether the message contains a NLP result.
115   *
116   * @return {@code true} if the message contains a NLP result, {@code false} otherwise
117   */
118  public boolean hasNlp() {
119    return nlp != null;
120  }
121
122  /**
123   * Returns wether the message is a reply to another message
124   *
125   * @return {@code true} if the message is a reply of another message, {@code false} otherwise
126   */
127  public boolean isReply() {
128    return replyTo != null;
129  }
130
131  @java.lang.Override
132  @java.lang.SuppressWarnings("all")
133  public java.lang.String toString() {
134    return "MessageItem(mid=" + this.getMid() + ", seq=" + this.getSeq() + ", text=" + this.getText() + ", isEcho=" + this.isEcho() + ", appId=" + this.getAppId() + ", metadata=" + this.getMetadata() + ", quickReply=" + this.getQuickReply() + ", stickerId=" + this.getStickerId() + ", attachments=" + this.getAttachments() + ", nlp=" + this.getNlp() + ", replyTo=" + this.getReplyTo() + ")";
135  }
136
137  /**
138   * Message ID
139   */
140  @java.lang.SuppressWarnings("all")
141  public String getMid() {
142    return this.mid;
143  }
144
145  /**
146   * Message ID
147   */
148  @java.lang.SuppressWarnings("all")
149  public void setMid(final String mid) {
150    this.mid = mid;
151  }
152
153  /**
154   * Message sequence number
155   *
156   * @deprecated https://messengerblog.com/platform-updates/introducing-messenger-platform-v1-3-and-new-ways-to-drive-the-conversation/
157   *             "Developers who previously relied on using seq ID for deduping can use mid instead, and those who were
158   *             using it for ordering purposes can use timestamp instead."
159   */
160  @java.lang.Deprecated
161  @java.lang.SuppressWarnings("all")
162  public Long getSeq() {
163    return this.seq;
164  }
165
166  /**
167   * Message sequence number
168   *
169   * @deprecated https://messengerblog.com/platform-updates/introducing-messenger-platform-v1-3-and-new-ways-to-drive-the-conversation/
170   *             "Developers who previously relied on using seq ID for deduping can use mid instead, and those who were
171   *             using it for ordering purposes can use timestamp instead."
172   */
173  @java.lang.Deprecated
174  @java.lang.SuppressWarnings("all")
175  public void setSeq(final Long seq) {
176    this.seq = seq;
177  }
178
179  /**
180   * Text of message
181   */
182  @java.lang.SuppressWarnings("all")
183  public String getText() {
184    return this.text;
185  }
186
187  /**
188   * Text of message
189   */
190  @java.lang.SuppressWarnings("all")
191  public void setText(final String text) {
192    this.text = text;
193  }
194
195  /**
196   * Indicates the message sent from the page itself
197   */
198  @java.lang.SuppressWarnings("all")
199  public boolean isEcho() {
200    return this.isEcho;
201  }
202
203  /**
204   * Indicates the message sent from the page itself
205   */
206  @java.lang.SuppressWarnings("all")
207  public void setEcho(final boolean isEcho) {
208    this.isEcho = isEcho;
209  }
210
211  /**
212   * ID of the app from which the message was sent
213   */
214  @java.lang.SuppressWarnings("all")
215  public String getAppId() {
216    return this.appId;
217  }
218
219  /**
220   * ID of the app from which the message was sent
221   */
222  @java.lang.SuppressWarnings("all")
223  public void setAppId(final String appId) {
224    this.appId = appId;
225  }
226
227  /**
228   * Custom string passed to the Send API as the metadata field
229   */
230  @java.lang.SuppressWarnings("all")
231  public String getMetadata() {
232    return this.metadata;
233  }
234
235  /**
236   * Custom string passed to the Send API as the metadata field
237   */
238  @java.lang.SuppressWarnings("all")
239  public void setMetadata(final String metadata) {
240    this.metadata = metadata;
241  }
242
243  @java.lang.SuppressWarnings("all")
244  public QuickReplyItem getQuickReply() {
245    return this.quickReply;
246  }
247
248  @java.lang.SuppressWarnings("all")
249  public void setQuickReply(final QuickReplyItem quickReply) {
250    this.quickReply = quickReply;
251  }
252
253  @java.lang.SuppressWarnings("all")
254  public String getStickerId() {
255    return this.stickerId;
256  }
257
258  @java.lang.SuppressWarnings("all")
259  public void setStickerId(final String stickerId) {
260    this.stickerId = stickerId;
261  }
262
263  /**
264   * Array containing attachment data
265   */
266  @java.lang.SuppressWarnings("all")
267  public List<MessagingAttachment> getAttachments() {
268    return this.attachments;
269  }
270
271  /**
272   * Array containing attachment data
273   */
274  @java.lang.SuppressWarnings("all")
275  public void setAttachments(final List<MessagingAttachment> attachments) {
276    this.attachments = attachments;
277  }
278
279  @java.lang.SuppressWarnings("all")
280  public NlpResult getNlp() {
281    return this.nlp;
282  }
283
284  @java.lang.SuppressWarnings("all")
285  public ReplyTo getReplyTo() {
286    return this.replyTo;
287  }
288}