001// Generated by delombok at Fri Oct 04 16:05:59 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.whatsapp.platform; 024 025import java.util.ArrayList; 026import java.util.List; 027import com.restfb.Facebook; 028import com.restfb.types.AbstractFacebookType; 029import com.restfb.types.whatsapp.platform.send.*; 030 031public class SendMessage extends AbstractFacebookType { 032 @Facebook 033 private String to; 034 @Facebook 035 private Context context; 036 @Facebook 037 private Text text; 038 @Facebook 039 private Reaction reaction; 040 @Facebook 041 private Video video; 042 @Facebook 043 private Audio audio; 044 @Facebook 045 private Image image; 046 @Facebook 047 private Document document; 048 @Facebook 049 private Sticker sticker; 050 @Facebook 051 private Interactive interactive; 052 @Facebook 053 private Location location; 054 @Facebook 055 private List<Contact> contacts; 056 @Facebook 057 private Type type = Type.text; 058 @Facebook("messaging_product") 059 private final String messagingProduct = "whatsapp"; 060 061 public SendMessage(String to) { 062 setTo(to); 063 } 064 065 public void setReaction(Reaction reaction) { 066 this.reaction = reaction; 067 this.type = Type.reaction; 068 } 069 070 public void setText(Text text) { 071 this.text = text; 072 this.type = Type.text; 073 } 074 075 public void setMedia(Media media) { 076 if (media instanceof Audio) { 077 this.audio = media.as(Audio.class); 078 this.type = Type.audio; 079 } 080 if (media instanceof Video) { 081 this.video = media.as(Video.class); 082 this.type = Type.video; 083 } 084 if (media instanceof Image) { 085 this.image = media.as(Image.class); 086 this.type = Type.image; 087 } 088 if (media instanceof Document) { 089 this.document = media.as(Document.class); 090 this.type = Type.document; 091 } 092 if (media instanceof Sticker) { 093 this.sticker = media.as(Sticker.class); 094 this.type = Type.sticker; 095 } 096 } 097 098 public void setInteractive(Interactive interactive) { 099 this.interactive = interactive; 100 this.type = Type.interactive; 101 } 102 103 public void setLocation(Location location) { 104 this.location = location; 105 this.type = Type.location; 106 } 107 108 public void addContact(Contact contact) { 109 if (contacts == null) { 110 contacts = new ArrayList<>(); 111 } 112 contacts.add(contact); 113 this.type = Type.contacts; 114 } 115 116 117 public enum Type { 118 text, reaction, audio, video, document, sticker, image, interactive, location, contacts; 119 } 120 121 @java.lang.SuppressWarnings("all") 122 public String getTo() { 123 return this.to; 124 } 125 126 @java.lang.SuppressWarnings("all") 127 public void setTo(final String to) { 128 this.to = to; 129 } 130 131 @java.lang.SuppressWarnings("all") 132 public Context getContext() { 133 return this.context; 134 } 135 136 @java.lang.SuppressWarnings("all") 137 public void setContext(final Context context) { 138 this.context = context; 139 } 140 141 @java.lang.SuppressWarnings("all") 142 public Text getText() { 143 return this.text; 144 } 145 146 @java.lang.SuppressWarnings("all") 147 public Reaction getReaction() { 148 return this.reaction; 149 } 150 151 @java.lang.SuppressWarnings("all") 152 public void setType(final Type type) { 153 this.type = type; 154 } 155}