diff --git a/pom.xml b/pom.xml index 2bff182..736e829 100644 --- a/pom.xml +++ b/pom.xml @@ -1,12 +1,13 @@ - - 4.0.0 - co.aurasphere.botmill - telegram-botmill - 0.0.1-SNAPSHOT - Telegram-BotMill - A Java framework for building bots on Telegram. - - + + 4.0.0 + co.aurasphere.botmill + telegram-botmill + 0.0.1-SNAPSHOT + Telegram-BotMill + A Java framework for building bots on Telegram. + + javax.servlet diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/Audio.java b/src/main/java/co/aurasphere/botmill/telegram/model/Audio.java new file mode 100644 index 0000000..f84a76d --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/Audio.java @@ -0,0 +1,236 @@ +/** + * + */ +package co.aurasphere.botmill.telegram.model; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +/** + * This object represents an audio file to be treated as music by the Telegram + * clients. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class Audio implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Unique identifier for this file. + */ + @SerializedName("file_id") + private String fileId; + + /** + * Duration of the audio in seconds as defined by sender. + */ + private int duration; + + /** + * Optional. Performer of the audio as defined by sender or by audio tags. + */ + private String performer; + + /** + * Optional. Performer of the audio as defined by sender or by audio tags. + */ + private String title; + + /** + * Optional. MIME type of the file as defined by sender. + */ + @SerializedName("mime_type") + private String mimeType; + + /** + * Optional. File size. + */ + @SerializedName("file_size") + private String fileSize; + + /** + * Gets the {@link #fileId}. + * + * @return the {@link #fileId}. + */ + public String getFileId() { + return fileId; + } + + /** + * Sets the {@link #fileId}. + * + * @param fileId the {@link #fileId} to set. + */ + public void setFileId(String fileId) { + this.fileId = fileId; + } + + /** + * Gets the {@link #duration}. + * + * @return the {@link #duration}. + */ + public int getDuration() { + return duration; + } + + /** + * Sets the {@link #duration}. + * + * @param duration the {@link #duration} to set. + */ + public void setDuration(int duration) { + this.duration = duration; + } + + /** + * Gets the {@link #performer}. + * + * @return the {@link #performer}. + */ + public String getPerformer() { + return performer; + } + + /** + * Sets the {@link #performer}. + * + * @param performer the {@link #performer} to set. + */ + public void setPerformer(String performer) { + this.performer = performer; + } + + /** + * Gets the {@link #title}. + * + * @return the {@link #title}. + */ + public String getTitle() { + return title; + } + + /** + * Sets the {@link #title}. + * + * @param title the {@link #title} to set. + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * Gets the {@link #mimeType}. + * + * @return the {@link #mimeType}. + */ + public String getMimeType() { + return mimeType; + } + + /** + * Sets the {@link #mimeType}. + * + * @param mimeType the {@link #mimeType} to set. + */ + public void setMimeType(String mimeType) { + this.mimeType = mimeType; + } + + /** + * Gets the {@link #fileSize}. + * + * @return the {@link #fileSize}. + */ + public String getFileSize() { + return fileSize; + } + + /** + * Sets the {@link #fileSize}. + * + * @param fileSize the {@link #fileSize} to set. + */ + public void setFileSize(String fileSize) { + this.fileSize = fileSize; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + duration; + result = prime * result + ((fileId == null) ? 0 : fileId.hashCode()); + result = prime * result + + ((fileSize == null) ? 0 : fileSize.hashCode()); + result = prime * result + + ((mimeType == null) ? 0 : mimeType.hashCode()); + result = prime * result + + ((performer == null) ? 0 : performer.hashCode()); + result = prime * result + ((title == null) ? 0 : title.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Audio other = (Audio) obj; + if (duration != other.duration) + return false; + if (fileId == null) { + if (other.fileId != null) + return false; + } else if (!fileId.equals(other.fileId)) + return false; + if (fileSize == null) { + if (other.fileSize != null) + return false; + } else if (!fileSize.equals(other.fileSize)) + return false; + if (mimeType == null) { + if (other.mimeType != null) + return false; + } else if (!mimeType.equals(other.mimeType)) + return false; + if (performer == null) { + if (other.performer != null) + return false; + } else if (!performer.equals(other.performer)) + return false; + if (title == null) { + if (other.title != null) + return false; + } else if (!title.equals(other.title)) + return false; + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Audio [fileId=" + fileId + ", duration=" + duration + + ", performer=" + performer + ", title=" + title + + ", mimeType=" + mimeType + ", fileSize=" + fileSize + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/CallbackQuery.java b/src/main/java/co/aurasphere/botmill/telegram/model/CallbackQuery.java new file mode 100644 index 0000000..8e74be6 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/CallbackQuery.java @@ -0,0 +1,288 @@ +package co.aurasphere.botmill.telegram.model; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +//TODO: link the methods in the javadoc note +/** + * This object represents an incoming callback query from a callback button in + * an inline keyboard. If the button that originated the query was attached to + * a message sent by the bot, the field message will be present. If the button + * was attached to a message sent via the bot (in inline mode), the field + * inline_message_id will be present. Exactly one of the fields data or + * game_short_name will be present.
+ *
+ * NOTE: After the user presses an inline button, Telegram clients will display + * a progress bar until you call answerCallbackQuery. It is, therefore, + * necessary to react by calling answerCallbackQuery even if no notification to + * the user is needed (e.g., without specifying any of the optional parameters). + * + * @see Inline Mode. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class CallbackQuery implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Unique identifier for this query. + */ + private String id; + + /** + * Sender. + */ + private User from; + + /** + * Optional. Message with the callback button that originated the query. + * Note that message content and message date will not be available if the + * message is too old. + */ + private Message message; + + /** + * Optional. Identifier of the message sent via the bot in inline mode, that + * originated the query. + */ + @SerializedName("inline_message_id") + private String inlineMessageId; + + /** + * Global identifier, uniquely corresponding to the chat to which the + * message with the callback button was sent. Useful for high scores in games. + */ + @SerializedName("chat_instance") + private String chatInstance; + + /** + * Optional. Data associated with the callback button. Be aware that a bad + * client can send arbitrary data in this field. + */ + private String data; + + /** + * Optional. Short name of a Game to be returned, + * serves as the unique identifier for the game. + */ + @SerializedName("game_short_name") + private String gameShortName; + + /** + * Gets the {@link #id}. + * + * @return the {@link #id}. + */ + public String getId() { + return id; + } + + /** + * Sets the {@link #id}. + * + * @param id the {@link #id} to set. + */ + public void setId(String id) { + this.id = id; + } + + /** + * Gets the {@link #from}. + * + * @return the {@link #from}. + */ + public User getFrom() { + return from; + } + + /** + * Sets the {@link #from}. + * + * @param from the {@link #from} to set. + */ + public void setFrom(User from) { + this.from = from; + } + + /** + * Gets the {@link #message}. + * + * @return the {@link #message}. + */ + public Message getMessage() { + return message; + } + + /** + * Sets the {@link #message}. + * + * @param message the {@link #message} to set. + */ + public void setMessage(Message message) { + this.message = message; + } + + /** + * Gets the {@link #inlineMessageId}. + * + * @return the {@link #inlineMessageId}. + */ + public String getInlineMessageId() { + return inlineMessageId; + } + + /** + * Sets the {@link #inlineMessageId}. + * + * @param inlineMessageId the {@link #inlineMessageId} to set. + */ + public void setInlineMessageId(String inlineMessageId) { + this.inlineMessageId = inlineMessageId; + } + + /** + * Gets the {@link #chatInstance}. + * + * @return the {@link #chatInstance}. + */ + public String getChatInstance() { + return chatInstance; + } + + /** + * Sets the {@link #chatInstance}. + * + * @param chatInstance the {@link #chatInstance} to set. + */ + public void setChatInstance(String chatInstance) { + this.chatInstance = chatInstance; + } + + /** + * Gets the {@link #data}. + * + * @return the {@link #data}. + */ + public String getData() { + return data; + } + + /** + * Sets the {@link #data}. + * + * @param data the {@link #data} to set. + */ + public void setData(String data) { + this.data = data; + } + + /** + * Gets the {@link #gameShortName}. + * + * @return the {@link #gameShortName}. + */ + public String getGameShortName() { + return gameShortName; + } + + /** + * Sets the {@link #gameShortName}. + * + * @param gameShortName the {@link #gameShortName} to set. + */ + public void setGameShortName(String gameShortName) { + this.gameShortName = gameShortName; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((chatInstance == null) ? 0 : chatInstance.hashCode()); + result = prime * result + ((data == null) ? 0 : data.hashCode()); + result = prime * result + ((from == null) ? 0 : from.hashCode()); + result = prime * result + + ((gameShortName == null) ? 0 : gameShortName.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + + ((inlineMessageId == null) ? 0 : inlineMessageId.hashCode()); + result = prime * result + ((message == null) ? 0 : message.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + CallbackQuery other = (CallbackQuery) obj; + if (chatInstance == null) { + if (other.chatInstance != null) + return false; + } else if (!chatInstance.equals(other.chatInstance)) + return false; + if (data == null) { + if (other.data != null) + return false; + } else if (!data.equals(other.data)) + return false; + if (from == null) { + if (other.from != null) + return false; + } else if (!from.equals(other.from)) + return false; + if (gameShortName == null) { + if (other.gameShortName != null) + return false; + } else if (!gameShortName.equals(other.gameShortName)) + return false; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + if (inlineMessageId == null) { + if (other.inlineMessageId != null) + return false; + } else if (!inlineMessageId.equals(other.inlineMessageId)) + return false; + if (message == null) { + if (other.message != null) + return false; + } else if (!message.equals(other.message)) + return false; + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "CallbackQuery [id=" + id + ", from=" + from + ", message=" + + message + ", inlineMessageId=" + inlineMessageId + + ", chatInstance=" + chatInstance + ", data=" + data + + ", gameShortName=" + gameShortName + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/Chat.java b/src/main/java/co/aurasphere/botmill/telegram/model/Chat.java index 928d08e..77e5beb 100644 --- a/src/main/java/co/aurasphere/botmill/telegram/model/Chat.java +++ b/src/main/java/co/aurasphere/botmill/telegram/model/Chat.java @@ -168,9 +168,9 @@ public void setLastName(String lastName) { } /** - * Checks if is all members are administrators. + * Gets the {@link #allMembersAreAdministrators}. * - * @return true, if is all members are administrators + * @return the {@link #allMembersAreAdministrators}. */ public boolean isAllMembersAreAdministrators() { return allMembersAreAdministrators; diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/ChatMember.java b/src/main/java/co/aurasphere/botmill/telegram/model/ChatMember.java new file mode 100644 index 0000000..70abadf --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/ChatMember.java @@ -0,0 +1,104 @@ +package co.aurasphere.botmill.telegram.model; + +import java.io.Serializable; + +/** + * This object contains information about one member of the chat. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class ChatMember implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Information about the user. + */ + private User user; + + /** + * The member's status in the chat. Can be “creator”, “administrator”, + * “member”, “left” or “kicked”. + */ + private ChatMemberStatus status; + + /** + * Gets the {@link #user}. + * + * @return the {@link #user}. + */ + public User getUser() { + return user; + } + + /** + * Sets the {@link #user}. + * + * @param user the {@link #user} to set. + */ + public void setUser(User user) { + this.user = user; + } + + /** + * Gets the {@link #status}. + * + * @return the {@link #status}. + */ + public ChatMemberStatus getStatus() { + return status; + } + + /** + * Sets the {@link #status}. + * + * @param status the {@link #status} to set. + */ + public void setStatus(ChatMemberStatus status) { + this.status = status; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((user == null) ? 0 : user.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ChatMember other = (ChatMember) obj; + if (user == null) { + if (other.user != null) + return false; + } else if (!user.equals(other.user)) + return false; + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ChatMember [user=" + user + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/ChatMemberStatus.java b/src/main/java/co/aurasphere/botmill/telegram/model/ChatMemberStatus.java new file mode 100644 index 0000000..9fe92ce --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/ChatMemberStatus.java @@ -0,0 +1,44 @@ +package co.aurasphere.botmill.telegram.model; + +import com.google.gson.annotations.SerializedName; + +/** + * The member's status in the chat. Can be “creator”, “administrator”, “member”, + * “left” or “kicked”. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public enum ChatMemberStatus { + + /** + * The creator. + */ + @SerializedName("creator") + CREATOR, + + /** + * The administrator. + */ + @SerializedName("administrator") + ADMINISTRATOR, + + /** + * The member. + */ + @SerializedName("member") + MEMBER, + + /** + * The left. + */ + @SerializedName("left") + LEFT, + + /** + * The kicked. + */ + @SerializedName("kicked") + KICKED; + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/Contact.java b/src/main/java/co/aurasphere/botmill/telegram/model/Contact.java new file mode 100644 index 0000000..fb555e9 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/Contact.java @@ -0,0 +1,178 @@ +package co.aurasphere.botmill.telegram.model; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +/** + * This object represents a phone contact. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class Contact implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Contact's phone number. + */ + @SerializedName("phone_number") + private String phoneNumber; + + /** + * Contact's phone number. + */ + @SerializedName("first_name") + private String firstName; + + /** + * Optional. Contact's last name. + */ + @SerializedName("last_name") + private String lastName; + + /** + * Optional. Contact's user identifier in Telegram. + */ + @SerializedName("user_id") + private String userId; + + /** + * Gets the {@link #phoneNumber}. + * + * @return the {@link #phoneNumber}. + */ + public String getPhoneNumber() { + return phoneNumber; + } + + /** + * Sets the {@link #phoneNumber}. + * + * @param phoneNumber the {@link #phoneNumber} to set. + */ + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + /** + * Gets the {@link #firstName}. + * + * @return the {@link #firstName}. + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets the {@link #firstName}. + * + * @param firstName the {@link #firstName} to set. + */ + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + /** + * Gets the {@link #lastName}. + * + * @return the {@link #lastName}. + */ + public String getLastName() { + return lastName; + } + + /** + * Sets the {@link #lastName}. + * + * @param lastName the {@link #lastName} to set. + */ + public void setLastName(String lastName) { + this.lastName = lastName; + } + + /** + * Gets the {@link #userId}. + * + * @return the {@link #userId}. + */ + public String getUserId() { + return userId; + } + + /** + * Sets the {@link #userId}. + * + * @param userId the {@link #userId} to set. + */ + public void setUserId(String userId) { + this.userId = userId; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((firstName == null) ? 0 : firstName.hashCode()); + result = prime * result + + ((lastName == null) ? 0 : lastName.hashCode()); + result = prime * result + + ((phoneNumber == null) ? 0 : phoneNumber.hashCode()); + result = prime * result + ((userId == null) ? 0 : userId.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Contact other = (Contact) obj; + if (firstName == null) { + if (other.firstName != null) + return false; + } else if (!firstName.equals(other.firstName)) + return false; + if (lastName == null) { + if (other.lastName != null) + return false; + } else if (!lastName.equals(other.lastName)) + return false; + if (phoneNumber == null) { + if (other.phoneNumber != null) + return false; + } else if (!phoneNumber.equals(other.phoneNumber)) + return false; + if (userId == null) { + if (other.userId != null) + return false; + } else if (!userId.equals(other.userId)) + return false; + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Contact [phoneNumber=" + phoneNumber + ", firstName=" + + firstName + ", lastName=" + lastName + ", userId=" + userId + + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/Document.java b/src/main/java/co/aurasphere/botmill/telegram/model/Document.java new file mode 100644 index 0000000..a5f7c87 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/Document.java @@ -0,0 +1,204 @@ +package co.aurasphere.botmill.telegram.model; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +/** + * This object represents a general file (as opposed to photos, voice messages + * and audio files). + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class Document implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Unique file identifier. + */ + @SerializedName("file_id") + private String fileId; + + /** + * Optional. Document thumbnail as defined by sender. + */ + private PhotoSize thumb; + + /** + * Optional. Original filename as defined by sender. + */ + @SerializedName("file_name") + private String fileName; + + /** + * Optional. MIME type of the file as defined by sender. + */ + @SerializedName("mime_type") + private String mimeType; + + /** + * Optional. File size. + */ + @SerializedName("file_type") + private int fileSize; + + /** + * Gets the {@link #fileId}. + * + * @return the {@link #fileId}. + */ + public String getFileId() { + return fileId; + } + + /** + * Sets the {@link #fileId}. + * + * @param fileId the {@link #fileId} to set. + */ + public void setFileId(String fileId) { + this.fileId = fileId; + } + + /** + * Gets the {@link #thumb}. + * + * @return the {@link #thumb}. + */ + public PhotoSize getThumb() { + return thumb; + } + + /** + * Sets the {@link #thumb}. + * + * @param thumb the {@link #thumb} to set. + */ + public void setThumb(PhotoSize thumb) { + this.thumb = thumb; + } + + /** + * Gets the {@link #fileName}. + * + * @return the {@link #fileName}. + */ + public String getFileName() { + return fileName; + } + + /** + * Sets the {@link #fileName}. + * + * @param fileName the {@link #fileName} to set. + */ + public void setFileName(String fileName) { + this.fileName = fileName; + } + + /** + * Gets the {@link #mimeType}. + * + * @return the {@link #mimeType}. + */ + public String getMimeType() { + return mimeType; + } + + /** + * Sets the {@link #mimeType}. + * + * @param mimeType the {@link #mimeType} to set. + */ + public void setMimeType(String mimeType) { + this.mimeType = mimeType; + } + + /** + * Gets the {@link #fileSize}. + * + * @return the {@link #fileSize}. + */ + public int getFileSize() { + return fileSize; + } + + /** + * Sets the {@link #fileSize}. + * + * @param fileSize the {@link #fileSize} to set. + */ + public void setFileSize(int fileSize) { + this.fileSize = fileSize; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((fileId == null) ? 0 : fileId.hashCode()); + result = prime * result + + ((fileName == null) ? 0 : fileName.hashCode()); + result = prime * result + fileSize; + result = prime * result + + ((mimeType == null) ? 0 : mimeType.hashCode()); + result = prime * result + ((thumb == null) ? 0 : thumb.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Document other = (Document) obj; + if (fileId == null) { + if (other.fileId != null) + return false; + } else if (!fileId.equals(other.fileId)) + return false; + if (fileName == null) { + if (other.fileName != null) + return false; + } else if (!fileName.equals(other.fileName)) + return false; + if (fileSize != other.fileSize) + return false; + if (mimeType == null) { + if (other.mimeType != null) + return false; + } else if (!mimeType.equals(other.mimeType)) + return false; + if (thumb == null) { + if (other.thumb != null) + return false; + } else if (!thumb.equals(other.thumb)) + return false; + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Document [fileId=" + fileId + ", thumb=" + thumb + + ", fileName=" + fileName + ", mimeType=" + mimeType + + ", fileSize=" + fileSize + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/File.java b/src/main/java/co/aurasphere/botmill/telegram/model/File.java new file mode 100644 index 0000000..cb8a733 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/File.java @@ -0,0 +1,147 @@ +package co.aurasphere.botmill.telegram.model; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +/** + * This object represents a file ready to be downloaded. The file can be + * downloaded via the link https://api.telegram.org/file/bot/. + * It is guaranteed that the link will be valid for at least 1 hour. When the + * link expires, a new one can be requested by calling getFile. Maximum file + * size to download is 20 MB. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class File implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Unique identifier for this file. + */ + @SerializedName("file_id") + private String fileId; + + /** + * Optional. File size, if known. + */ + @SerializedName("file_size") + private int fileSize; + + /** + * Optional. File path. Use + * https://api.telegram.org/file/bot/ to get the file. + */ + @SerializedName("file_path") + private String filePath; + + /** + * Gets the {@link #fileId}. + * + * @return the {@link #fileId}. + */ + public String getFileId() { + return fileId; + } + + /** + * Sets the {@link #fileId}. + * + * @param fileId the {@link #fileId} to set. + */ + public void setFileId(String fileId) { + this.fileId = fileId; + } + + /** + * Gets the {@link #fileSize}. + * + * @return the {@link #fileSize}. + */ + public int getFileSize() { + return fileSize; + } + + /** + * Sets the {@link #fileSize}. + * + * @param fileSize the {@link #fileSize} to set. + */ + public void setFileSize(int fileSize) { + this.fileSize = fileSize; + } + + /** + * Gets the {@link #filePath}. + * + * @return the {@link #filePath}. + */ + public String getFilePath() { + return filePath; + } + + /** + * Sets the {@link #filePath}. + * + * @param filePath the {@link #filePath} to set. + */ + public void setFilePath(String filePath) { + this.filePath = filePath; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((fileId == null) ? 0 : fileId.hashCode()); + result = prime * result + + ((filePath == null) ? 0 : filePath.hashCode()); + result = prime * result + fileSize; + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + File other = (File) obj; + if (fileId == null) { + if (other.fileId != null) + return false; + } else if (!fileId.equals(other.fileId)) + return false; + if (filePath == null) { + if (other.filePath != null) + return false; + } else if (!filePath.equals(other.filePath)) + return false; + if (fileSize != other.fileSize) + return false; + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "File [fileId=" + fileId + ", fileSize=" + fileSize + + ", filePath=" + filePath + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/ForceReply.java b/src/main/java/co/aurasphere/botmill/telegram/model/ForceReply.java new file mode 100644 index 0000000..2c7ce04 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/ForceReply.java @@ -0,0 +1,131 @@ +package co.aurasphere.botmill.telegram.model; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +/** + * Upon receiving a message with this object, Telegram clients will display a + * reply interface to the user (act as if the user has selected the bot‘s + * message and tapped ’Reply'). This can be extremely useful if you want to + * create user-friendly step-by-step interfaces without having to sacrifice privacy mode.
+ *
+ * Example: A poll bot for groups runs in privacy mode (only receives commands, + * replies to its messages and mentions). There could be two ways to create a + * new poll: + *
    + *
  • Explain the user how to send a command with parameters (e.g. /newpoll + * question answer1 answer2). May be appealing for hardcore users but lacks + * modern day polish.
  • + *
  • Guide the user through a step-by-step process. ‘Please send me your + * question’, ‘Cool, now let’s add the first answer option‘, ’Great. Keep adding + * answer options, then send /done when you‘re ready’.
  • + *
+ * The last option is definitely more attractive. And if you use ForceReply in + * your bot‘s questions, it will receive the user’s answers even if it only + * receives replies, commands and mentions — without any extra work for the + * user. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class ForceReply implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Shows reply interface to the user, as if they manually selected the bot‘s + * message and tapped ’Reply'. + */ + @SerializedName("force_reply") + private boolean forceReply; + + /** + * Optional. Use this parameter if you want to force reply from specific + * users only. Targets: 1) users that are @mentioned in the text of the + * {@link Message} object; 2) if the bot's message is a reply (has + * reply_to_message_id), sender of the original message. + */ + private boolean selective; + + /** + * Gets the {@link #forceReply}. + * + * @return the {@link #forceReply}. + */ + public boolean isForceReply() { + return forceReply; + } + + /** + * Sets the {@link #forceReply}. + * + * @param forceReply the {@link #forceReply} to set. + */ + public void setForceReply(boolean forceReply) { + this.forceReply = forceReply; + } + + /** + * Gets the {@link #selective}. + * + * @return the {@link #selective}. + */ + public boolean isSelective() { + return selective; + } + + /** + * Sets the {@link #selective}. + * + * @param selective the {@link #selective} to set. + */ + public void setSelective(boolean selective) { + this.selective = selective; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (forceReply ? 1231 : 1237); + result = prime * result + (selective ? 1231 : 1237); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ForceReply other = (ForceReply) obj; + if (forceReply != other.forceReply) + return false; + if (selective != other.selective) + return false; + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ForceReply [forceReply=" + forceReply + ", selective=" + + selective + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/InlineKeyboardButton.java b/src/main/java/co/aurasphere/botmill/telegram/model/InlineKeyboardButton.java new file mode 100644 index 0000000..a41720e --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/InlineKeyboardButton.java @@ -0,0 +1,260 @@ +package co.aurasphere.botmill.telegram.model; + +import java.io.Serializable; + +import co.aurasphere.botmill.telegram.model.game.CallbackGame; + +import com.google.gson.annotations.SerializedName; + +/** + * This object represents one button of an inline keyboard. You must use exactly + * one of the optional fields. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class InlineKeyboardButton implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Label text on the button. + */ + private String text; + + /** + * Optional. HTTP url to be opened when button is pressed. + */ + private String url; + + /** + * Optional. Data to be sent in a {@link CallbackQuery} to the bot when + * button is pressed, 1-64 bytes. + */ + @SerializedName("callback_data") + private String callbackData; + + /** + * Optional. If set, pressing the button will prompt the user to select one + * of their chats, open that chat and insert the bot‘s username and the + * specified inline query in the input field. Can be empty, in which case + * just the bot’s username will be inserted.
+ *
+ * Note: This offers an easy way for users to start using your bot in inline + * mode when they are currently in a private chat with it. Especially useful + * when combined with switch_pm… actions – in this case the user will be + * automatically returned to the chat they switched from, skipping the chat + * selection screen. + * + * @see Inline Mode. + */ + @SerializedName("switch_inline_query") + private String switchInlineQuery; + + /** + * Optional. If set, pressing the button will insert the bot‘s username and + * the specified inline query in the current chat's input field. Can be + * empty, in which case only the bot’s username will be inserted.
+ *
+ * This offers a quick way for the user to open your bot in inline mode in + * the same chat – good for selecting something from multiple options. + */ + @SerializedName("switch_inline_query_current_chat") + private String switchInlineQueryCurrentChat; + + /** + * Optional. Description of the game that will be launched when the user + * presses the button.
+ *
+ * NOTE: This type of button must always be the first button in the first + * row. + */ + @SerializedName("callback_game") + private CallbackGame callbackGame; + + /** + * Gets the {@link #text}. + * + * @return the {@link #text}. + */ + public String getText() { + return text; + } + + /** + * Sets the {@link #text}. + * + * @param text the {@link #text} to set. + */ + public void setText(String text) { + this.text = text; + } + + /** + * Gets the {@link #url}. + * + * @return the {@link #url}. + */ + public String getUrl() { + return url; + } + + /** + * Sets the {@link #url}. + * + * @param url the {@link #url} to set. + */ + public void setUrl(String url) { + this.url = url; + } + + /** + * Gets the {@link #callbackData}. + * + * @return the {@link #callbackData}. + */ + public String getCallbackData() { + return callbackData; + } + + /** + * Sets the {@link #callbackData}. + * + * @param callbackData the {@link #callbackData} to set. + */ + public void setCallbackData(String callbackData) { + this.callbackData = callbackData; + } + + /** + * Gets the {@link #switchInlineQuery}. + * + * @return the {@link #switchInlineQuery}. + */ + public String getSwitchInlineQuery() { + return switchInlineQuery; + } + + /** + * Sets the {@link #switchInlineQuery}. + * + * @param switchInlineQuery the {@link #switchInlineQuery} to set. + */ + public void setSwitchInlineQuery(String switchInlineQuery) { + this.switchInlineQuery = switchInlineQuery; + } + + /** + * Gets the {@link #switchInlineQueryCurrentChat}. + * + * @return the {@link #switchInlineQueryCurrentChat}. + */ + public String getSwitchInlineQueryCurrentChat() { + return switchInlineQueryCurrentChat; + } + + /** + * Sets the {@link #switchInlineQueryCurrentChat}. + * + * @param switchInlineQueryCurrentChat the {@link #switchInlineQueryCurrentChat} to set. + */ + public void setSwitchInlineQueryCurrentChat(String switchInlineQueryCurrentChat) { + this.switchInlineQueryCurrentChat = switchInlineQueryCurrentChat; + } + + /** + * Gets the {@link #callbackGame}. + * + * @return the {@link #callbackGame}. + */ + public CallbackGame getCallbackGame() { + return callbackGame; + } + + /** + * Sets the {@link #callbackGame}. + * + * @param callbackGame the {@link #callbackGame} to set. + */ + public void setCallbackGame(CallbackGame callbackGame) { + this.callbackGame = callbackGame; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((callbackData == null) ? 0 : callbackData.hashCode()); + result = prime + * result + + ((switchInlineQuery == null) ? 0 : switchInlineQuery + .hashCode()); + result = prime + * result + + ((switchInlineQueryCurrentChat == null) ? 0 + : switchInlineQueryCurrentChat.hashCode()); + result = prime * result + ((text == null) ? 0 : text.hashCode()); + result = prime * result + ((url == null) ? 0 : url.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + InlineKeyboardButton other = (InlineKeyboardButton) obj; + if (callbackData == null) { + if (other.callbackData != null) + return false; + } else if (!callbackData.equals(other.callbackData)) + return false; + if (switchInlineQuery == null) { + if (other.switchInlineQuery != null) + return false; + } else if (!switchInlineQuery.equals(other.switchInlineQuery)) + return false; + if (switchInlineQueryCurrentChat == null) { + if (other.switchInlineQueryCurrentChat != null) + return false; + } else if (!switchInlineQueryCurrentChat + .equals(other.switchInlineQueryCurrentChat)) + return false; + if (text == null) { + if (other.text != null) + return false; + } else if (!text.equals(other.text)) + return false; + if (url == null) { + if (other.url != null) + return false; + } else if (!url.equals(other.url)) + return false; + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "InlineKeyboardButton [text=" + text + ", url=" + url + + ", callbackData=" + callbackData + ", switchInlineQuery=" + + switchInlineQuery + ", switchInlineQueryCurrentChat=" + + switchInlineQueryCurrentChat + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/InlineKeyboardMarkup.java b/src/main/java/co/aurasphere/botmill/telegram/model/InlineKeyboardMarkup.java new file mode 100644 index 0000000..42938e6 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/InlineKeyboardMarkup.java @@ -0,0 +1,98 @@ +package co.aurasphere.botmill.telegram.model; + +import java.io.Serializable; +import java.util.Arrays; + +import com.google.gson.annotations.SerializedName; + +/** + * This object represents an inline keyboard that appears right next to the + * message it belongs to.
+ *
Inline + * Keyboard. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class InlineKeyboardMarkup implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Array of button rows, each represented by an Array of + * InlineKeyboardButton objects. + */ + @SerializedName("inline_keyboard") + private InlineKeyboardButton[][] inlineKeyboard; + + /** + * Gets the {@link #inlineKeyboard}. + * + * @return the {@link #inlineKeyboard}. + */ + public InlineKeyboardButton[][] getInlineKeyboard() { + return inlineKeyboard; + } + + /** + * Sets the {@link #inlineKeyboard}. + * + * @param inlineKeyboard + * the {@link #inlineKeyboard} to set. + */ + public void setInlineKeyboard(InlineKeyboardButton[][] inlineKeyboard) { + this.inlineKeyboard = inlineKeyboard; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + Arrays.hashCode(inlineKeyboard); + return result; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + InlineKeyboardMarkup other = (InlineKeyboardMarkup) obj; + if (!Arrays.deepEquals(inlineKeyboard, other.inlineKeyboard)) + return false; + return true; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "InlineKeyboardMarkup [inlineKeyboard=" + + Arrays.toString(inlineKeyboard) + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/KeyboardButton.java b/src/main/java/co/aurasphere/botmill/telegram/model/KeyboardButton.java new file mode 100644 index 0000000..ad8608d --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/KeyboardButton.java @@ -0,0 +1,150 @@ +package co.aurasphere.botmill.telegram.model; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +/** + * This object represents one button of the reply keyboard. For simple text + * buttons String can be used instead of this object to specify text of the + * button. Optional fields are mutually exclusive. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class KeyboardButton implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Text of the button. If none of the optional fields are used, it will be + * sent to the bot as a message when the button is pressed. + */ + private String text; + + /** + * Optional. If True, the user's phone number will be sent as a contact when + * the button is pressed. Available in private chats only.
+ *
+ * Note: request_contact and request_location options will only work in + * Telegram versions released after 9 April, 2016. Older clients will ignore + * them. + */ + @SerializedName("request_contact") + private boolean requestContact; + + /** + * Optional. If True, the user's current location will be sent when the + * button is pressed. Available in private chats only.
+ *
+ * Note: request_contact and request_location options will only work in + * Telegram versions released after 9 April, 2016. Older clients will ignore + * them. + */ + @SerializedName("request_location") + private boolean requestLocation; + + /** + * Gets the {@link #text}. + * + * @return the {@link #text}. + */ + public String getText() { + return text; + } + + /** + * Sets the {@link #text}. + * + * @param text the {@link #text} to set. + */ + public void setText(String text) { + this.text = text; + } + + /** + * Gets the {@link #requestContact}. + * + * @return the {@link #requestContact}. + */ + public boolean isRequestContact() { + return requestContact; + } + + /** + * Sets the {@link #requestContact}. + * + * @param requestContact the {@link #requestContact} to set. + */ + public void setRequestContact(boolean requestContact) { + this.requestContact = requestContact; + } + + /** + * Gets the {@link #requestLocation}. + * + * @return the {@link #requestLocation}. + */ + public boolean isRequestLocation() { + return requestLocation; + } + + /** + * Sets the {@link #requestLocation}. + * + * @param requestLocation the {@link #requestLocation} to set. + */ + public void setRequestLocation(boolean requestLocation) { + this.requestLocation = requestLocation; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (requestContact ? 1231 : 1237); + result = prime * result + (requestLocation ? 1231 : 1237); + result = prime * result + ((text == null) ? 0 : text.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + KeyboardButton other = (KeyboardButton) obj; + if (requestContact != other.requestContact) + return false; + if (requestLocation != other.requestLocation) + return false; + if (text == null) { + if (other.text != null) + return false; + } else if (!text.equals(other.text)) + return false; + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "KeyboardButton [text=" + text + ", requestContact=" + + requestContact + ", requestLocation=" + requestLocation + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/Location.java b/src/main/java/co/aurasphere/botmill/telegram/model/Location.java new file mode 100644 index 0000000..cc9264e --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/Location.java @@ -0,0 +1,108 @@ +package co.aurasphere.botmill.telegram.model; + +import java.io.Serializable; + +/** + * This object represents a point on the map. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class Location implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Longitude as defined by sender. + */ + private double longitude; + + /** + * Latitude as defined by sender. + */ + private double latitude; + + /** + * Gets the {@link #longitude}. + * + * @return the {@link #longitude}. + */ + public double getLongitude() { + return longitude; + } + + /** + * Sets the {@link #longitude}. + * + * @param longitude the {@link #longitude} to set. + */ + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + /** + * Gets the {@link #latitude}. + * + * @return the {@link #latitude}. + */ + public double getLatitude() { + return latitude; + } + + /** + * Sets the {@link #latitude}. + * + * @param latitude the {@link #latitude} to set. + */ + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + long temp; + temp = Double.doubleToLongBits(latitude); + result = prime * result + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(longitude); + result = prime * result + (int) (temp ^ (temp >>> 32)); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Location other = (Location) obj; + if (Double.doubleToLongBits(latitude) != Double + .doubleToLongBits(other.latitude)) + return false; + if (Double.doubleToLongBits(longitude) != Double + .doubleToLongBits(other.longitude)) + return false; + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Location [longitude=" + longitude + ", latitude=" + latitude + + "]"; + } +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/MentionType.java b/src/main/java/co/aurasphere/botmill/telegram/model/MentionType.java new file mode 100644 index 0000000..9711cf2 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/MentionType.java @@ -0,0 +1,82 @@ +package co.aurasphere.botmill.telegram.model; + +import com.google.gson.annotations.SerializedName; + +/** + * Type of the entity. Can be mention (@username), hashtag, bot_command, url, + * email, bold (bold text), italic (italic text), code (monowidth string), pre + * (monowidth block), text_link (for clickable text URLs), text_mention (for + * users without usernames). + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public enum MentionType { + + /** + * The mention (@username). + */ + @SerializedName("mention") + MENTION, + + /** + * The hashtag. + */ + @SerializedName("hashtag") + HASHTAG, + + /** + * The bot command. + */ + @SerializedName("bot_command") + BOT_COMMAND, + + /** + * The url. + */ + @SerializedName("url") + URL, + + /** + * The email. + */ + @SerializedName("email") + EMAIL, + + /** + * The bold (bold text). + */ + @SerializedName("bold") + BOLD, + + /** + * The italic (italic text). + */ + @SerializedName("italic") + ITALIC, + + /** + * The code (monowidth string). + */ + @SerializedName("code") + CODE, + + /** + * The pre (monowidth block). + */ + @SerializedName("pre") + PRE, + + /** + * The text link (for clickable text URLs). + */ + @SerializedName("text_link") + TEXT_LINK, + + /** + * The text mention (for users without usernames). + */ + @SerializedName("text_mention") + TEXT_MENTION; + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/Message.java b/src/main/java/co/aurasphere/botmill/telegram/model/Message.java index 05515c6..7937eb3 100644 --- a/src/main/java/co/aurasphere/botmill/telegram/model/Message.java +++ b/src/main/java/co/aurasphere/botmill/telegram/model/Message.java @@ -7,6 +7,8 @@ import java.util.Calendar; import java.util.List; +import co.aurasphere.botmill.telegram.model.game.Game; + import com.google.gson.annotations.SerializedName; /** @@ -731,9 +733,9 @@ public void setNewChatPhoto(List newChatPhoto) { } /** - * Checks if is delete chat photo. + * Gets the {@link #deleteChatPhoto}. * - * @return true, if is delete chat photo + * @return the {@link #deleteChatPhoto}. */ public boolean isDeleteChatPhoto() { return deleteChatPhoto; @@ -749,9 +751,9 @@ public void setDeleteChatPhoto(boolean deleteChatPhoto) { } /** - * Checks if is group chat created. + * Gets the {@link #groupChatCreated}. * - * @return true, if is group chat created + * @return the {@link #groupChatCreated}. */ public boolean isGroupChatCreated() { return groupChatCreated; @@ -767,9 +769,9 @@ public void setGroupChatCreated(boolean groupChatCreated) { } /** - * Checks if is supergroup chat created. + * Gets the {@link #supergroupChatCreated}. * - * @return true, if is supergroup chat created + * @return the {@link #supergroupChatCreated}. */ public boolean isSupergroupChatCreated() { return supergroupChatCreated; @@ -785,9 +787,9 @@ public void setSupergroupChatCreated(boolean supergroupChatCreated) { } /** - * Checks if is channel chat created. + * Gets the {@link #channelChatCreated}. * - * @return true, if is channel chat created + * @return the {@link #channelChatCreated}. */ public boolean isChannelChatCreated() { return channelChatCreated; diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/MessageEntity.java b/src/main/java/co/aurasphere/botmill/telegram/model/MessageEntity.java new file mode 100644 index 0000000..cc27268 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/MessageEntity.java @@ -0,0 +1,190 @@ +package co.aurasphere.botmill.telegram.model; + +import java.io.Serializable; + +/** + * This object represents one special entity in a text message. For example, + * hashtags, usernames, URLs, etc. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class MessageEntity implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Type of the entity. Can be mention (@username), hashtag, bot_command, + * url, email, bold (bold text), italic (italic text), code (monowidth + * string), pre (monowidth block), text_link (for clickable text URLs), + * text_mention (for users without usernames). + */ + private MentionType type; + + /** + * Offset in UTF-16 code units to the start of the entity. + */ + private int offset; + + /** + * Length of the entity in UTF-16 code units. + */ + private int length; + + /** + * Optional. For “text_link” only, url that will be opened after user taps + * on the text. + */ + private String url; + + /** + * Optional. For “text_mention” only, the mentioned user. + */ + private User user; + + /** + * Gets the {@link #type}. + * + * @return the {@link #type}. + */ + public MentionType getType() { + return type; + } + + /** + * Sets the {@link #type}. + * + * @param type the {@link #type} to set. + */ + public void setType(MentionType type) { + this.type = type; + } + + /** + * Gets the {@link #offset}. + * + * @return the {@link #offset}. + */ + public int getOffset() { + return offset; + } + + /** + * Sets the {@link #offset}. + * + * @param offset the {@link #offset} to set. + */ + public void setOffset(int offset) { + this.offset = offset; + } + + /** + * Gets the {@link #length}. + * + * @return the {@link #length}. + */ + public int getLength() { + return length; + } + + /** + * Sets the {@link #length}. + * + * @param length the {@link #length} to set. + */ + public void setLength(int length) { + this.length = length; + } + + /** + * Gets the {@link #url}. + * + * @return the {@link #url}. + */ + public String getUrl() { + return url; + } + + /** + * Sets the {@link #url}. + * + * @param url the {@link #url} to set. + */ + public void setUrl(String url) { + this.url = url; + } + + /** + * Gets the {@link #user}. + * + * @return the {@link #user}. + */ + public User getUser() { + return user; + } + + /** + * Sets the {@link #user}. + * + * @param user the {@link #user} to set. + */ + public void setUser(User user) { + this.user = user; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + length; + result = prime * result + offset; + result = prime * result + ((url == null) ? 0 : url.hashCode()); + result = prime * result + ((user == null) ? 0 : user.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + MessageEntity other = (MessageEntity) obj; + if (length != other.length) + return false; + if (offset != other.offset) + return false; + if (url == null) { + if (other.url != null) + return false; + } else if (!url.equals(other.url)) + return false; + if (user == null) { + if (other.user != null) + return false; + } else if (!user.equals(other.user)) + return false; + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "MessageEntity [offset=" + offset + ", length=" + length + + ", url=" + url + ", user=" + user + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/PhotoSize.java b/src/main/java/co/aurasphere/botmill/telegram/model/PhotoSize.java new file mode 100644 index 0000000..a0f4080 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/PhotoSize.java @@ -0,0 +1,164 @@ +package co.aurasphere.botmill.telegram.model; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +/** + * + * This object represents one size of a photo or a file / sticker thumbnail. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class PhotoSize implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Unique identifier for this file. + */ + @SerializedName("file_id") + private String fileId; + + /** + * Photo width. + */ + private int width; + + /** + * Photo height. + */ + private int height; + + /** + * Optional. File size. + */ + @SerializedName("file_size") + private int fileSize; + + /** + * Gets the {@link #fileId}. + * + * @return the {@link #fileId}. + */ + public String getFileId() { + return fileId; + } + + /** + * Sets the {@link #fileId}. + * + * @param fileId the {@link #fileId} to set. + */ + public void setFileId(String fileId) { + this.fileId = fileId; + } + + /** + * Gets the {@link #width}. + * + * @return the {@link #width}. + */ + public int getWidth() { + return width; + } + + /** + * Sets the {@link #width}. + * + * @param width the {@link #width} to set. + */ + public void setWidth(int width) { + this.width = width; + } + + /** + * Gets the {@link #height}. + * + * @return the {@link #height}. + */ + public int getHeight() { + return height; + } + + /** + * Sets the {@link #height}. + * + * @param height the {@link #height} to set. + */ + public void setHeight(int height) { + this.height = height; + } + + /** + * Gets the {@link #fileSize}. + * + * @return the {@link #fileSize}. + */ + public int getFileSize() { + return fileSize; + } + + /** + * Sets the {@link #fileSize}. + * + * @param fileSize the {@link #fileSize} to set. + */ + public void setFileSize(int fileSize) { + this.fileSize = fileSize; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((fileId == null) ? 0 : fileId.hashCode()); + result = prime * result + fileSize; + result = prime * result + height; + result = prime * result + width; + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + PhotoSize other = (PhotoSize) obj; + if (fileId == null) { + if (other.fileId != null) + return false; + } else if (!fileId.equals(other.fileId)) + return false; + if (fileSize != other.fileSize) + return false; + if (height != other.height) + return false; + if (width != other.width) + return false; + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "PhotoSize [fileId=" + fileId + ", width=" + width + ", height=" + + height + ", fileSize=" + fileSize + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/ReplyKeyboardMarkup.java b/src/main/java/co/aurasphere/botmill/telegram/model/ReplyKeyboardMarkup.java new file mode 100644 index 0000000..9366103 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/ReplyKeyboardMarkup.java @@ -0,0 +1,176 @@ +package co.aurasphere.botmill.telegram.model; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +/** + * This object represents a custom keyboard with reply options. + * + * @see Introduction to bots + * with details and examples. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class ReplyKeyboardMarkup implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Array of button rows, each represented by an Array of KeyboardButton + * objects. + */ + private KeyboardButton[][] keyboard; + + /** + * Optional. Requests clients to resize the keyboard vertically for optimal + * fit (e.g., make the keyboard smaller if there are just two rows of + * buttons). Defaults to false, in which case the custom keyboard is always + * of the same height as the app's standard keyboard. + */ + @SerializedName("resize_keyboard") + private boolean resizeKeyboard; + + /** + * Optional. Requests clients to hide the keyboard as soon as it's been + * used. The keyboard will still be available, but clients will + * automatically display the usual letter-keyboard in the chat – the user + * can press a special button in the input field to see the custom keyboard + * again. Defaults to false. + */ + @SerializedName("one_time_keyboard") + private boolean oneTimeKeyboard; + + /** + * Optional. Use this parameter if you want to show the keyboard to specific + * users only. Targets: 1) users that are @mentioned in the text of the + * Message object; 2) if the bot's message is a reply (has + * reply_to_message_id), sender of the original message.
+ *
+ * Example: A user requests to change the bot‘s language, bot replies to the + * request with a keyboard to select the new language. Other users in the + * group don’t see the keyboard. + */ + private boolean selective; + + /** + * Gets the {@link #keyboard}. + * + * @return the {@link #keyboard}. + */ + public KeyboardButton[][] getKeyboard() { + return keyboard; + } + + /** + * Sets the {@link #keyboard}. + * + * @param keyboard the {@link #keyboard} to set. + */ + public void setKeyboard(KeyboardButton[][] keyboard) { + this.keyboard = keyboard; + } + + /** + * Gets the {@link #resizeKeyboard}. + * + * @return the {@link #resizeKeyboard}. + */ + public boolean isResizeKeyboard() { + return resizeKeyboard; + } + + /** + * Sets the {@link #resizeKeyboard}. + * + * @param resizeKeyboard the {@link #resizeKeyboard} to set. + */ + public void setResizeKeyboard(boolean resizeKeyboard) { + this.resizeKeyboard = resizeKeyboard; + } + + /** + * Gets the {@link #oneTimeKeyboard}. + * + * @return the {@link #oneTimeKeyboard}. + */ + public boolean isOneTimeKeyboard() { + return oneTimeKeyboard; + } + + /** + * Sets the {@link #oneTimeKeyboard}. + * + * @param oneTimeKeyboard the {@link #oneTimeKeyboard} to set. + */ + public void setOneTimeKeyboard(boolean oneTimeKeyboard) { + this.oneTimeKeyboard = oneTimeKeyboard; + } + + /** + * Gets the {@link #selective}. + * + * @return the {@link #selective}. + */ + public boolean isSelective() { + return selective; + } + + /** + * Sets the {@link #selective}. + * + * @param selective the {@link #selective} to set. + */ + public void setSelective(boolean selective) { + this.selective = selective; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (oneTimeKeyboard ? 1231 : 1237); + result = prime * result + (resizeKeyboard ? 1231 : 1237); + result = prime * result + (selective ? 1231 : 1237); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ReplyKeyboardMarkup other = (ReplyKeyboardMarkup) obj; + if (oneTimeKeyboard != other.oneTimeKeyboard) + return false; + if (resizeKeyboard != other.resizeKeyboard) + return false; + if (selective != other.selective) + return false; + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ReplyKeyboardMarkup [resizeKeyboard=" + resizeKeyboard + + ", oneTimeKeyboard=" + oneTimeKeyboard + ", selective=" + + selective + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/ReplyKeyboardRemove.java b/src/main/java/co/aurasphere/botmill/telegram/model/ReplyKeyboardRemove.java new file mode 100644 index 0000000..2d784a1 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/ReplyKeyboardRemove.java @@ -0,0 +1,120 @@ +package co.aurasphere.botmill.telegram.model; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +/** + * Upon receiving a message with this object, Telegram clients will remove the + * current custom keyboard and display the default letter-keyboard. By default, + * custom keyboards are displayed until a new keyboard is sent by a bot. An + * exception is made for one-time keyboards that are hidden immediately after + * the user presses a button (see {@link ReplyKeyboardMarkup}). + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class ReplyKeyboardRemove implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Requests clients to remove the custom keyboard (user will not be able to + * summon this keyboard; if you want to hide the keyboard from sight but + * keep it accessible, use one_time_keyboard in {@link ReplyKeyboardMarkup}). + */ + @SerializedName("remove_keyboard") + private boolean removeKeyboard; + + /** + * Optional. Use this parameter if you want to remove the keyboard for + * specific users only. Targets: 1) users that are @mentioned in the text of + * the Message object; 2) if the bot's message is a reply (has + * reply_to_message_id), sender of the original message.
+ *
+ * Example: A user votes in a poll, bot returns confirmation message in + * reply to the vote and removes the keyboard for that user, while still + * showing the keyboard with poll options to users who haven't voted yet. + */ + private boolean selective; + + /** + * Gets the {@link #removeKeyboard}. + * + * @return the {@link #removeKeyboard}. + */ + public boolean isRemoveKeyboard() { + return removeKeyboard; + } + + /** + * Sets the {@link #removeKeyboard}. + * + * @param removeKeyboard the {@link #removeKeyboard} to set. + */ + public void setRemoveKeyboard(boolean removeKeyboard) { + this.removeKeyboard = removeKeyboard; + } + + /** + * Gets the {@link #selective}. + * + * @return the {@link #selective}. + */ + public boolean isSelective() { + return selective; + } + + /** + * Sets the {@link #selective}. + * + * @param selective the {@link #selective} to set. + */ + public void setSelective(boolean selective) { + this.selective = selective; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (removeKeyboard ? 1231 : 1237); + result = prime * result + (selective ? 1231 : 1237); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ReplyKeyboardRemove other = (ReplyKeyboardRemove) obj; + if (removeKeyboard != other.removeKeyboard) + return false; + if (selective != other.selective) + return false; + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ReplyKeyboardRemove [removeKeyboard=" + removeKeyboard + + ", selective=" + selective + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/ResponseParameters.java b/src/main/java/co/aurasphere/botmill/telegram/model/ResponseParameters.java new file mode 100644 index 0000000..a8a2b5a --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/ResponseParameters.java @@ -0,0 +1,117 @@ +package co.aurasphere.botmill.telegram.model; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +/** + * Contains information about why a request was unsuccessfull. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class ResponseParameters implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Optional. The group has been migrated to a supergroup with the specified + * identifier. This number may be greater than 32 bits and some programming + * languages may have difficulty/silent defects in interpreting it. But it + * is smaller than 52 bits, so a signed 64 bit integer or double-precision + * float type are safe for storing this identifier. + */ + @SerializedName("migrate_to_chat_id") + private String migrateToChatId; + + /** + * Optional. In case of exceeding flood control, the number of seconds left + * to wait before the request can be repeated. + */ + @SerializedName("retry_after") + private int retryAfter; + + /** + * Gets the {@link #migrateToChatId}. + * + * @return the {@link #migrateToChatId}. + */ + public String getMigrateToChatId() { + return migrateToChatId; + } + + /** + * Sets the {@link #migrateToChatId}. + * + * @param migrateToChatId the {@link #migrateToChatId} to set. + */ + public void setMigrateToChatId(String migrateToChatId) { + this.migrateToChatId = migrateToChatId; + } + + /** + * Gets the {@link #retryAfter}. + * + * @return the {@link #retryAfter}. + */ + public int getRetryAfter() { + return retryAfter; + } + + /** + * Sets the {@link #retryAfter}. + * + * @param retryAfter the {@link #retryAfter} to set. + */ + public void setRetryAfter(int retryAfter) { + this.retryAfter = retryAfter; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((migrateToChatId == null) ? 0 : migrateToChatId.hashCode()); + result = prime * result + retryAfter; + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ResponseParameters other = (ResponseParameters) obj; + if (migrateToChatId == null) { + if (other.migrateToChatId != null) + return false; + } else if (!migrateToChatId.equals(other.migrateToChatId)) + return false; + if (retryAfter != other.retryAfter) + return false; + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ResponseParameters [migrateToChatId=" + migrateToChatId + + ", retryAfter=" + retryAfter + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/Sticker.java b/src/main/java/co/aurasphere/botmill/telegram/model/Sticker.java new file mode 100644 index 0000000..4992d5f --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/Sticker.java @@ -0,0 +1,222 @@ +package co.aurasphere.botmill.telegram.model; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +/** + * This object represents a sticker. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class Sticker implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Unique identifier for this file. + */ + @SerializedName("file_id") + private String fileId; + + /** + * Sticker width. + */ + private int width; + + /** + * Sticker height. + */ + private int height; + + /** + * Optional. Sticker thumbnail in .webp or .jpg format. + */ + private PhotoSize thumb; + + /** + * Optional. Emoji associated with the sticker. + */ + private String emoji; + + /** + * Optional. File size. + */ + @SerializedName("file_size") + private int fileSize; + + /** + * Gets the {@link #fileId}. + * + * @return the {@link #fileId}. + */ + public String getFileId() { + return fileId; + } + + /** + * Sets the {@link #fileId}. + * + * @param fileId the {@link #fileId} to set. + */ + public void setFileId(String fileId) { + this.fileId = fileId; + } + + /** + * Gets the {@link #width}. + * + * @return the {@link #width}. + */ + public int getWidth() { + return width; + } + + /** + * Sets the {@link #width}. + * + * @param width the {@link #width} to set. + */ + public void setWidth(int width) { + this.width = width; + } + + /** + * Gets the {@link #height}. + * + * @return the {@link #height}. + */ + public int getHeight() { + return height; + } + + /** + * Sets the {@link #height}. + * + * @param height the {@link #height} to set. + */ + public void setHeight(int height) { + this.height = height; + } + + /** + * Gets the {@link #thumb}. + * + * @return the {@link #thumb}. + */ + public PhotoSize getThumb() { + return thumb; + } + + /** + * Sets the {@link #thumb}. + * + * @param thumb the {@link #thumb} to set. + */ + public void setThumb(PhotoSize thumb) { + this.thumb = thumb; + } + + /** + * Gets the {@link #emoji}. + * + * @return the {@link #emoji}. + */ + public String getEmoji() { + return emoji; + } + + /** + * Sets the {@link #emoji}. + * + * @param emoji the {@link #emoji} to set. + */ + public void setEmoji(String emoji) { + this.emoji = emoji; + } + + /** + * Gets the {@link #fileSize}. + * + * @return the {@link #fileSize}. + */ + public int getFileSize() { + return fileSize; + } + + /** + * Sets the {@link #fileSize}. + * + * @param fileSize the {@link #fileSize} to set. + */ + public void setFileSize(int fileSize) { + this.fileSize = fileSize; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((emoji == null) ? 0 : emoji.hashCode()); + result = prime * result + ((fileId == null) ? 0 : fileId.hashCode()); + result = prime * result + fileSize; + result = prime * result + height; + result = prime * result + ((thumb == null) ? 0 : thumb.hashCode()); + result = prime * result + width; + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Sticker other = (Sticker) obj; + if (emoji == null) { + if (other.emoji != null) + return false; + } else if (!emoji.equals(other.emoji)) + return false; + if (fileId == null) { + if (other.fileId != null) + return false; + } else if (!fileId.equals(other.fileId)) + return false; + if (fileSize != other.fileSize) + return false; + if (height != other.height) + return false; + if (thumb == null) { + if (other.thumb != null) + return false; + } else if (!thumb.equals(other.thumb)) + return false; + if (width != other.width) + return false; + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Sticker [fileId=" + fileId + ", width=" + width + ", height=" + + height + ", thumb=" + thumb + ", emoji=" + emoji + + ", fileSize=" + fileSize + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/UserProfilePhotos.java b/src/main/java/co/aurasphere/botmill/telegram/model/UserProfilePhotos.java new file mode 100644 index 0000000..a10a012 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/UserProfilePhotos.java @@ -0,0 +1,111 @@ +package co.aurasphere.botmill.telegram.model; + +import java.io.Serializable; +import java.util.List; + +import com.google.gson.annotations.SerializedName; + +/** + * This object represent a user's profile pictures. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class UserProfilePhotos implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Total number of profile pictures the target user has. + */ + @SerializedName("total_count") + private int totalCount; + + /** + * Requested profile pictures (in up to 4 sizes each). + */ + private List photos; + + /** + * Gets the {@link #totalCount}. + * + * @return the {@link #totalCount}. + */ + public int getTotalCount() { + return totalCount; + } + + /** + * Sets the {@link #totalCount}. + * + * @param totalCount the {@link #totalCount} to set. + */ + public void setTotalCount(int totalCount) { + this.totalCount = totalCount; + } + + /** + * Gets the {@link #photos}. + * + * @return the {@link #photos}. + */ + public List getPhotos() { + return photos; + } + + /** + * Sets the {@link #photos}. + * + * @param photos the {@link #photos} to set. + */ + public void setPhotos(List photos) { + this.photos = photos; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((photos == null) ? 0 : photos.hashCode()); + result = prime * result + totalCount; + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + UserProfilePhotos other = (UserProfilePhotos) obj; + if (photos == null) { + if (other.photos != null) + return false; + } else if (!photos.equals(other.photos)) + return false; + if (totalCount != other.totalCount) + return false; + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "UserProfilePhotos [totalCount=" + totalCount + ", photos=" + + photos + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/Venue.java b/src/main/java/co/aurasphere/botmill/telegram/model/Venue.java new file mode 100644 index 0000000..08b74d3 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/Venue.java @@ -0,0 +1,174 @@ +package co.aurasphere.botmill.telegram.model; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +/** + * This object represents a venue. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class Venue implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Venue location. + */ + private Location location; + + /** + * Name of the venue. + */ + private String title; + + /** + * Address of the venue. + */ + private String address; + + /** + * Optional. Foursquare identifier of the venue. + */ + @SerializedName("foursquare_id") + private String foursquareId; + + /** + * Gets the {@link #location}. + * + * @return the {@link #location}. + */ + public Location getLocation() { + return location; + } + + /** + * Sets the {@link #location}. + * + * @param location the {@link #location} to set. + */ + public void setLocation(Location location) { + this.location = location; + } + + /** + * Gets the {@link #title}. + * + * @return the {@link #title}. + */ + public String getTitle() { + return title; + } + + /** + * Sets the {@link #title}. + * + * @param title the {@link #title} to set. + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * Gets the {@link #address}. + * + * @return the {@link #address}. + */ + public String getAddress() { + return address; + } + + /** + * Sets the {@link #address}. + * + * @param address the {@link #address} to set. + */ + public void setAddress(String address) { + this.address = address; + } + + /** + * Gets the {@link #foursquareId}. + * + * @return the {@link #foursquareId}. + */ + public String getFoursquareId() { + return foursquareId; + } + + /** + * Sets the {@link #foursquareId}. + * + * @param foursquareId the {@link #foursquareId} to set. + */ + public void setFoursquareId(String foursquareId) { + this.foursquareId = foursquareId; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((address == null) ? 0 : address.hashCode()); + result = prime * result + + ((foursquareId == null) ? 0 : foursquareId.hashCode()); + result = prime * result + + ((location == null) ? 0 : location.hashCode()); + result = prime * result + ((title == null) ? 0 : title.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Venue other = (Venue) obj; + if (address == null) { + if (other.address != null) + return false; + } else if (!address.equals(other.address)) + return false; + if (foursquareId == null) { + if (other.foursquareId != null) + return false; + } else if (!foursquareId.equals(other.foursquareId)) + return false; + if (location == null) { + if (other.location != null) + return false; + } else if (!location.equals(other.location)) + return false; + if (title == null) { + if (other.title != null) + return false; + } else if (!title.equals(other.title)) + return false; + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Venue [location=" + location + ", title=" + title + + ", address=" + address + ", foursquareId=" + foursquareId + + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/Video.java b/src/main/java/co/aurasphere/botmill/telegram/model/Video.java new file mode 100644 index 0000000..1de34b9 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/Video.java @@ -0,0 +1,249 @@ +package co.aurasphere.botmill.telegram.model; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +/** + * This object represents a video file. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class Video implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Unique identifier for this file. + */ + @SerializedName("file_id") + private String fileId; + + /** + * Video width as defined by sender. + */ + private int width; + + /** + * Video height as defined by sender. + */ + private int height; + + /** + * Duration of the video in seconds as defined by sender. + */ + private int duration; + + /** + * Optional. Video thumbnail. + */ + private PhotoSize thumb; + + /** + * Optional. Mime type of a file as defined by sender. + */ + @SerializedName("mime_type") + private String mimeType; + + /** + * Optional. File size. + */ + @SerializedName("file_size") + private int fileSize; + + /** + * Gets the {@link #fileId}. + * + * @return the {@link #fileId}. + */ + public String getFileId() { + return fileId; + } + + /** + * Sets the {@link #fileId}. + * + * @param fileId the {@link #fileId} to set. + */ + public void setFileId(String fileId) { + this.fileId = fileId; + } + + /** + * Gets the {@link #width}. + * + * @return the {@link #width}. + */ + public int getWidth() { + return width; + } + + /** + * Sets the {@link #width}. + * + * @param width the {@link #width} to set. + */ + public void setWidth(int width) { + this.width = width; + } + + /** + * Gets the {@link #height}. + * + * @return the {@link #height}. + */ + public int getHeight() { + return height; + } + + /** + * Sets the {@link #height}. + * + * @param height the {@link #height} to set. + */ + public void setHeight(int height) { + this.height = height; + } + + /** + * Gets the {@link #duration}. + * + * @return the {@link #duration}. + */ + public int getDuration() { + return duration; + } + + /** + * Sets the {@link #duration}. + * + * @param duration the {@link #duration} to set. + */ + public void setDuration(int duration) { + this.duration = duration; + } + + /** + * Gets the {@link #thumb}. + * + * @return the {@link #thumb}. + */ + public PhotoSize getThumb() { + return thumb; + } + + /** + * Sets the {@link #thumb}. + * + * @param thumb the {@link #thumb} to set. + */ + public void setThumb(PhotoSize thumb) { + this.thumb = thumb; + } + + /** + * Gets the {@link #mimeType}. + * + * @return the {@link #mimeType}. + */ + public String getMimeType() { + return mimeType; + } + + /** + * Sets the {@link #mimeType}. + * + * @param mimeType the {@link #mimeType} to set. + */ + public void setMimeType(String mimeType) { + this.mimeType = mimeType; + } + + /** + * Gets the {@link #fileSize}. + * + * @return the {@link #fileSize}. + */ + public int getFileSize() { + return fileSize; + } + + /** + * Sets the {@link #fileSize}. + * + * @param fileSize the {@link #fileSize} to set. + */ + public void setFileSize(int fileSize) { + this.fileSize = fileSize; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + duration; + result = prime * result + ((fileId == null) ? 0 : fileId.hashCode()); + result = prime * result + fileSize; + result = prime * result + height; + result = prime * result + + ((mimeType == null) ? 0 : mimeType.hashCode()); + result = prime * result + ((thumb == null) ? 0 : thumb.hashCode()); + result = prime * result + width; + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Video other = (Video) obj; + if (duration != other.duration) + return false; + if (fileId == null) { + if (other.fileId != null) + return false; + } else if (!fileId.equals(other.fileId)) + return false; + if (fileSize != other.fileSize) + return false; + if (height != other.height) + return false; + if (mimeType == null) { + if (other.mimeType != null) + return false; + } else if (!mimeType.equals(other.mimeType)) + return false; + if (thumb == null) { + if (other.thumb != null) + return false; + } else if (!thumb.equals(other.thumb)) + return false; + if (width != other.width) + return false; + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Video [fileId=" + fileId + ", width=" + width + ", height=" + + height + ", duration=" + duration + ", thumb=" + thumb + + ", mimeType=" + mimeType + ", fileSize=" + fileSize + "]"; + } +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/Voice.java b/src/main/java/co/aurasphere/botmill/telegram/model/Voice.java new file mode 100644 index 0000000..a44f668 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/Voice.java @@ -0,0 +1,167 @@ +package co.aurasphere.botmill.telegram.model; + +import java.io.Serializable; + +import com.google.gson.annotations.SerializedName; + +/** + * This object represents a voice note. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class Voice implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Unique identifier for this file. + */ + @SerializedName("file_id") + private String fileId; + + /** + * Duration of the audio in seconds as defined by sender. + */ + private int duration; + + /** + * Optional. MIME type of the file as defined by sender. + */ + @SerializedName("mime_type") + private String mimeType; + + /** + * Optional. File size. + */ + @SerializedName("file_size") + private int fileSize; + + /** + * Gets the {@link #fileId}. + * + * @return the {@link #fileId}. + */ + public String getFileId() { + return fileId; + } + + /** + * Sets the {@link #fileId}. + * + * @param fileId the {@link #fileId} to set. + */ + public void setFileId(String fileId) { + this.fileId = fileId; + } + + /** + * Gets the {@link #duration}. + * + * @return the {@link #duration}. + */ + public int getDuration() { + return duration; + } + + /** + * Sets the {@link #duration}. + * + * @param duration the {@link #duration} to set. + */ + public void setDuration(int duration) { + this.duration = duration; + } + + /** + * Gets the {@link #mimeType}. + * + * @return the {@link #mimeType}. + */ + public String getMimeType() { + return mimeType; + } + + /** + * Sets the {@link #mimeType}. + * + * @param mimeType the {@link #mimeType} to set. + */ + public void setMimeType(String mimeType) { + this.mimeType = mimeType; + } + + /** + * Gets the {@link #fileSize}. + * + * @return the {@link #fileSize}. + */ + public int getFileSize() { + return fileSize; + } + + /** + * Sets the {@link #fileSize}. + * + * @param fileSize the {@link #fileSize} to set. + */ + public void setFileSize(int fileSize) { + this.fileSize = fileSize; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + duration; + result = prime * result + ((fileId == null) ? 0 : fileId.hashCode()); + result = prime * result + fileSize; + result = prime * result + + ((mimeType == null) ? 0 : mimeType.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Voice other = (Voice) obj; + if (duration != other.duration) + return false; + if (fileId == null) { + if (other.fileId != null) + return false; + } else if (!fileId.equals(other.fileId)) + return false; + if (fileSize != other.fileSize) + return false; + if (mimeType == null) { + if (other.mimeType != null) + return false; + } else if (!mimeType.equals(other.mimeType)) + return false; + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Voice [fileId=" + fileId + ", duration=" + duration + + ", mimeType=" + mimeType + ", fileSize=" + fileSize + "]"; + } +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/game/Animation.java b/src/main/java/co/aurasphere/botmill/telegram/model/game/Animation.java new file mode 100644 index 0000000..147881b --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/game/Animation.java @@ -0,0 +1,209 @@ +package co.aurasphere.botmill.telegram.model.game; + +import java.io.Serializable; + +import co.aurasphere.botmill.telegram.model.PhotoSize; + +import com.google.gson.annotations.SerializedName; + +/** + * You can provide an animation for your {@link Game} so that it looks stylish + * in chats (check out Lumberjack for an example). This object represents an + * animation file to be displayed in the message containing a game. + * + * @see Telegram Games. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class Animation implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Unique file identifier. + */ + @SerializedName("file_id") + private String fileId; + + /** + * Optional. Animation thumbnail as defined by sender. + */ + private PhotoSize thumb; + + /** + * Optional. Original animation filename as defined by sender. + */ + @SerializedName("file_name") + private String fileName; + + /** + * Optional. MIME type of the file as defined by sender. + */ + @SerializedName("mime_type") + private String mimeType; + + /** + * Optional. File size. + */ + @SerializedName("file_size") + private int fileSize; + + /** + * Gets the {@link #fileId}. + * + * @return the {@link #fileId}. + */ + public String getFileId() { + return fileId; + } + + /** + * Sets the {@link #fileId}. + * + * @param fileId the {@link #fileId} to set. + */ + public void setFileId(String fileId) { + this.fileId = fileId; + } + + /** + * Gets the {@link #thumb}. + * + * @return the {@link #thumb}. + */ + public PhotoSize getThumb() { + return thumb; + } + + /** + * Sets the {@link #thumb}. + * + * @param thumb the {@link #thumb} to set. + */ + public void setThumb(PhotoSize thumb) { + this.thumb = thumb; + } + + /** + * Gets the {@link #fileName}. + * + * @return the {@link #fileName}. + */ + public String getFileName() { + return fileName; + } + + /** + * Sets the {@link #fileName}. + * + * @param fileName the {@link #fileName} to set. + */ + public void setFileName(String fileName) { + this.fileName = fileName; + } + + /** + * Gets the {@link #mimeType}. + * + * @return the {@link #mimeType}. + */ + public String getMimeType() { + return mimeType; + } + + /** + * Sets the {@link #mimeType}. + * + * @param mimeType the {@link #mimeType} to set. + */ + public void setMimeType(String mimeType) { + this.mimeType = mimeType; + } + + /** + * Gets the {@link #fileSize}. + * + * @return the {@link #fileSize}. + */ + public int getFileSize() { + return fileSize; + } + + /** + * Sets the {@link #fileSize}. + * + * @param fileSize the {@link #fileSize} to set. + */ + public void setFileSize(int fileSize) { + this.fileSize = fileSize; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((fileId == null) ? 0 : fileId.hashCode()); + result = prime * result + + ((fileName == null) ? 0 : fileName.hashCode()); + result = prime * result + fileSize; + result = prime * result + + ((mimeType == null) ? 0 : mimeType.hashCode()); + result = prime * result + ((thumb == null) ? 0 : thumb.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Animation other = (Animation) obj; + if (fileId == null) { + if (other.fileId != null) + return false; + } else if (!fileId.equals(other.fileId)) + return false; + if (fileName == null) { + if (other.fileName != null) + return false; + } else if (!fileName.equals(other.fileName)) + return false; + if (fileSize != other.fileSize) + return false; + if (mimeType == null) { + if (other.mimeType != null) + return false; + } else if (!mimeType.equals(other.mimeType)) + return false; + if (thumb == null) { + if (other.thumb != null) + return false; + } else if (!thumb.equals(other.thumb)) + return false; + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Animation [fileId=" + fileId + ", thumb=" + thumb + + ", fileName=" + fileName + ", mimeType=" + mimeType + + ", fileSize=" + fileSize + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/game/CallbackGame.java b/src/main/java/co/aurasphere/botmill/telegram/model/game/CallbackGame.java new file mode 100644 index 0000000..f2743ab --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/game/CallbackGame.java @@ -0,0 +1,27 @@ +package co.aurasphere.botmill.telegram.model.game; + +import java.io.Serializable; + +/** + * A placeholder, currently holds no information. Use BotFather to set up your + * game. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class CallbackGame implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "CallbackGame []"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/game/Game.java b/src/main/java/co/aurasphere/botmill/telegram/model/game/Game.java new file mode 100644 index 0000000..197852c --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/game/Game.java @@ -0,0 +1,237 @@ +package co.aurasphere.botmill.telegram.model.game; + +import java.io.Serializable; +import java.util.List; + +import co.aurasphere.botmill.telegram.model.MessageEntity; +import co.aurasphere.botmill.telegram.model.PhotoSize; + +import com.google.gson.annotations.SerializedName; + +/** + * This object represents a game. Use BotFather to create and edit games, their + * short names will act as unique identifiers. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class Game implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Title of the game. + */ + private String title; + + /** + * Description of the game. + */ + private String description; + + /** + * Photo that will be displayed in the game message in chats. + */ + private List photo; + + // TODO: link these javadoc methods + /** + * Optional. Brief description of the game or high scores included in the + * game message. Can be automatically edited to include current high scores + * for the game when the bot calls setGameScore, or manually edited using + * editMessageText. 0-4096 characters. + */ + private String text; + + /** + * Optional. Special entities that appear in text, such as usernames, URLs, + * bot commands, etc. + */ + @SerializedName("text_entities") + private List textEntities; + + /** + * Optional. Animation that will be displayed in the game message in chats. + * Upload via BotFather. + */ + private Animation animation; + + /** + * Gets the {@link #title}. + * + * @return the {@link #title}. + */ + public String getTitle() { + return title; + } + + /** + * Sets the {@link #title}. + * + * @param title the {@link #title} to set. + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * Gets the {@link #description}. + * + * @return the {@link #description}. + */ + public String getDescription() { + return description; + } + + /** + * Sets the {@link #description}. + * + * @param description the {@link #description} to set. + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * Gets the {@link #photo}. + * + * @return the {@link #photo}. + */ + public List getPhoto() { + return photo; + } + + /** + * Sets the {@link #photo}. + * + * @param photo the {@link #photo} to set. + */ + public void setPhoto(List photo) { + this.photo = photo; + } + + /** + * Gets the {@link #text}. + * + * @return the {@link #text}. + */ + public String getText() { + return text; + } + + /** + * Sets the {@link #text}. + * + * @param text the {@link #text} to set. + */ + public void setText(String text) { + this.text = text; + } + + /** + * Gets the {@link #textEntities}. + * + * @return the {@link #textEntities}. + */ + public List getTextEntities() { + return textEntities; + } + + /** + * Sets the {@link #textEntities}. + * + * @param textEntities the {@link #textEntities} to set. + */ + public void setTextEntities(List textEntities) { + this.textEntities = textEntities; + } + + /** + * Gets the {@link #animation}. + * + * @return the {@link #animation}. + */ + public Animation getAnimation() { + return animation; + } + + /** + * Sets the {@link #animation}. + * + * @param animation the {@link #animation} to set. + */ + public void setAnimation(Animation animation) { + this.animation = animation; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((description == null) ? 0 : description.hashCode()); + result = prime * result + ((photo == null) ? 0 : photo.hashCode()); + result = prime * result + ((text == null) ? 0 : text.hashCode()); + result = prime * result + + ((textEntities == null) ? 0 : textEntities.hashCode()); + result = prime * result + ((title == null) ? 0 : title.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Game other = (Game) obj; + if (description == null) { + if (other.description != null) + return false; + } else if (!description.equals(other.description)) + return false; + if (photo == null) { + if (other.photo != null) + return false; + } else if (!photo.equals(other.photo)) + return false; + if (text == null) { + if (other.text != null) + return false; + } else if (!text.equals(other.text)) + return false; + if (textEntities == null) { + if (other.textEntities != null) + return false; + } else if (!textEntities.equals(other.textEntities)) + return false; + if (title == null) { + if (other.title != null) + return false; + } else if (!title.equals(other.title)) + return false; + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Game [title=" + title + ", description=" + description + + ", photo=" + photo + ", text=" + text + ", textEntities=" + + textEntities + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/game/GameHighScore.java b/src/main/java/co/aurasphere/botmill/telegram/model/game/GameHighScore.java new file mode 100644 index 0000000..8a4f272 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/game/GameHighScore.java @@ -0,0 +1,134 @@ +package co.aurasphere.botmill.telegram.model.game; + +import java.io.Serializable; + +import co.aurasphere.botmill.telegram.model.User; + +/** + * This object represents one row of the high scores table for a game. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class GameHighScore implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Position in high score table for the game. + */ + private int position; + + /** + * User. + */ + private User user; + + /** + * Score. + */ + private int score; + + /** + * Gets the {@link #position}. + * + * @return the {@link #position}. + */ + public int getPosition() { + return position; + } + + /** + * Sets the {@link #position}. + * + * @param position the {@link #position} to set. + */ + public void setPosition(int position) { + this.position = position; + } + + /** + * Gets the {@link #user}. + * + * @return the {@link #user}. + */ + public User getUser() { + return user; + } + + /** + * Sets the {@link #user}. + * + * @param user the {@link #user} to set. + */ + public void setUser(User user) { + this.user = user; + } + + /** + * Gets the {@link #score}. + * + * @return the {@link #score}. + */ + public int getScore() { + return score; + } + + /** + * Sets the {@link #score}. + * + * @param score the {@link #score} to set. + */ + public void setScore(int score) { + this.score = score; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + position; + result = prime * result + score; + result = prime * result + ((user == null) ? 0 : user.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + GameHighScore other = (GameHighScore) obj; + if (position != other.position) + return false; + if (score != other.score) + return false; + if (user == null) { + if (other.user != null) + return false; + } else if (!user.equals(other.user)) + return false; + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "GameHighScore [position=" + position + ", user=" + user + + ", score=" + score + "]"; + } +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/ChosenInlineResult.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/ChosenInlineResult.java new file mode 100644 index 0000000..709fa5b --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/ChosenInlineResult.java @@ -0,0 +1,201 @@ +package co.aurasphere.botmill.telegram.model.inline; + +import java.io.Serializable; + +import co.aurasphere.botmill.telegram.model.CallbackQuery; +import co.aurasphere.botmill.telegram.model.InlineKeyboardMarkup; +import co.aurasphere.botmill.telegram.model.Location; +import co.aurasphere.botmill.telegram.model.User; + +import com.google.gson.annotations.SerializedName; + +/** + * Represents a result of an inline query that was chosen by the user and sent + * to their chat partner. + * + * @author Donato Rimenti + * @date Dec 27, 2016 + */ +public class ChosenInlineResult implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * The unique identifier for the result that was chosen. + */ + @SerializedName("result_id") + private String resultId; + + /** + * The user that chose the result. + */ + private User from; + + /** + * Optional. Sender location, only for bots that require user location. + */ + private Location location; + + // TODO: link below javadoc to edit message when implemented. + /** + * Optional. Identifier of the sent inline message. Available only if there + * is an {@link InlineKeyboardMarkup} attached to the message. Will be also + * received in @link {@link CallbackQuery} and can be used to edit the + * message. + */ + @SerializedName("inline_message_id") + private String inlineMessageId; + + /** + * The query that was used to obtain the result. + */ + private String query; + + /** + * Gets the {@link #resultId}. + * + * @return the {@link #resultId}. + */ + public String getResultId() { + return resultId; + } + + /** + * Sets the {@link #resultId}. + * + * @param resultId the {@link #resultId} to set. + */ + public void setResultId(String resultId) { + this.resultId = resultId; + } + + /** + * Gets the {@link #from}. + * + * @return the {@link #from}. + */ + public User getFrom() { + return from; + } + + /** + * Sets the {@link #from}. + * + * @param from the {@link #from} to set. + */ + public void setFrom(User from) { + this.from = from; + } + + /** + * Gets the {@link #location}. + * + * @return the {@link #location}. + */ + public Location getLocation() { + return location; + } + + /** + * Sets the {@link #location}. + * + * @param location the {@link #location} to set. + */ + public void setLocation(Location location) { + this.location = location; + } + + /** + * Gets the {@link #inlineMessageId}. + * + * @return the {@link #inlineMessageId}. + */ + public String getInlineMessageId() { + return inlineMessageId; + } + + /** + * Sets the {@link #inlineMessageId}. + * + * @param inlineMessageId the {@link #inlineMessageId} to set. + */ + public void setInlineMessageId(String inlineMessageId) { + this.inlineMessageId = inlineMessageId; + } + + /** + * Gets the {@link #query}. + * + * @return the {@link #query}. + */ + public String getQuery() { + return query; + } + + /** + * Sets the {@link #query}. + * + * @param query the {@link #query} to set. + */ + public void setQuery(String query) { + this.query = query; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((inlineMessageId == null) ? 0 : inlineMessageId.hashCode()); + result = prime * result + ((query == null) ? 0 : query.hashCode()); + result = prime * result + + ((resultId == null) ? 0 : resultId.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ChosenInlineResult other = (ChosenInlineResult) obj; + if (inlineMessageId == null) { + if (other.inlineMessageId != null) + return false; + } else if (!inlineMessageId.equals(other.inlineMessageId)) + return false; + if (query == null) { + if (other.query != null) + return false; + } else if (!query.equals(other.query)) + return false; + if (resultId == null) { + if (other.resultId != null) + return false; + } else if (!resultId.equals(other.resultId)) + return false; + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "ChosenInlineResult [resultId=" + resultId + + ", inlineMessageId=" + inlineMessageId + ", query=" + query + + "]"; + } +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQuery.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQuery.java new file mode 100644 index 0000000..bda0e47 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQuery.java @@ -0,0 +1,203 @@ +package co.aurasphere.botmill.telegram.model.inline; + +import java.io.Serializable; + +import co.aurasphere.botmill.telegram.model.Location; +import co.aurasphere.botmill.telegram.model.User; + +/** + * This object represents an incoming inline query. When the user sends an empty + * query, your bot could return some default or trending results. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class InlineQuery implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Unique identifier for this query. + */ + private String id; + + /** + * Sender. + */ + private User from; + + /** + * Optional. Sender location, only for bots that request user location. + */ + private Location location; + + // TODO: validation? + /** + * Text of the query (up to 512 characters). + */ + private String query; + + /** + * Offset of the results to be returned, can be controlled by the bot. + */ + private String offset; + + /** + * Gets the {@link #id}. + * + * @return the {@link #id}. + */ + public String getId() { + return id; + } + + /** + * Sets the {@link #id}. + * + * @param id the {@link #id} to set. + */ + public void setId(String id) { + this.id = id; + } + + /** + * Gets the {@link #from}. + * + * @return the {@link #from}. + */ + public User getFrom() { + return from; + } + + /** + * Sets the {@link #from}. + * + * @param from the {@link #from} to set. + */ + public void setFrom(User from) { + this.from = from; + } + + /** + * Gets the {@link #location}. + * + * @return the {@link #location}. + */ + public Location getLocation() { + return location; + } + + /** + * Sets the {@link #location}. + * + * @param location the {@link #location} to set. + */ + public void setLocation(Location location) { + this.location = location; + } + + /** + * Gets the {@link #query}. + * + * @return the {@link #query}. + */ + public String getQuery() { + return query; + } + + /** + * Sets the {@link #query}. + * + * @param query the {@link #query} to set. + */ + public void setQuery(String query) { + this.query = query; + } + + /** + * Gets the {@link #offset}. + * + * @return the {@link #offset}. + */ + public String getOffset() { + return offset; + } + + /** + * Sets the {@link #offset}. + * + * @param offset the {@link #offset} to set. + */ + public void setOffset(String offset) { + this.offset = offset; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((from == null) ? 0 : from.hashCode()); + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + + ((location == null) ? 0 : location.hashCode()); + result = prime * result + ((offset == null) ? 0 : offset.hashCode()); + result = prime * result + ((query == null) ? 0 : query.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + InlineQuery other = (InlineQuery) obj; + if (from == null) { + if (other.from != null) + return false; + } else if (!from.equals(other.from)) + return false; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + if (location == null) { + if (other.location != null) + return false; + } else if (!location.equals(other.location)) + return false; + if (offset == null) { + if (other.offset != null) + return false; + } else if (!offset.equals(other.offset)) + return false; + if (query == null) { + if (other.query != null) + return false; + } else if (!query.equals(other.query)) + return false; + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "InlineQuery [id=" + id + ", from=" + from + ", location=" + + location + ", query=" + query + ", offset=" + offset + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResult.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResult.java new file mode 100644 index 0000000..c592beb --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResult.java @@ -0,0 +1,124 @@ +package co.aurasphere.botmill.telegram.model.inline; + +import java.io.Serializable; + +/** + * This object represents one result of an inline query. + * + * @author Donato Rimenti + * @date Dec 26, 2016 + */ +public class InlineQueryResult implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Type of the result. + */ + protected InlineQueryResultType type; + + /** + * Unique identifier for this result, 1-64 Bytes. + */ + protected String id; + + /** + * Instantiates a new InlineQueryResult. + * + * @param type + * the {@link #type}. + */ + public InlineQueryResult(InlineQueryResultType type) { + this.type = type; + } + + /** + * Gets the {@link #type}. + * + * @return the {@link #type}. + */ + public InlineQueryResultType getType() { + return type; + } + + /** + * Sets the {@link #type}. + * + * @param type + * the {@link #type} to set. + */ + public void setType(InlineQueryResultType type) { + this.type = type; + } + + /** + * Gets the {@link #id}. + * + * @return the {@link #id}. + */ + public String getId() { + return id; + } + + /** + * Sets the {@link #id}. + * + * @param id + * the {@link #id} to set. + */ + public void setId(String id) { + this.id = id; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + result = prime * result + ((type == null) ? 0 : type.hashCode()); + return result; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + InlineQueryResult other = (InlineQueryResult) obj; + if (id == null) { + if (other.id != null) + return false; + } else if (!id.equals(other.id)) + return false; + if (type != other.type) + return false; + return true; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "InlineQueryResult [type=" + type + ", id=" + id + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultArticle.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultArticle.java new file mode 100644 index 0000000..29704d1 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultArticle.java @@ -0,0 +1,318 @@ +package co.aurasphere.botmill.telegram.model.inline; + +import co.aurasphere.botmill.telegram.model.InlineKeyboardMarkup; +import co.aurasphere.botmill.telegram.model.inline.input.InlineQueryInputMessageContentResult; + +import com.google.gson.annotations.SerializedName; + +/** + * Represents a link to an article or web page. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class InlineQueryResultArticle extends + InlineQueryInputMessageContentResult { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Optional. URL of the result. + */ + private String url; + + /** + * Optional. Pass True, if you don't want the URL to be shown in the + * message. + */ + @SerializedName("hide_url") + private boolean hideUrl; + + /** + * Optional. Short description of the result. + */ + private String description; + + /** + * Optional. Thumbnail width. + */ + @SerializedName("thumb_width") + private int thumbWidth; + + /** + * Optional. Thumbnail height. + */ + @SerializedName("thumb_height") + private int thumbHeight; + + /** + * Title of the result. + */ + private String title; + + /** + * Optional. Inline keyboard attached to the message. + */ + @SerializedName("reply_markup") + private InlineKeyboardMarkup replyMarkup; + + /** + * Optional. Url of the thumbnail for the result. + */ + @SerializedName("thumb_url") + private String thumbUrl; + + /** + * Instantiates a new InlineQueryResultArticle. + */ + public InlineQueryResultArticle() { + super(InlineQueryResultType.ARTICLE); + } + + /** + * Gets the {@link #url}. + * + * @return the {@link #url}. + */ + public String getUrl() { + return url; + } + + /** + * Sets the {@link #url}. + * + * @param url + * the {@link #url} to set. + */ + public void setUrl(String url) { + this.url = url; + } + + /** + * Gets the {@link #hideUrl}. + * + * @return the {@link #hideUrl}. + */ + public boolean isHideUrl() { + return hideUrl; + } + + /** + * Sets the {@link #hideUrl}. + * + * @param hideUrl + * the {@link #hideUrl} to set. + */ + public void setHideUrl(boolean hideUrl) { + this.hideUrl = hideUrl; + } + + /** + * Gets the {@link #description}. + * + * @return the {@link #description}. + */ + public String getDescription() { + return description; + } + + /** + * Sets the {@link #description}. + * + * @param description + * the {@link #description} to set. + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * Gets the {@link #thumbWidth}. + * + * @return the {@link #thumbWidth}. + */ + public int getThumbWidth() { + return thumbWidth; + } + + /** + * Sets the {@link #thumbWidth}. + * + * @param thumbWidth + * the {@link #thumbWidth} to set. + */ + public void setThumbWidth(int thumbWidth) { + this.thumbWidth = thumbWidth; + } + + /** + * Gets the {@link #thumbHeight}. + * + * @return the {@link #thumbHeight}. + */ + public int getThumbHeight() { + return thumbHeight; + } + + /** + * Sets the {@link #thumbHeight}. + * + * @param thumbHeight + * the {@link #thumbHeight} to set. + */ + public void setThumbHeight(int thumbHeight) { + this.thumbHeight = thumbHeight; + } + + /** + * Gets the {@link #title}. + * + * @return the {@link #title}. + */ + public String getTitle() { + return title; + } + + /** + * Sets the {@link #title}. + * + * @param title + * the {@link #title} to set. + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * Gets the {@link #replyMarkup}. + * + * @return the {@link #replyMarkup}. + */ + public InlineKeyboardMarkup getReplyMarkup() { + return replyMarkup; + } + + /** + * Sets the {@link #replyMarkup}. + * + * @param replyMarkup + * the {@link #replyMarkup} to set. + */ + public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) { + this.replyMarkup = replyMarkup; + } + + /** + * Gets the {@link #thumbUrl}. + * + * @return the {@link #thumbUrl}. + */ + public String getThumbUrl() { + return thumbUrl; + } + + /** + * Sets the {@link #thumbUrl}. + * + * @param thumbUrl + * the {@link #thumbUrl} to set. + */ + public void setThumbUrl(String thumbUrl) { + this.thumbUrl = thumbUrl; + } + + /* + * (non-Javadoc) + * + * @see co.aurasphere.botmill.telegram.model.inline.input. + * InlineQueryInputMessageContentResult#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + + ((description == null) ? 0 : description.hashCode()); + result = prime * result + (hideUrl ? 1231 : 1237); + result = prime * result + + ((replyMarkup == null) ? 0 : replyMarkup.hashCode()); + result = prime * result + thumbHeight; + result = prime * result + + ((thumbUrl == null) ? 0 : thumbUrl.hashCode()); + result = prime * result + thumbWidth; + result = prime * result + ((title == null) ? 0 : title.hashCode()); + result = prime * result + ((url == null) ? 0 : url.hashCode()); + return result; + } + + /* + * (non-Javadoc) + * + * @see co.aurasphere.botmill.telegram.model.inline.input. + * InlineQueryInputMessageContentResult#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + InlineQueryResultArticle other = (InlineQueryResultArticle) obj; + if (description == null) { + if (other.description != null) + return false; + } else if (!description.equals(other.description)) + return false; + if (hideUrl != other.hideUrl) + return false; + if (replyMarkup == null) { + if (other.replyMarkup != null) + return false; + } else if (!replyMarkup.equals(other.replyMarkup)) + return false; + if (thumbHeight != other.thumbHeight) + return false; + if (thumbUrl == null) { + if (other.thumbUrl != null) + return false; + } else if (!thumbUrl.equals(other.thumbUrl)) + return false; + if (thumbWidth != other.thumbWidth) + return false; + if (title == null) { + if (other.title != null) + return false; + } else if (!title.equals(other.title)) + return false; + if (url == null) { + if (other.url != null) + return false; + } else if (!url.equals(other.url)) + return false; + return true; + } + + /* + * (non-Javadoc) + * + * @see co.aurasphere.botmill.telegram.model.inline.input. + * InlineQueryInputMessageContentResult#toString() + */ + @Override + public String toString() { + return "InlineQueryResultArticle [url=" + url + ", hideUrl=" + hideUrl + + ", description=" + description + ", thumbWidth=" + thumbWidth + + ", thumbHeight=" + thumbHeight + ", title=" + title + + ", replyMarkup=" + replyMarkup + ", thumbUrl=" + thumbUrl + + ", type=" + type + ", id=" + id + ", inputMessageContent=" + + inputMessageContent + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultAudio.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultAudio.java new file mode 100644 index 0000000..25e1829 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultAudio.java @@ -0,0 +1,281 @@ +package co.aurasphere.botmill.telegram.model.inline; + +import co.aurasphere.botmill.telegram.model.InlineKeyboardMarkup; +import co.aurasphere.botmill.telegram.model.inline.input.InlineQueryInputMessageContentResult; + +import com.google.gson.annotations.SerializedName; + +/** + * Represents a link to an mp3 audio file. By default, this audio file will be + * sent by the user. Alternatively, you can use input_message_content to send a + * message with the specified content instead of the audio.
+ *
+ * Note: This will only work in Telegram versions released after 9 April, 2016. + * Older clients will ignore them. + * + * @author Donato Rimenti + * @date Dec 26, 2016 + */ +public class InlineQueryResultAudio extends InlineQueryInputMessageContentResult { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * A valid URL for the audio file. + */ + @SerializedName("audio_url") + private String audioUrl; + + // TODO: validation? + /** + * Optional. Caption, 0-200 characters. + */ + private String caption; + + /** + * Optional. Performer. + */ + private String performer; + + /** + * Optional. Audio duration in seconds. + */ + @SerializedName("audio_duration") + private int audioDuration; + + /** + * Title of the result. + */ + private String title; + + /** + * Optional. Inline keyboard attached to the message. + */ + @SerializedName("reply_markup") + private InlineKeyboardMarkup replyMarkup; + + /** + * Optional. Url of the thumbnail for the result. + */ + @SerializedName("thumb_url") + private String thumbUrl; + + /** + * Instantiates a new InlineQueryResultAudio. + */ + public InlineQueryResultAudio() { + super(InlineQueryResultType.AUDIO); + } + + /** + * Gets the {@link #audioUrl}. + * + * @return the {@link #audioUrl}. + */ + public String getAudioUrl() { + return audioUrl; + } + + /** + * Sets the {@link #audioUrl}. + * + * @param audioUrl the {@link #audioUrl} to set. + */ + public void setAudioUrl(String audioUrl) { + this.audioUrl = audioUrl; + } + + /** + * Gets the {@link #caption}. + * + * @return the {@link #caption}. + */ + public String getCaption() { + return caption; + } + + /** + * Sets the {@link #caption}. + * + * @param caption the {@link #caption} to set. + */ + public void setCaption(String caption) { + this.caption = caption; + } + + /** + * Gets the {@link #performer}. + * + * @return the {@link #performer}. + */ + public String getPerformer() { + return performer; + } + + /** + * Sets the {@link #performer}. + * + * @param performer the {@link #performer} to set. + */ + public void setPerformer(String performer) { + this.performer = performer; + } + + /** + * Gets the {@link #audioDuration}. + * + * @return the {@link #audioDuration}. + */ + public int getAudioDuration() { + return audioDuration; + } + + /** + * Sets the {@link #audioDuration}. + * + * @param audioDuration the {@link #audioDuration} to set. + */ + public void setAudioDuration(int audioDuration) { + this.audioDuration = audioDuration; + } + + /** + * Gets the {@link #title}. + * + * @return the {@link #title}. + */ + public String getTitle() { + return title; + } + + /** + * Sets the {@link #title}. + * + * @param title the {@link #title} to set. + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * Gets the {@link #replyMarkup}. + * + * @return the {@link #replyMarkup}. + */ + public InlineKeyboardMarkup getReplyMarkup() { + return replyMarkup; + } + + /** + * Sets the {@link #replyMarkup}. + * + * @param replyMarkup the {@link #replyMarkup} to set. + */ + public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) { + this.replyMarkup = replyMarkup; + } + + /** + * Gets the {@link #thumbUrl}. + * + * @return the {@link #thumbUrl}. + */ + public String getThumbUrl() { + return thumbUrl; + } + + /** + * Sets the {@link #thumbUrl}. + * + * @param thumbUrl the {@link #thumbUrl} to set. + */ + public void setThumbUrl(String thumbUrl) { + this.thumbUrl = thumbUrl; + } + + /* (non-Javadoc) + * @see co.aurasphere.botmill.telegram.model.inline.input.InlineQueryInputMessageContentResult#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + audioDuration; + result = prime * result + + ((audioUrl == null) ? 0 : audioUrl.hashCode()); + result = prime * result + ((caption == null) ? 0 : caption.hashCode()); + result = prime * result + + ((performer == null) ? 0 : performer.hashCode()); + result = prime * result + + ((replyMarkup == null) ? 0 : replyMarkup.hashCode()); + result = prime * result + + ((thumbUrl == null) ? 0 : thumbUrl.hashCode()); + result = prime * result + ((title == null) ? 0 : title.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + InlineQueryResultAudio other = (InlineQueryResultAudio) obj; + if (audioDuration != other.audioDuration) + return false; + if (audioUrl == null) { + if (other.audioUrl != null) + return false; + } else if (!audioUrl.equals(other.audioUrl)) + return false; + if (caption == null) { + if (other.caption != null) + return false; + } else if (!caption.equals(other.caption)) + return false; + if (performer == null) { + if (other.performer != null) + return false; + } else if (!performer.equals(other.performer)) + return false; + if (replyMarkup == null) { + if (other.replyMarkup != null) + return false; + } else if (!replyMarkup.equals(other.replyMarkup)) + return false; + if (thumbUrl == null) { + if (other.thumbUrl != null) + return false; + } else if (!thumbUrl.equals(other.thumbUrl)) + return false; + if (title == null) { + if (other.title != null) + return false; + } else if (!title.equals(other.title)) + return false; + return true; + } + + /* (non-Javadoc) + * @see co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#toString() + */ + @Override + public String toString() { + return "InlineQueryResultAudio [audioUrl=" + audioUrl + ", caption=" + + caption + ", performer=" + performer + ", audioDuration=" + + audioDuration + ", title=" + title + ", replyMarkup=" + + replyMarkup + ", thumbUrl=" + thumbUrl + ", type=" + type + + ", id=" + id + ", inputMessageContent=" + inputMessageContent + + "]"; + } +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultContact.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultContact.java new file mode 100644 index 0000000..f3062d7 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultContact.java @@ -0,0 +1,362 @@ +package co.aurasphere.botmill.telegram.model.inline; + +import co.aurasphere.botmill.telegram.model.InlineKeyboardMarkup; +import co.aurasphere.botmill.telegram.model.inline.input.InlineQueryInputMessageContentResult; + +import com.google.gson.annotations.SerializedName; + +/** + * Represents a contact with a phone number. By default, this contact will be + * sent by the user. Alternatively, you can use input_message_content to send a + * message with the specified content instead of the contact.
+ *
+ * Note: This will only work in Telegram versions released after 9 April, 2016. + * Older clients will ignore them. + * + * @author Donato Rimenti + * @date Dec 26, 2016 + */ +public class InlineQueryResultContact extends InlineQueryInputMessageContentResult { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Contact's phone number. + */ + @SerializedName("phone_number") + private String phoneNumber; + + /** + * Contact's first name. + */ + @SerializedName("first_name") + private String firstName; + + /** + * Optional. Contact's last name. + */ + @SerializedName("last_name") + private String lastName; + + /** + * Optional. Thumbnail width. + */ + @SerializedName("thumb_width") + private int thumbWidth; + + /** + * Optional. Thumbnail height. + */ + @SerializedName("thumb_height") + private int thumbHeight; + + /** + * Title of the result. + */ + private String title; + + /** + * Optional. Inline keyboard attached to the message. + */ + @SerializedName("reply_markup") + private InlineKeyboardMarkup replyMarkup; + + /** + * Optional. Url of the thumbnail for the result. + */ + @SerializedName("thumb_url") + private String thumbUrl; + + /** + * Instantiates a new InlineQueryResultContact. + */ + public InlineQueryResultContact() { + super(InlineQueryResultType.CONTACT); + } + + /** + * Gets the {@link #phoneNumber}. + * + * @return the {@link #phoneNumber}. + */ + public String getPhoneNumber() { + return phoneNumber; + } + + /** + * Sets the {@link #phoneNumber}. + * + * @param phoneNumber the {@link #phoneNumber} to set. + */ + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + /** + * Gets the {@link #firstName}. + * + * @return the {@link #firstName}. + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets the {@link #firstName}. + * + * @param firstName the {@link #firstName} to set. + */ + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + /** + * Gets the {@link #lastName}. + * + * @return the {@link #lastName}. + */ + public String getLastName() { + return lastName; + } + + /** + * Sets the {@link #lastName}. + * + * @param lastName the {@link #lastName} to set. + */ + public void setLastName(String lastName) { + this.lastName = lastName; + } + + /** + * Gets the {@link #thumbWidth}. + * + * @return the {@link #thumbWidth}. + */ + public int getThumbWidth() { + return thumbWidth; + } + + /** + * Sets the {@link #thumbWidth}. + * + * @param thumbWidth the {@link #thumbWidth} to set. + */ + public void setThumbWidth(int thumbWidth) { + this.thumbWidth = thumbWidth; + } + + /** + * Gets the {@link #thumbHeight}. + * + * @return the {@link #thumbHeight}. + */ + public int getThumbHeight() { + return thumbHeight; + } + + /** + * Sets the {@link #thumbHeight}. + * + * @param thumbHeight the {@link #thumbHeight} to set. + */ + public void setThumbHeight(int thumbHeight) { + this.thumbHeight = thumbHeight; + } + + /** + * Gets the {@link #title}. + * + * @return the {@link #title}. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#getTitle() + */ + public String getTitle() { + return title; + } + + /** + * Sets the {@link #title}. + * + * @param title the {@link #title} to set. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#setTitle + * (java.lang.String) + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * Gets the {@link #replyMarkup}. + * + * @return the {@link #replyMarkup}. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#getReplyMarkup + * () + */ + public InlineKeyboardMarkup getReplyMarkup() { + return replyMarkup; + } + + /** + * Sets the {@link #replyMarkup}. + * + * @param replyMarkup the {@link #replyMarkup} to set. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#setReplyMarkup + * (co.aurasphere.botmill.telegram.model.core.InlineKeyboardMarkup) + */ + public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) { + this.replyMarkup = replyMarkup; + } + + /** + * Gets the {@link #thumbUrl}. + * + * @return the {@link #thumbUrl}. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#getThumbUrl + * () + */ + public String getThumbUrl() { + return thumbUrl; + } + + /** + * Sets the {@link #thumbUrl}. + * + * @param thumbUrl the {@link #thumbUrl} to set. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#setThumbUrl + * (java.lang.String) + */ + public void setThumbUrl(String thumbUrl) { + this.thumbUrl = thumbUrl; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + + ((firstName == null) ? 0 : firstName.hashCode()); + result = prime * result + + ((lastName == null) ? 0 : lastName.hashCode()); + result = prime * result + + ((phoneNumber == null) ? 0 : phoneNumber.hashCode()); + result = prime * result + + ((replyMarkup == null) ? 0 : replyMarkup.hashCode()); + result = prime * result + thumbHeight; + result = prime * result + + ((thumbUrl == null) ? 0 : thumbUrl.hashCode()); + result = prime * result + thumbWidth; + result = prime * result + ((title == null) ? 0 : title.hashCode()); + return result; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#equals( + * java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + InlineQueryResultContact other = (InlineQueryResultContact) obj; + if (firstName == null) { + if (other.firstName != null) + return false; + } else if (!firstName.equals(other.firstName)) + return false; + if (lastName == null) { + if (other.lastName != null) + return false; + } else if (!lastName.equals(other.lastName)) + return false; + if (phoneNumber == null) { + if (other.phoneNumber != null) + return false; + } else if (!phoneNumber.equals(other.phoneNumber)) + return false; + if (replyMarkup == null) { + if (other.replyMarkup != null) + return false; + } else if (!replyMarkup.equals(other.replyMarkup)) + return false; + if (thumbHeight != other.thumbHeight) + return false; + if (thumbUrl == null) { + if (other.thumbUrl != null) + return false; + } else if (!thumbUrl.equals(other.thumbUrl)) + return false; + if (thumbWidth != other.thumbWidth) + return false; + if (title == null) { + if (other.title != null) + return false; + } else if (!title.equals(other.title)) + return false; + return true; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#toString() + */ + @Override + public String toString() { + return "InlineQueryResultContact [phoneNumber=" + phoneNumber + + ", firstName=" + firstName + ", lastName=" + lastName + + ", thumbWidth=" + thumbWidth + ", thumbHeight=" + thumbHeight + + ", title=" + title + ", replyMarkup=" + replyMarkup + + ", thumbUrl=" + thumbUrl + ", type=" + type + ", id=" + id + + ", inputMessageContent=" + inputMessageContent + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultDocument.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultDocument.java new file mode 100644 index 0000000..4e7c171 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultDocument.java @@ -0,0 +1,405 @@ +package co.aurasphere.botmill.telegram.model.inline; + +import co.aurasphere.botmill.telegram.model.InlineKeyboardMarkup; +import co.aurasphere.botmill.telegram.model.inline.input.InlineQueryInputMessageContentResult; + +import com.google.gson.annotations.SerializedName; + +/** + * Represents a link to a file. By default, this file will be sent by the user + * with an optional caption. Alternatively, you can use input_message_content to + * send a message with the specified content instead of the file. Currently, + * only .PDF and .ZIP files can be sent using this method.
+ *
+ * Note: This will only work in Telegram versions released after 9 April, 2016. + * Older clients will ignore them. + * + * @author Donato Rimenti + * @date Dec 26, 2016 + */ +public class InlineQueryResultDocument extends + InlineQueryInputMessageContentResult { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + // TODO: validation? + /** + * Optional. Caption of the document to be sent, 0-200 characters. + */ + private String caption; + + /** + * A valid URL for the file. + */ + @SerializedName("document_url") + private String documentUrl; + + // TODO: enum? + /** + * Mime type of the content of the file, either “application/pdf” or + * “application/zip”. + */ + @SerializedName("mime_type") + private String mimeType; + + /** + * Optional. Short description of the result. + */ + private String description; + + /** + * Optional. Thumbnail width. + */ + @SerializedName("thumb_width") + private int thumbWidth; + + /** + * Optional. Thumbnail height. + */ + @SerializedName("thumb_height") + private int thumbHeight; + + /** + * Title of the result. + */ + private String title; + + /** + * Optional. Inline keyboard attached to the message. + */ + @SerializedName("reply_markup") + private InlineKeyboardMarkup replyMarkup; + + /** + * Optional. Url of the thumbnail for the result. + */ + @SerializedName("thumb_url") + private String thumbUrl; + + /** + * Instantiates a new InlineQueryResultDocument. + */ + public InlineQueryResultDocument() { + super(InlineQueryResultType.DOCUMENT); + } + + /** + * Gets the {@link #caption}. + * + * @return the {@link #caption}. + */ + public String getCaption() { + return caption; + } + + /** + * Sets the {@link #caption}. + * + * @param caption + * the {@link #caption} to set. + */ + public void setCaption(String caption) { + this.caption = caption; + } + + /** + * Gets the {@link #documentUrl}. + * + * @return the {@link #documentUrl}. + */ + public String getDocumentUrl() { + return documentUrl; + } + + /** + * Sets the {@link #documentUrl}. + * + * @param documentUrl + * the {@link #documentUrl} to set. + */ + public void setDocumentUrl(String documentUrl) { + this.documentUrl = documentUrl; + } + + /** + * Gets the {@link #mimeType}. + * + * @return the {@link #mimeType}. + */ + public String getMimeType() { + return mimeType; + } + + /** + * Sets the {@link #mimeType}. + * + * @param mimeType + * the {@link #mimeType} to set. + */ + public void setMimeType(String mimeType) { + this.mimeType = mimeType; + } + + /** + * Gets the {@link #description}. + * + * @return the {@link #description}. + */ + public String getDescription() { + return description; + } + + /** + * Sets the {@link #description}. + * + * @param description + * the {@link #description} to set. + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * Gets the {@link #thumbWidth}. + * + * @return the {@link #thumbWidth}. + */ + public int getThumbWidth() { + return thumbWidth; + } + + /** + * Sets the {@link #thumbWidth}. + * + * @param thumbWidth + * the {@link #thumbWidth} to set. + */ + public void setThumbWidth(int thumbWidth) { + this.thumbWidth = thumbWidth; + } + + /** + * Gets the {@link #thumbHeight}. + * + * @return the {@link #thumbHeight}. + */ + public int getThumbHeight() { + return thumbHeight; + } + + /** + * Sets the {@link #thumbHeight}. + * + * @param thumbHeight + * the {@link #thumbHeight} to set. + */ + public void setThumbHeight(int thumbHeight) { + this.thumbHeight = thumbHeight; + } + + /** + * Gets the {@link #title}. + * + * @return the {@link #title}. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#getTitle() + */ + public String getTitle() { + return title; + } + + /** + * Sets the {@link #title}. + * + * @param title + * the {@link #title} to set. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#setTitle + * (java.lang.String) + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * Gets the {@link #replyMarkup}. + * + * @return the {@link #replyMarkup}. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#getReplyMarkup + * () + */ + public InlineKeyboardMarkup getReplyMarkup() { + return replyMarkup; + } + + /** + * Sets the {@link #replyMarkup}. + * + * @param replyMarkup + * the {@link #replyMarkup} to set. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#setReplyMarkup + * (co.aurasphere.botmill.telegram.model.core.InlineKeyboardMarkup) + */ + public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) { + this.replyMarkup = replyMarkup; + } + + /** + * Gets the {@link #thumbUrl}. + * + * @return the {@link #thumbUrl}. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#getThumbUrl + * () + */ + public String getThumbUrl() { + return thumbUrl; + } + + /** + * Sets the {@link #thumbUrl}. + * + * @param thumbUrl + * the {@link #thumbUrl} to set. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#setThumbUrl + * (java.lang.String) + */ + public void setThumbUrl(String thumbUrl) { + this.thumbUrl = thumbUrl; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((caption == null) ? 0 : caption.hashCode()); + result = prime * result + + ((description == null) ? 0 : description.hashCode()); + result = prime * result + + ((documentUrl == null) ? 0 : documentUrl.hashCode()); + result = prime * result + + ((mimeType == null) ? 0 : mimeType.hashCode()); + result = prime * result + + ((replyMarkup == null) ? 0 : replyMarkup.hashCode()); + result = prime * result + thumbHeight; + result = prime * result + + ((thumbUrl == null) ? 0 : thumbUrl.hashCode()); + result = prime * result + thumbWidth; + result = prime * result + ((title == null) ? 0 : title.hashCode()); + return result; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#equals( + * java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + InlineQueryResultDocument other = (InlineQueryResultDocument) obj; + if (caption == null) { + if (other.caption != null) + return false; + } else if (!caption.equals(other.caption)) + return false; + if (description == null) { + if (other.description != null) + return false; + } else if (!description.equals(other.description)) + return false; + if (documentUrl == null) { + if (other.documentUrl != null) + return false; + } else if (!documentUrl.equals(other.documentUrl)) + return false; + if (mimeType == null) { + if (other.mimeType != null) + return false; + } else if (!mimeType.equals(other.mimeType)) + return false; + if (replyMarkup == null) { + if (other.replyMarkup != null) + return false; + } else if (!replyMarkup.equals(other.replyMarkup)) + return false; + if (thumbHeight != other.thumbHeight) + return false; + if (thumbUrl == null) { + if (other.thumbUrl != null) + return false; + } else if (!thumbUrl.equals(other.thumbUrl)) + return false; + if (thumbWidth != other.thumbWidth) + return false; + if (title == null) { + if (other.title != null) + return false; + } else if (!title.equals(other.title)) + return false; + return true; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#toString() + */ + @Override + public String toString() { + return "InlineQueryResultDocument [caption=" + caption + + ", documentUrl=" + documentUrl + ", mimeType=" + mimeType + + ", description=" + description + ", thumbWidth=" + thumbWidth + + ", thumbHeight=" + thumbHeight + ", title=" + title + + ", replyMarkup=" + replyMarkup + ", thumbUrl=" + thumbUrl + + ", type=" + type + ", id=" + id + ", inputMessageContent=" + + inputMessageContent + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultGame.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultGame.java new file mode 100644 index 0000000..7335b79 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultGame.java @@ -0,0 +1,105 @@ +package co.aurasphere.botmill.telegram.model.inline; + +import com.google.gson.annotations.SerializedName; + +/** + * Represents a Game.
+ *
+ * Note: This will only work in Telegram versions released after October 1, + * 2016. Older clients will not display any inline results if a game result is + * among them. + * + * @author Donato Rimenti + * @date Dec 26, 2016 + */ +public class InlineQueryResultGame extends InlineQueryResult { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + @SerializedName("game_short_name") + private String gameShortName; + + /** + * Instantiates a new InlineQueryResultGame. + * + * @param type + * the {@link #type}. + */ + public InlineQueryResultGame(InlineQueryResultType type) { + super(InlineQueryResultType.GAME); + } + + /** + * Gets the {@link #gameShortName}. + * + * @return the {@link #gameShortName}. + */ + public String getGameShortName() { + return gameShortName; + } + + /** + * Sets the {@link #gameShortName}. + * + * @param gameShortName + * the {@link #gameShortName} to set. + */ + public void setGameShortName(String gameShortName) { + this.gameShortName = gameShortName; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + + ((gameShortName == null) ? 0 : gameShortName.hashCode()); + return result; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#equals( + * java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + InlineQueryResultGame other = (InlineQueryResultGame) obj; + if (gameShortName == null) { + if (other.gameShortName != null) + return false; + } else if (!gameShortName.equals(other.gameShortName)) + return false; + return true; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#toString() + */ + @Override + public String toString() { + return "InlineQueryResultGame [gameShortName=" + gameShortName + + ", type=" + type + ", id=" + id + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultGif.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultGif.java new file mode 100644 index 0000000..4365f9f --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultGif.java @@ -0,0 +1,303 @@ +package co.aurasphere.botmill.telegram.model.inline; + +import co.aurasphere.botmill.telegram.model.InlineKeyboardMarkup; +import co.aurasphere.botmill.telegram.model.inline.input.InlineQueryInputMessageContentResult; + +import com.google.gson.annotations.SerializedName; + +/** + * Represents a link to an animated GIF file. By default, this animated GIF file + * will be sent by the user with optional caption. Alternatively, you can use + * input_message_content to send a message with the specified content instead of + * the animation. + * + * @author Donato Rimenti + * @date Dec 26, 2016 + */ +public class InlineQueryResultGif extends InlineQueryInputMessageContentResult { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * A valid URL for the GIF file. File size must not exceed 1MB. + */ + @SerializedName("gif_url") + private String gifUrl; + + /** + * Optional. Width of the GIF. + */ + @SerializedName("gif_width") + private int gifWidth; + + /** + * Optional. Height of the GIF. + */ + @SerializedName("gif_height") + private int gifHeight; + + /** + * Represents a link to an animated GIF file. By default, this animated GIF + * file will be sent by the user with optional caption. Alternatively, you + * can use input_message_content to send a message with the specified + * content instead of the animation. + */ + private String caption; + + /** + * Title of the result. + */ + private String title; + + /** + * Optional. Inline keyboard attached to the message. + */ + @SerializedName("reply_markup") + private InlineKeyboardMarkup replyMarkup; + + /** + * Optional. Url of the thumbnail for the result. + */ + @SerializedName("thumb_url") + private String thumbUrl; + + /** + * Instantiates a new InlineQueryResultGif. + */ + public InlineQueryResultGif() { + super(InlineQueryResultType.GIF); + } + + /** + * Gets the {@link #gifUrl}. + * + * @return the {@link #gifUrl}. + */ + public String getGifUrl() { + return gifUrl; + } + + /** + * Sets the {@link #gifUrl}. + * + * @param gifUrl + * the {@link #gifUrl} to set. + */ + public void setGifUrl(String gifUrl) { + this.gifUrl = gifUrl; + } + + /** + * Gets the {@link #gifWidth}. + * + * @return the {@link #gifWidth}. + */ + public int getGifWidth() { + return gifWidth; + } + + /** + * Sets the {@link #gifWidth}. + * + * @param gifWidth + * the {@link #gifWidth} to set. + */ + public void setGifWidth(int gifWidth) { + this.gifWidth = gifWidth; + } + + /** + * Gets the {@link #gifHeight}. + * + * @return the {@link #gifHeight}. + */ + public int getGifHeight() { + return gifHeight; + } + + /** + * Sets the {@link #gifHeight}. + * + * @param gifHeight + * the {@link #gifHeight} to set. + */ + public void setGifHeight(int gifHeight) { + this.gifHeight = gifHeight; + } + + /** + * Gets the {@link #caption}. + * + * @return the {@link #caption}. + */ + public String getCaption() { + return caption; + } + + /** + * Sets the {@link #caption}. + * + * @param caption + * the {@link #caption} to set. + */ + public void setCaption(String caption) { + this.caption = caption; + } + + /** + * Gets the {@link #replyMarkup}. + * + * @return the {@link #replyMarkup}. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#getReplyMarkup + * () + */ + public InlineKeyboardMarkup getReplyMarkup() { + return replyMarkup; + } + + /** + * Sets the {@link #replyMarkup}. + * + * @param replyMarkup + * the {@link #replyMarkup} to set. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#setReplyMarkup + * (co.aurasphere.botmill.telegram.model.core.InlineKeyboardMarkup) + */ + public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) { + this.replyMarkup = replyMarkup; + } + + /** + * Gets the {@link #thumbUrl}. + * + * @return the {@link #thumbUrl}. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#getThumbUrl + * () + */ + public String getThumbUrl() { + return thumbUrl; + } + + /** + * Sets the {@link #thumbUrl}. + * + * @param thumbUrl + * the {@link #thumbUrl} to set. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#setThumbUrl + * (java.lang.String) + */ + public void setThumbUrl(String thumbUrl) { + this.thumbUrl = thumbUrl; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((caption == null) ? 0 : caption.hashCode()); + result = prime * result + gifHeight; + result = prime * result + ((gifUrl == null) ? 0 : gifUrl.hashCode()); + result = prime * result + gifWidth; + result = prime * result + + ((replyMarkup == null) ? 0 : replyMarkup.hashCode()); + result = prime * result + + ((thumbUrl == null) ? 0 : thumbUrl.hashCode()); + result = prime * result + ((title == null) ? 0 : title.hashCode()); + return result; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#equals( + * java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + InlineQueryResultGif other = (InlineQueryResultGif) obj; + if (caption == null) { + if (other.caption != null) + return false; + } else if (!caption.equals(other.caption)) + return false; + if (gifHeight != other.gifHeight) + return false; + if (gifUrl == null) { + if (other.gifUrl != null) + return false; + } else if (!gifUrl.equals(other.gifUrl)) + return false; + if (gifWidth != other.gifWidth) + return false; + if (replyMarkup == null) { + if (other.replyMarkup != null) + return false; + } else if (!replyMarkup.equals(other.replyMarkup)) + return false; + if (thumbUrl == null) { + if (other.thumbUrl != null) + return false; + } else if (!thumbUrl.equals(other.thumbUrl)) + return false; + if (title == null) { + if (other.title != null) + return false; + } else if (!title.equals(other.title)) + return false; + return true; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#toString() + */ + @Override + public String toString() { + return "InlineQueryResultGif [gifUrl=" + gifUrl + ", gifWidth=" + + gifWidth + ", gifHeight=" + gifHeight + ", caption=" + + caption + ", title=" + title + ", replyMarkup=" + replyMarkup + + ", thumbUrl=" + thumbUrl + ", type=" + type + ", id=" + id + + ", inputMessageContent=" + inputMessageContent + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultLocation.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultLocation.java new file mode 100644 index 0000000..834eba6 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultLocation.java @@ -0,0 +1,334 @@ +package co.aurasphere.botmill.telegram.model.inline; + +import co.aurasphere.botmill.telegram.model.InlineKeyboardMarkup; +import co.aurasphere.botmill.telegram.model.inline.input.InlineQueryInputMessageContentResult; + +import com.google.gson.annotations.SerializedName; + +/** + * Represents a location on a map. By default, the location will be sent by the + * user. Alternatively, you can use input_message_content to send a message with + * the specified content instead of the location.
+ *
+ * Note: This will only work in Telegram versions released after 9 April, 2016. + * Older clients will ignore them. + * + * @author Donato Rimenti + * @date Dec 26, 2016 + */ +public class InlineQueryResultLocation extends + InlineQueryInputMessageContentResult { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Location latitude in degrees. + */ + private double latitude; + + /** + * Location longitude in degrees. + */ + private double longitude; + + /** + * Optional. Thumbnail width. + */ + @SerializedName("thumb_width") + private int thumbWidth; + + /** + * Optional. Thumbnail height. + */ + @SerializedName("thumb_height") + private int thumbHeight; + + /** + * Title of the result. + */ + private String title; + + /** + * Optional. Inline keyboard attached to the message. + */ + @SerializedName("reply_markup") + private InlineKeyboardMarkup replyMarkup; + + /** + * Optional. Url of the thumbnail for the result. + */ + @SerializedName("thumb_url") + private String thumbUrl; + + /** + * Instantiates a new InlineQueryResultLocation. + */ + public InlineQueryResultLocation() { + super(InlineQueryResultType.LOCATION); + } + + /** + * Gets the {@link #latitude}. + * + * @return the {@link #latitude}. + */ + public double getLatitude() { + return latitude; + } + + /** + * Sets the {@link #latitude}. + * + * @param latitude + * the {@link #latitude} to set. + */ + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + /** + * Gets the {@link #longitude}. + * + * @return the {@link #longitude}. + */ + public double getLongitude() { + return longitude; + } + + /** + * Sets the {@link #longitude}. + * + * @param longitude + * the {@link #longitude} to set. + */ + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + /** + * Gets the {@link #thumbWidth}. + * + * @return the {@link #thumbWidth}. + */ + public int getThumbWidth() { + return thumbWidth; + } + + /** + * Sets the {@link #thumbWidth}. + * + * @param thumbWidth + * the {@link #thumbWidth} to set. + */ + public void setThumbWidth(int thumbWidth) { + this.thumbWidth = thumbWidth; + } + + /** + * Gets the {@link #thumbHeight}. + * + * @return the {@link #thumbHeight}. + */ + public int getThumbHeight() { + return thumbHeight; + } + + /** + * Sets the {@link #thumbHeight}. + * + * @param thumbHeight + * the {@link #thumbHeight} to set. + */ + public void setThumbHeight(int thumbHeight) { + this.thumbHeight = thumbHeight; + } + + /** + * Gets the {@link #title}. + * + * @return the {@link #title}. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#getTitle() + */ + public String getTitle() { + return title; + } + + /** + * Sets the {@link #title}. + * + * @param title + * the {@link #title} to set. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#setTitle + * (java.lang.String) + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * Gets the {@link #replyMarkup}. + * + * @return the {@link #replyMarkup}. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#getReplyMarkup + * () + */ + public InlineKeyboardMarkup getReplyMarkup() { + return replyMarkup; + } + + /** + * Sets the {@link #replyMarkup}. + * + * @param replyMarkup + * the {@link #replyMarkup} to set. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#setReplyMarkup + * (co.aurasphere.botmill.telegram.model.core.InlineKeyboardMarkup) + */ + public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) { + this.replyMarkup = replyMarkup; + } + + /** + * Gets the {@link #thumbUrl}. + * + * @return the {@link #thumbUrl}. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#getThumbUrl + * () + */ + public String getThumbUrl() { + return thumbUrl; + } + + /** + * Sets the {@link #thumbUrl}. + * + * @param thumbUrl + * the {@link #thumbUrl} to set. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#setThumbUrl + * (java.lang.String) + */ + public void setThumbUrl(String thumbUrl) { + this.thumbUrl = thumbUrl; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + long temp; + temp = Double.doubleToLongBits(latitude); + result = prime * result + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(longitude); + result = prime * result + (int) (temp ^ (temp >>> 32)); + result = prime * result + + ((replyMarkup == null) ? 0 : replyMarkup.hashCode()); + result = prime * result + thumbHeight; + result = prime * result + + ((thumbUrl == null) ? 0 : thumbUrl.hashCode()); + result = prime * result + thumbWidth; + result = prime * result + ((title == null) ? 0 : title.hashCode()); + return result; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#equals( + * java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + InlineQueryResultLocation other = (InlineQueryResultLocation) obj; + if (Double.doubleToLongBits(latitude) != Double + .doubleToLongBits(other.latitude)) + return false; + if (Double.doubleToLongBits(longitude) != Double + .doubleToLongBits(other.longitude)) + return false; + if (replyMarkup == null) { + if (other.replyMarkup != null) + return false; + } else if (!replyMarkup.equals(other.replyMarkup)) + return false; + if (thumbHeight != other.thumbHeight) + return false; + if (thumbUrl == null) { + if (other.thumbUrl != null) + return false; + } else if (!thumbUrl.equals(other.thumbUrl)) + return false; + if (thumbWidth != other.thumbWidth) + return false; + if (title == null) { + if (other.title != null) + return false; + } else if (!title.equals(other.title)) + return false; + return true; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#toString() + */ + @Override + public String toString() { + return "InlineQueryResultLocation [latitude=" + latitude + + ", longitude=" + longitude + ", thumbWidth=" + thumbWidth + + ", thumbHeight=" + thumbHeight + ", title=" + title + + ", replyMarkup=" + replyMarkup + ", thumbUrl=" + thumbUrl + + ", type=" + type + ", id=" + id + ", inputMessageContent=" + + inputMessageContent + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultMpeg4Gif.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultMpeg4Gif.java new file mode 100644 index 0000000..0b6a6a4 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultMpeg4Gif.java @@ -0,0 +1,336 @@ +package co.aurasphere.botmill.telegram.model.inline; + +import co.aurasphere.botmill.telegram.model.InlineKeyboardMarkup; +import co.aurasphere.botmill.telegram.model.inline.input.InlineQueryInputMessageContentResult; + +import com.google.gson.annotations.SerializedName; + +/** + * Represents a link to a video animation (H.264/MPEG-4 AVC video without + * sound). By default, this animated MPEG-4 file will be sent by the user with + * optional caption. Alternatively, you can use input_message_content to send a + * message with the specified content instead of the animation. + * + * @author Donato Rimenti + * @date Dec 26, 2016 + */ +public class InlineQueryResultMpeg4Gif extends + InlineQueryInputMessageContentResult { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * A valid URL for the MP4 file. File size must not exceed 1MB. + */ + @SerializedName("mpeg4_url") + private String mpeg4Url; + + /** + * Optional. Video width. + */ + @SerializedName("mpeg4_width") + private int mpeg4Width; + + /** + * Optional. Video height. + */ + @SerializedName("mpeg4_height") + private int mpeg4Height; + + // TODO: validation? + /** + * Optional. Caption of the MPEG-4 file to be sent, 0-200 characters. + */ + private String caption; + + /** + * Title of the result. + */ + private String title; + + /** + * Optional. Inline keyboard attached to the message. + */ + @SerializedName("reply_markup") + private InlineKeyboardMarkup replyMarkup; + + /** + * Optional. Url of the thumbnail for the result. + */ + @SerializedName("thumb_url") + private String thumbUrl; + + /** + * Instantiates a new InlineQueryResultMpeg4Gif. + */ + public InlineQueryResultMpeg4Gif() { + super(InlineQueryResultType.MPEG4_GIF); + } + + /** + * Gets the {@link #mpeg4Url}. + * + * @return the {@link #mpeg4Url}. + */ + public String getMpeg4Url() { + return mpeg4Url; + } + + /** + * Sets the {@link #mpeg4Url}. + * + * @param mpeg4Url + * the {@link #mpeg4Url} to set. + */ + public void setMpeg4Url(String mpeg4Url) { + this.mpeg4Url = mpeg4Url; + } + + /** + * Gets the {@link #mpeg4Width}. + * + * @return the {@link #mpeg4Width}. + */ + public int getMpeg4Width() { + return mpeg4Width; + } + + /** + * Sets the {@link #mpeg4Width}. + * + * @param mpeg4Width + * the {@link #mpeg4Width} to set. + */ + public void setMpeg4Width(int mpeg4Width) { + this.mpeg4Width = mpeg4Width; + } + + /** + * Gets the {@link #mpeg4Height}. + * + * @return the {@link #mpeg4Height}. + */ + public int getMpeg4Height() { + return mpeg4Height; + } + + /** + * Sets the {@link #mpeg4Height}. + * + * @param mpeg4Height + * the {@link #mpeg4Height} to set. + */ + public void setMpeg4Height(int mpeg4Height) { + this.mpeg4Height = mpeg4Height; + } + + /** + * Gets the {@link #caption}. + * + * @return the {@link #caption}. + */ + public String getCaption() { + return caption; + } + + /** + * Sets the {@link #caption}. + * + * @param caption + * the {@link #caption} to set. + */ + public void setCaption(String caption) { + this.caption = caption; + } + + /** + * Gets the {@link #title}. + * + * @return the {@link #title}. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#getTitle() + */ + public String getTitle() { + return title; + } + + /** + * Sets the {@link #title}. + * + * @param title + * the {@link #title} to set. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#setTitle + * (java.lang.String) + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * Gets the {@link #replyMarkup}. + * + * @return the {@link #replyMarkup}. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#getReplyMarkup + * () + */ + public InlineKeyboardMarkup getReplyMarkup() { + return replyMarkup; + } + + /** + * Sets the {@link #replyMarkup}. + * + * @param replyMarkup + * the {@link #replyMarkup} to set. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#setReplyMarkup + * (co.aurasphere.botmill.telegram.model.core.InlineKeyboardMarkup) + */ + public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) { + this.replyMarkup = replyMarkup; + } + + /** + * Gets the {@link #thumbUrl}. + * + * @return the {@link #thumbUrl}. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#getThumbUrl + * () + */ + public String getThumbUrl() { + return thumbUrl; + } + + /** + * Sets the {@link #thumbUrl}. + * + * @param thumbUrl + * the {@link #thumbUrl} to set. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#setThumbUrl + * (java.lang.String) + */ + public void setThumbUrl(String thumbUrl) { + this.thumbUrl = thumbUrl; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((caption == null) ? 0 : caption.hashCode()); + result = prime * result + mpeg4Height; + result = prime * result + + ((mpeg4Url == null) ? 0 : mpeg4Url.hashCode()); + result = prime * result + mpeg4Width; + result = prime * result + + ((replyMarkup == null) ? 0 : replyMarkup.hashCode()); + result = prime * result + + ((thumbUrl == null) ? 0 : thumbUrl.hashCode()); + result = prime * result + ((title == null) ? 0 : title.hashCode()); + return result; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#equals( + * java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + InlineQueryResultMpeg4Gif other = (InlineQueryResultMpeg4Gif) obj; + if (caption == null) { + if (other.caption != null) + return false; + } else if (!caption.equals(other.caption)) + return false; + if (mpeg4Height != other.mpeg4Height) + return false; + if (mpeg4Url == null) { + if (other.mpeg4Url != null) + return false; + } else if (!mpeg4Url.equals(other.mpeg4Url)) + return false; + if (mpeg4Width != other.mpeg4Width) + return false; + if (replyMarkup == null) { + if (other.replyMarkup != null) + return false; + } else if (!replyMarkup.equals(other.replyMarkup)) + return false; + if (thumbUrl == null) { + if (other.thumbUrl != null) + return false; + } else if (!thumbUrl.equals(other.thumbUrl)) + return false; + if (title == null) { + if (other.title != null) + return false; + } else if (!title.equals(other.title)) + return false; + return true; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#toString() + */ + @Override + public String toString() { + return "InlineQueryResultMpeg4Gif [mpeg4Url=" + mpeg4Url + + ", mpeg4Width=" + mpeg4Width + ", mpeg4Height=" + mpeg4Height + + ", caption=" + caption + ", title=" + title + + ", replyMarkup=" + replyMarkup + ", thumbUrl=" + thumbUrl + + ", type=" + type + ", id=" + id + ", inputMessageContent=" + + inputMessageContent + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultPhoto.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultPhoto.java new file mode 100644 index 0000000..cac27ef --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultPhoto.java @@ -0,0 +1,369 @@ +/** + * + */ +package co.aurasphere.botmill.telegram.model.inline; + +import co.aurasphere.botmill.telegram.model.InlineKeyboardMarkup; +import co.aurasphere.botmill.telegram.model.inline.input.InlineQueryInputMessageContentResult; + +import com.google.gson.annotations.SerializedName; + +/** + * Represents a link to a photo. By default, this photo will be sent by the user + * with optional caption. Alternatively, you can use input_message_content to + * send a message with the specified content instead of the photo. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class InlineQueryResultPhoto extends + InlineQueryInputMessageContentResult { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * A valid URL of the photo. Photo must be in jpeg format. Photo size must + * not exceed 5MB. + */ + @SerializedName("photo_url") + private String photoUrl; + + /** + * Optional. Width of the photo. + */ + @SerializedName("photo_width") + private int photoWidth; + + /** + * Optional. Height of the photo. + */ + @SerializedName("photo_height") + private int photoHeight; + + /** + * Optional. Short description of the result. + */ + private String description; + + /** + * Optional. Caption of the photo to be sent, 0-200 characters. + */ + private String caption; + + /** + * Title of the result. + */ + private String title; + + /** + * Optional. Inline keyboard attached to the message. + */ + @SerializedName("reply_markup") + private InlineKeyboardMarkup replyMarkup; + + /** + * Optional. Url of the thumbnail for the result. + */ + @SerializedName("thumb_url") + private String thumbUrl; + + /** + * Instantiates a new InlineQueryResultPhoto. + */ + public InlineQueryResultPhoto() { + super(InlineQueryResultType.PHOTO); + } + + /** + * Gets the {@link #photoUrl}. + * + * @return the {@link #photoUrl}. + */ + public String getPhotoUrl() { + return photoUrl; + } + + /** + * Sets the {@link #photoUrl}. + * + * @param photoUrl + * the {@link #photoUrl} to set. + */ + public void setPhotoUrl(String photoUrl) { + this.photoUrl = photoUrl; + } + + /** + * Gets the {@link #photoWidth}. + * + * @return the {@link #photoWidth}. + */ + public int getPhotoWidth() { + return photoWidth; + } + + /** + * Sets the {@link #photoWidth}. + * + * @param photoWidth + * the {@link #photoWidth} to set. + */ + public void setPhotoWidth(int photoWidth) { + this.photoWidth = photoWidth; + } + + /** + * Gets the {@link #photoHeight}. + * + * @return the {@link #photoHeight}. + */ + public int getPhotoHeight() { + return photoHeight; + } + + /** + * Sets the {@link #photoHeight}. + * + * @param photoHeight + * the {@link #photoHeight} to set. + */ + public void setPhotoHeight(int photoHeight) { + this.photoHeight = photoHeight; + } + + /** + * Gets the {@link #description}. + * + * @return the {@link #description}. + */ + public String getDescription() { + return description; + } + + /** + * Sets the {@link #description}. + * + * @param description + * the {@link #description} to set. + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * Gets the {@link #caption}. + * + * @return the {@link #caption}. + */ + public String getCaption() { + return caption; + } + + /** + * Sets the {@link #caption}. + * + * @param caption + * the {@link #caption} to set. + */ + public void setCaption(String caption) { + this.caption = caption; + } + + /** + * Gets the {@link #title}. + * + * @return the {@link #title}. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#getTitle() + */ + public String getTitle() { + return title; + } + + /** + * Sets the {@link #title}. + * + * @param title + * the {@link #title} to set. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#setTitle + * (java.lang.String) + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * Gets the {@link #replyMarkup}. + * + * @return the {@link #replyMarkup}. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#getReplyMarkup + * () + */ + public InlineKeyboardMarkup getReplyMarkup() { + return replyMarkup; + } + + /** + * Sets the {@link #replyMarkup}. + * + * @param replyMarkup + * the {@link #replyMarkup} to set. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#setReplyMarkup + * (co.aurasphere.botmill.telegram.model.core.InlineKeyboardMarkup) + */ + public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) { + this.replyMarkup = replyMarkup; + } + + /** + * Gets the {@link #thumbUrl}. + * + * @return the {@link #thumbUrl}. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#getThumbUrl + * () + */ + public String getThumbUrl() { + return thumbUrl; + } + + /** + * Sets the {@link #thumbUrl}. + * + * @param thumbUrl + * the {@link #thumbUrl} to set. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#setThumbUrl + * (java.lang.String) + */ + public void setThumbUrl(String thumbUrl) { + this.thumbUrl = thumbUrl; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((caption == null) ? 0 : caption.hashCode()); + result = prime * result + + ((description == null) ? 0 : description.hashCode()); + result = prime * result + photoHeight; + result = prime * result + + ((photoUrl == null) ? 0 : photoUrl.hashCode()); + result = prime * result + photoWidth; + result = prime * result + + ((replyMarkup == null) ? 0 : replyMarkup.hashCode()); + result = prime * result + + ((thumbUrl == null) ? 0 : thumbUrl.hashCode()); + result = prime * result + ((title == null) ? 0 : title.hashCode()); + return result; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#equals( + * java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + InlineQueryResultPhoto other = (InlineQueryResultPhoto) obj; + if (caption == null) { + if (other.caption != null) + return false; + } else if (!caption.equals(other.caption)) + return false; + if (description == null) { + if (other.description != null) + return false; + } else if (!description.equals(other.description)) + return false; + if (photoHeight != other.photoHeight) + return false; + if (photoUrl == null) { + if (other.photoUrl != null) + return false; + } else if (!photoUrl.equals(other.photoUrl)) + return false; + if (photoWidth != other.photoWidth) + return false; + if (replyMarkup == null) { + if (other.replyMarkup != null) + return false; + } else if (!replyMarkup.equals(other.replyMarkup)) + return false; + if (thumbUrl == null) { + if (other.thumbUrl != null) + return false; + } else if (!thumbUrl.equals(other.thumbUrl)) + return false; + if (title == null) { + if (other.title != null) + return false; + } else if (!title.equals(other.title)) + return false; + return true; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#toString() + */ + @Override + public String toString() { + return "InlineQueryResultPhoto [photoUrl=" + photoUrl + ", photoWidth=" + + photoWidth + ", photoHeight=" + photoHeight + + ", description=" + description + ", caption=" + caption + + ", title=" + title + ", replyMarkup=" + replyMarkup + + ", thumbUrl=" + thumbUrl + ", type=" + type + ", id=" + id + + ", inputMessageContent=" + inputMessageContent + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultType.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultType.java new file mode 100644 index 0000000..6d3453d --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultType.java @@ -0,0 +1,78 @@ +package co.aurasphere.botmill.telegram.model.inline; + +import co.aurasphere.botmill.telegram.model.inline.input.InlineQueryInputMessageContentResult; + +/** + * Type of the {@link InlineQueryInputMessageContentResult}. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public enum InlineQueryResultType { + + /** + * The article. + */ + ARTICLE, + + /** + * The photo. + */ + PHOTO, + + /** + * The gif. + */ + GIF, + + /** + * The mpeg4 gif. + */ + MPEG4_GIF, + + /** + * The video. + */ + VIDEO, + + /** + * The audio. + */ + AUDIO, + + /** + * The voice. + */ + VOICE, + + /** + * The document. + */ + DOCUMENT, + + /** + * The location. + */ + LOCATION, + + /** + * The venue. + */ + VENUE, + + /** + * The contact. + */ + CONTACT, + + /** + * The game. + */ + GAME, + + /** + * The sticker. + */ + STICKER; + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultVenue.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultVenue.java new file mode 100644 index 0000000..e0c31cc --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultVenue.java @@ -0,0 +1,397 @@ +package co.aurasphere.botmill.telegram.model.inline; + +import co.aurasphere.botmill.telegram.model.InlineKeyboardMarkup; +import co.aurasphere.botmill.telegram.model.inline.input.InlineQueryInputMessageContentResult; + +import com.google.gson.annotations.SerializedName; + +/** + * Represents a venue. By default, the venue will be sent by the user. + * Alternatively, you can use input_message_content to send a message with the + * specified content instead of the venue.
+ *
+ * Note: This will only work in Telegram versions released after 9 April, 2016. + * Older clients will ignore them. + * + * @author Donato Rimenti + * @date Dec 26, 2016 + */ +public class InlineQueryResultVenue extends + InlineQueryInputMessageContentResult { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Latitude of the venue location in degrees. + */ + private double latitude; + + /** + * Longitude of the venue location in degrees. + */ + private double longitude; + + /** + * Address of the venue. + */ + private String address; + + /** + * Optional. Foursquare identifier of the venue if known. + */ + @SerializedName("foursquare_id") + private String foursquareId; + + /** + * Optional. Thumbnail width. + */ + @SerializedName("thumb_width") + private int thumbWidth; + + /** + * Optional. Thumbnail height. + */ + @SerializedName("thumb_height") + private int thumbHeight; + + /** + * Title of the result. + */ + private String title; + + /** + * Optional. Inline keyboard attached to the message. + */ + @SerializedName("reply_markup") + private InlineKeyboardMarkup replyMarkup; + + /** + * Optional. Url of the thumbnail for the result. + */ + @SerializedName("thumb_url") + private String thumbUrl; + + /** + * Instantiates a new InlineQueryResultVenue. + */ + public InlineQueryResultVenue() { + super(InlineQueryResultType.VENUE); + } + + /** + * Gets the {@link #latitude}. + * + * @return the {@link #latitude}. + */ + public double getLatitude() { + return latitude; + } + + /** + * Sets the {@link #latitude}. + * + * @param latitude + * the {@link #latitude} to set. + */ + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + /** + * Gets the {@link #longitude}. + * + * @return the {@link #longitude}. + */ + public double getLongitude() { + return longitude; + } + + /** + * Sets the {@link #longitude}. + * + * @param longitude + * the {@link #longitude} to set. + */ + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + /** + * Gets the {@link #address}. + * + * @return the {@link #address}. + */ + public String getAddress() { + return address; + } + + /** + * Sets the {@link #address}. + * + * @param address + * the {@link #address} to set. + */ + public void setAddress(String address) { + this.address = address; + } + + /** + * Gets the {@link #foursquareId}. + * + * @return the {@link #foursquareId}. + */ + public String getFoursquareId() { + return foursquareId; + } + + /** + * Sets the {@link #foursquareId}. + * + * @param foursquareId + * the {@link #foursquareId} to set. + */ + public void setFoursquareId(String foursquareId) { + this.foursquareId = foursquareId; + } + + /** + * Gets the {@link #thumbWidth}. + * + * @return the {@link #thumbWidth}. + */ + public int getThumbWidth() { + return thumbWidth; + } + + /** + * Sets the {@link #thumbWidth}. + * + * @param thumbWidth + * the {@link #thumbWidth} to set. + */ + public void setThumbWidth(int thumbWidth) { + this.thumbWidth = thumbWidth; + } + + /** + * Gets the {@link #thumbHeight}. + * + * @return the {@link #thumbHeight}. + */ + public int getThumbHeight() { + return thumbHeight; + } + + /** + * Sets the {@link #thumbHeight}. + * + * @param thumbHeight + * the {@link #thumbHeight} to set. + */ + public void setThumbHeight(int thumbHeight) { + this.thumbHeight = thumbHeight; + } + + /** + * Gets the {@link #title}. + * + * @return the {@link #title}. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#getTitle() + */ + public String getTitle() { + return title; + } + + /** + * Sets the {@link #title}. + * + * @param title + * the {@link #title} to set. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#setTitle + * (java.lang.String) + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * Gets the {@link #replyMarkup}. + * + * @return the {@link #replyMarkup}. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#getReplyMarkup + * () + */ + public InlineKeyboardMarkup getReplyMarkup() { + return replyMarkup; + } + + /** + * Sets the {@link #replyMarkup}. + * + * @param replyMarkup + * the {@link #replyMarkup} to set. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#setReplyMarkup + * (co.aurasphere.botmill.telegram.model.core.InlineKeyboardMarkup) + */ + public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) { + this.replyMarkup = replyMarkup; + } + + /** + * Gets the {@link #thumbUrl}. + * + * @return the {@link #thumbUrl}. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#getThumbUrl + * () + */ + public String getThumbUrl() { + return thumbUrl; + } + + /** + * Sets the {@link #thumbUrl}. + * + * @param thumbUrl + * the {@link #thumbUrl} to set. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#setThumbUrl + * (java.lang.String) + */ + public void setThumbUrl(String thumbUrl) { + this.thumbUrl = thumbUrl; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((address == null) ? 0 : address.hashCode()); + result = prime * result + + ((foursquareId == null) ? 0 : foursquareId.hashCode()); + long temp; + temp = Double.doubleToLongBits(latitude); + result = prime * result + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(longitude); + result = prime * result + (int) (temp ^ (temp >>> 32)); + result = prime * result + + ((replyMarkup == null) ? 0 : replyMarkup.hashCode()); + result = prime * result + thumbHeight; + result = prime * result + + ((thumbUrl == null) ? 0 : thumbUrl.hashCode()); + result = prime * result + thumbWidth; + result = prime * result + ((title == null) ? 0 : title.hashCode()); + return result; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#equals( + * java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + InlineQueryResultVenue other = (InlineQueryResultVenue) obj; + if (address == null) { + if (other.address != null) + return false; + } else if (!address.equals(other.address)) + return false; + if (foursquareId == null) { + if (other.foursquareId != null) + return false; + } else if (!foursquareId.equals(other.foursquareId)) + return false; + if (Double.doubleToLongBits(latitude) != Double + .doubleToLongBits(other.latitude)) + return false; + if (Double.doubleToLongBits(longitude) != Double + .doubleToLongBits(other.longitude)) + return false; + if (replyMarkup == null) { + if (other.replyMarkup != null) + return false; + } else if (!replyMarkup.equals(other.replyMarkup)) + return false; + if (thumbHeight != other.thumbHeight) + return false; + if (thumbUrl == null) { + if (other.thumbUrl != null) + return false; + } else if (!thumbUrl.equals(other.thumbUrl)) + return false; + if (thumbWidth != other.thumbWidth) + return false; + if (title == null) { + if (other.title != null) + return false; + } else if (!title.equals(other.title)) + return false; + return true; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#toString() + */ + @Override + public String toString() { + return "InlineQueryResultVenue [latitude=" + latitude + ", longitude=" + + longitude + ", address=" + address + ", foursquareId=" + + foursquareId + ", thumbWidth=" + thumbWidth + + ", thumbHeight=" + thumbHeight + ", title=" + title + + ", replyMarkup=" + replyMarkup + ", thumbUrl=" + thumbUrl + + ", type=" + type + ", id=" + id + ", inputMessageContent=" + + inputMessageContent + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultVideo.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultVideo.java new file mode 100644 index 0000000..1044b6d --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultVideo.java @@ -0,0 +1,430 @@ +package co.aurasphere.botmill.telegram.model.inline; + +import co.aurasphere.botmill.telegram.model.InlineKeyboardMarkup; +import co.aurasphere.botmill.telegram.model.inline.input.InlineQueryInputMessageContentResult; + +import com.google.gson.annotations.SerializedName; + +/** + * Represents a link to a page containing an embedded video player or a video + * file. By default, this video file will be sent by the user with an optional + * caption. Alternatively, you can use input_message_content to send a message + * with the specified content instead of the video. + * + * @author Donato Rimenti + * @date Dec 26, 2016 + */ +public class InlineQueryResultVideo extends + InlineQueryInputMessageContentResult { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * A valid URL for the embedded video player or video file. + */ + @SerializedName("video_url") + private String videoUrl; + + // TODO: enum? Check if only these + /** + * Mime type of the content of video url, “text/html” or “video/mp4”. + */ + @SerializedName("mime_type") + private String mimeType; + + // TODO: validation? + /** + * Optional. Caption of the video to be sent, 0-200 characters. + */ + private String caption; + + /** + * Optional. Video width. + */ + @SerializedName("video_width") + private int videoWidth; + + /** + * Optional. Video height. + */ + @SerializedName("video_height") + private int videoHeight; + + /** + * Optional. Video duration in seconds. + */ + @SerializedName("video_duration") + private int videoDuration; + + /** + * Optional. Short description of the result. + */ + private String description; + + /** + * Title of the result. + */ + private String title; + + /** + * Optional. Inline keyboard attached to the message. + */ + @SerializedName("reply_markup") + private InlineKeyboardMarkup replyMarkup; + + /** + * Optional. Url of the thumbnail for the result. + */ + @SerializedName("thumb_url") + private String thumbUrl; + + /** + * Instantiates a new InlineQueryResultVideo. + */ + public InlineQueryResultVideo() { + super(InlineQueryResultType.VIDEO); + } + + /** + * Gets the {@link #videoUrl}. + * + * @return the {@link #videoUrl}. + */ + public String getVideoUrl() { + return videoUrl; + } + + /** + * Sets the {@link #videoUrl}. + * + * @param videoUrl + * the {@link #videoUrl} to set. + */ + public void setVideoUrl(String videoUrl) { + this.videoUrl = videoUrl; + } + + /** + * Gets the {@link #mimeType}. + * + * @return the {@link #mimeType}. + */ + public String getMimeType() { + return mimeType; + } + + /** + * Sets the {@link #mimeType}. + * + * @param mimeType + * the {@link #mimeType} to set. + */ + public void setMimeType(String mimeType) { + this.mimeType = mimeType; + } + + /** + * Gets the {@link #caption}. + * + * @return the {@link #caption}. + */ + public String getCaption() { + return caption; + } + + /** + * Sets the {@link #caption}. + * + * @param caption + * the {@link #caption} to set. + */ + public void setCaption(String caption) { + this.caption = caption; + } + + /** + * Gets the {@link #videoWidth}. + * + * @return the {@link #videoWidth}. + */ + public int getVideoWidth() { + return videoWidth; + } + + /** + * Sets the {@link #videoWidth}. + * + * @param videoWidth + * the {@link #videoWidth} to set. + */ + public void setVideoWidth(int videoWidth) { + this.videoWidth = videoWidth; + } + + /** + * Gets the {@link #videoHeight}. + * + * @return the {@link #videoHeight}. + */ + public int getVideoHeight() { + return videoHeight; + } + + /** + * Sets the {@link #videoHeight}. + * + * @param videoHeight + * the {@link #videoHeight} to set. + */ + public void setVideoHeight(int videoHeight) { + this.videoHeight = videoHeight; + } + + /** + * Gets the {@link #videoDuration}. + * + * @return the {@link #videoDuration}. + */ + public int getVideoDuration() { + return videoDuration; + } + + /** + * Sets the {@link #videoDuration}. + * + * @param videoDuration + * the {@link #videoDuration} to set. + */ + public void setVideoDuration(int videoDuration) { + this.videoDuration = videoDuration; + } + + /** + * Gets the {@link #description}. + * + * @return the {@link #description}. + */ + public String getDescription() { + return description; + } + + /** + * Sets the {@link #description}. + * + * @param description + * the {@link #description} to set. + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * Gets the {@link #title}. + * + * @return the {@link #title}. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#getTitle() + */ + public String getTitle() { + return title; + } + + /** + * Sets the {@link #title}. + * + * @param title + * the {@link #title} to set. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#setTitle + * (java.lang.String) + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * Gets the {@link #replyMarkup}. + * + * @return the {@link #replyMarkup}. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#getReplyMarkup + * () + */ + public InlineKeyboardMarkup getReplyMarkup() { + return replyMarkup; + } + + /** + * Sets the {@link #replyMarkup}. + * + * @param replyMarkup + * the {@link #replyMarkup} to set. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#setReplyMarkup + * (co.aurasphere.botmill.telegram.model.core.InlineKeyboardMarkup) + */ + public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) { + this.replyMarkup = replyMarkup; + } + + /** + * Gets the {@link #thumbUrl}. + * + * @return the {@link #thumbUrl}. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#getThumbUrl + * () + */ + public String getThumbUrl() { + return thumbUrl; + } + + /** + * Sets the {@link #thumbUrl}. + * + * @param thumbUrl + * the {@link #thumbUrl} to set. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#setThumbUrl + * (java.lang.String) + */ + public void setThumbUrl(String thumbUrl) { + this.thumbUrl = thumbUrl; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((caption == null) ? 0 : caption.hashCode()); + result = prime * result + + ((description == null) ? 0 : description.hashCode()); + result = prime * result + + ((mimeType == null) ? 0 : mimeType.hashCode()); + result = prime * result + + ((replyMarkup == null) ? 0 : replyMarkup.hashCode()); + result = prime * result + + ((thumbUrl == null) ? 0 : thumbUrl.hashCode()); + result = prime * result + ((title == null) ? 0 : title.hashCode()); + result = prime * result + videoDuration; + result = prime * result + videoHeight; + result = prime * result + + ((videoUrl == null) ? 0 : videoUrl.hashCode()); + result = prime * result + videoWidth; + return result; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#equals( + * java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + InlineQueryResultVideo other = (InlineQueryResultVideo) obj; + if (caption == null) { + if (other.caption != null) + return false; + } else if (!caption.equals(other.caption)) + return false; + if (description == null) { + if (other.description != null) + return false; + } else if (!description.equals(other.description)) + return false; + if (mimeType == null) { + if (other.mimeType != null) + return false; + } else if (!mimeType.equals(other.mimeType)) + return false; + if (replyMarkup == null) { + if (other.replyMarkup != null) + return false; + } else if (!replyMarkup.equals(other.replyMarkup)) + return false; + if (thumbUrl == null) { + if (other.thumbUrl != null) + return false; + } else if (!thumbUrl.equals(other.thumbUrl)) + return false; + if (title == null) { + if (other.title != null) + return false; + } else if (!title.equals(other.title)) + return false; + if (videoDuration != other.videoDuration) + return false; + if (videoHeight != other.videoHeight) + return false; + if (videoUrl == null) { + if (other.videoUrl != null) + return false; + } else if (!videoUrl.equals(other.videoUrl)) + return false; + if (videoWidth != other.videoWidth) + return false; + return true; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#toString() + */ + @Override + public String toString() { + return "InlineQueryResultVideo [videoUrl=" + videoUrl + ", mimeType=" + + mimeType + ", caption=" + caption + ", videoWidth=" + + videoWidth + ", videoHeight=" + videoHeight + + ", videoDuration=" + videoDuration + ", description=" + + description + ", title=" + title + ", replyMarkup=" + + replyMarkup + ", thumbUrl=" + thumbUrl + ", type=" + type + + ", id=" + id + ", inputMessageContent=" + inputMessageContent + + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultVoice.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultVoice.java new file mode 100644 index 0000000..21fdb22 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/InlineQueryResultVoice.java @@ -0,0 +1,302 @@ +package co.aurasphere.botmill.telegram.model.inline; + +import co.aurasphere.botmill.telegram.model.InlineKeyboardMarkup; +import co.aurasphere.botmill.telegram.model.inline.input.InlineQueryInputMessageContentResult; + +import com.google.gson.annotations.SerializedName; + +/** + * Represents a link to a voice recording in an .ogg container encoded with + * OPUS. By default, this voice recording will be sent by the user. + * Alternatively, you can use input_message_content to send a message with the + * specified content instead of the the voice message.
+ *
+ * Note: This will only work in Telegram versions released after 9 April, 2016. + * Older clients will ignore them. + * + * @author Donato Rimenti + * @date Dec 26, 2016 + */ +public class InlineQueryResultVoice extends + InlineQueryInputMessageContentResult { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * A valid URL for the voice recording. + */ + @SerializedName("voice_url") + private String voiceUrl; + + /** + * Optional. Caption, 0-200 characters. + */ + private String caption; + + /** + * Optional. Recording duration in seconds. + */ + @SerializedName("voice_duration") + private int voiceDuration; + + /** + * Title of the result. + */ + private String title; + + /** + * Optional. Inline keyboard attached to the message. + */ + @SerializedName("reply_markup") + private InlineKeyboardMarkup replyMarkup; + + /** + * Optional. Url of the thumbnail for the result. + */ + @SerializedName("thumb_url") + private String thumbUrl; + + /** + * Instantiates a new InlineQueryResultVoice. + */ + public InlineQueryResultVoice() { + super(InlineQueryResultType.VOICE); + } + + /** + * Gets the {@link #voiceUrl}. + * + * @return the {@link #voiceUrl}. + */ + public String getVoiceUrl() { + return voiceUrl; + } + + /** + * Sets the {@link #voiceUrl}. + * + * @param voiceUrl + * the {@link #voiceUrl} to set. + */ + public void setVoiceUrl(String voiceUrl) { + this.voiceUrl = voiceUrl; + } + + /** + * Gets the {@link #caption}. + * + * @return the {@link #caption}. + */ + public String getCaption() { + return caption; + } + + /** + * Sets the {@link #caption}. + * + * @param caption + * the {@link #caption} to set. + */ + public void setCaption(String caption) { + this.caption = caption; + } + + /** + * Gets the {@link #voiceDuration}. + * + * @return the {@link #voiceDuration}. + */ + public int getVoiceDuration() { + return voiceDuration; + } + + /** + * Sets the {@link #voiceDuration}. + * + * @param voiceDuration + * the {@link #voiceDuration} to set. + */ + public void setVoiceDuration(int voiceDuration) { + this.voiceDuration = voiceDuration; + } + + /** + * Gets the {@link #title}. + * + * @return the {@link #title}. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#getTitle() + */ + public String getTitle() { + return title; + } + + /** + * Sets the {@link #title}. + * + * @param title + * the {@link #title} to set. + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * Gets the {@link #replyMarkup}. + * + * @return the {@link #replyMarkup}. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#getReplyMarkup + * () + */ + public InlineKeyboardMarkup getReplyMarkup() { + return replyMarkup; + } + + /** + * Sets the {@link #replyMarkup}. + * + * @param replyMarkup + * the {@link #replyMarkup} to set. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#setReplyMarkup + * (co.aurasphere.botmill.telegram.model.core.InlineKeyboardMarkup) + */ + public void setReplyMarkup(InlineKeyboardMarkup replyMarkup) { + this.replyMarkup = replyMarkup; + } + + /** + * Gets the {@link #thumbUrl}. + * + * @return the {@link #thumbUrl}. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#getThumbUrl + * () + */ + public String getThumbUrl() { + return thumbUrl; + } + + /** + * Sets the {@link #thumbUrl}. + * + * @param thumbUrl + * the {@link #thumbUrl} to set. + */ + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#setThumbUrl + * (java.lang.String) + */ + public void setThumbUrl(String thumbUrl) { + this.thumbUrl = thumbUrl; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((caption == null) ? 0 : caption.hashCode()); + result = prime * result + + ((replyMarkup == null) ? 0 : replyMarkup.hashCode()); + result = prime * result + + ((thumbUrl == null) ? 0 : thumbUrl.hashCode()); + result = prime * result + ((title == null) ? 0 : title.hashCode()); + result = prime * result + voiceDuration; + result = prime * result + + ((voiceUrl == null) ? 0 : voiceUrl.hashCode()); + return result; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#equals( + * java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + InlineQueryResultVoice other = (InlineQueryResultVoice) obj; + if (caption == null) { + if (other.caption != null) + return false; + } else if (!caption.equals(other.caption)) + return false; + if (replyMarkup == null) { + if (other.replyMarkup != null) + return false; + } else if (!replyMarkup.equals(other.replyMarkup)) + return false; + if (thumbUrl == null) { + if (other.thumbUrl != null) + return false; + } else if (!thumbUrl.equals(other.thumbUrl)) + return false; + if (title == null) { + if (other.title != null) + return false; + } else if (!title.equals(other.title)) + return false; + if (voiceDuration != other.voiceDuration) + return false; + if (voiceUrl == null) { + if (other.voiceUrl != null) + return false; + } else if (!voiceUrl.equals(other.voiceUrl)) + return false; + return true; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#toString() + */ + @Override + public String toString() { + return "InlineQueryResultVoice [voiceUrl=" + voiceUrl + ", caption=" + + caption + ", voiceDuration=" + voiceDuration + ", title=" + + title + ", replyMarkup=" + replyMarkup + ", thumbUrl=" + + thumbUrl + ", type=" + type + ", id=" + id + + ", inputMessageContent=" + inputMessageContent + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/cache/InlineQueryResultCached.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/cache/InlineQueryResultCached.java new file mode 100644 index 0000000..e073703 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/cache/InlineQueryResultCached.java @@ -0,0 +1,43 @@ +package co.aurasphere.botmill.telegram.model.inline.cache; + +import co.aurasphere.botmill.telegram.model.inline.InlineQueryResult; +import co.aurasphere.botmill.telegram.model.inline.InlineQueryResultType; +import co.aurasphere.botmill.telegram.model.inline.input.InlineQueryInputMessageContentResult; + +/** + * Represents a link to something stored on the Telegram servers. + * + * @author Donato Rimenti + * @date Dec 26, 2016 + */ +public class InlineQueryResultCached extends + InlineQueryInputMessageContentResult { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Instantiates a new InlineQueryResultCached. + * + * @param type + * the {@link InlineQueryResult#type}. + */ + public InlineQueryResultCached(InlineQueryResultType type) { + super(type); + } + + /* + * (non-Javadoc) + * + * @see co.aurasphere.botmill.telegram.model.inline. + * InlineQueryInputMessageContentResult#toString() + */ + @Override + public String toString() { + return "InlineQueryResultCached [inputMessageContent=" + + inputMessageContent + ", type=" + type + ", id=" + id + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/cache/InlineQueryResultCachedAudio.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/cache/InlineQueryResultCachedAudio.java new file mode 100644 index 0000000..d394501 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/cache/InlineQueryResultCachedAudio.java @@ -0,0 +1,141 @@ +package co.aurasphere.botmill.telegram.model.inline.cache; + +import com.google.gson.annotations.SerializedName; + +import co.aurasphere.botmill.telegram.model.inline.InlineQueryResultType; + +/** + * Represents a link to an mp3 audio file stored on the Telegram servers. By + * default, this audio file will be sent by the user. Alternatively, you can use + * input_message_content to send a message with the specified content instead of + * the audio.
+ *
+ * Note: This will only work in Telegram versions released after 9 April, 2016. + * Older clients will ignore them. + * + * @author Donato Rimenti + * @date Dec 27, 2016 + */ +public class InlineQueryResultCachedAudio extends InlineQueryResultCached { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * A valid file identifier for the audio file. + */ + @SerializedName("audio_file_id") + private String audioFileId; + + // TODO: validation? + /** + * Optional. Caption, 0-200 characters. + */ + private String caption; + + /** + * Instantiates a new InlineQueryResultCachedAudio. + */ + public InlineQueryResultCachedAudio() { + super(InlineQueryResultType.AUDIO); + } + + /** + * Gets the {@link #audioFileId}. + * + * @return the {@link #audioFileId}. + */ + public String getAudioFileId() { + return audioFileId; + } + + /** + * Sets the {@link #audioFileId}. + * + * @param audioFileId + * the {@link #audioFileId} to set. + */ + public void setAudioFileId(String audioFileId) { + this.audioFileId = audioFileId; + } + + /** + * Gets the {@link #caption}. + * + * @return the {@link #caption}. + */ + public String getCaption() { + return caption; + } + + /** + * Sets the {@link #caption}. + * + * @param caption + * the {@link #caption} to set. + */ + public void setCaption(String caption) { + this.caption = caption; + } + + /* + * (non-Javadoc) + * + * @see co.aurasphere.botmill.telegram.model.inline. + * InlineQueryInputMessageContentResult#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + + ((audioFileId == null) ? 0 : audioFileId.hashCode()); + result = prime * result + ((caption == null) ? 0 : caption.hashCode()); + return result; + } + + /* + * (non-Javadoc) + * + * @see co.aurasphere.botmill.telegram.model.inline. + * InlineQueryInputMessageContentResult#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + InlineQueryResultCachedAudio other = (InlineQueryResultCachedAudio) obj; + if (audioFileId == null) { + if (other.audioFileId != null) + return false; + } else if (!audioFileId.equals(other.audioFileId)) + return false; + if (caption == null) { + if (other.caption != null) + return false; + } else if (!caption.equals(other.caption)) + return false; + return true; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.cache.InlineQueryResultCached + * #toString() + */ + @Override + public String toString() { + return "InlineQueryResultCachedAudio [audioFileId=" + audioFileId + + ", caption=" + caption + ", inputMessageContent=" + + inputMessageContent + ", type=" + type + ", id=" + id + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/cache/InlineQueryResultCachedDocument.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/cache/InlineQueryResultCachedDocument.java new file mode 100644 index 0000000..e9437ae --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/cache/InlineQueryResultCachedDocument.java @@ -0,0 +1,203 @@ +package co.aurasphere.botmill.telegram.model.inline.cache; + +import com.google.gson.annotations.SerializedName; + +import co.aurasphere.botmill.telegram.model.inline.InlineQueryResultType; + +/** + * Represents a link to a file stored on the Telegram servers. By default, this + * file will be sent by the user with an optional caption. Alternatively, you + * can use input_message_content to send a message with the specified content + * instead of the file.
+ *
+ * Note: This will only work in Telegram versions released after 9 April, 2016. + * Older clients will ignore them. + * + * @author Donato Rimenti + * @date Dec 27, 2016 + */ +public class InlineQueryResultCachedDocument extends InlineQueryResultCached { + + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * Title for the result. + */ + private String title; + + /** + * A valid file identifier for the file. + */ + @SerializedName("document_file_id") + private String documentFileId; + + /** + * Optional. Short description of the result. + */ + private String description; + + // TODO: validation? + /** + * Optional. Caption of the document to be sent, 0-200 characters. + */ + private String caption; + + /** + * Instantiates a new InlineQueryResultCachedDocument. + */ + public InlineQueryResultCachedDocument() { + super(InlineQueryResultType.DOCUMENT); + } + + /** + * Gets the {@link #title}. + * + * @return the {@link #title}. + */ + public String getTitle() { + return title; + } + + /** + * Sets the {@link #title}. + * + * @param title + * the {@link #title} to set. + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * Gets the {@link #documentFileId}. + * + * @return the {@link #documentFileId}. + */ + public String getDocumentFileId() { + return documentFileId; + } + + /** + * Sets the {@link #documentFileId}. + * + * @param documentFileId + * the {@link #documentFileId} to set. + */ + public void setDocumentFileId(String documentFileId) { + this.documentFileId = documentFileId; + } + + /** + * Gets the {@link #description}. + * + * @return the {@link #description}. + */ + public String getDescription() { + return description; + } + + /** + * Sets the {@link #description}. + * + * @param description + * the {@link #description} to set. + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * Gets the {@link #caption}. + * + * @return the {@link #caption}. + */ + public String getCaption() { + return caption; + } + + /** + * Sets the {@link #caption}. + * + * @param caption + * the {@link #caption} to set. + */ + public void setCaption(String caption) { + this.caption = caption; + } + + /* + * (non-Javadoc) + * + * @see co.aurasphere.botmill.telegram.model.inline. + * InlineQueryInputMessageContentResult#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((caption == null) ? 0 : caption.hashCode()); + result = prime * result + + ((description == null) ? 0 : description.hashCode()); + result = prime * result + + ((documentFileId == null) ? 0 : documentFileId.hashCode()); + result = prime * result + ((title == null) ? 0 : title.hashCode()); + return result; + } + + /* + * (non-Javadoc) + * + * @see co.aurasphere.botmill.telegram.model.inline. + * InlineQueryInputMessageContentResult#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + InlineQueryResultCachedDocument other = (InlineQueryResultCachedDocument) obj; + if (caption == null) { + if (other.caption != null) + return false; + } else if (!caption.equals(other.caption)) + return false; + if (description == null) { + if (other.description != null) + return false; + } else if (!description.equals(other.description)) + return false; + if (documentFileId == null) { + if (other.documentFileId != null) + return false; + } else if (!documentFileId.equals(other.documentFileId)) + return false; + if (title == null) { + if (other.title != null) + return false; + } else if (!title.equals(other.title)) + return false; + return true; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.cache.InlineQueryResultCached + * #toString() + */ + @Override + public String toString() { + return "InlineQueryResultCachedDocument [title=" + title + + ", documentFileId=" + documentFileId + ", description=" + + description + ", caption=" + caption + + ", inputMessageContent=" + inputMessageContent + ", type=" + + type + ", id=" + id + "]"; + } +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/cache/InlineQueryResultCachedGif.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/cache/InlineQueryResultCachedGif.java new file mode 100644 index 0000000..4d0a15f --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/cache/InlineQueryResultCachedGif.java @@ -0,0 +1,169 @@ +package co.aurasphere.botmill.telegram.model.inline.cache; + +import com.google.gson.annotations.SerializedName; + +import co.aurasphere.botmill.telegram.model.inline.InlineQueryResultType; + +/** + * Represents a link to an animated GIF file stored on the Telegram servers. By + * default, this animated GIF file will be sent by the user with an optional + * caption. Alternatively, you can use input_message_content to send a message + * with specified content instead of the animation. + * + * @author Donato Rimenti + * @date Dec 27, 2016 + */ +public class InlineQueryResultCachedGif extends InlineQueryResultCached { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * A valid file identifier for the GIF file. + */ + @SerializedName("gif_file_id") + private String gifFileId; + + /** + * Optional. Title for the result. + */ + private String title; + + // TODO: validation? + /** + * Optional. Caption of the GIF file to be sent, 0-200 characters. + */ + private String caption; + + /** + * Instantiates a new InlineQueryResultCachedGif. + */ + public InlineQueryResultCachedGif() { + super(InlineQueryResultType.GIF); + } + + /** + * Gets the {@link #gifFileId}. + * + * @return the {@link #gifFileId}. + */ + public String getGifFileId() { + return gifFileId; + } + + /** + * Sets the {@link #gifFileId}. + * + * @param gifFileId + * the {@link #gifFileId} to set. + */ + public void setGifFileId(String gifFileId) { + this.gifFileId = gifFileId; + } + + /** + * Gets the {@link #title}. + * + * @return the {@link #title}. + */ + public String getTitle() { + return title; + } + + /** + * Sets the {@link #title}. + * + * @param title + * the {@link #title} to set. + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * Gets the {@link #caption}. + * + * @return the {@link #caption}. + */ + public String getCaption() { + return caption; + } + + /** + * Sets the {@link #caption}. + * + * @param caption + * the {@link #caption} to set. + */ + public void setCaption(String caption) { + this.caption = caption; + } + + /* + * (non-Javadoc) + * + * @see co.aurasphere.botmill.telegram.model.inline. + * InlineQueryInputMessageContentResult#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((caption == null) ? 0 : caption.hashCode()); + result = prime * result + + ((gifFileId == null) ? 0 : gifFileId.hashCode()); + result = prime * result + ((title == null) ? 0 : title.hashCode()); + return result; + } + + /* + * (non-Javadoc) + * + * @see co.aurasphere.botmill.telegram.model.inline. + * InlineQueryInputMessageContentResult#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + InlineQueryResultCachedGif other = (InlineQueryResultCachedGif) obj; + if (caption == null) { + if (other.caption != null) + return false; + } else if (!caption.equals(other.caption)) + return false; + if (gifFileId == null) { + if (other.gifFileId != null) + return false; + } else if (!gifFileId.equals(other.gifFileId)) + return false; + if (title == null) { + if (other.title != null) + return false; + } else if (!title.equals(other.title)) + return false; + return true; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.cache.InlineQueryResultCached + * #toString() + */ + @Override + public String toString() { + return "InlineQueryResultCachedGif [gifFileId=" + gifFileId + + ", title=" + title + ", caption=" + caption + + ", inputMessageContent=" + inputMessageContent + ", type=" + + type + ", id=" + id + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/cache/InlineQueryResultCachedMpeg4Gif.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/cache/InlineQueryResultCachedMpeg4Gif.java new file mode 100644 index 0000000..bf4074c --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/cache/InlineQueryResultCachedMpeg4Gif.java @@ -0,0 +1,169 @@ +package co.aurasphere.botmill.telegram.model.inline.cache; + +import com.google.gson.annotations.SerializedName; + +import co.aurasphere.botmill.telegram.model.inline.InlineQueryResultType; + +/** + * Represents a link to a video animation (H.264/MPEG-4 AVC video without sound) + * stored on the Telegram servers. By default, this animated MPEG-4 file will be + * sent by the user with an optional caption. Alternatively, you can use + * input_message_content to send a message with the specified content instead of + * the animation. + * + * @author Donato Rimenti + * @date Dec 27, 2016 + */ +public class InlineQueryResultCachedMpeg4Gif extends InlineQueryResultCached { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * A valid file identifier for the MP4 file. + */ + @SerializedName("mpeg4_file_id") + private String mpeg4FileId; + + /** + * Optional. Title for the result. + */ + private String title; + + /** + * Optional. Caption of the MPEG-4 file to be sent, 0-200 characters. + */ + private String caption; + + /** + * Instantiates a new InlineQueryResultCachedMpeg4Gif. + */ + public InlineQueryResultCachedMpeg4Gif() { + super(InlineQueryResultType.MPEG4_GIF); + } + + /** + * Gets the {@link #mpeg4FileId}. + * + * @return the {@link #mpeg4FileId}. + */ + public String getMpeg4FileId() { + return mpeg4FileId; + } + + /** + * Sets the {@link #mpeg4FileId}. + * + * @param mpeg4FileId + * the {@link #mpeg4FileId} to set. + */ + public void setMpeg4FileId(String mpeg4FileId) { + this.mpeg4FileId = mpeg4FileId; + } + + /** + * Gets the {@link #title}. + * + * @return the {@link #title}. + */ + public String getTitle() { + return title; + } + + /** + * Sets the {@link #title}. + * + * @param title + * the {@link #title} to set. + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * Gets the {@link #caption}. + * + * @return the {@link #caption}. + */ + public String getCaption() { + return caption; + } + + /** + * Sets the {@link #caption}. + * + * @param caption + * the {@link #caption} to set. + */ + public void setCaption(String caption) { + this.caption = caption; + } + + /* + * (non-Javadoc) + * + * @see co.aurasphere.botmill.telegram.model.inline. + * InlineQueryInputMessageContentResult#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((caption == null) ? 0 : caption.hashCode()); + result = prime * result + + ((mpeg4FileId == null) ? 0 : mpeg4FileId.hashCode()); + result = prime * result + ((title == null) ? 0 : title.hashCode()); + return result; + } + + /* + * (non-Javadoc) + * + * @see co.aurasphere.botmill.telegram.model.inline. + * InlineQueryInputMessageContentResult#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + InlineQueryResultCachedMpeg4Gif other = (InlineQueryResultCachedMpeg4Gif) obj; + if (caption == null) { + if (other.caption != null) + return false; + } else if (!caption.equals(other.caption)) + return false; + if (mpeg4FileId == null) { + if (other.mpeg4FileId != null) + return false; + } else if (!mpeg4FileId.equals(other.mpeg4FileId)) + return false; + if (title == null) { + if (other.title != null) + return false; + } else if (!title.equals(other.title)) + return false; + return true; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.cache.InlineQueryResultCached + * #toString() + */ + @Override + public String toString() { + return "InlineQueryResultCachedMpeg4Gif [mpeg4FileId=" + mpeg4FileId + + ", title=" + title + ", caption=" + caption + + ", inputMessageContent=" + inputMessageContent + ", type=" + + type + ", id=" + id + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/cache/InlineQueryResultCachedPhoto.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/cache/InlineQueryResultCachedPhoto.java new file mode 100644 index 0000000..7ddd7fe --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/cache/InlineQueryResultCachedPhoto.java @@ -0,0 +1,203 @@ +/** + * + */ +package co.aurasphere.botmill.telegram.model.inline.cache; + +import com.google.gson.annotations.SerializedName; + +import co.aurasphere.botmill.telegram.model.inline.InlineQueryResultType; + +/** + * Represents a link to a photo stored on the Telegram servers. By default, this + * photo will be sent by the user with an optional caption. Alternatively, you + * can use input_message_content to send a message with the specified content + * instead of the photo. + * + * @author Donato Rimenti + * @date Dec 26, 2016 + */ +public class InlineQueryResultCachedPhoto extends InlineQueryResultCached { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * A valid file identifier of the photo. + */ + @SerializedName("photo_file_id") + private String photoFileId; + + /** + * Optional. Title for the result. + */ + private String title; + + /** + * Optional. Short description of the result. + */ + private String description; + + // TODO: validation? + /** + * Optional. Caption of the photo to be sent, 0-200 characters. + */ + private String caption; + + /** + * Instantiates a new InlineQueryResultCachedPhoto. + */ + public InlineQueryResultCachedPhoto() { + super(InlineQueryResultType.PHOTO); + } + + /** + * Gets the {@link #photoFileId}. + * + * @return the {@link #photoFileId}. + */ + public String getPhotoFileId() { + return photoFileId; + } + + /** + * Sets the {@link #photoFileId}. + * + * @param photoFileId + * the {@link #photoFileId} to set. + */ + public void setPhotoFileId(String photoFileId) { + this.photoFileId = photoFileId; + } + + /** + * Gets the {@link #title}. + * + * @return the {@link #title}. + */ + public String getTitle() { + return title; + } + + /** + * Sets the {@link #title}. + * + * @param title + * the {@link #title} to set. + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * Gets the {@link #description}. + * + * @return the {@link #description}. + */ + public String getDescription() { + return description; + } + + /** + * Sets the {@link #description}. + * + * @param description + * the {@link #description} to set. + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * Gets the {@link #caption}. + * + * @return the {@link #caption}. + */ + public String getCaption() { + return caption; + } + + /** + * Sets the {@link #caption}. + * + * @param caption + * the {@link #caption} to set. + */ + public void setCaption(String caption) { + this.caption = caption; + } + + /* + * (non-Javadoc) + * + * @see co.aurasphere.botmill.telegram.model.inline. + * InlineQueryInputMessageContentResult#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((caption == null) ? 0 : caption.hashCode()); + result = prime * result + + ((description == null) ? 0 : description.hashCode()); + result = prime * result + + ((photoFileId == null) ? 0 : photoFileId.hashCode()); + result = prime * result + ((title == null) ? 0 : title.hashCode()); + return result; + } + + /* + * (non-Javadoc) + * + * @see co.aurasphere.botmill.telegram.model.inline. + * InlineQueryInputMessageContentResult#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + InlineQueryResultCachedPhoto other = (InlineQueryResultCachedPhoto) obj; + if (caption == null) { + if (other.caption != null) + return false; + } else if (!caption.equals(other.caption)) + return false; + if (description == null) { + if (other.description != null) + return false; + } else if (!description.equals(other.description)) + return false; + if (photoFileId == null) { + if (other.photoFileId != null) + return false; + } else if (!photoFileId.equals(other.photoFileId)) + return false; + if (title == null) { + if (other.title != null) + return false; + } else if (!title.equals(other.title)) + return false; + return true; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.cache.InlineQueryResultCached + * #toString() + */ + @Override + public String toString() { + return "InlineQueryResultCachedPhoto [photoFileId=" + photoFileId + + ", title=" + title + ", description=" + description + + ", caption=" + caption + ", inputMessageContent=" + + inputMessageContent + ", type=" + type + ", id=" + id + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/cache/InlineQueryResultCachedSticker.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/cache/InlineQueryResultCachedSticker.java new file mode 100644 index 0000000..77037db --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/cache/InlineQueryResultCachedSticker.java @@ -0,0 +1,107 @@ +package co.aurasphere.botmill.telegram.model.inline.cache; + +import com.google.gson.annotations.SerializedName; + +import co.aurasphere.botmill.telegram.model.inline.InlineQueryResultType; + +/** + * Represents a link to a sticker stored on the Telegram servers. By default, + * this sticker will be sent by the user. Alternatively, you can use + * input_message_content to send a message with the specified content instead of + * the sticker.
+ *
+ * Note: This will only work in Telegram versions released after 9 April, 2016. + * Older clients will ignore them. + * + * @author Donato Rimenti + * @date Dec 27, 2016 + */ +public class InlineQueryResultCachedSticker extends InlineQueryResultCached { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + @SerializedName("sticker_file_id") + private String stickerFileId; + + /** + * Instantiates a new InlineQueryResultCachedSticker. + */ + public InlineQueryResultCachedSticker() { + super(InlineQueryResultType.STICKER); + } + + /** + * Gets the {@link #stickerFileId}. + * + * @return the {@link #stickerFileId}. + */ + public String getStickerFileId() { + return stickerFileId; + } + + /** + * Sets the {@link #stickerFileId}. + * + * @param stickerFileId + * the {@link #stickerFileId} to set. + */ + public void setStickerFileId(String stickerFileId) { + this.stickerFileId = stickerFileId; + } + + /* + * (non-Javadoc) + * + * @see co.aurasphere.botmill.telegram.model.inline. + * InlineQueryInputMessageContentResult#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + + ((stickerFileId == null) ? 0 : stickerFileId.hashCode()); + return result; + } + + /* + * (non-Javadoc) + * + * @see co.aurasphere.botmill.telegram.model.inline. + * InlineQueryInputMessageContentResult#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + InlineQueryResultCachedSticker other = (InlineQueryResultCachedSticker) obj; + if (stickerFileId == null) { + if (other.stickerFileId != null) + return false; + } else if (!stickerFileId.equals(other.stickerFileId)) + return false; + return true; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.cache.InlineQueryResultCached + * #toString() + */ + @Override + public String toString() { + return "InlineQueryResultCachedSticker [stickerFileId=" + stickerFileId + + ", inputMessageContent=" + inputMessageContent + ", type=" + + type + ", id=" + id + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/cache/InlineQueryResultCachedVideo.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/cache/InlineQueryResultCachedVideo.java new file mode 100644 index 0000000..3b1c40d --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/cache/InlineQueryResultCachedVideo.java @@ -0,0 +1,200 @@ +package co.aurasphere.botmill.telegram.model.inline.cache; + +import com.google.gson.annotations.SerializedName; + +import co.aurasphere.botmill.telegram.model.inline.InlineQueryResultType; + +/** + * Represents a link to a video file stored on the Telegram servers. By default, + * this video file will be sent by the user with an optional caption. + * Alternatively, you can use input_message_content to send a message with the + * specified content instead of the video. + * + * @author Donato Rimenti + * @date Dec 27, 2016 + */ +public class InlineQueryResultCachedVideo extends InlineQueryResultCached { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * A valid file identifier for the video file. + */ + @SerializedName("video_file_id") + private String videoFileId; + + /** + * Title for the result. + */ + private String title; + + /** + * Optional. Short description of the result. + */ + private String description; + + // TODO: validation? + /** + * Optional. Caption of the video to be sent, 0-200 characters. + */ + private String caption; + + /** + * Instantiates a new InlineQueryResultCachedVideo. + */ + public InlineQueryResultCachedVideo() { + super(InlineQueryResultType.VIDEO); + } + + /** + * Gets the {@link #videoFileId}. + * + * @return the {@link #videoFileId}. + */ + public String getVideoFileId() { + return videoFileId; + } + + /** + * Sets the {@link #videoFileId}. + * + * @param videoFileId + * the {@link #videoFileId} to set. + */ + public void setVideoFileId(String videoFileId) { + this.videoFileId = videoFileId; + } + + /** + * Gets the {@link #title}. + * + * @return the {@link #title}. + */ + public String getTitle() { + return title; + } + + /** + * Sets the {@link #title}. + * + * @param title + * the {@link #title} to set. + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * Gets the {@link #description}. + * + * @return the {@link #description}. + */ + public String getDescription() { + return description; + } + + /** + * Sets the {@link #description}. + * + * @param description + * the {@link #description} to set. + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * Gets the {@link #caption}. + * + * @return the {@link #caption}. + */ + public String getCaption() { + return caption; + } + + /** + * Sets the {@link #caption}. + * + * @param caption + * the {@link #caption} to set. + */ + public void setCaption(String caption) { + this.caption = caption; + } + + /* + * (non-Javadoc) + * + * @see co.aurasphere.botmill.telegram.model.inline. + * InlineQueryInputMessageContentResult#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((caption == null) ? 0 : caption.hashCode()); + result = prime * result + + ((description == null) ? 0 : description.hashCode()); + result = prime * result + ((title == null) ? 0 : title.hashCode()); + result = prime * result + + ((videoFileId == null) ? 0 : videoFileId.hashCode()); + return result; + } + + /* + * (non-Javadoc) + * + * @see co.aurasphere.botmill.telegram.model.inline. + * InlineQueryInputMessageContentResult#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + InlineQueryResultCachedVideo other = (InlineQueryResultCachedVideo) obj; + if (caption == null) { + if (other.caption != null) + return false; + } else if (!caption.equals(other.caption)) + return false; + if (description == null) { + if (other.description != null) + return false; + } else if (!description.equals(other.description)) + return false; + if (title == null) { + if (other.title != null) + return false; + } else if (!title.equals(other.title)) + return false; + if (videoFileId == null) { + if (other.videoFileId != null) + return false; + } else if (!videoFileId.equals(other.videoFileId)) + return false; + return true; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.cache.InlineQueryResultCached + * #toString() + */ + @Override + public String toString() { + return "InlineQueryResultCachedVideo [videoFileId=" + videoFileId + + ", title=" + title + ", description=" + description + + ", caption=" + caption + ", inputMessageContent=" + + inputMessageContent + ", type=" + type + ", id=" + id + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/cache/InlineQueryResultCachedVoice.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/cache/InlineQueryResultCachedVoice.java new file mode 100644 index 0000000..3e1afec --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/cache/InlineQueryResultCachedVoice.java @@ -0,0 +1,172 @@ +package co.aurasphere.botmill.telegram.model.inline.cache; + +import com.google.gson.annotations.SerializedName; + +import co.aurasphere.botmill.telegram.model.inline.InlineQueryResultType; + +/** + * Represents a link to a voice message stored on the Telegram servers. By + * default, this voice message will be sent by the user. Alternatively, you can + * use input_message_content to send a message with the specified content + * instead of the voice message.
+ *
+ * Note: This will only work in Telegram versions released after 9 April, 2016. + * Older clients will ignore them. + * + * @author Donato Rimenti + * @date Dec 27, 2016 + */ +public class InlineQueryResultCachedVoice extends InlineQueryResultCached { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * A valid file identifier for the voice message. + */ + @SerializedName("voice_file_id") + private String voiceFileId; + + /** + * Voice message title. + */ + private String title; + + // TODO: validation? + /** + * Optional. Caption, 0-200 characters. + */ + private String caption; + + /** + * Instantiates a new InlineQueryResultCachedVoice. + */ + public InlineQueryResultCachedVoice() { + super(InlineQueryResultType.VOICE); + } + + /** + * Gets the {@link #voiceFileId}. + * + * @return the {@link #voiceFileId}. + */ + public String getVoiceFileId() { + return voiceFileId; + } + + /** + * Sets the {@link #voiceFileId}. + * + * @param voiceFileId + * the {@link #voiceFileId} to set. + */ + public void setVoiceFileId(String voiceFileId) { + this.voiceFileId = voiceFileId; + } + + /** + * Gets the {@link #title}. + * + * @return the {@link #title}. + */ + public String getTitle() { + return title; + } + + /** + * Sets the {@link #title}. + * + * @param title + * the {@link #title} to set. + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * Gets the {@link #caption}. + * + * @return the {@link #caption}. + */ + public String getCaption() { + return caption; + } + + /** + * Sets the {@link #caption}. + * + * @param caption + * the {@link #caption} to set. + */ + public void setCaption(String caption) { + this.caption = caption; + } + + /* + * (non-Javadoc) + * + * @see co.aurasphere.botmill.telegram.model.inline. + * InlineQueryInputMessageContentResult#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((caption == null) ? 0 : caption.hashCode()); + result = prime * result + ((title == null) ? 0 : title.hashCode()); + result = prime * result + + ((voiceFileId == null) ? 0 : voiceFileId.hashCode()); + return result; + } + + /* + * (non-Javadoc) + * + * @see co.aurasphere.botmill.telegram.model.inline. + * InlineQueryInputMessageContentResult#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + InlineQueryResultCachedVoice other = (InlineQueryResultCachedVoice) obj; + if (caption == null) { + if (other.caption != null) + return false; + } else if (!caption.equals(other.caption)) + return false; + if (title == null) { + if (other.title != null) + return false; + } else if (!title.equals(other.title)) + return false; + if (voiceFileId == null) { + if (other.voiceFileId != null) + return false; + } else if (!voiceFileId.equals(other.voiceFileId)) + return false; + return true; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.cache.InlineQueryResultCached + * #toString() + */ + @Override + public String toString() { + return "InlineQueryResultCachedVoice [voiceFileId=" + voiceFileId + + ", title=" + title + ", caption=" + caption + + ", inputMessageContent=" + inputMessageContent + ", type=" + + type + ", id=" + id + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/input/InlineQueryInputMessageContentResult.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/input/InlineQueryInputMessageContentResult.java new file mode 100644 index 0000000..df0e416 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/input/InlineQueryInputMessageContentResult.java @@ -0,0 +1,107 @@ +package co.aurasphere.botmill.telegram.model.inline.input; + +import co.aurasphere.botmill.telegram.model.inline.InlineQueryResult; +import co.aurasphere.botmill.telegram.model.inline.InlineQueryResultType; + +import com.google.gson.annotations.SerializedName; + +/** + * This object represents one result of an inline query. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public abstract class InlineQueryInputMessageContentResult extends + InlineQueryResult { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Content of the message to be sent. + */ + @SerializedName("input_message_content") + protected InputMessageContent inputMessageContent; + + /** + * Instantiates a new InlineQueryInputMessageContentResult. + * + * @param type + * the {@link InlineQueryResult#type}. + */ + public InlineQueryInputMessageContentResult(InlineQueryResultType type) { + super(type); + } + + /** + * Gets the {@link #inputMessageContent}. + * + * @return the {@link #inputMessageContent}. + */ + public InputMessageContent getInputMessageContent() { + return inputMessageContent; + } + + /** + * Sets the {@link #inputMessageContent}. + * + * @param inputMessageContent + * the {@link #inputMessageContent} to set. + */ + public void setInputMessageContent(InputMessageContent inputMessageContent) { + this.inputMessageContent = inputMessageContent; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime + * result + + ((inputMessageContent == null) ? 0 : inputMessageContent + .hashCode()); + return result; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#equals( + * java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + InlineQueryInputMessageContentResult other = (InlineQueryInputMessageContentResult) obj; + if (inputMessageContent != other.inputMessageContent) + return false; + return true; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.InlineQueryResult#toString() + */ + @Override + public String toString() { + return "InlineQueryInputMessageContentResult [inputMessageContent=" + + inputMessageContent + ", type=" + type + ", id=" + id + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/input/InputContactMessageContent.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/input/InputContactMessageContent.java new file mode 100644 index 0000000..17964d1 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/input/InputContactMessageContent.java @@ -0,0 +1,160 @@ +package co.aurasphere.botmill.telegram.model.inline.input; + +import com.google.gson.annotations.SerializedName; + +/** + * Represents the content of a contact message to be sent as the result of an + * inline query.
+ *
+ * Note: This will only work in Telegram versions released after 9 April, 2016. + * Older clients will ignore them. + * + * @author Donato Rimenti + * @date Dec 27, 2016 + */ +public class InputContactMessageContent extends InputMessageContent { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Contact's phone number. + */ + @SerializedName("phone_number") + private String phoneNumber; + + /** + * Contact's first name. + */ + @SerializedName("first_name") + private String firstName; + + /** + * Optional. Contact's last name. + */ + @SerializedName("last_name") + private String lastName; + + /** + * Gets the {@link #phoneNumber}. + * + * @return the {@link #phoneNumber}. + */ + public String getPhoneNumber() { + return phoneNumber; + } + + /** + * Sets the {@link #phoneNumber}. + * + * @param phoneNumber + * the {@link #phoneNumber} to set. + */ + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + /** + * Gets the {@link #firstName}. + * + * @return the {@link #firstName}. + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets the {@link #firstName}. + * + * @param firstName + * the {@link #firstName} to set. + */ + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + /** + * Gets the {@link #lastName}. + * + * @return the {@link #lastName}. + */ + public String getLastName() { + return lastName; + } + + /** + * Sets the {@link #lastName}. + * + * @param lastName + * the {@link #lastName} to set. + */ + public void setLastName(String lastName) { + this.lastName = lastName; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((firstName == null) ? 0 : firstName.hashCode()); + result = prime * result + + ((lastName == null) ? 0 : lastName.hashCode()); + result = prime * result + + ((phoneNumber == null) ? 0 : phoneNumber.hashCode()); + return result; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + InputContactMessageContent other = (InputContactMessageContent) obj; + if (firstName == null) { + if (other.firstName != null) + return false; + } else if (!firstName.equals(other.firstName)) + return false; + if (lastName == null) { + if (other.lastName != null) + return false; + } else if (!lastName.equals(other.lastName)) + return false; + if (phoneNumber == null) { + if (other.phoneNumber != null) + return false; + } else if (!phoneNumber.equals(other.phoneNumber)) + return false; + return true; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.input.InputMessageContent + * #toString() + */ + @Override + public String toString() { + return "InputContactMessageContent [phoneNumber=" + phoneNumber + + ", firstName=" + firstName + ", lastName=" + lastName + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/input/InputLocationMessageContent.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/input/InputLocationMessageContent.java new file mode 100644 index 0000000..99c71bc --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/input/InputLocationMessageContent.java @@ -0,0 +1,121 @@ +package co.aurasphere.botmill.telegram.model.inline.input; + +/** + * Represents the content of a location message to be sent as the result of an + * inline query.
+ *
+ * Note: This will only work in Telegram versions released after 9 April, 2016. + * Older clients will ignore them. + * + * @author Donato Rimenti + * @date Dec 27, 2016 + */ +public class InputLocationMessageContent extends InputMessageContent { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Latitude of the location in degrees. + */ + protected double latitude; + + /** + * Longitude of the location in degrees. + */ + protected double longitude; + + /** + * Gets the {@link #latitude}. + * + * @return the {@link #latitude}. + */ + public double getLatitude() { + return latitude; + } + + /** + * Sets the {@link #latitude}. + * + * @param latitude + * the {@link #latitude} to set. + */ + public void setLatitude(double latitude) { + this.latitude = latitude; + } + + /** + * Gets the {@link #longitude}. + * + * @return the {@link #longitude}. + */ + public double getLongitude() { + return longitude; + } + + /** + * Sets the {@link #longitude}. + * + * @param longitude + * the {@link #longitude} to set. + */ + public void setLongitude(double longitude) { + this.longitude = longitude; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + long temp; + temp = Double.doubleToLongBits(latitude); + result = prime * result + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(longitude); + result = prime * result + (int) (temp ^ (temp >>> 32)); + return result; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + InputLocationMessageContent other = (InputLocationMessageContent) obj; + if (Double.doubleToLongBits(latitude) != Double + .doubleToLongBits(other.latitude)) + return false; + if (Double.doubleToLongBits(longitude) != Double + .doubleToLongBits(other.longitude)) + return false; + return true; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.input.InputMessageContent + * #toString() + */ + @Override + public String toString() { + return "InputLocationMessageContent [latitude=" + latitude + + ", longitude=" + longitude + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/input/InputMessageContent.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/input/InputMessageContent.java new file mode 100644 index 0000000..e6f049b --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/input/InputMessageContent.java @@ -0,0 +1,27 @@ +package co.aurasphere.botmill.telegram.model.inline.input; + +import java.io.Serializable; + +/** + * This object represents the content of a message to be sent as a result of an + * inline query. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public abstract class InputMessageContent implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "InputMessageContent []"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/input/InputTextMessageContent.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/input/InputTextMessageContent.java new file mode 100644 index 0000000..1b47dc4 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/input/InputTextMessageContent.java @@ -0,0 +1,155 @@ +package co.aurasphere.botmill.telegram.model.inline.input; + +import com.google.gson.annotations.SerializedName; + +/** + * Represents the content of a text message to be sent as the result of an + * inline query. + * + * @author Donato Rimenti + * @date Dec 27, 2016 + */ +public class InputTextMessageContent extends InputMessageContent { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + // TODO: validation? + /** + * Text of the message to be sent, 1-4096 characters. + */ + @SerializedName("message_text") + private String messageText; + + /** + * Optional. Send {@link ParseMode#MARKDOWN} or {@link ParseMode#HTML}, if + * you want Telegram apps to show bold, + * italic, fixed-width text or inline URLs in your bot's message. + */ + @SerializedName("parse_mode") + private ParseMode parseMode; + + /** + * Optional. Disables link previews for links in the sent message. + */ + @SerializedName("disable_web_page_preview") + private boolean disableWebPagePreview; + + /** + * Gets the {@link #messageText}. + * + * @return the {@link #messageText}. + */ + public String getMessageText() { + return messageText; + } + + /** + * Sets the {@link #messageText}. + * + * @param messageText + * the {@link #messageText} to set. + */ + public void setMessageText(String messageText) { + this.messageText = messageText; + } + + /** + * Gets the {@link #parseMode}. + * + * @return the {@link #parseMode}. + */ + public ParseMode getParseMode() { + return parseMode; + } + + /** + * Sets the {@link #parseMode}. + * + * @param parseMode + * the {@link #parseMode} to set. + */ + public void setParseMode(ParseMode parseMode) { + this.parseMode = parseMode; + } + + /** + * Gets the {@link #disableWebPagePreview}. + * + * @return the {@link #disableWebPagePreview}. + */ + public boolean isDisableWebPagePreview() { + return disableWebPagePreview; + } + + /** + * Sets the {@link #disableWebPagePreview}. + * + * @param disableWebPagePreview + * the {@link #disableWebPagePreview} to set. + */ + public void setDisableWebPagePreview(boolean disableWebPagePreview) { + this.disableWebPagePreview = disableWebPagePreview; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (disableWebPagePreview ? 1231 : 1237); + result = prime * result + + ((messageText == null) ? 0 : messageText.hashCode()); + result = prime * result + + ((parseMode == null) ? 0 : parseMode.hashCode()); + return result; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + InputTextMessageContent other = (InputTextMessageContent) obj; + if (disableWebPagePreview != other.disableWebPagePreview) + return false; + if (messageText == null) { + if (other.messageText != null) + return false; + } else if (!messageText.equals(other.messageText)) + return false; + if (parseMode != other.parseMode) + return false; + return true; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.input.InputMessageContent + * #toString() + */ + @Override + public String toString() { + return "InputTextMessageContent [messageText=" + messageText + + ", parseMode=" + parseMode + ", disableWebPagePreview=" + + disableWebPagePreview + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/input/InputVenueMessageContent.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/input/InputVenueMessageContent.java new file mode 100644 index 0000000..aa8153d --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/input/InputVenueMessageContent.java @@ -0,0 +1,160 @@ +package co.aurasphere.botmill.telegram.model.inline.input; + +import com.google.gson.annotations.SerializedName; + +/** + * Represents the content of a venue message to be sent as the result of an + * inline query.
+ *
+ * Note: This will only work in Telegram versions released after 9 April, 2016. + * Older clients will ignore them. + * + * @author Donato Rimenti + * @date Dec 27, 2016 + */ +public class InputVenueMessageContent extends InputLocationMessageContent { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Name of the venue. + */ + private String title; + + /** + * Address of the venue. + */ + private String address; + + /** + * Optional. Foursquare identifier of the venue, if known. + */ + @SerializedName("foursquare_id") + private String foursquareId; + + /** + * Gets the {@link #title}. + * + * @return the {@link #title}. + */ + public String getTitle() { + return title; + } + + /** + * Sets the {@link #title}. + * + * @param title + * the {@link #title} to set. + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * Gets the {@link #address}. + * + * @return the {@link #address}. + */ + public String getAddress() { + return address; + } + + /** + * Sets the {@link #address}. + * + * @param address + * the {@link #address} to set. + */ + public void setAddress(String address) { + this.address = address; + } + + /** + * Gets the {@link #foursquareId}. + * + * @return the {@link #foursquareId}. + */ + public String getFoursquareId() { + return foursquareId; + } + + /** + * Sets the {@link #foursquareId}. + * + * @param foursquareId + * the {@link #foursquareId} to set. + */ + public void setFoursquareId(String foursquareId) { + this.foursquareId = foursquareId; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.input.InputLocationMessageContent + * #hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((address == null) ? 0 : address.hashCode()); + result = prime * result + + ((foursquareId == null) ? 0 : foursquareId.hashCode()); + result = prime * result + ((title == null) ? 0 : title.hashCode()); + return result; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.input.InputLocationMessageContent + * #equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + InputVenueMessageContent other = (InputVenueMessageContent) obj; + if (address == null) { + if (other.address != null) + return false; + } else if (!address.equals(other.address)) + return false; + if (foursquareId == null) { + if (other.foursquareId != null) + return false; + } else if (!foursquareId.equals(other.foursquareId)) + return false; + if (title == null) { + if (other.title != null) + return false; + } else if (!title.equals(other.title)) + return false; + return true; + } + + /* + * (non-Javadoc) + * + * @see + * co.aurasphere.botmill.telegram.model.inline.input.InputLocationMessageContent + * #toString() + */ + @Override + public String toString() { + return "InputVenueMessageContent [title=" + title + ", address=" + + address + ", foursquareId=" + foursquareId + ", latitude=" + + latitude + ", longitude=" + longitude + "]"; + } +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/inline/input/ParseMode.java b/src/main/java/co/aurasphere/botmill/telegram/model/inline/input/ParseMode.java new file mode 100644 index 0000000..7a68cbd --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/inline/input/ParseMode.java @@ -0,0 +1,31 @@ +package co.aurasphere.botmill.telegram.model.inline.input; + +import com.google.gson.annotations.SerializedName; + +/** + * The Bot API supports basic formatting for messages. You can use bold and + * italic text, as well as inline links and pre-formatted code in your bots' + * messages. Telegram clients will render them accordingly. You can use either + * markdown-style or HTML-style formatting. + * + * @see Formatting + * options. + * + * @author Donato Rimenti + * @date Dec 27, 2016 + */ +public enum ParseMode { + + /** + * The html. + */ + HTML, + + /** + * The markdown. + */ + @SerializedName("Markdown") + MARKDOWN; + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/update/Update.java b/src/main/java/co/aurasphere/botmill/telegram/model/update/Update.java new file mode 100644 index 0000000..6ede932 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/update/Update.java @@ -0,0 +1,298 @@ +package co.aurasphere.botmill.telegram.model.update; + +import java.io.Serializable; + +import co.aurasphere.botmill.telegram.model.CallbackQuery; +import co.aurasphere.botmill.telegram.model.Message; +import co.aurasphere.botmill.telegram.model.inline.ChosenInlineResult; +import co.aurasphere.botmill.telegram.model.inline.InlineQuery; + +import com.google.gson.annotations.SerializedName; + +/** + * This object represents an incoming update. At most one of the optional + * parameters can be present in any given update. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class Update implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + // TODO: link to setWebhook method once created + /** + * The update‘s unique identifier. Update identifiers start from a certain + * positive number and increase sequentially. This ID becomes especially + * handy if you’re using Webhooks, since it allows you to ignore repeated + * updates or to restore the correct update sequence, should they get out of + * order. + */ + @SerializedName("update_id") + private String updateId; + + /** + * Optional. New incoming message of any kind — text, photo, sticker, etc. + */ + private Message message; + + /** + * Optional. New version of a message that is known to the bot and was + * edited. + */ + @SerializedName("edited_message") + private Message editedMessage; + + /** + * Optional. New incoming channel post of any kind — text, photo, sticker, + * etc. + */ + @SerializedName("channel_post") + private Message channelPost; + + /** + * Optional. New version of a channel post that is known to the bot and was + * edited. + */ + @SerializedName("edited_channel_post") + private Message editedChannelPost; + + /** + * Optional. New incoming inline query. + */ + @SerializedName("inline_query") + private InlineQuery inlineQuery; + + /** + * Optional. The result of an inline query that was chosen by a user and + * sent to their chat partner. + */ + @SerializedName("chosen_inline_result") + private ChosenInlineResult chosenInlineResult; + + /** + * Optional. New incoming callback query. + */ + @SerializedName("callback_query") + private CallbackQuery callbackQuery; + + /** + * Gets the {@link #updateId}. + * + * @return the {@link #updateId}. + */ + public String getUpdateId() { + return updateId; + } + + /** + * Sets the {@link #updateId}. + * + * @param updateId the {@link #updateId} to set. + */ + public void setUpdateId(String updateId) { + this.updateId = updateId; + } + + /** + * Gets the {@link #message}. + * + * @return the {@link #message}. + */ + public Message getMessage() { + return message; + } + + /** + * Sets the {@link #message}. + * + * @param message the {@link #message} to set. + */ + public void setMessage(Message message) { + this.message = message; + } + + /** + * Gets the {@link #editedMessage}. + * + * @return the {@link #editedMessage}. + */ + public Message getEditedMessage() { + return editedMessage; + } + + /** + * Sets the {@link #editedMessage}. + * + * @param editedMessage the {@link #editedMessage} to set. + */ + public void setEditedMessage(Message editedMessage) { + this.editedMessage = editedMessage; + } + + /** + * Gets the {@link #channelPost}. + * + * @return the {@link #channelPost}. + */ + public Message getChannelPost() { + return channelPost; + } + + /** + * Sets the {@link #channelPost}. + * + * @param channelPost the {@link #channelPost} to set. + */ + public void setChannelPost(Message channelPost) { + this.channelPost = channelPost; + } + + /** + * Gets the {@link #editedChannelPost}. + * + * @return the {@link #editedChannelPost}. + */ + public Message getEditedChannelPost() { + return editedChannelPost; + } + + /** + * Sets the {@link #editedChannelPost}. + * + * @param editedChannelPost the {@link #editedChannelPost} to set. + */ + public void setEditedChannelPost(Message editedChannelPost) { + this.editedChannelPost = editedChannelPost; + } + + /** + * Gets the {@link #inlineQuery}. + * + * @return the {@link #inlineQuery}. + */ + public InlineQuery getInlineQuery() { + return inlineQuery; + } + + /** + * Sets the {@link #inlineQuery}. + * + * @param inlineQuery the {@link #inlineQuery} to set. + */ + public void setInlineQuery(InlineQuery inlineQuery) { + this.inlineQuery = inlineQuery; + } + + /** + * Gets the {@link #chosenInlineResult}. + * + * @return the {@link #chosenInlineResult}. + */ + public ChosenInlineResult getChosenInlineResult() { + return chosenInlineResult; + } + + /** + * Sets the {@link #chosenInlineResult}. + * + * @param chosenInlineResult the {@link #chosenInlineResult} to set. + */ + public void setChosenInlineResult(ChosenInlineResult chosenInlineResult) { + this.chosenInlineResult = chosenInlineResult; + } + + /** + * Gets the {@link #callbackQuery}. + * + * @return the {@link #callbackQuery}. + */ + public CallbackQuery getCallbackQuery() { + return callbackQuery; + } + + /** + * Sets the {@link #callbackQuery}. + * + * @param callbackQuery the {@link #callbackQuery} to set. + */ + public void setCallbackQuery(CallbackQuery callbackQuery) { + this.callbackQuery = callbackQuery; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((channelPost == null) ? 0 : channelPost.hashCode()); + result = prime + * result + + ((editedChannelPost == null) ? 0 : editedChannelPost + .hashCode()); + result = prime * result + + ((editedMessage == null) ? 0 : editedMessage.hashCode()); + result = prime * result + ((message == null) ? 0 : message.hashCode()); + result = prime * result + + ((updateId == null) ? 0 : updateId.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Update other = (Update) obj; + if (channelPost == null) { + if (other.channelPost != null) + return false; + } else if (!channelPost.equals(other.channelPost)) + return false; + if (editedChannelPost == null) { + if (other.editedChannelPost != null) + return false; + } else if (!editedChannelPost.equals(other.editedChannelPost)) + return false; + if (editedMessage == null) { + if (other.editedMessage != null) + return false; + } else if (!editedMessage.equals(other.editedMessage)) + return false; + if (message == null) { + if (other.message != null) + return false; + } else if (!message.equals(other.message)) + return false; + if (updateId == null) { + if (other.updateId != null) + return false; + } else if (!updateId.equals(other.updateId)) + return false; + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "Update [updateId=" + updateId + ", message=" + message + + ", editedMessage=" + editedMessage + ", channelPost=" + + channelPost + ", editedChannelPost=" + editedChannelPost + + "]"; + } + +} diff --git a/src/main/java/co/aurasphere/botmill/telegram/model/update/WebhookInfo.java b/src/main/java/co/aurasphere/botmill/telegram/model/update/WebhookInfo.java new file mode 100644 index 0000000..94a2a61 --- /dev/null +++ b/src/main/java/co/aurasphere/botmill/telegram/model/update/WebhookInfo.java @@ -0,0 +1,261 @@ +package co.aurasphere.botmill.telegram.model.update; + +import java.io.Serializable; +import java.util.Calendar; +import java.util.List; + +import com.google.gson.annotations.SerializedName; + +/** + * Contains information about the current status of a webhook. + * + * @author Donato Rimenti + * @date Dec 25, 2016 + */ +public class WebhookInfo implements Serializable { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Webhook URL, may be empty if webhook is not set up. + */ + private String url; + + /** + * True, if a custom certificate was provided for webhook certificate + * checks. + */ + @SerializedName("has_custom_certificate") + private boolean hasCustomCertificate; + + /** + * Number of updates awaiting delivery. + */ + @SerializedName("pending_update_count") + private int pendingUpdateCount; + + // TODO: check if this works + /** + * Optional. Unix time for the most recent error that happened when trying + * to deliver an update via webhook. + */ + @SerializedName("last_error_date") + private Calendar lastErrorDate; + + /** + * Optional. Error message in human-readable format for the most recent + * error that happened when trying to deliver an update via webhook. + */ + @SerializedName("last_error_message") + private String lastErrorMessage; + + /** + * Optional. Maximum allowed number of simultaneous HTTPS connections to the + * webhook for update delivery. + */ + @SerializedName("max_connections") + private int maxConnections; + + /** + * Optional. A list of update types the bot is subscribed to. Defaults to + * all update types. + */ + @SerializedName("allowed_updates") + private List allowedUpdates; + + /** + * Gets the {@link #url}. + * + * @return the {@link #url}. + */ + public String getUrl() { + return url; + } + + /** + * Sets the {@link #url}. + * + * @param url the {@link #url} to set. + */ + public void setUrl(String url) { + this.url = url; + } + + /** + * Gets the {@link #hasCustomCertificate}. + * + * @return the {@link #hasCustomCertificate}. + */ + public boolean isHasCustomCertificate() { + return hasCustomCertificate; + } + + /** + * Sets the {@link #hasCustomCertificate}. + * + * @param hasCustomCertificate the {@link #hasCustomCertificate} to set. + */ + public void setHasCustomCertificate(boolean hasCustomCertificate) { + this.hasCustomCertificate = hasCustomCertificate; + } + + /** + * Gets the {@link #pendingUpdateCount}. + * + * @return the {@link #pendingUpdateCount}. + */ + public int getPendingUpdateCount() { + return pendingUpdateCount; + } + + /** + * Sets the {@link #pendingUpdateCount}. + * + * @param pendingUpdateCount the {@link #pendingUpdateCount} to set. + */ + public void setPendingUpdateCount(int pendingUpdateCount) { + this.pendingUpdateCount = pendingUpdateCount; + } + + /** + * Gets the {@link #lastErrorDate}. + * + * @return the {@link #lastErrorDate}. + */ + public Calendar getLastErrorDate() { + return lastErrorDate; + } + + /** + * Sets the {@link #lastErrorDate}. + * + * @param lastErrorDate the {@link #lastErrorDate} to set. + */ + public void setLastErrorDate(Calendar lastErrorDate) { + this.lastErrorDate = lastErrorDate; + } + + /** + * Gets the {@link #lastErrorMessage}. + * + * @return the {@link #lastErrorMessage}. + */ + public String getLastErrorMessage() { + return lastErrorMessage; + } + + /** + * Sets the {@link #lastErrorMessage}. + * + * @param lastErrorMessage the {@link #lastErrorMessage} to set. + */ + public void setLastErrorMessage(String lastErrorMessage) { + this.lastErrorMessage = lastErrorMessage; + } + + /** + * Gets the {@link #maxConnections}. + * + * @return the {@link #maxConnections}. + */ + public int getMaxConnections() { + return maxConnections; + } + + /** + * Sets the {@link #maxConnections}. + * + * @param maxConnections the {@link #maxConnections} to set. + */ + public void setMaxConnections(int maxConnections) { + this.maxConnections = maxConnections; + } + + /** + * Gets the {@link #allowedUpdates}. + * + * @return the {@link #allowedUpdates}. + */ + public List getAllowedUpdates() { + return allowedUpdates; + } + + /** + * Sets the {@link #allowedUpdates}. + * + * @param allowedUpdates the {@link #allowedUpdates} to set. + */ + public void setAllowedUpdates(List allowedUpdates) { + this.allowedUpdates = allowedUpdates; + } + + /* (non-Javadoc) + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (hasCustomCertificate ? 1231 : 1237); + result = prime * result + + ((lastErrorDate == null) ? 0 : lastErrorDate.hashCode()); + result = prime + * result + + ((lastErrorMessage == null) ? 0 : lastErrorMessage.hashCode()); + result = prime * result + maxConnections; + result = prime * result + pendingUpdateCount; + result = prime * result + ((url == null) ? 0 : url.hashCode()); + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + WebhookInfo other = (WebhookInfo) obj; + if (hasCustomCertificate != other.hasCustomCertificate) + return false; + if (lastErrorDate == null) { + if (other.lastErrorDate != null) + return false; + } else if (!lastErrorDate.equals(other.lastErrorDate)) + return false; + if (lastErrorMessage == null) { + if (other.lastErrorMessage != null) + return false; + } else if (!lastErrorMessage.equals(other.lastErrorMessage)) + return false; + if (maxConnections != other.maxConnections) + return false; + if (pendingUpdateCount != other.pendingUpdateCount) + return false; + if (url == null) { + if (other.url != null) + return false; + } else if (!url.equals(other.url)) + return false; + return true; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return "WebhookInfo [url=" + url + ", hasCustomCertificate=" + + hasCustomCertificate + ", pendingUpdateCount=" + + pendingUpdateCount + ", lastErrorDate=" + lastErrorDate + + ", lastErrorMessage=" + lastErrorMessage + + ", maxConnections=" + maxConnections + "]"; + } +}