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