diff --git a/build.gradle b/build.gradle index 51049dfb..83d7d641 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,19 @@ +buildscript { + ext.versions = [ + 'kotlin': '1.3.70' + ] + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}" + } + repositories { + mavenCentral() + google() + } +} + subprojects { repositories { - jcenter() + mavenCentral() + google() } } \ No newline at end of file diff --git a/library/build.gradle b/library/build.gradle index e00ddb37..58469fa3 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -1,5 +1,6 @@ apply plugin: 'java' apply plugin: 'jacoco' +apply plugin: 'kotlin' sourceCompatibility = 1.6 targetCompatibility = 1.6 @@ -10,6 +11,7 @@ compileTestJava { } dependencies { + compile "org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlin}" compile 'com.google.code.gson:gson:2.8.5' compile 'com.squareup.okhttp3:okhttp:3.12.3' compile 'com.squareup.okhttp3:logging-interceptor:3.12.3' @@ -20,7 +22,7 @@ dependencies { } jacoco { - toolVersion = "0.8.3" + toolVersion = "0.8.5" } jacocoTestReport { diff --git a/library/hamcrest-core-1.3.jar b/library/hamcrest-core-1.3.jar new file mode 100644 index 00000000..9d5fe16e Binary files /dev/null and b/library/hamcrest-core-1.3.jar differ diff --git a/library/junit-4.12.jar b/library/junit-4.12.jar new file mode 100644 index 00000000..3a7fc266 Binary files /dev/null and b/library/junit-4.12.jar differ diff --git a/library/src/main/java/com/pengrad/telegrambot/impl/SerialName.kt b/library/src/main/java/com/pengrad/telegrambot/impl/SerialName.kt new file mode 100644 index 00000000..c30d2d93 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/impl/SerialName.kt @@ -0,0 +1,9 @@ +package com.pengrad.telegrambot.impl + +import com.google.gson.annotations.SerializedName + +/** + * Stas Parshin + * 23 February 2020 + */ +internal typealias SerialName = SerializedName \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Animation.java b/library/src/main/java/com/pengrad/telegrambot/model/Animation.java deleted file mode 100644 index ce79ba0a..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/Animation.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * Stas Parshin - * 03 October 2016 - */ -public class Animation implements Serializable { - private final static long serialVersionUID = 0L; - - private String file_id; - private String file_unique_id; - private Integer width; - private Integer height; - private Integer duration; - private PhotoSize thumb; - private String file_name; - private String mime_type; - private Integer file_size; - - public String fileId() { - return file_id; - } - - public String fileUniqueId() { - return file_unique_id; - } - - public Integer width() { - return width; - } - - public Integer height() { - return height; - } - - public Integer duration() { - return duration; - } - - public PhotoSize thumb() { - return thumb; - } - - public String fileName() { - return file_name; - } - - public String mimeType() { - return mime_type; - } - - public Integer fileSize() { - return file_size; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Animation animation = (Animation) o; - - if (file_id != null ? !file_id.equals(animation.file_id) : animation.file_id != null) return false; - if (file_unique_id != null ? !file_unique_id.equals(animation.file_unique_id) : animation.file_unique_id != null) - return false; - if (width != null ? !width.equals(animation.width) : animation.width != null) return false; - if (height != null ? !height.equals(animation.height) : animation.height != null) return false; - if (duration != null ? !duration.equals(animation.duration) : animation.duration != null) return false; - if (thumb != null ? !thumb.equals(animation.thumb) : animation.thumb != null) return false; - if (file_name != null ? !file_name.equals(animation.file_name) : animation.file_name != null) return false; - if (mime_type != null ? !mime_type.equals(animation.mime_type) : animation.mime_type != null) return false; - return file_size != null ? file_size.equals(animation.file_size) : animation.file_size == null; - } - - @Override - public int hashCode() { - return file_id != null ? file_id.hashCode() : 0; - } - - @Override - public String toString() { - return "Animation{" + - "file_id='" + file_id + '\'' + - ", file_unique_id='" + file_unique_id + '\'' + - ", width=" + width + - ", height=" + height + - ", duration=" + duration + - ", thumb=" + thumb + - ", file_name='" + file_name + '\'' + - ", mime_type='" + mime_type + '\'' + - ", file_size=" + file_size + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Animation.kt b/library/src/main/java/com/pengrad/telegrambot/model/Animation.kt new file mode 100644 index 00000000..fe559fc4 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/Animation.kt @@ -0,0 +1,23 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * Stas Parshin + * 03 October 2016 + */ +data class Animation( + @get:JvmName("fileId") val file_id: String? = null, + @get:JvmName("fileUniqueId") val file_unique_id: String? = null, + @get:JvmName("width") val width: Int? = null, + @get:JvmName("height") val height: Int? = null, + @get:JvmName("duration") val duration: Int? = null, + @get:JvmName("thumb") val thumb: PhotoSize? = null, + @get:JvmName("fileName") val file_name: String? = null, + @get:JvmName("mimeType") val mime_type: String? = null, + @get:JvmName("fileSize") val file_size: Int? = null +) : Serializable { + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Audio.java b/library/src/main/java/com/pengrad/telegrambot/model/Audio.java deleted file mode 100644 index 60b0fce1..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/Audio.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * stas - * 8/5/15. - */ -public class Audio implements Serializable { - private final static long serialVersionUID = 0L; - - private String file_id; - private String file_unique_id; - private Integer duration; - private String performer; - private String title; - private String mime_type; - private Integer file_size; - private PhotoSize thumb; - - public String fileId() { - return file_id; - } - - public String fileUniqueId() { - return file_unique_id; - } - - public Integer duration() { - return duration; - } - - public String performer() { - return performer; - } - - public String title() { - return title; - } - - public String mimeType() { - return mime_type; - } - - public Integer fileSize() { - return file_size; - } - - public PhotoSize thumb() { - return thumb; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Audio audio = (Audio) o; - - if (file_id != null ? !file_id.equals(audio.file_id) : audio.file_id != null) return false; - if (file_unique_id != null ? !file_unique_id.equals(audio.file_unique_id) : audio.file_unique_id != null) return false; - if (duration != null ? !duration.equals(audio.duration) : audio.duration != null) return false; - if (performer != null ? !performer.equals(audio.performer) : audio.performer != null) return false; - if (title != null ? !title.equals(audio.title) : audio.title != null) return false; - if (mime_type != null ? !mime_type.equals(audio.mime_type) : audio.mime_type != null) return false; - if (file_size != null ? !file_size.equals(audio.file_size) : audio.file_size != null) return false; - return thumb != null ? thumb.equals(audio.thumb) : audio.thumb == null; - } - - @Override - public int hashCode() { - return file_id != null ? file_id.hashCode() : 0; - } - - @Override - public String toString() { - return "Audio{" + - "file_id='" + file_id + '\'' + - ", file_unique_id='" + file_unique_id + '\'' + - ", duration=" + duration + - ", performer='" + performer + '\'' + - ", title='" + title + '\'' + - ", mime_type='" + mime_type + '\'' + - ", file_size=" + file_size + - ", thumb=" + thumb + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Audio.kt b/library/src/main/java/com/pengrad/telegrambot/model/Audio.kt new file mode 100644 index 00000000..4097fd66 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/Audio.kt @@ -0,0 +1,22 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * stas + * 8/5/15. + */ +data class Audio( + @get:JvmName("fileId") val file_id: String? = null, + @get:JvmName("fileUniqueId") val file_unique_id: String? = null, + @get:JvmName("duration") val duration: Int? = null, + @get:JvmName("performer") val performer: String? = null, + @get:JvmName("title") val title: String? = null, + @get:JvmName("mimeType") val mime_type: String? = null, + @get:JvmName("fileSize") val file_size: Int? = null, + @get:JvmName("thumb") val thumb: PhotoSize? = null +) : Serializable { + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/CallbackQuery.java b/library/src/main/java/com/pengrad/telegrambot/model/CallbackQuery.java deleted file mode 100644 index 9c96cd8e..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/CallbackQuery.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * Stas Parshin - * 07 May 2016 - */ -public class CallbackQuery implements Serializable { - private final static long serialVersionUID = 0L; - - private String id; - private User from; - private Message message; - private String inline_message_id; - private String chat_instance; - private String data; - private String game_short_name; - - public String id() { - return id; - } - - public User from() { - return from; - } - - public Message message() { - return message; - } - - public String inlineMessageId() { - return inline_message_id; - } - - public String chatInstance() { - return chat_instance; - } - - public String data() { - return data; - } - - public String gameShortName() { - return game_short_name; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - CallbackQuery that = (CallbackQuery) o; - - if (id != null ? !id.equals(that.id) : that.id != null) return false; - if (from != null ? !from.equals(that.from) : that.from != null) return false; - if (message != null ? !message.equals(that.message) : that.message != null) return false; - if (inline_message_id != null ? !inline_message_id.equals(that.inline_message_id) : that.inline_message_id != null) - return false; - if (chat_instance != null ? !chat_instance.equals(that.chat_instance) : that.chat_instance != null) return false; - if (data != null ? !data.equals(that.data) : that.data != null) return false; - return game_short_name != null ? game_short_name.equals(that.game_short_name) : that.game_short_name == null; - } - - @Override - public int hashCode() { - return id != null ? id.hashCode() : 0; - } - - @Override - public String toString() { - return "CallbackQuery{" + - "id='" + id + '\'' + - ", from=" + from + - ", message=" + message + - ", inline_message_id='" + inline_message_id + '\'' + - ", chat_instance='" + chat_instance + '\'' + - ", data='" + data + '\'' + - ", game_short_name='" + game_short_name + '\'' + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/CallbackQuery.kt b/library/src/main/java/com/pengrad/telegrambot/model/CallbackQuery.kt new file mode 100644 index 00000000..35b2b249 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/CallbackQuery.kt @@ -0,0 +1,21 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * Stas Parshin + * 07 May 2016 + */ +data class CallbackQuery( + @get:JvmName("id") val id: String? = null, + @get:JvmName("from") val from: User? = null, + @get:JvmName("message") val message: Message? = null, + @get:JvmName("inlineMessageId") val inline_message_id: String? = null, + @get:JvmName("chatInstance") val chat_instance: String? = null, + @get:JvmName("data") val data: String? = null, + @get:JvmName("gameShortName") val game_short_name: String? = null +) : Serializable { + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Chat.java b/library/src/main/java/com/pengrad/telegrambot/model/Chat.java deleted file mode 100644 index 8e357e81..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/Chat.java +++ /dev/null @@ -1,155 +0,0 @@ -package com.pengrad.telegrambot.model; - -import com.google.gson.annotations.SerializedName; - -import java.io.Serializable; - -/** - * stas - * 8/5/15. - */ -public class Chat implements Serializable { - private final static long serialVersionUID = 0L; - - public enum Type { - @SerializedName("private") Private, group, supergroup, channel - } - - private Long id; - private Type type; - - //Private - private String first_name; - private String last_name; - - //Private and Channel - private String username; - - //Channel and Group - private String title; - - // TODO delete this field - private Boolean all_members_are_administrators; - - private ChatPhoto photo; - private String description; - private String invite_link; - private Message pinned_message; - private ChatPermissions permissions; - private Integer slow_mode_delay; - private String sticker_set_name; - private Boolean can_set_sticker_set; - - public Long id() { - return id; - } - - public Type type() { - return type; - } - - public String firstName() { - return first_name; - } - - public String lastName() { - return last_name; - } - - public String username() { - return username; - } - - public String title() { - return title; - } - - public Boolean allMembersAreAdministrators() { - return all_members_are_administrators; - } - - public ChatPhoto photo() { - return photo; - } - - public String description() { - return description; - } - - public String inviteLink() { - return invite_link; - } - - public Message pinnedMessage() { - return pinned_message; - } - - public ChatPermissions permissions() { - return permissions; - } - - public Integer slowModeDelay() { - return slow_mode_delay; - } - - public String stickerSetName() { - return sticker_set_name; - } - - public Boolean canSetStickerSet() { - return can_set_sticker_set; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Chat chat = (Chat) o; - - if (id != null ? !id.equals(chat.id) : chat.id != null) return false; - if (type != chat.type) return false; - if (first_name != null ? !first_name.equals(chat.first_name) : chat.first_name != null) return false; - if (last_name != null ? !last_name.equals(chat.last_name) : chat.last_name != null) return false; - if (username != null ? !username.equals(chat.username) : chat.username != null) return false; - if (title != null ? !title.equals(chat.title) : chat.title != null) return false; - if (all_members_are_administrators != null ? !all_members_are_administrators.equals(chat.all_members_are_administrators) : chat.all_members_are_administrators != null) - return false; - if (photo != null ? !photo.equals(chat.photo) : chat.photo != null) return false; - if (description != null ? !description.equals(chat.description) : chat.description != null) return false; - if (invite_link != null ? !invite_link.equals(chat.invite_link) : chat.invite_link != null) return false; - if (pinned_message != null ? !pinned_message.equals(chat.pinned_message) : chat.pinned_message != null) return false; - if (permissions != null ? !permissions.equals(chat.permissions) : chat.permissions != null) return false; - if (slow_mode_delay != null ? !slow_mode_delay.equals(chat.slow_mode_delay) : chat.slow_mode_delay != null) - return false; - if (sticker_set_name != null ? !sticker_set_name.equals(chat.sticker_set_name) : chat.sticker_set_name != null) - return false; - return can_set_sticker_set != null ? can_set_sticker_set.equals(chat.can_set_sticker_set) : chat.can_set_sticker_set == null; - } - - @Override - public int hashCode() { - return id != null ? id.hashCode() : 0; - } - - @Override - public String toString() { - return "Chat{" + - "id=" + id + - ", type=" + type + - ", first_name='" + first_name + '\'' + - ", last_name='" + last_name + '\'' + - ", username='" + username + '\'' + - ", title='" + title + '\'' + - ", all_members_are_administrators=" + all_members_are_administrators + - ", photo=" + photo + - ", description='" + description + '\'' + - ", invite_link='" + invite_link + '\'' + - ", pinned_message=" + pinned_message + - ", permissions=" + permissions + - ", slow_mode_delay=" + slow_mode_delay + - ", sticker_set_name='" + sticker_set_name + '\'' + - ", can_set_sticker_set=" + can_set_sticker_set + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Chat.kt b/library/src/main/java/com/pengrad/telegrambot/model/Chat.kt new file mode 100644 index 00000000..3ac58818 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/Chat.kt @@ -0,0 +1,43 @@ +package com.pengrad.telegrambot.model + +import com.pengrad.telegrambot.impl.SerialName +import java.io.Serializable + +/** + * stas + * 8/5/15. + */ +data class Chat( + @get:JvmName("id") val id: Long? = null, + @get:JvmName("type") val type: Type? = null, + //Private + @get:JvmName("firstName") val first_name: String? = null, + @get:JvmName("lastName") val last_name: String? = null, + //Private and Channel + @get:JvmName("username") val username: String? = null, + //Channel and Group + @get:JvmName("title") val title: String? = null, + @Deprecated("Use permissions field") + @get:JvmName("allMembersAreAdministrators") val all_members_are_administrators: Boolean? = null, + @get:JvmName("photo") val photo: ChatPhoto? = null, + @get:JvmName("description") val description: String? = null, + @get:JvmName("inviteLink") val invite_link: String? = null, + @get:JvmName("pinnedMessage") val pinned_message: Message? = null, + @get:JvmName("permissions") val permissions: ChatPermissions? = null, + @get:JvmName("slowModeDelay") val slow_mode_delay: Int? = null, + @get:JvmName("stickerSetName") val sticker_set_name: String? = null, + @get:JvmName("canSetStickerSet") val can_set_sticker_set: Boolean? = null +) : Serializable { + + enum class Type { + @SerialName("private") + Private, + group, + supergroup, + channel + } + + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ChatMember.java b/library/src/main/java/com/pengrad/telegrambot/model/ChatMember.java deleted file mode 100644 index c4d6acdb..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/ChatMember.java +++ /dev/null @@ -1,200 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * Stas Parshin - * 29 May 2016 - */ -public class ChatMember implements Serializable { - private final static long serialVersionUID = 0L; - - public enum Status { - creator, administrator, member, restricted, left, kicked; - } - - private User user; - private Status status; - - private String custom_title; - private Integer until_date; - private Boolean can_be_edited; - private Boolean can_post_messages; - private Boolean can_edit_messages; - private Boolean can_delete_messages; - private Boolean can_restrict_members; - private Boolean can_promote_members; - private Boolean can_change_info; - private Boolean can_invite_users; - private Boolean can_pin_messages; - private Boolean is_member; - private Boolean can_send_messages; - private Boolean can_send_media_messages; - private Boolean can_send_polls; - private Boolean can_send_other_messages; - private Boolean can_add_web_page_previews; - - public User user() { - return user; - } - - public Status status() { - return status; - } - - public String customTitle() { - return custom_title; - } - - public Integer untilDate() { - return until_date; - } - - public Boolean canBeEdited() { - return can_be_edited; - } - - public Boolean canPostMessages() { - return can_post_messages; - } - - public Boolean canEditMessages() { - return can_edit_messages; - } - - public Boolean canDeleteMessages() { - return can_delete_messages; - } - - public Boolean canRestrictMembers() { - return can_restrict_members; - } - - public Boolean canPromoteMembers() { - return can_promote_members; - } - - public Boolean canChangeInfo() { - return can_change_info; - } - - public Boolean canInviteUsers() { - return can_invite_users; - } - - public Boolean canPinMessages() { - return can_pin_messages; - } - - public Boolean isMember() { - return is_member; - } - - public Boolean canSendMessages() { - return can_send_messages; - } - - public Boolean canSendMediaMessages() { - return can_send_media_messages; - } - - public Boolean canSendPolls() { - return can_send_polls; - } - - public Boolean canSendOtherMessages() { - return can_send_other_messages; - } - - public Boolean canAddWebPagePreviews() { - return can_add_web_page_previews; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ChatMember that = (ChatMember) o; - - if (user != null ? !user.equals(that.user) : that.user != null) return false; - if (status != that.status) return false; - if (custom_title != null ? !custom_title.equals(that.custom_title) : that.custom_title != null) return false; - if (until_date != null ? !until_date.equals(that.until_date) : that.until_date != null) return false; - if (can_be_edited != null ? !can_be_edited.equals(that.can_be_edited) : that.can_be_edited != null) return false; - if (can_post_messages != null ? !can_post_messages.equals(that.can_post_messages) : that.can_post_messages != null) - return false; - if (can_edit_messages != null ? !can_edit_messages.equals(that.can_edit_messages) : that.can_edit_messages != null) - return false; - if (can_delete_messages != null ? !can_delete_messages.equals(that.can_delete_messages) : that.can_delete_messages != null) - return false; - if (can_restrict_members != null ? !can_restrict_members.equals(that.can_restrict_members) : that.can_restrict_members != null) - return false; - if (can_promote_members != null ? !can_promote_members.equals(that.can_promote_members) : that.can_promote_members != null) - return false; - if (can_change_info != null ? !can_change_info.equals(that.can_change_info) : that.can_change_info != null) - return false; - if (can_invite_users != null ? !can_invite_users.equals(that.can_invite_users) : that.can_invite_users != null) - return false; - if (can_pin_messages != null ? !can_pin_messages.equals(that.can_pin_messages) : that.can_pin_messages != null) - return false; - if (is_member != null ? !is_member.equals(that.is_member) : that.is_member != null) return false; - if (can_send_messages != null ? !can_send_messages.equals(that.can_send_messages) : that.can_send_messages != null) - return false; - if (can_send_media_messages != null ? !can_send_media_messages.equals(that.can_send_media_messages) : that.can_send_media_messages != null) - return false; - if (can_send_polls != null ? !can_send_polls.equals(that.can_send_polls) : that.can_send_polls != null) return false; - if (can_send_other_messages != null ? !can_send_other_messages.equals(that.can_send_other_messages) : that.can_send_other_messages != null) - return false; - return can_add_web_page_previews != null ? can_add_web_page_previews.equals(that.can_add_web_page_previews) : that.can_add_web_page_previews == null; - } - - @Override - public int hashCode() { - int result = user != null ? user.hashCode() : 0; - result = 31 * result + (status != null ? status.hashCode() : 0); - result = 31 * result + (custom_title != null ? custom_title.hashCode() : 0); - result = 31 * result + (until_date != null ? until_date.hashCode() : 0); - result = 31 * result + (can_be_edited != null ? can_be_edited.hashCode() : 0); - result = 31 * result + (can_post_messages != null ? can_post_messages.hashCode() : 0); - result = 31 * result + (can_edit_messages != null ? can_edit_messages.hashCode() : 0); - result = 31 * result + (can_delete_messages != null ? can_delete_messages.hashCode() : 0); - result = 31 * result + (can_restrict_members != null ? can_restrict_members.hashCode() : 0); - result = 31 * result + (can_promote_members != null ? can_promote_members.hashCode() : 0); - result = 31 * result + (can_change_info != null ? can_change_info.hashCode() : 0); - result = 31 * result + (can_invite_users != null ? can_invite_users.hashCode() : 0); - result = 31 * result + (can_pin_messages != null ? can_pin_messages.hashCode() : 0); - result = 31 * result + (is_member != null ? is_member.hashCode() : 0); - result = 31 * result + (can_send_messages != null ? can_send_messages.hashCode() : 0); - result = 31 * result + (can_send_media_messages != null ? can_send_media_messages.hashCode() : 0); - result = 31 * result + (can_send_polls != null ? can_send_polls.hashCode() : 0); - result = 31 * result + (can_send_other_messages != null ? can_send_other_messages.hashCode() : 0); - result = 31 * result + (can_add_web_page_previews != null ? can_add_web_page_previews.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "ChatMember{" + - "user=" + user + - ", status=" + status + - ", custom_title='" + custom_title + '\'' + - ", until_date=" + until_date + - ", can_be_edited=" + can_be_edited + - ", can_post_messages=" + can_post_messages + - ", can_edit_messages=" + can_edit_messages + - ", can_delete_messages=" + can_delete_messages + - ", can_restrict_members=" + can_restrict_members + - ", can_promote_members=" + can_promote_members + - ", can_change_info=" + can_change_info + - ", can_invite_users=" + can_invite_users + - ", can_pin_messages=" + can_pin_messages + - ", is_member=" + is_member + - ", can_send_messages=" + can_send_messages + - ", can_send_media_messages=" + can_send_media_messages + - ", can_send_polls=" + can_send_polls + - ", can_send_other_messages=" + can_send_other_messages + - ", can_add_web_page_previews=" + can_add_web_page_previews + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ChatMember.kt b/library/src/main/java/com/pengrad/telegrambot/model/ChatMember.kt new file mode 100644 index 00000000..b75b2414 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/ChatMember.kt @@ -0,0 +1,38 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * Stas Parshin + * 29 May 2016 + */ +data class ChatMember( + @get:JvmName("user") val user: User? = null, + @get:JvmName("status") val status: Status? = null, + @get:JvmName("customTitle") val custom_title: String? = null, + @get:JvmName("untilDate") val until_date: Int? = null, + @get:JvmName("canBeEdited") val can_be_edited: Boolean? = null, + @get:JvmName("canPostMessages") val can_post_messages: Boolean? = null, + @get:JvmName("canEditMessages") val can_edit_messages: Boolean? = null, + @get:JvmName("canDeleteMessages") val can_delete_messages: Boolean? = null, + @get:JvmName("canRestrictMembers") val can_restrict_members: Boolean? = null, + @get:JvmName("canPromoteMembers") val can_promote_members: Boolean? = null, + @get:JvmName("canChangeInfo") val can_change_info: Boolean? = null, + @get:JvmName("canInviteUsers") val can_invite_users: Boolean? = null, + @get:JvmName("canPinMessages") val can_pin_messages: Boolean? = null, + @get:JvmName("isMember") val is_member: Boolean? = null, + @get:JvmName("canSendMessages") val can_send_messages: Boolean? = null, + @get:JvmName("canSendMediaMessages") val can_send_media_messages: Boolean? = null, + @get:JvmName("canSendPolls") val can_send_polls: Boolean? = null, + @get:JvmName("canSendOtherMessages") val can_send_other_messages: Boolean? = null, + @get:JvmName("canAddWebPagePreviews") val can_add_web_page_previews: Boolean? = null +) : Serializable { + + enum class Status { + creator, administrator, member, restricted, left, kicked + } + + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ChatPermissions.java b/library/src/main/java/com/pengrad/telegrambot/model/ChatPermissions.java deleted file mode 100644 index e0420f4f..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/ChatPermissions.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * Stas Parshin - * 30 July 2019 - */ -public class ChatPermissions implements Serializable { - private final static long serialVersionUID = 0L; - - private Boolean can_send_messages; - private Boolean can_send_media_messages; - private Boolean can_send_polls; - private Boolean can_send_other_messages; - private Boolean can_add_web_page_previews; - private Boolean can_change_info; - private Boolean can_invite_users; - private Boolean can_pin_messages; - - public Boolean canSendMessages() { - return can_send_messages; - } - - public Boolean canSendMediaMessages() { - return can_send_media_messages; - } - - public Boolean canSendPolls() { - return can_send_polls; - } - - public Boolean canSendOtherMessages() { - return can_send_other_messages; - } - - public Boolean canAddWebPagePreviews() { - return can_add_web_page_previews; - } - - public Boolean canChangeInfo() { - return can_change_info; - } - - public Boolean canInviteUsers() { - return can_invite_users; - } - - public Boolean canPinMessages() { - return can_pin_messages; - } - - public ChatPermissions canSendMessages(boolean canSendMessages) { - can_send_messages = canSendMessages; - return this; - } - - public ChatPermissions canSendMediaMessages(boolean canSendMediaMessages) { - can_send_media_messages = canSendMediaMessages; - return this; - } - - public ChatPermissions canSendPolls(boolean canSendPolls) { - can_send_polls = canSendPolls; - return this; - } - - public ChatPermissions canSendOtherMessages(boolean canSendOtherMessages) { - can_send_other_messages = canSendOtherMessages; - return this; - } - - public ChatPermissions canAddWebPagePreviews(boolean canAddWebPagePreviews) { - can_add_web_page_previews = canAddWebPagePreviews; - return this; - } - - public ChatPermissions canChangeInfo(boolean canChangeInfo) { - can_change_info = canChangeInfo; - return this; - } - - public ChatPermissions canInviteUsers(boolean canInviteUsers) { - can_invite_users = canInviteUsers; - return this; - } - - public ChatPermissions canPinMessages(boolean canPinMessages) { - can_pin_messages = canPinMessages; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ChatPermissions that = (ChatPermissions) o; - - if (can_send_messages != null ? !can_send_messages.equals(that.can_send_messages) : that.can_send_messages != null) - return false; - if (can_send_media_messages != null ? !can_send_media_messages.equals(that.can_send_media_messages) : that.can_send_media_messages != null) - return false; - if (can_send_polls != null ? !can_send_polls.equals(that.can_send_polls) : that.can_send_polls != null) return false; - if (can_send_other_messages != null ? !can_send_other_messages.equals(that.can_send_other_messages) : that.can_send_other_messages != null) - return false; - if (can_add_web_page_previews != null ? !can_add_web_page_previews.equals(that.can_add_web_page_previews) : that.can_add_web_page_previews != null) - return false; - if (can_change_info != null ? !can_change_info.equals(that.can_change_info) : that.can_change_info != null) - return false; - if (can_invite_users != null ? !can_invite_users.equals(that.can_invite_users) : that.can_invite_users != null) - return false; - return can_pin_messages != null ? can_pin_messages.equals(that.can_pin_messages) : that.can_pin_messages == null; - } - - @Override - public int hashCode() { - int result = can_send_messages != null ? can_send_messages.hashCode() : 0; - result = 31 * result + (can_send_media_messages != null ? can_send_media_messages.hashCode() : 0); - result = 31 * result + (can_send_polls != null ? can_send_polls.hashCode() : 0); - result = 31 * result + (can_send_other_messages != null ? can_send_other_messages.hashCode() : 0); - result = 31 * result + (can_add_web_page_previews != null ? can_add_web_page_previews.hashCode() : 0); - result = 31 * result + (can_change_info != null ? can_change_info.hashCode() : 0); - result = 31 * result + (can_invite_users != null ? can_invite_users.hashCode() : 0); - result = 31 * result + (can_pin_messages != null ? can_pin_messages.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "ChatPermissions{" + - "can_send_messages=" + can_send_messages + - ", can_send_media_messages=" + can_send_media_messages + - ", can_send_polls=" + can_send_polls + - ", can_send_other_messages=" + can_send_other_messages + - ", can_add_web_page_previews=" + can_add_web_page_previews + - ", can_change_info=" + can_change_info + - ", can_invite_users=" + can_invite_users + - ", can_pin_messages=" + can_pin_messages + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ChatPermissions.kt b/library/src/main/java/com/pengrad/telegrambot/model/ChatPermissions.kt new file mode 100644 index 00000000..30378c98 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/ChatPermissions.kt @@ -0,0 +1,39 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * Stas Parshin + * 30 July 2019 + */ +data class ChatPermissions( + @set:JvmSynthetic @get:JvmName("canSendMessages") var can_send_messages: Boolean? = null, + @set:JvmSynthetic @get:JvmName("canSendMediaMessages") var can_send_media_messages: Boolean? = null, + @set:JvmSynthetic @get:JvmName("canSendPolls") var can_send_polls: Boolean? = null, + @set:JvmSynthetic @get:JvmName("canSendOtherMessages") var can_send_other_messages: Boolean? = null, + @set:JvmSynthetic @get:JvmName("canAddWebPagePreviews") var can_add_web_page_previews: Boolean? = null, + @set:JvmSynthetic @get:JvmName("canChangeInfo") var can_change_info: Boolean? = null, + @set:JvmSynthetic @get:JvmName("canInviteUsers") var can_invite_users: Boolean? = null, + @set:JvmSynthetic @get:JvmName("canPinMessages") var can_pin_messages: Boolean? = null +) : Serializable { + + fun canSendMessages(canSendMessages: Boolean) = apply { can_send_messages = canSendMessages } + + fun canSendMediaMessages(canSendMediaMessages: Boolean) = apply { can_send_media_messages = canSendMediaMessages } + + fun canSendPolls(canSendPolls: Boolean) = apply { can_send_polls = canSendPolls } + + fun canSendOtherMessages(canSendOtherMessages: Boolean) = apply { can_send_other_messages = canSendOtherMessages } + + fun canAddWebPagePreviews(canAddWebPagePreviews: Boolean) = apply { can_add_web_page_previews = canAddWebPagePreviews } + + fun canChangeInfo(canChangeInfo: Boolean) = apply { can_change_info = canChangeInfo } + + fun canInviteUsers(canInviteUsers: Boolean) = apply { can_invite_users = canInviteUsers } + + fun canPinMessages(canPinMessages: Boolean) = apply { can_pin_messages = canPinMessages } + + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ChatPhoto.java b/library/src/main/java/com/pengrad/telegrambot/model/ChatPhoto.java deleted file mode 100644 index f97da1f0..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/ChatPhoto.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * Stas Parshin - * 01 July 2017 - */ -public class ChatPhoto implements Serializable { - private final static long serialVersionUID = 0L; - - private String small_file_id; - private String small_file_unique_id; - private String big_file_id; - private String big_file_unique_id; - - public String smallFileId() { - return small_file_id; - } - - public String smallFileUniqueId() { - return small_file_unique_id; - } - - public String bigFileId() { - return big_file_id; - } - - public String bigFileUniqueId() { - return big_file_unique_id; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ChatPhoto chatPhoto = (ChatPhoto) o; - - if (small_file_id != null ? !small_file_id.equals(chatPhoto.small_file_id) : chatPhoto.small_file_id != null) - return false; - if (small_file_unique_id != null ? !small_file_unique_id.equals(chatPhoto.small_file_unique_id) : chatPhoto.small_file_unique_id != null) - return false; - if (big_file_id != null ? !big_file_id.equals(chatPhoto.big_file_id) : chatPhoto.big_file_id != null) return false; - return big_file_unique_id != null ? big_file_unique_id.equals(chatPhoto.big_file_unique_id) : chatPhoto.big_file_unique_id == null; - } - - @Override - public int hashCode() { - int result = small_file_id != null ? small_file_id.hashCode() : 0; - result = 31 * result + (big_file_id != null ? big_file_id.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "ChatPhoto{" + - "small_file_id='" + small_file_id + '\'' + - ", small_file_unique_id='" + small_file_unique_id + '\'' + - ", big_file_id='" + big_file_id + '\'' + - ", big_file_unique_id='" + big_file_unique_id + '\'' + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ChatPhoto.kt b/library/src/main/java/com/pengrad/telegrambot/model/ChatPhoto.kt new file mode 100644 index 00000000..8a125f04 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/ChatPhoto.kt @@ -0,0 +1,18 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * Stas Parshin + * 01 July 2017 + */ +data class ChatPhoto( + @get:JvmName("smallFileId") val small_file_id: String? = null, + @get:JvmName("smallFileUniqueId") val small_file_unique_id: String? = null, + @get:JvmName("bigFileId") val big_file_id: String? = null, + @get:JvmName("bigFileUniqueId") val big_file_unique_id: String? = null +) : Serializable { + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ChosenInlineResult.java b/library/src/main/java/com/pengrad/telegrambot/model/ChosenInlineResult.java deleted file mode 100644 index bae08ce1..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/ChosenInlineResult.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * stas - * 1/20/16. - */ -public class ChosenInlineResult implements Serializable { - private final static long serialVersionUID = 0L; - - private String result_id; - private User from; - private Location location; - private String inline_message_id; - private String query; - - public String resultId() { - return result_id; - } - - public User from() { - return from; - } - - public Location location() { - return location; - } - - public String inlineMessageId() { - return inline_message_id; - } - - public String query() { - return query; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ChosenInlineResult that = (ChosenInlineResult) o; - - if (result_id != null ? !result_id.equals(that.result_id) : that.result_id != null) return false; - if (from != null ? !from.equals(that.from) : that.from != null) return false; - if (location != null ? !location.equals(that.location) : that.location != null) return false; - if (inline_message_id != null ? !inline_message_id.equals(that.inline_message_id) : that.inline_message_id != null) - return false; - return query != null ? query.equals(that.query) : that.query == null; - - } - - @Override - public int hashCode() { - return result_id != null ? result_id.hashCode() : 0; - } - - @Override - public String toString() { - return "ChosenInlineResult{" + - "result_id='" + result_id + '\'' + - ", from=" + from + - ", location=" + location + - ", inline_message_id='" + inline_message_id + '\'' + - ", query='" + query + '\'' + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ChosenInlineResult.kt b/library/src/main/java/com/pengrad/telegrambot/model/ChosenInlineResult.kt new file mode 100644 index 00000000..745afb12 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/ChosenInlineResult.kt @@ -0,0 +1,19 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * stas + * 1/20/16. + */ +data class ChosenInlineResult( + @get:JvmName("resultId") val result_id: String? = null, + @get:JvmName("from") val from: User? = null, + @get:JvmName("location") val location: Location? = null, + @get:JvmName("inlineMessageId") val inline_message_id: String? = null, + @get:JvmName("query") val query: String? = null +) : Serializable { + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Contact.java b/library/src/main/java/com/pengrad/telegrambot/model/Contact.java deleted file mode 100644 index 65d74153..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/Contact.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * stas - * 8/5/15. - */ -public class Contact implements Serializable { - private final static long serialVersionUID = 0L; - - private String phone_number; - private String first_name; - private String last_name; - private Integer user_id; - private String vcard; - - public String phoneNumber() { - return phone_number; - } - - public String firstName() { - return first_name; - } - - public String lastName() { - return last_name; - } - - public Integer userId() { - return user_id; - } - - public String vcard() { - return vcard; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Contact contact = (Contact) o; - - if (phone_number != null ? !phone_number.equals(contact.phone_number) : contact.phone_number != null) return false; - if (first_name != null ? !first_name.equals(contact.first_name) : contact.first_name != null) return false; - if (last_name != null ? !last_name.equals(contact.last_name) : contact.last_name != null) return false; - if (user_id != null ? !user_id.equals(contact.user_id) : contact.user_id != null) return false; - return vcard != null ? vcard.equals(contact.vcard) : contact.vcard == null; - } - - @Override - public int hashCode() { - return phone_number != null ? phone_number.hashCode() : 0; - } - - @Override - public String toString() { - return "Contact{" + - "phone_number='" + phone_number + '\'' + - ", first_name='" + first_name + '\'' + - ", last_name='" + last_name + '\'' + - ", user_id=" + user_id + - ", vcard='" + vcard + '\'' + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Contact.kt b/library/src/main/java/com/pengrad/telegrambot/model/Contact.kt new file mode 100644 index 00000000..29dfb3e7 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/Contact.kt @@ -0,0 +1,19 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * stas + * 8/5/15. + */ +data class Contact( + @get:JvmName("phoneNumber") val phone_number: String? = null, + @get:JvmName("firstName") val first_name: String? = null, + @get:JvmName("lastName") val last_name: String? = null, + @get:JvmName("userId") val user_id: Int? = null, + @get:JvmName("vcard") val vcard: String? = null +) : Serializable { + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Document.java b/library/src/main/java/com/pengrad/telegrambot/model/Document.java deleted file mode 100644 index 0888d9ce..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/Document.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * stas - * 8/5/15. - */ -public class Document implements Serializable { - private final static long serialVersionUID = 0L; - - private String file_id; - private String file_unique_id; - private PhotoSize thumb; - private String file_name; - private String mime_type; - private Integer file_size; - - public String fileId() { - return file_id; - } - - public String fileUniqueId() { - return file_unique_id; - } - - public PhotoSize thumb() { - return thumb; - } - - public String fileName() { - return file_name; - } - - public String mimeType() { - return mime_type; - } - - public Integer fileSize() { - return file_size; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Document document = (Document) o; - - if (file_id != null ? !file_id.equals(document.file_id) : document.file_id != null) return false; - if (file_unique_id != null ? !file_unique_id.equals(document.file_unique_id) : document.file_unique_id != null) - return false; - if (thumb != null ? !thumb.equals(document.thumb) : document.thumb != null) return false; - if (file_name != null ? !file_name.equals(document.file_name) : document.file_name != null) return false; - if (mime_type != null ? !mime_type.equals(document.mime_type) : document.mime_type != null) return false; - return file_size != null ? file_size.equals(document.file_size) : document.file_size == null; - } - - @Override - public int hashCode() { - return file_id != null ? file_id.hashCode() : 0; - } - - @Override - public String toString() { - return "Document{" + - "file_id='" + file_id + '\'' + - ", file_unique_id='" + file_unique_id + '\'' + - ", thumb=" + thumb + - ", file_name='" + file_name + '\'' + - ", mime_type='" + mime_type + '\'' + - ", file_size=" + file_size + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Document.kt b/library/src/main/java/com/pengrad/telegrambot/model/Document.kt new file mode 100644 index 00000000..0a0137ae --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/Document.kt @@ -0,0 +1,20 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * stas + * 8/5/15. + */ +data class Document( + @get:JvmName("fileId") val file_id: String? = null, + @get:JvmName("fileUniqueId") val file_unique_id: String? = null, + @get:JvmName("thumb") val thumb: PhotoSize? = null, + @get:JvmName("fileName") val file_name: String? = null, + @get:JvmName("mimeType") val mime_type: String? = null, + @get:JvmName("fileSize") val file_size: Int? = null +) : Serializable { + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/File.java b/library/src/main/java/com/pengrad/telegrambot/model/File.java deleted file mode 100644 index cc86ff7c..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/File.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * Stas Parshin - * 16 October 2015 - */ -public class File implements Serializable { - private final static long serialVersionUID = 0L; - - private String file_id; - private String file_unique_id; - private Integer file_size; - private String file_path; - - public String fileId() { - return file_id; - } - - public String fileUniqueId() { - return file_unique_id; - } - - public Integer fileSize() { - return file_size; - } - - public String filePath() { - return file_path; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - File file = (File) o; - - if (file_id != null ? !file_id.equals(file.file_id) : file.file_id != null) return false; - if (file_unique_id != null ? !file_unique_id.equals(file.file_unique_id) : file.file_unique_id != null) return false; - if (file_size != null ? !file_size.equals(file.file_size) : file.file_size != null) return false; - return file_path != null ? file_path.equals(file.file_path) : file.file_path == null; - } - - @Override - public int hashCode() { - return file_id != null ? file_id.hashCode() : 0; - } - - @Override - public String toString() { - return "File{" + - "file_id='" + file_id + '\'' + - ", file_unique_id='" + file_unique_id + '\'' + - ", file_size=" + file_size + - ", file_path='" + file_path + '\'' + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/File.kt b/library/src/main/java/com/pengrad/telegrambot/model/File.kt new file mode 100644 index 00000000..ed372494 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/File.kt @@ -0,0 +1,18 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * Stas Parshin + * 16 October 2015 + */ +data class File( + @get:JvmName("fileId") val file_id: String? = null, + @get:JvmName("fileUniqueId") val file_unique_id: String? = null, + @get:JvmName("fileSize") val file_size: Int? = null, + @get:JvmName("filePath") val file_path: String? = null +) : Serializable { + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Game.java b/library/src/main/java/com/pengrad/telegrambot/model/Game.java deleted file mode 100644 index ae0db193..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/Game.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; -import java.util.Arrays; - -/** - * Stas Parshin - * 03 October 2016 - */ -public class Game implements Serializable { - private final static long serialVersionUID = 0L; - - private String title; - private String description; - private PhotoSize[] photo; - - private String text; - private MessageEntity[] text_entities; - private Animation animation; - - public String title() { - return title; - } - - public String description() { - return description; - } - - public PhotoSize[] photo() { - return photo; - } - - public String text() { - return text; - } - - public MessageEntity[] textEntities() { - return text_entities; - } - - public Animation animation() { - return animation; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Game game = (Game) o; - - if (title != null ? !title.equals(game.title) : game.title != null) return false; - if (description != null ? !description.equals(game.description) : game.description != null) return false; - // Probably incorrect - comparing Object[] arrays with Arrays.equals - if (!Arrays.equals(photo, game.photo)) return false; - if (text != null ? !text.equals(game.text) : game.text != null) return false; - // Probably incorrect - comparing Object[] arrays with Arrays.equals - if (!Arrays.equals(text_entities, game.text_entities)) return false; - return animation != null ? animation.equals(game.animation) : game.animation == null; - } - - @Override - public int hashCode() { - int result = title != null ? title.hashCode() : 0; - result = 31 * result + (description != null ? description.hashCode() : 0); - result = 31 * result + Arrays.hashCode(photo); - result = 31 * result + (text != null ? text.hashCode() : 0); - result = 31 * result + Arrays.hashCode(text_entities); - result = 31 * result + (animation != null ? animation.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "Game{" + - "title='" + title + '\'' + - ", description='" + description + '\'' + - ", photo=" + Arrays.toString(photo) + - ", text='" + text + '\'' + - ", text_entities=" + Arrays.toString(text_entities) + - ", animation=" + animation + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Game.kt b/library/src/main/java/com/pengrad/telegrambot/model/Game.kt new file mode 100644 index 00000000..606d3ccd --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/Game.kt @@ -0,0 +1,24 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * Stas Parshin + * 03 October 2016 + */ +data class Game( + @get:JvmName("title") val title: String? = null, + @get:JvmName("description") val description: String? = null, + @get:JvmSynthetic val photo: List? = null, + @get:JvmName("text") val text: String? = null, + @get:JvmSynthetic val text_entities: List? = null, + @get:JvmName("animation") val animation: Animation? = null +) : Serializable { + + fun photo(): Array? = photo?.toTypedArray() + fun textEntities(): Array? = text_entities?.toTypedArray() + + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/GameHighScore.java b/library/src/main/java/com/pengrad/telegrambot/model/GameHighScore.java deleted file mode 100644 index def3d7bf..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/GameHighScore.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * Stas Parshin - * 04 October 2016 - */ -public class GameHighScore implements Serializable { - private final static long serialVersionUID = 0L; - - private Integer position; - private User user; - private Integer score; - - public Integer position() { - return position; - } - - public User user() { - return user; - } - - public Integer score() { - return score; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - GameHighScore that = (GameHighScore) o; - - if (position != null ? !position.equals(that.position) : that.position != null) return false; - if (user != null ? !user.equals(that.user) : that.user != null) return false; - return score != null ? score.equals(that.score) : that.score == null; - } - - @Override - public int hashCode() { - int result = position != null ? position.hashCode() : 0; - result = 31 * result + (user != null ? user.hashCode() : 0); - result = 31 * result + (score != null ? score.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "GameHighScore{" + - "position=" + position + - ", user=" + user + - ", score=" + score + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/GameHighScore.kt b/library/src/main/java/com/pengrad/telegrambot/model/GameHighScore.kt new file mode 100644 index 00000000..4aab4b0f --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/GameHighScore.kt @@ -0,0 +1,17 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * Stas Parshin + * 04 October 2016 + */ +data class GameHighScore( + @get:JvmName("position") val position: Int? = null, + @get:JvmName("user") val user: User? = null, + @get:JvmName("score") val score: Int? = null +) : Serializable { + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/InlineQuery.java b/library/src/main/java/com/pengrad/telegrambot/model/InlineQuery.java deleted file mode 100644 index 75230cb5..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/InlineQuery.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * stas - * 1/12/16. - */ -public class InlineQuery implements Serializable { - private final static long serialVersionUID = 0L; - - private String id; - private User from; - private Location location; - private String query; - private String offset; - - public String id() { - return id; - } - - public User from() { - return from; - } - - public Location location() { - return location; - } - - public String query() { - return query; - } - - public String offset() { - return offset; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - InlineQuery that = (InlineQuery) o; - - if (id != null ? !id.equals(that.id) : that.id != null) return false; - if (from != null ? !from.equals(that.from) : that.from != null) return false; - if (location != null ? !location.equals(that.location) : that.location != null) return false; - if (query != null ? !query.equals(that.query) : that.query != null) return false; - return offset != null ? offset.equals(that.offset) : that.offset == null; - - } - - @Override - public int hashCode() { - return id != null ? id.hashCode() : 0; - } - - @Override - public String toString() { - return "InlineQuery{" + - "id='" + id + '\'' + - ", from=" + from + - ", location=" + location + - ", query='" + query + '\'' + - ", offset='" + offset + '\'' + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/InlineQuery.kt b/library/src/main/java/com/pengrad/telegrambot/model/InlineQuery.kt new file mode 100644 index 00000000..02c9b0ef --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/InlineQuery.kt @@ -0,0 +1,19 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * stas + * 1/12/16. + */ +data class InlineQuery( + @get:JvmName("id") val id: String? = null, + @get:JvmName("from") val from: User? = null, + @get:JvmName("location") val location: Location? = null, + @get:JvmName("query") val query: String? = null, + @get:JvmName("offset") val offset: String? = null +) : Serializable { + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Invoice.java b/library/src/main/java/com/pengrad/telegrambot/model/Invoice.java deleted file mode 100644 index 340095a5..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/Invoice.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * Stas Parshin - * 24 May 2017 - */ -public class Invoice implements Serializable { - private final static long serialVersionUID = 0L; - - private String title, description, start_parameter, currency; - private Integer total_amount; - - public String title() { - return title; - } - - public String description() { - return description; - } - - public String startParameter() { - return start_parameter; - } - - public String currency() { - return currency; - } - - public Integer totalAmount() { - return total_amount; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Invoice invoice = (Invoice) o; - - if (title != null ? !title.equals(invoice.title) : invoice.title != null) return false; - if (description != null ? !description.equals(invoice.description) : invoice.description != null) return false; - if (start_parameter != null ? !start_parameter.equals(invoice.start_parameter) : invoice.start_parameter != null) - return false; - if (currency != null ? !currency.equals(invoice.currency) : invoice.currency != null) return false; - return total_amount != null ? total_amount.equals(invoice.total_amount) : invoice.total_amount == null; - } - - @Override - public int hashCode() { - int result = title != null ? title.hashCode() : 0; - result = 31 * result + (description != null ? description.hashCode() : 0); - result = 31 * result + (start_parameter != null ? start_parameter.hashCode() : 0); - result = 31 * result + (currency != null ? currency.hashCode() : 0); - result = 31 * result + (total_amount != null ? total_amount.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "Invoice{" + - "title='" + title + '\'' + - ", description='" + description + '\'' + - ", start_parameter='" + start_parameter + '\'' + - ", currency='" + currency + '\'' + - ", total_amount=" + total_amount + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Invoice.kt b/library/src/main/java/com/pengrad/telegrambot/model/Invoice.kt new file mode 100644 index 00000000..39cc0252 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/Invoice.kt @@ -0,0 +1,19 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * Stas Parshin + * 24 May 2017 + */ +data class Invoice( + @get:JvmName("title") val title: String? = null, + @get:JvmName("description") val description: String? = null, + @get:JvmName("startParameter") val start_parameter: String? = null, + @get:JvmName("currency") val currency: String? = null, + @get:JvmName("totalAmount") val total_amount: Int? = null +) : Serializable { + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Location.java b/library/src/main/java/com/pengrad/telegrambot/model/Location.java deleted file mode 100644 index bd997bbd..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/Location.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * stas - * 8/5/15. - */ -public class Location implements Serializable { - private final static long serialVersionUID = 0L; - - private Float longitude; - private Float latitude; - - public Float longitude() { - return longitude; - } - - public Float latitude() { - return latitude; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Location location = (Location) o; - - if (longitude != null ? !longitude.equals(location.longitude) : location.longitude != null) return false; - return latitude != null ? latitude.equals(location.latitude) : location.latitude == null; - } - - @Override - public int hashCode() { - int result = longitude != null ? longitude.hashCode() : 0; - result = 31 * result + (latitude != null ? latitude.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "Location{" + - "longitude=" + longitude + - ", latitude=" + latitude + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Location.kt b/library/src/main/java/com/pengrad/telegrambot/model/Location.kt new file mode 100644 index 00000000..c72f24a6 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/Location.kt @@ -0,0 +1,16 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * stas + * 8/5/15. + */ +data class Location( + @get:JvmName("longitude") val longitude: Float? = null, + @get:JvmName("latitude") val latitude: Float? = null +) : Serializable { + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/MaskPosition.java b/library/src/main/java/com/pengrad/telegrambot/model/MaskPosition.java deleted file mode 100644 index ca47e411..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/MaskPosition.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.pengrad.telegrambot.model; - -import com.google.gson.Gson; - -import java.io.Serializable; - -/** - * Stas Parshin - * 23 July 2017 - */ -public class MaskPosition implements Serializable { - private final static long serialVersionUID = 0L; - private final static Gson gson = new Gson(); - - public enum Point { - forehead, eyes, mouth, chin - } - - private String point; - private Float x_shift, y_shift; - private Float scale; - - public MaskPosition() { - } - - public MaskPosition(Point point, Float x_shift, Float y_shift, Float scale) { - this(point.name(), x_shift, y_shift, scale); - } - - public MaskPosition(String point, Float xShift, Float yShift, Float scale) { - this.point = point; - this.x_shift = xShift; - this.y_shift = yShift; - this.scale = scale; - } - - public String point() { - return point; - } - - public Float xShift() { - return x_shift; - } - - public Float yShift() { - return y_shift; - } - - public Float scale() { - return scale; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - MaskPosition that = (MaskPosition) o; - - if (point != null ? !point.equals(that.point) : that.point != null) return false; - if (x_shift != null ? !x_shift.equals(that.x_shift) : that.x_shift != null) return false; - if (y_shift != null ? !y_shift.equals(that.y_shift) : that.y_shift != null) return false; - return scale != null ? scale.equals(that.scale) : that.scale == null; - } - - @Override - public int hashCode() { - int result = point != null ? point.hashCode() : 0; - result = 31 * result + (x_shift != null ? x_shift.hashCode() : 0); - result = 31 * result + (y_shift != null ? y_shift.hashCode() : 0); - result = 31 * result + (scale != null ? scale.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "MaskPosition{" + - "point='" + point + '\'' + - ", x_shift=" + x_shift + - ", y_shift=" + y_shift + - ", scale=" + scale + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/MaskPosition.kt b/library/src/main/java/com/pengrad/telegrambot/model/MaskPosition.kt new file mode 100644 index 00000000..9ffda623 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/MaskPosition.kt @@ -0,0 +1,25 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * Stas Parshin + * 23 July 2017 + */ +data class MaskPosition( + @get:JvmName("point") var point: String? = null, + @get:JvmName("xShift") var x_shift: Float? = null, + @get:JvmName("yShift") var y_shift: Float? = null, + @get:JvmName("scale") var scale: Float? = null +) : Serializable { + + enum class Point { + forehead, eyes, mouth, chin + } + + constructor(point: Point, xShift: Float?, yShift: Float?, scale: Float?) : this(point.name, xShift, yShift, scale) + + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Message.java b/library/src/main/java/com/pengrad/telegrambot/model/Message.java deleted file mode 100644 index e4d5e325..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/Message.java +++ /dev/null @@ -1,388 +0,0 @@ -package com.pengrad.telegrambot.model; - -import com.pengrad.telegrambot.model.request.InlineKeyboardMarkup; -import com.pengrad.telegrambot.passport.PassportData; - -import java.io.Serializable; -import java.util.Arrays; - -/** - * stas - * 8/4/15. - */ -public class Message implements Serializable { - private final static long serialVersionUID = 0L; - - private Integer message_id; - private User from; - private Integer date; - private Chat chat; - private User forward_from; - private Chat forward_from_chat; - private Integer forward_from_message_id; - private String forward_signature; - private String forward_sender_name; - private Integer forward_date; - private Message reply_to_message; - private Integer edit_date; - private String media_group_id; - private String author_signature; - private String text; - private MessageEntity[] entities; - private MessageEntity[] caption_entities; - private Audio audio; - private Document document; - private Animation animation; - private Game game; - private PhotoSize[] photo; - private Sticker sticker; - private Video video; - private Voice voice; - private VideoNote video_note; - private String caption; - private Contact contact; - private Location location; - private Venue venue; - private Poll poll; - private User[] new_chat_members; - private User left_chat_member; - private String new_chat_title; - private PhotoSize[] new_chat_photo; - private Boolean delete_chat_photo; - private Boolean group_chat_created; - private Boolean supergroup_chat_created; - private Boolean channel_chat_created; - private Long migrate_to_chat_id; - private Long migrate_from_chat_id; - private Message pinned_message; - private Invoice invoice; - private SuccessfulPayment successful_payment; - private String connected_website; - private PassportData passport_data; - private InlineKeyboardMarkup reply_markup; - - public Integer messageId() { - return message_id; - } - - public User from() { - return from; - } - - public Integer date() { - return date; - } - - public Chat chat() { - return chat; - } - - public User forwardFrom() { - return forward_from; - } - - public Chat forwardFromChat() { - return forward_from_chat; - } - - public Integer forwardFromMessageId() { - return forward_from_message_id; - } - - public String forwardSignature() { - return forward_signature; - } - - public String forwardSenderName() { - return forward_sender_name; - } - - public Integer forwardDate() { - return forward_date; - } - - public Message replyToMessage() { - return reply_to_message; - } - - public Integer editDate() { - return edit_date; - } - - public String mediaGroupId() { - return media_group_id; - } - - public String authorSignature() { - return author_signature; - } - - public String text() { - return text; - } - - public MessageEntity[] entities() { - return entities; - } - - public MessageEntity[] captionEntities() { - return caption_entities; - } - - public Audio audio() { - return audio; - } - - public Document document() { - return document; - } - - public Animation animation() { - return animation; - } - - public Game game() { - return game; - } - - public PhotoSize[] photo() { - return photo; - } - - public Sticker sticker() { - return sticker; - } - - public Video video() { - return video; - } - - public Voice voice() { - return voice; - } - - public VideoNote videoNote() { - return video_note; - } - - public String caption() { - return caption; - } - - public Contact contact() { - return contact; - } - - public Location location() { - return location; - } - - public Venue venue() { - return venue; - } - - public Poll poll() { - return poll; - } - - public User[] newChatMembers() { - return new_chat_members; - } - - public User leftChatMember() { - return left_chat_member; - } - - public String newChatTitle() { - return new_chat_title; - } - - public PhotoSize[] newChatPhoto() { - return new_chat_photo; - } - - public Boolean deleteChatPhoto() { - return delete_chat_photo; - } - - public Boolean groupChatCreated() { - return group_chat_created; - } - - public Boolean supergroupChatCreated() { - return supergroup_chat_created; - } - - public Boolean channelChatCreated() { - return channel_chat_created; - } - - public Long migrateToChatId() { - return migrate_to_chat_id; - } - - public Long migrateFromChatId() { - return migrate_from_chat_id; - } - - public Message pinnedMessage() { - return pinned_message; - } - - public Invoice invoice() { - return invoice; - } - - public SuccessfulPayment successfulPayment() { - return successful_payment; - } - - public String connectedWebsite() { - return connected_website; - } - - public PassportData passportData() { - return passport_data; - } - - public InlineKeyboardMarkup replyMarkup() { - return reply_markup; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Message message = (Message) o; - - if (message_id != null ? !message_id.equals(message.message_id) : message.message_id != null) return false; - if (from != null ? !from.equals(message.from) : message.from != null) return false; - if (date != null ? !date.equals(message.date) : message.date != null) return false; - if (chat != null ? !chat.equals(message.chat) : message.chat != null) return false; - if (forward_from != null ? !forward_from.equals(message.forward_from) : message.forward_from != null) return false; - if (forward_from_chat != null ? !forward_from_chat.equals(message.forward_from_chat) : message.forward_from_chat != null) - return false; - if (forward_from_message_id != null ? !forward_from_message_id.equals(message.forward_from_message_id) : message.forward_from_message_id != null) - return false; - if (forward_signature != null ? !forward_signature.equals(message.forward_signature) : message.forward_signature != null) - return false; - if (forward_sender_name != null ? !forward_sender_name.equals(message.forward_sender_name) : message.forward_sender_name != null) - return false; - if (forward_date != null ? !forward_date.equals(message.forward_date) : message.forward_date != null) return false; - if (reply_to_message != null ? !reply_to_message.equals(message.reply_to_message) : message.reply_to_message != null) - return false; - if (edit_date != null ? !edit_date.equals(message.edit_date) : message.edit_date != null) return false; - if (media_group_id != null ? !media_group_id.equals(message.media_group_id) : message.media_group_id != null) - return false; - if (author_signature != null ? !author_signature.equals(message.author_signature) : message.author_signature != null) - return false; - if (text != null ? !text.equals(message.text) : message.text != null) return false; - // Probably incorrect - comparing Object[] arrays with Arrays.equals - if (!Arrays.equals(entities, message.entities)) return false; - // Probably incorrect - comparing Object[] arrays with Arrays.equals - if (!Arrays.equals(caption_entities, message.caption_entities)) return false; - if (audio != null ? !audio.equals(message.audio) : message.audio != null) return false; - if (document != null ? !document.equals(message.document) : message.document != null) return false; - if (animation != null ? !animation.equals(message.animation) : message.animation != null) return false; - if (game != null ? !game.equals(message.game) : message.game != null) return false; - // Probably incorrect - comparing Object[] arrays with Arrays.equals - if (!Arrays.equals(photo, message.photo)) return false; - if (sticker != null ? !sticker.equals(message.sticker) : message.sticker != null) return false; - if (video != null ? !video.equals(message.video) : message.video != null) return false; - if (voice != null ? !voice.equals(message.voice) : message.voice != null) return false; - if (video_note != null ? !video_note.equals(message.video_note) : message.video_note != null) return false; - if (caption != null ? !caption.equals(message.caption) : message.caption != null) return false; - if (contact != null ? !contact.equals(message.contact) : message.contact != null) return false; - if (location != null ? !location.equals(message.location) : message.location != null) return false; - if (venue != null ? !venue.equals(message.venue) : message.venue != null) return false; - if (poll != null ? !poll.equals(message.poll) : message.poll != null) return false; - // Probably incorrect - comparing Object[] arrays with Arrays.equals - if (!Arrays.equals(new_chat_members, message.new_chat_members)) return false; - if (left_chat_member != null ? !left_chat_member.equals(message.left_chat_member) : message.left_chat_member != null) - return false; - if (new_chat_title != null ? !new_chat_title.equals(message.new_chat_title) : message.new_chat_title != null) - return false; - // Probably incorrect - comparing Object[] arrays with Arrays.equals - if (!Arrays.equals(new_chat_photo, message.new_chat_photo)) return false; - if (delete_chat_photo != null ? !delete_chat_photo.equals(message.delete_chat_photo) : message.delete_chat_photo != null) - return false; - if (group_chat_created != null ? !group_chat_created.equals(message.group_chat_created) : message.group_chat_created != null) - return false; - if (supergroup_chat_created != null ? !supergroup_chat_created.equals(message.supergroup_chat_created) : message.supergroup_chat_created != null) - return false; - if (channel_chat_created != null ? !channel_chat_created.equals(message.channel_chat_created) : message.channel_chat_created != null) - return false; - if (migrate_to_chat_id != null ? !migrate_to_chat_id.equals(message.migrate_to_chat_id) : message.migrate_to_chat_id != null) - return false; - if (migrate_from_chat_id != null ? !migrate_from_chat_id.equals(message.migrate_from_chat_id) : message.migrate_from_chat_id != null) - return false; - if (pinned_message != null ? !pinned_message.equals(message.pinned_message) : message.pinned_message != null) - return false; - if (invoice != null ? !invoice.equals(message.invoice) : message.invoice != null) return false; - if (successful_payment != null ? !successful_payment.equals(message.successful_payment) : message.successful_payment != null) - return false; - if (connected_website != null ? !connected_website.equals(message.connected_website) : message.connected_website != null) - return false; - if (passport_data != null ? !passport_data.equals(message.passport_data) : message.passport_data != null) return false; - return reply_markup != null ? reply_markup.equals(message.reply_markup) : message.reply_markup == null; - } - - @Override - public int hashCode() { - return message_id != null ? message_id.hashCode() : 0; - } - - @Override - public String toString() { - return "Message{" + - "message_id=" + message_id + - ", from=" + from + - ", date=" + date + - ", chat=" + chat + - ", forward_from=" + forward_from + - ", forward_from_chat=" + forward_from_chat + - ", forward_from_message_id=" + forward_from_message_id + - ", forward_signature='" + forward_signature + '\'' + - ", forward_sender_name='" + forward_sender_name + '\'' + - ", forward_date=" + forward_date + - ", reply_to_message=" + reply_to_message + - ", edit_date=" + edit_date + - ", media_group_id='" + media_group_id + '\'' + - ", author_signature='" + author_signature + '\'' + - ", text='" + text + '\'' + - ", entities=" + Arrays.toString(entities) + - ", caption_entities=" + Arrays.toString(caption_entities) + - ", audio=" + audio + - ", document=" + document + - ", animation=" + animation + - ", game=" + game + - ", photo=" + Arrays.toString(photo) + - ", sticker=" + sticker + - ", video=" + video + - ", voice=" + voice + - ", video_note=" + video_note + - ", caption='" + caption + '\'' + - ", contact=" + contact + - ", location=" + location + - ", venue=" + venue + - ", poll=" + poll + - ", new_chat_members=" + Arrays.toString(new_chat_members) + - ", left_chat_member=" + left_chat_member + - ", new_chat_title='" + new_chat_title + '\'' + - ", new_chat_photo=" + Arrays.toString(new_chat_photo) + - ", delete_chat_photo=" + delete_chat_photo + - ", group_chat_created=" + group_chat_created + - ", supergroup_chat_created=" + supergroup_chat_created + - ", channel_chat_created=" + channel_chat_created + - ", migrate_to_chat_id=" + migrate_to_chat_id + - ", migrate_from_chat_id=" + migrate_from_chat_id + - ", pinned_message=" + pinned_message + - ", invoice=" + invoice + - ", successful_payment=" + successful_payment + - ", connected_website='" + connected_website + '\'' + - ", passport_data=" + passport_data + - ", reply_markup=" + reply_markup + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Message.kt b/library/src/main/java/com/pengrad/telegrambot/model/Message.kt new file mode 100644 index 00000000..fd778741 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/Message.kt @@ -0,0 +1,70 @@ +package com.pengrad.telegrambot.model + +import com.pengrad.telegrambot.model.request.InlineKeyboardMarkup +import com.pengrad.telegrambot.passport.PassportData +import java.io.Serializable + +/** + * stas + * 8/4/15. + */ +data class Message( + @get:JvmName("messageId") val message_id: Int? = null, + @get:JvmName("from") val from: User? = null, + @get:JvmName("date") val date: Int? = null, + @get:JvmName("chat") val chat: Chat? = null, + @get:JvmName("forwardFrom") val forward_from: User? = null, + @get:JvmName("forwardFromChat") val forward_from_chat: Chat? = null, + @get:JvmName("forwardFromMessageId") val forward_from_message_id: Int? = null, + @get:JvmName("forwardSignature") val forward_signature: String? = null, + @get:JvmName("forwardSenderName") val forward_sender_name: String? = null, + @get:JvmName("forwardDate") val forward_date: Int? = null, + @get:JvmName("replyToMessage") val reply_to_message: Message? = null, + @get:JvmName("editDate") val edit_date: Int? = null, + @get:JvmName("mediaGroupId") val media_group_id: String? = null, + @get:JvmName("authorSignature") val author_signature: String? = null, + @get:JvmName("text") val text: String? = null, + @get:JvmSynthetic val entities: List? = null, + @get:JvmSynthetic val caption_entities: List? = null, + @get:JvmName("audio") val audio: Audio? = null, + @get:JvmName("document") val document: Document? = null, + @get:JvmName("animation") val animation: Animation? = null, + @get:JvmName("game") val game: Game? = null, + @get:JvmSynthetic val photo: List? = null, + @get:JvmName("sticker") val sticker: Sticker? = null, + @get:JvmName("video") val video: Video? = null, + @get:JvmName("voice") val voice: Voice? = null, + @get:JvmName("videoNote") val video_note: VideoNote? = null, + @get:JvmName("caption") val caption: String? = null, + @get:JvmName("contact") val contact: Contact? = null, + @get:JvmName("location") val location: Location? = null, + @get:JvmName("venue") val venue: Venue? = null, + @get:JvmName("poll") val poll: Poll? = null, + @get:JvmSynthetic val new_chat_members: List? = null, + @get:JvmName("leftChatMember") val left_chat_member: User? = null, + @get:JvmName("newChatTitle") val new_chat_title: String? = null, + @get:JvmSynthetic val new_chat_photo: List? = null, + @get:JvmName("deleteChatPhoto") val delete_chat_photo: Boolean? = null, + @get:JvmName("groupChatCreated") val group_chat_created: Boolean? = null, + @get:JvmName("supergroupChatCreated") val supergroup_chat_created: Boolean? = null, + @get:JvmName("channelChatCreated") val channel_chat_created: Boolean? = null, + @get:JvmName("migrateToChatId") val migrate_to_chat_id: Long? = null, + @get:JvmName("migrateFromChatId") val migrate_from_chat_id: Long? = null, + @get:JvmName("pinnedMessage") val pinned_message: Message? = null, + @get:JvmName("invoice") val invoice: Invoice? = null, + @get:JvmName("successfulPayment") val successful_payment: SuccessfulPayment? = null, + @get:JvmName("connectedWebsite") val connected_website: String? = null, + @get:JvmName("passportData") val passport_data: PassportData? = null, + @get:JvmName("replyMarkup") val reply_markup: InlineKeyboardMarkup? = null +) : Serializable { + + fun entities(): Array? = entities?.toTypedArray() + fun captionEntities(): Array? = caption_entities?.toTypedArray() + fun photo(): Array? = photo?.toTypedArray() + fun newChatMembers(): Array? = new_chat_members?.toTypedArray() + fun newChatPhoto(): Array? = new_chat_photo?.toTypedArray() + + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/MessageEntity.java b/library/src/main/java/com/pengrad/telegrambot/model/MessageEntity.java deleted file mode 100644 index 9ff46506..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/MessageEntity.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * stas - * 5/3/16. - */ -public class MessageEntity implements Serializable { - private final static long serialVersionUID = 0L; - - public enum Type { - mention, hashtag, cashtag, bot_command, url, email, phone_number, bold, italic, code, pre, text_link, - text_mention, underline, strikethrough - } - - private Type type; - private Integer offset; - private Integer length; - private String url; - private User user; - private String language; - - public Type type() { - return type; - } - - public Integer offset() { - return offset; - } - - public Integer length() { - return length; - } - - public String url() { - return url; - } - - public User user() { - return user; - } - - public String language() { - return language; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - MessageEntity that = (MessageEntity) o; - - if (type != that.type) return false; - if (offset != null ? !offset.equals(that.offset) : that.offset != null) return false; - if (length != null ? !length.equals(that.length) : that.length != null) return false; - if (url != null ? !url.equals(that.url) : that.url != null) return false; - if (user != null ? !user.equals(that.user) : that.user != null) return false; - return language != null ? language.equals(that.language) : that.language == null; - } - - @Override - public int hashCode() { - int result = type != null ? type.hashCode() : 0; - result = 31 * result + (offset != null ? offset.hashCode() : 0); - result = 31 * result + (length != null ? length.hashCode() : 0); - result = 31 * result + (url != null ? url.hashCode() : 0); - result = 31 * result + (user != null ? user.hashCode() : 0); - result = 31 * result + (language != null ? language.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "MessageEntity{" + - "type=" + type + - ", offset=" + offset + - ", length=" + length + - ", url='" + url + '\'' + - ", user=" + user + - ", language='" + language + '\'' + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/MessageEntity.kt b/library/src/main/java/com/pengrad/telegrambot/model/MessageEntity.kt new file mode 100644 index 00000000..bdda5d0b --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/MessageEntity.kt @@ -0,0 +1,25 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * stas + * 5/3/16. + */ +data class MessageEntity( + @get:JvmName("type") val type: Type? = null, + @get:JvmName("offset") val offset: Int? = null, + @get:JvmName("length") val length: Int? = null, + @get:JvmName("url") val url: String? = null, + @get:JvmName("user") val user: User? = null, + @get:JvmName("language") val language: String? = null +) : Serializable { + + enum class Type { + mention, hashtag, cashtag, bot_command, url, email, phone_number, bold, italic, code, pre, text_link, text_mention, underline, strikethrough + } + + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/OrderInfo.java b/library/src/main/java/com/pengrad/telegrambot/model/OrderInfo.java deleted file mode 100644 index fd057391..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/OrderInfo.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * Stas Parshin - * 24 May 2017 - */ -public class OrderInfo implements Serializable { - private final static long serialVersionUID = 0L; - - private String name, phone_number, email; - private ShippingAddress shipping_address; - - public String name() { - return name; - } - - public String phoneNumber() { - return phone_number; - } - - public String email() { - return email; - } - - public ShippingAddress shippingAddress() { - return shipping_address; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - OrderInfo orderInfo = (OrderInfo) o; - - if (name != null ? !name.equals(orderInfo.name) : orderInfo.name != null) return false; - if (phone_number != null ? !phone_number.equals(orderInfo.phone_number) : orderInfo.phone_number != null) return false; - if (email != null ? !email.equals(orderInfo.email) : orderInfo.email != null) return false; - return shipping_address != null ? shipping_address.equals(orderInfo.shipping_address) : orderInfo.shipping_address == null; - - } - - @Override - public int hashCode() { - int result = name != null ? name.hashCode() : 0; - result = 31 * result + (phone_number != null ? phone_number.hashCode() : 0); - result = 31 * result + (email != null ? email.hashCode() : 0); - result = 31 * result + (shipping_address != null ? shipping_address.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "OrderInfo{" + - "name='" + name + '\'' + - ", phone_number='" + phone_number + '\'' + - ", email='" + email + '\'' + - ", shipping_address=" + shipping_address + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/OrderInfo.kt b/library/src/main/java/com/pengrad/telegrambot/model/OrderInfo.kt new file mode 100644 index 00000000..ab92a1ff --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/OrderInfo.kt @@ -0,0 +1,18 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * Stas Parshin + * 24 May 2017 + */ +data class OrderInfo( + @get:JvmName("name") val name: String? = null, + @get:JvmName("phoneNumber") val phone_number: String? = null, + @get:JvmName("email") val email: String? = null, + @get:JvmName("shippingAddress") val shipping_address: ShippingAddress? = null +) : Serializable { + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/PhotoSize.java b/library/src/main/java/com/pengrad/telegrambot/model/PhotoSize.java deleted file mode 100644 index 04fd8618..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/PhotoSize.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * stas - * 8/4/15. - */ -public class PhotoSize implements Serializable { - private final static long serialVersionUID = 0L; - - private String file_id; - private String file_unique_id; - private Integer width; - private Integer height; - private Integer file_size; - - public String fileId() { - return file_id; - } - - public String fileUniqueId() { - return file_unique_id; - } - - public Integer width() { - return width; - } - - public Integer height() { - return height; - } - - public Integer fileSize() { - return file_size; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - PhotoSize photoSize = (PhotoSize) o; - - if (file_id != null ? !file_id.equals(photoSize.file_id) : photoSize.file_id != null) return false; - if (file_unique_id != null ? !file_unique_id.equals(photoSize.file_unique_id) : photoSize.file_unique_id != null) - return false; - if (width != null ? !width.equals(photoSize.width) : photoSize.width != null) return false; - if (height != null ? !height.equals(photoSize.height) : photoSize.height != null) return false; - return file_size != null ? file_size.equals(photoSize.file_size) : photoSize.file_size == null; - } - - @Override - public int hashCode() { - return file_id != null ? file_id.hashCode() : 0; - } - - @Override - public String toString() { - return "PhotoSize{" + - "file_id='" + file_id + '\'' + - ", file_unique_id='" + file_unique_id + '\'' + - ", width=" + width + - ", height=" + height + - ", file_size=" + file_size + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/PhotoSize.kt b/library/src/main/java/com/pengrad/telegrambot/model/PhotoSize.kt new file mode 100644 index 00000000..9f406691 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/PhotoSize.kt @@ -0,0 +1,19 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * stas + * 8/4/15. + */ +data class PhotoSize( + @get:JvmName("fileId") val file_id: String? = null, + @get:JvmName("fileUniqueId") val file_unique_id: String? = null, + @get:JvmName("width") val width: Int? = null, + @get:JvmName("height") val height: Int? = null, + @get:JvmName("fileSize") val file_size: Int? = null +) : Serializable { + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Poll.java b/library/src/main/java/com/pengrad/telegrambot/model/Poll.java deleted file mode 100644 index ad252701..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/Poll.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; -import java.util.Arrays; - -/** - * Stas Parshin - * 17 April 2019 - */ -public class Poll implements Serializable { - private final static long serialVersionUID = 0L; - - public enum Type { - quiz, regular - } - - private String id; - private String question; - private PollOption[] options; - private Integer total_voter_count; - private Boolean is_closed; - private Boolean is_anonymous; - private Type type; - private Boolean allows_multiple_answers; - private Integer correct_option_id; - - public String id() { - return id; - } - - public String question() { - return question; - } - - public PollOption[] options() { - return options; - } - - public Integer totalVoterCount() { - return total_voter_count; - } - - public Boolean isClosed() { - return is_closed; - } - - public Boolean isAnonymous() { - return is_anonymous; - } - - public Type type() { - return type; - } - - public Boolean allowsMultipleAnswers() { - return allows_multiple_answers; - } - - public Integer correctOptionId() { - return correct_option_id; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Poll poll = (Poll) o; - - if (id != null ? !id.equals(poll.id) : poll.id != null) return false; - if (question != null ? !question.equals(poll.question) : poll.question != null) return false; - // Probably incorrect - comparing Object[] arrays with Arrays.equals - if (!Arrays.equals(options, poll.options)) return false; - if (total_voter_count != null ? !total_voter_count.equals(poll.total_voter_count) : poll.total_voter_count != null) - return false; - if (is_closed != null ? !is_closed.equals(poll.is_closed) : poll.is_closed != null) return false; - if (is_anonymous != null ? !is_anonymous.equals(poll.is_anonymous) : poll.is_anonymous != null) return false; - if (type != poll.type) return false; - if (allows_multiple_answers != null ? !allows_multiple_answers.equals(poll.allows_multiple_answers) : poll.allows_multiple_answers != null) - return false; - return correct_option_id != null ? correct_option_id.equals(poll.correct_option_id) : poll.correct_option_id == null; - } - - @Override - public int hashCode() { - return id != null ? id.hashCode() : 0; - } - - @Override - public String toString() { - return "Poll{" + - "id='" + id + '\'' + - ", question='" + question + '\'' + - ", options=" + Arrays.toString(options) + - ", total_voter_count=" + total_voter_count + - ", is_closed=" + is_closed + - ", is_anonymous=" + is_anonymous + - ", type=" + type + - ", allows_multiple_answers=" + allows_multiple_answers + - ", correct_option_id=" + correct_option_id + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Poll.kt b/library/src/main/java/com/pengrad/telegrambot/model/Poll.kt new file mode 100644 index 00000000..64af588e --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/Poll.kt @@ -0,0 +1,30 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * Stas Parshin + * 17 April 2019 + */ +data class Poll( + @get:JvmName("id") val id: String? = null, + @get:JvmName("question") val question: String? = null, + @get:JvmSynthetic val options: List? = null, + @get:JvmName("totalVoterCount") val total_voter_count: Int? = null, + @get:JvmName("isClosed") val is_closed: Boolean? = null, + @get:JvmName("isAnonymous") val is_anonymous: Boolean? = null, + @get:JvmName("type") val type: Type? = null, + @get:JvmName("allowsMultipleAnswers") val allows_multiple_answers: Boolean? = null, + @get:JvmName("correctOptionId") val correct_option_id: Int? = null +) : Serializable { + + enum class Type { + quiz, regular + } + + fun options(): Array? = options?.toTypedArray() + + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/PollAnswer.java b/library/src/main/java/com/pengrad/telegrambot/model/PollAnswer.java deleted file mode 100644 index 3a17ec9f..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/PollAnswer.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; -import java.util.Arrays; - -/** - * Stas Parshin - * 25 January 2020 - */ -public class PollAnswer implements Serializable { - private final static long serialVersionUID = 0L; - - private String poll_id; - private User user; - private Integer[] option_ids; - - public String pollId() { - return poll_id; - } - - public User user() { - return user; - } - - public Integer[] optionIds() { - return option_ids; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - PollAnswer that = (PollAnswer) o; - - if (poll_id != null ? !poll_id.equals(that.poll_id) : that.poll_id != null) return false; - if (user != null ? !user.equals(that.user) : that.user != null) return false; - // Probably incorrect - comparing Object[] arrays with Arrays.equals - return Arrays.equals(option_ids, that.option_ids); - } - - @Override - public int hashCode() { - int result = poll_id != null ? poll_id.hashCode() : 0; - result = 31 * result + (user != null ? user.hashCode() : 0); - result = 31 * result + Arrays.hashCode(option_ids); - return result; - } - - @Override - public String toString() { - return "PollAnswer{" + - "poll_id='" + poll_id + '\'' + - ", user=" + user + - ", option_ids=" + Arrays.toString(option_ids) + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/PollAnswer.kt b/library/src/main/java/com/pengrad/telegrambot/model/PollAnswer.kt new file mode 100644 index 00000000..ee24e73c --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/PollAnswer.kt @@ -0,0 +1,20 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * Stas Parshin + * 25 January 2020 + */ +data class PollAnswer( + @get:JvmName("pollId") val poll_id: String? = null, + @get:JvmName("user") val user: User? = null, + @get:JvmSynthetic val option_ids: List? = null +) : Serializable { + + fun optionIds(): Array? = option_ids?.toTypedArray() + + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/PollOption.java b/library/src/main/java/com/pengrad/telegrambot/model/PollOption.java deleted file mode 100644 index c67b7b22..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/PollOption.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * Stas Parshin - * 17 April 2019 - */ -public class PollOption implements Serializable { - private final static long serialVersionUID = 0L; - - private String text; - private Integer voter_count; - - public String text() { - return text; - } - - public Integer voterCount() { - return voter_count; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - PollOption that = (PollOption) o; - - if (text != null ? !text.equals(that.text) : that.text != null) return false; - return voter_count != null ? voter_count.equals(that.voter_count) : that.voter_count == null; - } - - @Override - public int hashCode() { - int result = text != null ? text.hashCode() : 0; - result = 31 * result + (voter_count != null ? voter_count.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "PollOption{" + - "text='" + text + '\'' + - ", voter_count=" + voter_count + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/PollOption.kt b/library/src/main/java/com/pengrad/telegrambot/model/PollOption.kt new file mode 100644 index 00000000..cdf000fa --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/PollOption.kt @@ -0,0 +1,16 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * Stas Parshin + * 17 April 2019 + */ +data class PollOption( + @get:JvmName("text") val text: String? = null, + @get:JvmName("voterCount") val voter_count: Int? = null +) : Serializable { + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/PreCheckoutQuery.java b/library/src/main/java/com/pengrad/telegrambot/model/PreCheckoutQuery.java deleted file mode 100644 index d956397a..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/PreCheckoutQuery.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * Stas Parshin - * 24 May 2017 - */ -public class PreCheckoutQuery implements Serializable { - private final static long serialVersionUID = 0L; - - private String id; - private User from; - private String currency; - private Integer total_amount; - private String invoice_payload; - private String shipping_option_id; - private OrderInfo order_info; - - public String id() { - return id; - } - - public User from() { - return from; - } - - public String currency() { - return currency; - } - - public Integer totalAmount() { - return total_amount; - } - - public String invoicePayload() { - return invoice_payload; - } - - public String shippingOptionId() { - return shipping_option_id; - } - - public OrderInfo orderInfo() { - return order_info; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - PreCheckoutQuery that = (PreCheckoutQuery) o; - - if (id != null ? !id.equals(that.id) : that.id != null) return false; - if (from != null ? !from.equals(that.from) : that.from != null) return false; - if (currency != null ? !currency.equals(that.currency) : that.currency != null) return false; - if (total_amount != null ? !total_amount.equals(that.total_amount) : that.total_amount != null) return false; - if (invoice_payload != null ? !invoice_payload.equals(that.invoice_payload) : that.invoice_payload != null) - return false; - if (shipping_option_id != null ? !shipping_option_id.equals(that.shipping_option_id) : that.shipping_option_id != null) - return false; - return order_info != null ? order_info.equals(that.order_info) : that.order_info == null; - } - - @Override - public int hashCode() { - return id != null ? id.hashCode() : 0; - } - - @Override - public String toString() { - return "PreCheckoutQuery{" + - "id='" + id + '\'' + - ", from=" + from + - ", currency='" + currency + '\'' + - ", total_amount=" + total_amount + - ", invoice_payload='" + invoice_payload + '\'' + - ", shipping_option_id='" + shipping_option_id + '\'' + - ", order_info=" + order_info + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/PreCheckoutQuery.kt b/library/src/main/java/com/pengrad/telegrambot/model/PreCheckoutQuery.kt new file mode 100644 index 00000000..39aa516a --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/PreCheckoutQuery.kt @@ -0,0 +1,21 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * Stas Parshin + * 24 May 2017 + */ +data class PreCheckoutQuery( + @get:JvmName("id") val id: String? = null, + @get:JvmName("from") val from: User? = null, + @get:JvmName("currency") val currency: String? = null, + @get:JvmName("totalAmount") val total_amount: Int? = null, + @get:JvmName("invoicePayload") val invoice_payload: String? = null, + @get:JvmName("shippingOptionId") val shipping_option_id: String? = null, + @get:JvmName("orderInfo") val order_info: OrderInfo? = null +) : Serializable { + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ResponseParameters.java b/library/src/main/java/com/pengrad/telegrambot/model/ResponseParameters.java deleted file mode 100644 index bf7dd261..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/ResponseParameters.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * Stas Parshin - * 03 October 2016 - */ -public class ResponseParameters implements Serializable { - private final static long serialVersionUID = 0L; - - private Long migrate_to_chat_id; - private Integer retry_after; - - public Long migrateToChatId() { - return migrate_to_chat_id; - } - - public Integer retryAfter() { - return retry_after; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ResponseParameters that = (ResponseParameters) o; - - if (migrate_to_chat_id != null ? !migrate_to_chat_id.equals(that.migrate_to_chat_id) : that.migrate_to_chat_id != null) - return false; - return retry_after != null ? retry_after.equals(that.retry_after) : that.retry_after == null; - } - - @Override - public int hashCode() { - int result = migrate_to_chat_id != null ? migrate_to_chat_id.hashCode() : 0; - result = 31 * result + (retry_after != null ? retry_after.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "ResponseParameters{" + - "migrate_to_chat_id=" + migrate_to_chat_id + - ", retry_after=" + retry_after + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ResponseParameters.kt b/library/src/main/java/com/pengrad/telegrambot/model/ResponseParameters.kt new file mode 100644 index 00000000..cbb40df7 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/ResponseParameters.kt @@ -0,0 +1,16 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * Stas Parshin + * 03 October 2016 + */ +data class ResponseParameters( + @get:JvmName("migrateToChatId") val migrate_to_chat_id: Long? = null, + @get:JvmName("retryAfter") val retry_after: Int? = null +) : Serializable { + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ShippingAddress.java b/library/src/main/java/com/pengrad/telegrambot/model/ShippingAddress.java deleted file mode 100644 index f2e5a609..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/ShippingAddress.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * Stas Parshin - * 24 May 2017 - */ -public class ShippingAddress implements Serializable { - private final static long serialVersionUID = 0L; - - private String country_code, state, city, street_line1, street_line2, post_code; - - public String countryCode() { - return country_code; - } - - public String state() { - return state; - } - - public String city() { - return city; - } - - public String streetLine1() { - return street_line1; - } - - public String streetLine2() { - return street_line2; - } - - public String postCode() { - return post_code; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ShippingAddress that = (ShippingAddress) o; - - if (country_code != null ? !country_code.equals(that.country_code) : that.country_code != null) return false; - if (state != null ? !state.equals(that.state) : that.state != null) return false; - if (city != null ? !city.equals(that.city) : that.city != null) return false; - if (street_line1 != null ? !street_line1.equals(that.street_line1) : that.street_line1 != null) return false; - if (street_line2 != null ? !street_line2.equals(that.street_line2) : that.street_line2 != null) return false; - return post_code != null ? post_code.equals(that.post_code) : that.post_code == null; - - } - - @Override - public int hashCode() { - int result = country_code != null ? country_code.hashCode() : 0; - result = 31 * result + (state != null ? state.hashCode() : 0); - result = 31 * result + (city != null ? city.hashCode() : 0); - result = 31 * result + (street_line1 != null ? street_line1.hashCode() : 0); - result = 31 * result + (street_line2 != null ? street_line2.hashCode() : 0); - result = 31 * result + (post_code != null ? post_code.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "ShippingAddress{" + - "country_code='" + country_code + '\'' + - ", state='" + state + '\'' + - ", city='" + city + '\'' + - ", street_line1='" + street_line1 + '\'' + - ", street_line2='" + street_line2 + '\'' + - ", post_code='" + post_code + '\'' + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ShippingAddress.kt b/library/src/main/java/com/pengrad/telegrambot/model/ShippingAddress.kt new file mode 100644 index 00000000..cd44aefc --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/ShippingAddress.kt @@ -0,0 +1,20 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * Stas Parshin + * 24 May 2017 + */ +data class ShippingAddress( + @get:JvmName("countryCode") val country_code: String? = null, + @get:JvmName("state") val state: String? = null, + @get:JvmName("city") val city: String? = null, + @get:JvmName("streetLine1") val street_line1: String? = null, + @get:JvmName("streetLine2") val street_line2: String? = null, + @get:JvmName("postCode") val post_code: String? = null +) : Serializable { + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ShippingQuery.java b/library/src/main/java/com/pengrad/telegrambot/model/ShippingQuery.java deleted file mode 100644 index 3fc95f6a..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/ShippingQuery.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * Stas Parshin - * 24 May 2017 - */ -public class ShippingQuery implements Serializable { - private final static long serialVersionUID = 0L; - - private String id; - private User from; - private String invoice_payload; - private ShippingAddress shipping_address; - - public String id() { - return id; - } - - public User from() { - return from; - } - - public String invoicePayload() { - return invoice_payload; - } - - public ShippingAddress shippingAddress() { - return shipping_address; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - ShippingQuery that = (ShippingQuery) o; - - if (id != null ? !id.equals(that.id) : that.id != null) return false; - if (from != null ? !from.equals(that.from) : that.from != null) return false; - if (invoice_payload != null ? !invoice_payload.equals(that.invoice_payload) : that.invoice_payload != null) - return false; - return shipping_address != null ? shipping_address.equals(that.shipping_address) : that.shipping_address == null; - } - - @Override - public int hashCode() { - return id != null ? id.hashCode() : 0; - } - - @Override - public String toString() { - return "ShippingQuery{" + - "id='" + id + '\'' + - ", from=" + from + - ", invoice_payload='" + invoice_payload + '\'' + - ", shipping_address=" + shipping_address + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/ShippingQuery.kt b/library/src/main/java/com/pengrad/telegrambot/model/ShippingQuery.kt new file mode 100644 index 00000000..fa627cc0 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/ShippingQuery.kt @@ -0,0 +1,18 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * Stas Parshin + * 24 May 2017 + */ +data class ShippingQuery( + @get:JvmName("id") val id: String? = null, + @get:JvmName("from") val from: User? = null, + @get:JvmName("invoicePayload") val invoice_payload: String? = null, + @get:JvmName("shippingAddress") val shipping_address: ShippingAddress? = null +) : Serializable { + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Sticker.java b/library/src/main/java/com/pengrad/telegrambot/model/Sticker.java deleted file mode 100644 index 4e503ea0..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/Sticker.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * stas - * 8/5/15. - */ -public class Sticker implements Serializable { - private final static long serialVersionUID = 0L; - - private String file_id; - private String file_unique_id; - private Integer width; - private Integer height; - private Boolean is_animated; - private PhotoSize thumb; - private String emoji; - private String set_name; - private MaskPosition mask_position; - private Integer file_size; - - public String fileId() { - return file_id; - } - - public String fileUniqueId() { - return file_unique_id; - } - - public Integer width() { - return width; - } - - public Integer height() { - return height; - } - - public Boolean isAnimated() { - return is_animated; - } - - public PhotoSize thumb() { - return thumb; - } - - public String emoji() { - return emoji; - } - - public String setName() { - return set_name; - } - - public MaskPosition maskPosition() { - return mask_position; - } - - public Integer fileSize() { - return file_size; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Sticker sticker = (Sticker) o; - - if (file_id != null ? !file_id.equals(sticker.file_id) : sticker.file_id != null) return false; - if (file_unique_id != null ? !file_unique_id.equals(sticker.file_unique_id) : sticker.file_unique_id != null) - return false; - if (width != null ? !width.equals(sticker.width) : sticker.width != null) return false; - if (height != null ? !height.equals(sticker.height) : sticker.height != null) return false; - if (is_animated != null ? !is_animated.equals(sticker.is_animated) : sticker.is_animated != null) return false; - if (thumb != null ? !thumb.equals(sticker.thumb) : sticker.thumb != null) return false; - if (emoji != null ? !emoji.equals(sticker.emoji) : sticker.emoji != null) return false; - if (set_name != null ? !set_name.equals(sticker.set_name) : sticker.set_name != null) return false; - if (mask_position != null ? !mask_position.equals(sticker.mask_position) : sticker.mask_position != null) return false; - return file_size != null ? file_size.equals(sticker.file_size) : sticker.file_size == null; - } - - @Override - public int hashCode() { - return file_id != null ? file_id.hashCode() : 0; - } - - @Override - public String toString() { - return "Sticker{" + - "file_id='" + file_id + '\'' + - ", file_unique_id='" + file_unique_id + '\'' + - ", width=" + width + - ", height=" + height + - ", is_animated=" + is_animated + - ", thumb=" + thumb + - ", emoji='" + emoji + '\'' + - ", set_name='" + set_name + '\'' + - ", mask_position=" + mask_position + - ", file_size=" + file_size + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Sticker.kt b/library/src/main/java/com/pengrad/telegrambot/model/Sticker.kt new file mode 100644 index 00000000..4422b624 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/Sticker.kt @@ -0,0 +1,24 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * stas + * 8/5/15. + */ +data class Sticker( + @get:JvmName("fileId") val file_id: String? = null, + @get:JvmName("fileUniqueId") val file_unique_id: String? = null, + @get:JvmName("width") val width: Int? = null, + @get:JvmName("height") val height: Int? = null, + @get:JvmName("isAnimated") val is_animated: Boolean? = null, + @get:JvmName("thumb") val thumb: PhotoSize? = null, + @get:JvmName("emoji") val emoji: String? = null, + @get:JvmName("setName") val set_name: String? = null, + @get:JvmName("maskPosition") val mask_position: MaskPosition? = null, + @get:JvmName("fileSize") val file_size: Int? = null +) : Serializable { + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/StickerSet.java b/library/src/main/java/com/pengrad/telegrambot/model/StickerSet.java deleted file mode 100644 index 8753003e..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/StickerSet.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; -import java.util.Arrays; - -/** - * Stas Parshin - * 23 July 2017 - */ -public class StickerSet implements Serializable { - private final static long serialVersionUID = 0L; - - private String name; - private String title; - private Boolean is_animated; - private Boolean contains_masks; - private Sticker[] stickers; - - public String name() { - return name; - } - - public String title() { - return title; - } - - public Boolean isAnimated() { - return is_animated; - } - - public Boolean containsMasks() { - return contains_masks; - } - - public Sticker[] stickers() { - return stickers; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - StickerSet that = (StickerSet) o; - - if (name != null ? !name.equals(that.name) : that.name != null) return false; - if (title != null ? !title.equals(that.title) : that.title != null) return false; - if (is_animated != null ? !is_animated.equals(that.is_animated) : that.is_animated != null) return false; - if (contains_masks != null ? !contains_masks.equals(that.contains_masks) : that.contains_masks != null) return false; - // Probably incorrect - comparing Object[] arrays with Arrays.equals - return Arrays.equals(stickers, that.stickers); - } - - @Override - public int hashCode() { - int result = name != null ? name.hashCode() : 0; - result = 31 * result + (title != null ? title.hashCode() : 0); - result = 31 * result + (is_animated != null ? is_animated.hashCode() : 0); - result = 31 * result + (contains_masks != null ? contains_masks.hashCode() : 0); - result = 31 * result + Arrays.hashCode(stickers); - return result; - } - - @Override - public String toString() { - return "StickerSet{" + - "name='" + name + '\'' + - ", title='" + title + '\'' + - ", is_animated=" + is_animated + - ", contains_masks=" + contains_masks + - ", stickers=" + Arrays.toString(stickers) + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/StickerSet.kt b/library/src/main/java/com/pengrad/telegrambot/model/StickerSet.kt new file mode 100644 index 00000000..a6599dd7 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/StickerSet.kt @@ -0,0 +1,22 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * Stas Parshin + * 23 July 2017 + */ +data class StickerSet( + @get:JvmName("name") val name: String? = null, + @get:JvmName("title") val title: String? = null, + @get:JvmName("isAnimated") val is_animated: Boolean? = null, + @get:JvmName("containsMasks") val contains_masks: Boolean? = null, + @get:JvmSynthetic val stickers: List? = null +) : Serializable { + + fun stickers(): Array? = stickers?.toTypedArray() + + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/SuccessfulPayment.java b/library/src/main/java/com/pengrad/telegrambot/model/SuccessfulPayment.java deleted file mode 100644 index 64e81c31..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/SuccessfulPayment.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * Stas Parshin - * 24 May 2017 - */ -public class SuccessfulPayment implements Serializable { - private final static long serialVersionUID = 0L; - - private String currency; - private Integer total_amount; - private String invoice_payload; - private String shipping_option_id; - private OrderInfo order_info; - private String telegram_payment_charge_id; - private String provider_payment_charge_id; - - public String currency() { - return currency; - } - - public Integer totalAmount() { - return total_amount; - } - - public String invoicePayload() { - return invoice_payload; - } - - public String shippingOptionId() { - return shipping_option_id; - } - - public OrderInfo orderInfo() { - return order_info; - } - - public String telegramPaymentChargeId() { - return telegram_payment_charge_id; - } - - public String providerPaymentChargeId() { - return provider_payment_charge_id; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - SuccessfulPayment that = (SuccessfulPayment) o; - - if (currency != null ? !currency.equals(that.currency) : that.currency != null) return false; - if (total_amount != null ? !total_amount.equals(that.total_amount) : that.total_amount != null) return false; - if (invoice_payload != null ? !invoice_payload.equals(that.invoice_payload) : that.invoice_payload != null) - return false; - if (shipping_option_id != null ? !shipping_option_id.equals(that.shipping_option_id) : that.shipping_option_id != null) - return false; - if (order_info != null ? !order_info.equals(that.order_info) : that.order_info != null) return false; - if (telegram_payment_charge_id != null ? !telegram_payment_charge_id.equals(that.telegram_payment_charge_id) : that.telegram_payment_charge_id != null) - return false; - return provider_payment_charge_id != null ? provider_payment_charge_id.equals(that.provider_payment_charge_id) : that.provider_payment_charge_id == null; - - } - - @Override - public int hashCode() { - int result = currency != null ? currency.hashCode() : 0; - result = 31 * result + (total_amount != null ? total_amount.hashCode() : 0); - result = 31 * result + (invoice_payload != null ? invoice_payload.hashCode() : 0); - result = 31 * result + (shipping_option_id != null ? shipping_option_id.hashCode() : 0); - result = 31 * result + (order_info != null ? order_info.hashCode() : 0); - result = 31 * result + (telegram_payment_charge_id != null ? telegram_payment_charge_id.hashCode() : 0); - result = 31 * result + (provider_payment_charge_id != null ? provider_payment_charge_id.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "SuccessfulPayment{" + - "currency='" + currency + '\'' + - ", total_amount=" + total_amount + - ", invoice_payload='" + invoice_payload + '\'' + - ", shipping_option_id='" + shipping_option_id + '\'' + - ", order_info=" + order_info + - ", telegram_payment_charge_id='" + telegram_payment_charge_id + '\'' + - ", provider_payment_charge_id='" + provider_payment_charge_id + '\'' + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/SuccessfulPayment.kt b/library/src/main/java/com/pengrad/telegrambot/model/SuccessfulPayment.kt new file mode 100644 index 00000000..5dad023f --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/SuccessfulPayment.kt @@ -0,0 +1,21 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * Stas Parshin + * 24 May 2017 + */ +data class SuccessfulPayment( + @get:JvmName("currency") val currency: String? = null, + @get:JvmName("totalAmount") val total_amount: Int? = null, + @get:JvmName("invoicePayload") val invoice_payload: String? = null, + @get:JvmName("shippingOptionId") val shipping_option_id: String? = null, + @get:JvmName("orderInfo") val order_info: OrderInfo? = null, + @get:JvmName("telegramPaymentChargeId") val telegram_payment_charge_id: String? = null, + @get:JvmName("providerPaymentChargeId") val provider_payment_charge_id: String? = null +) : Serializable { + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Update.java b/library/src/main/java/com/pengrad/telegrambot/model/Update.java deleted file mode 100644 index e038915e..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/Update.java +++ /dev/null @@ -1,124 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * stas - * 8/4/15. - */ -public class Update implements Serializable { - private final static long serialVersionUID = 0L; - - private Integer update_id; - private Message message; - private Message edited_message; - private Message channel_post; - private Message edited_channel_post; - private InlineQuery inline_query; - private ChosenInlineResult chosen_inline_result; - private CallbackQuery callback_query; - private ShippingQuery shipping_query; - private PreCheckoutQuery pre_checkout_query; - private Poll poll; - private PollAnswer poll_answer; - - public Integer updateId() { - return update_id; - } - - public Message message() { - return message; - } - - public Message editedMessage() { - return edited_message; - } - - public Message channelPost() { - return channel_post; - } - - public Message editedChannelPost() { - return edited_channel_post; - } - - public InlineQuery inlineQuery() { - return inline_query; - } - - public ChosenInlineResult chosenInlineResult() { - return chosen_inline_result; - } - - public CallbackQuery callbackQuery() { - return callback_query; - } - - public ShippingQuery shippingQuery() { - return shipping_query; - } - - public PreCheckoutQuery preCheckoutQuery() { - return pre_checkout_query; - } - - public Poll poll() { - return poll; - } - - public PollAnswer pollAnswer() { - return poll_answer; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Update update = (Update) o; - - if (update_id != null ? !update_id.equals(update.update_id) : update.update_id != null) return false; - if (message != null ? !message.equals(update.message) : update.message != null) return false; - if (edited_message != null ? !edited_message.equals(update.edited_message) : update.edited_message != null) - return false; - if (channel_post != null ? !channel_post.equals(update.channel_post) : update.channel_post != null) - return false; - if (edited_channel_post != null ? !edited_channel_post.equals(update.edited_channel_post) : update.edited_channel_post != null) - return false; - if (inline_query != null ? !inline_query.equals(update.inline_query) : update.inline_query != null) - return false; - if (chosen_inline_result != null ? !chosen_inline_result.equals(update.chosen_inline_result) : update.chosen_inline_result != null) - return false; - if (callback_query != null ? !callback_query.equals(update.callback_query) : update.callback_query != null) - return false; - if (shipping_query != null ? !shipping_query.equals(update.shipping_query) : update.shipping_query != null) - return false; - if (pre_checkout_query != null ? !pre_checkout_query.equals(update.pre_checkout_query) : update.pre_checkout_query != null) - return false; - if (poll != null ? !poll.equals(update.poll) : update.poll != null) return false; - return poll_answer != null ? poll_answer.equals(update.poll_answer) : update.poll_answer == null; - } - - @Override - public int hashCode() { - return update_id != null ? update_id.hashCode() : 0; - } - - @Override - public String toString() { - return "Update{" + - "update_id=" + update_id + - ", message=" + message + - ", edited_message=" + edited_message + - ", channel_post=" + channel_post + - ", edited_channel_post=" + edited_channel_post + - ", inline_query=" + inline_query + - ", chosen_inline_result=" + chosen_inline_result + - ", callback_query=" + callback_query + - ", shipping_query=" + shipping_query + - ", pre_checkout_query=" + pre_checkout_query + - ", poll=" + poll + - ", poll_answer=" + poll_answer + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Update.kt b/library/src/main/java/com/pengrad/telegrambot/model/Update.kt new file mode 100644 index 00000000..7053680a --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/Update.kt @@ -0,0 +1,26 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * stas + * 8/4/15. + */ +data class Update( + @get:JvmName("updateId") val update_id: Int? = null, + @get:JvmName("message") val message: Message? = null, + @get:JvmName("editedMessage") val edited_message: Message? = null, + @get:JvmName("channelPost") val channel_post: Message? = null, + @get:JvmName("editedChannelPost") val edited_channel_post: Message? = null, + @get:JvmName("inlineQuery") val inline_query: InlineQuery? = null, + @get:JvmName("chosenInlineResult") val chosen_inline_result: ChosenInlineResult? = null, + @get:JvmName("callbackQuery") val callback_query: CallbackQuery? = null, + @get:JvmName("shippingQuery") val shipping_query: ShippingQuery? = null, + @get:JvmName("preCheckoutQuery") val pre_checkout_query: PreCheckoutQuery? = null, + @get:JvmName("poll") val poll: Poll? = null, + @get:JvmName("pollAnswer") val poll_answer: PollAnswer? = null +) : Serializable { + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/User.java b/library/src/main/java/com/pengrad/telegrambot/model/User.java deleted file mode 100644 index 68ca25cf..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/User.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * stas - * 8/4/15. - */ -public class User implements Serializable { - private final static long serialVersionUID = 0L; - - private Integer id; - private Boolean is_bot; - private String first_name; - private String last_name; - private String username; - private String language_code; - private Boolean can_join_groups; - private Boolean can_read_all_group_messages; - private Boolean supports_inline_queries; - - public Integer id() { - return id; - } - - public Boolean isBot() { - return is_bot; - } - - public String firstName() { - return first_name; - } - - public String lastName() { - return last_name; - } - - public String username() { - return username; - } - - public String languageCode() { - return language_code; - } - - public Boolean canJoinGroups() { - return can_join_groups; - } - - public Boolean canReadAllGroupMessages() { - return can_read_all_group_messages; - } - - public Boolean supportsInlineQueries() { - return supports_inline_queries; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - User user = (User) o; - - if (id != null ? !id.equals(user.id) : user.id != null) return false; - if (is_bot != null ? !is_bot.equals(user.is_bot) : user.is_bot != null) return false; - if (first_name != null ? !first_name.equals(user.first_name) : user.first_name != null) return false; - if (last_name != null ? !last_name.equals(user.last_name) : user.last_name != null) return false; - if (username != null ? !username.equals(user.username) : user.username != null) return false; - if (language_code != null ? !language_code.equals(user.language_code) : user.language_code != null) - return false; - if (can_join_groups != null ? !can_join_groups.equals(user.can_join_groups) : user.can_join_groups != null) - return false; - if (can_read_all_group_messages != null ? !can_read_all_group_messages.equals(user.can_read_all_group_messages) : user.can_read_all_group_messages != null) - return false; - return supports_inline_queries != null ? supports_inline_queries.equals(user.supports_inline_queries) : user.supports_inline_queries == null; - } - - @Override - public int hashCode() { - return id != null ? id.hashCode() : 0; - } - - @Override - public String toString() { - return "User{" + - "id=" + id + - ", is_bot=" + is_bot + - ", first_name='" + first_name + '\'' + - ", last_name='" + last_name + '\'' + - ", username='" + username + '\'' + - ", language_code='" + language_code + '\'' + - ", can_join_groups=" + can_join_groups + - ", can_read_all_group_messages=" + can_read_all_group_messages + - ", supports_inline_queries=" + supports_inline_queries + - '}'; - } -} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/User.kt b/library/src/main/java/com/pengrad/telegrambot/model/User.kt new file mode 100644 index 00000000..dc2b9c6d --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/User.kt @@ -0,0 +1,23 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * stas + * 8/4/15. + */ +data class User( + @get:JvmName("id") val id: Int? = null, + @get:JvmName("isBot") val is_bot: Boolean? = null, + @get:JvmName("firstName") val first_name: String? = null, + @get:JvmName("lastName") val last_name: String? = null, + @get:JvmName("username") val username: String? = null, + @get:JvmName("languageCode") val language_code: String? = null, + @get:JvmName("canJoinGroups") val can_join_groups: Boolean? = null, + @get:JvmName("canReadAllGroupMessages") val can_read_all_group_messages: Boolean? = null, + @get:JvmName("supportsInlineQueries") val supports_inline_queries: Boolean? = null +) : Serializable { + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/UserProfilePhotos.java b/library/src/main/java/com/pengrad/telegrambot/model/UserProfilePhotos.java deleted file mode 100644 index 8301e6b0..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/UserProfilePhotos.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; -import java.util.Arrays; - -/** - * stas - * 8/5/15. - */ -public class UserProfilePhotos implements Serializable { - private final static long serialVersionUID = 0L; - - private Integer total_count; - private PhotoSize[][] photos; - - public Integer totalCount() { - return total_count; - } - - public PhotoSize[][] photos() { - return photos; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - UserProfilePhotos that = (UserProfilePhotos) o; - - if (total_count != null ? !total_count.equals(that.total_count) : that.total_count != null) return false; - return Arrays.deepEquals(photos, that.photos); - } - - @Override - public int hashCode() { - int result = total_count != null ? total_count.hashCode() : 0; - result = 31 * result + Arrays.deepHashCode(photos); - return result; - } - - @Override - public String toString() { - return "UserProfilePhotos{" + - "total_count=" + total_count + - ", photos=" + Arrays.deepToString(photos) + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/UserProfilePhotos.kt b/library/src/main/java/com/pengrad/telegrambot/model/UserProfilePhotos.kt new file mode 100644 index 00000000..bdaa32e6 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/UserProfilePhotos.kt @@ -0,0 +1,19 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * stas + * 8/5/15. + */ +data class UserProfilePhotos( + @get:JvmName("totalCount") val total_count: Int? = null, + @get:JvmSynthetic val photos: List>? = null +) : Serializable { + + fun photos(): Array>? = photos?.map { it.toTypedArray() }?.toTypedArray() + + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Venue.java b/library/src/main/java/com/pengrad/telegrambot/model/Venue.java deleted file mode 100644 index 77cbd449..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/Venue.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * stas - * 5/3/16. - */ -public class Venue implements Serializable { - private final static long serialVersionUID = 0L; - - private Location location; - private String title; - private String address; - private String foursquare_id; - private String foursquare_type; - - public Location location() { - return location; - } - - public String title() { - return title; - } - - public String address() { - return address; - } - - public String foursquareId() { - return foursquare_id; - } - - public String foursquareType() { - return foursquare_type; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Venue venue = (Venue) o; - - if (location != null ? !location.equals(venue.location) : venue.location != null) return false; - if (title != null ? !title.equals(venue.title) : venue.title != null) return false; - if (address != null ? !address.equals(venue.address) : venue.address != null) return false; - if (foursquare_id != null ? !foursquare_id.equals(venue.foursquare_id) : venue.foursquare_id != null) return false; - return foursquare_type != null ? foursquare_type.equals(venue.foursquare_type) : venue.foursquare_type == null; - } - - @Override - public int hashCode() { - int result = location != null ? location.hashCode() : 0; - result = 31 * result + (title != null ? title.hashCode() : 0); - result = 31 * result + (address != null ? address.hashCode() : 0); - result = 31 * result + (foursquare_id != null ? foursquare_id.hashCode() : 0); - result = 31 * result + (foursquare_type != null ? foursquare_type.hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "Venue{" + - "location=" + location + - ", title='" + title + '\'' + - ", address='" + address + '\'' + - ", foursquare_id='" + foursquare_id + '\'' + - ", foursquare_type='" + foursquare_type + '\'' + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Venue.kt b/library/src/main/java/com/pengrad/telegrambot/model/Venue.kt new file mode 100644 index 00000000..bb1d613a --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/Venue.kt @@ -0,0 +1,19 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * stas + * 5/3/16. + */ +data class Venue( + @get:JvmName("location") val location: Location? = null, + @get:JvmName("title") val title: String? = null, + @get:JvmName("address") val address: String? = null, + @get:JvmName("foursquareId") val foursquare_id: String? = null, + @get:JvmName("foursquareType") val foursquare_type: String? = null +) : Serializable { + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Video.java b/library/src/main/java/com/pengrad/telegrambot/model/Video.java deleted file mode 100644 index d22b4991..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/Video.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * stas - * 8/5/15. - */ -public class Video implements Serializable { - private final static long serialVersionUID = 0L; - - private String file_id; - private String file_unique_id; - private Integer width; - private Integer height; - private Integer duration; - private PhotoSize thumb; - private String mime_type; - private Integer file_size; - - public String fileId() { - return file_id; - } - - public String fileUniqueId() { - return file_unique_id; - } - - public Integer width() { - return width; - } - - public Integer height() { - return height; - } - - public Integer duration() { - return duration; - } - - public PhotoSize thumb() { - return thumb; - } - - public String mimeType() { - return mime_type; - } - - public Integer fileSize() { - return file_size; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Video video = (Video) o; - - if (file_id != null ? !file_id.equals(video.file_id) : video.file_id != null) return false; - if (file_unique_id != null ? !file_unique_id.equals(video.file_unique_id) : video.file_unique_id != null) return false; - if (width != null ? !width.equals(video.width) : video.width != null) return false; - if (height != null ? !height.equals(video.height) : video.height != null) return false; - if (duration != null ? !duration.equals(video.duration) : video.duration != null) return false; - if (thumb != null ? !thumb.equals(video.thumb) : video.thumb != null) return false; - if (mime_type != null ? !mime_type.equals(video.mime_type) : video.mime_type != null) return false; - return file_size != null ? file_size.equals(video.file_size) : video.file_size == null; - } - - @Override - public int hashCode() { - return file_id != null ? file_id.hashCode() : 0; - } - - @Override - public String toString() { - return "Video{" + - "file_id='" + file_id + '\'' + - ", file_unique_id='" + file_unique_id + '\'' + - ", width=" + width + - ", height=" + height + - ", duration=" + duration + - ", thumb=" + thumb + - ", mime_type='" + mime_type + '\'' + - ", file_size=" + file_size + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Video.kt b/library/src/main/java/com/pengrad/telegrambot/model/Video.kt new file mode 100644 index 00000000..1b1c9f40 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/Video.kt @@ -0,0 +1,22 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * stas + * 8/5/15. + */ +data class Video( + @get:JvmName("fileId") val file_id: String? = null, + @get:JvmName("fileUniqueId") val file_unique_id: String? = null, + @get:JvmName("width") val width: Int? = null, + @get:JvmName("height") val height: Int? = null, + @get:JvmName("duration") val duration: Int? = null, + @get:JvmName("thumb") val thumb: PhotoSize? = null, + @get:JvmName("mimeType") val mime_type: String? = null, + @get:JvmName("fileSize") val file_size: Int? = null +) : Serializable { + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/VideoNote.java b/library/src/main/java/com/pengrad/telegrambot/model/VideoNote.java deleted file mode 100644 index 41b98089..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/VideoNote.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * Stas Parshin - * 23 May 2017 - */ -public class VideoNote implements Serializable { - private final static long serialVersionUID = 0L; - - private String file_id; - private String file_unique_id; - private Integer length; - private Integer duration; - private PhotoSize thumb; - private Integer file_size; - - public String fileId() { - return file_id; - } - - public String fileUniqueId() { - return file_unique_id; - } - - public Integer length() { - return length; - } - - public Integer duration() { - return duration; - } - - public PhotoSize thumb() { - return thumb; - } - - public Integer fileSize() { - return file_size; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - VideoNote videoNote = (VideoNote) o; - - if (file_id != null ? !file_id.equals(videoNote.file_id) : videoNote.file_id != null) return false; - if (file_unique_id != null ? !file_unique_id.equals(videoNote.file_unique_id) : videoNote.file_unique_id != null) - return false; - if (length != null ? !length.equals(videoNote.length) : videoNote.length != null) return false; - if (duration != null ? !duration.equals(videoNote.duration) : videoNote.duration != null) return false; - if (thumb != null ? !thumb.equals(videoNote.thumb) : videoNote.thumb != null) return false; - return file_size != null ? file_size.equals(videoNote.file_size) : videoNote.file_size == null; - } - - @Override - public int hashCode() { - return file_id != null ? file_id.hashCode() : 0; - } - - @Override - public String toString() { - return "VideoNote{" + - "file_id='" + file_id + '\'' + - ", file_unique_id='" + file_unique_id + '\'' + - ", length=" + length + - ", duration=" + duration + - ", thumb=" + thumb + - ", file_size=" + file_size + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/VideoNote.kt b/library/src/main/java/com/pengrad/telegrambot/model/VideoNote.kt new file mode 100644 index 00000000..96f2172a --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/VideoNote.kt @@ -0,0 +1,20 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * Stas Parshin + * 23 May 2017 + */ +data class VideoNote( + @get:JvmName("fileId") val file_id: String? = null, + @get:JvmName("fileUniqueId") val file_unique_id: String? = null, + @get:JvmName("length") val length: Int? = null, + @get:JvmName("duration") val duration: Int? = null, + @get:JvmName("thumb") val thumb: PhotoSize? = null, + @get:JvmName("fileSize") val file_size: Int? = null +) : Serializable { + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Voice.java b/library/src/main/java/com/pengrad/telegrambot/model/Voice.java deleted file mode 100644 index 99159297..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/Voice.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; - -/** - * stas - * 10/21/15. - */ -public class Voice implements Serializable { - private final static long serialVersionUID = 0L; - - private String file_id; - private String file_unique_id; - private Integer duration; - private String mime_type; - private Integer file_size; - - public String fileId() { - return file_id; - } - - public String fileUniqueId() { - return file_unique_id; - } - - public Integer duration() { - return duration; - } - - public String mimeType() { - return mime_type; - } - - public Integer fileSize() { - return file_size; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Voice voice = (Voice) o; - - if (file_id != null ? !file_id.equals(voice.file_id) : voice.file_id != null) return false; - if (file_unique_id != null ? !file_unique_id.equals(voice.file_unique_id) : voice.file_unique_id != null) return false; - if (duration != null ? !duration.equals(voice.duration) : voice.duration != null) return false; - if (mime_type != null ? !mime_type.equals(voice.mime_type) : voice.mime_type != null) return false; - return file_size != null ? file_size.equals(voice.file_size) : voice.file_size == null; - } - - @Override - public int hashCode() { - return file_id != null ? file_id.hashCode() : 0; - } - - @Override - public String toString() { - return "Voice{" + - "file_id='" + file_id + '\'' + - ", file_unique_id='" + file_unique_id + '\'' + - ", duration=" + duration + - ", mime_type='" + mime_type + '\'' + - ", file_size=" + file_size + - '}'; - } -} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/Voice.kt b/library/src/main/java/com/pengrad/telegrambot/model/Voice.kt new file mode 100644 index 00000000..b97cada9 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/Voice.kt @@ -0,0 +1,19 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * stas + * 10/21/15. + */ +data class Voice( + @get:JvmName("fileId") val file_id: String? = null, + @get:JvmName("fileUniqueId") val file_unique_id: String? = null, + @get:JvmName("duration") val duration: Int? = null, + @get:JvmName("mimeType") val mime_type: String? = null, + @get:JvmName("fileSize") val file_size: Int? = null +) : Serializable { + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pengrad/telegrambot/model/WebhookInfo.java b/library/src/main/java/com/pengrad/telegrambot/model/WebhookInfo.java deleted file mode 100644 index 4a83df5e..00000000 --- a/library/src/main/java/com/pengrad/telegrambot/model/WebhookInfo.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.pengrad.telegrambot.model; - -import java.io.Serializable; -import java.util.Arrays; - -/** - * Stas Parshin - * 03 October 2016 - */ -public class WebhookInfo implements Serializable { - private final static long serialVersionUID = 0L; - - private String url; - private Boolean has_custom_certificate; - private Integer pending_update_count; - private Integer last_error_date; - private String last_error_message; - private Integer max_connections; - private String[] allowed_updates; - - public String url() { - return url; - } - - public Boolean hasCustomCertificate() { - return has_custom_certificate; - } - - public Integer pendingUpdateCount() { - return pending_update_count; - } - - public Integer lastErrorDate() { - return last_error_date; - } - - public String lastErrorMessage() { - return last_error_message; - } - - public Integer maxConnections() { - return max_connections; - } - - public String[] allowedUpdates() { - return allowed_updates; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - WebhookInfo that = (WebhookInfo) o; - - if (url != null ? !url.equals(that.url) : that.url != null) return false; - if (has_custom_certificate != null ? !has_custom_certificate.equals(that.has_custom_certificate) : that.has_custom_certificate != null) - return false; - if (pending_update_count != null ? !pending_update_count.equals(that.pending_update_count) : that.pending_update_count != null) - return false; - if (last_error_date != null ? !last_error_date.equals(that.last_error_date) : that.last_error_date != null) - return false; - if (last_error_message != null ? !last_error_message.equals(that.last_error_message) : that.last_error_message != null) - return false; - if (max_connections != null ? !max_connections.equals(that.max_connections) : that.max_connections != null) - return false; - // Probably incorrect - comparing Object[] arrays with Arrays.equals - return Arrays.equals(allowed_updates, that.allowed_updates); - } - - @Override - public int hashCode() { - int result = url != null ? url.hashCode() : 0; - result = 31 * result + (has_custom_certificate != null ? has_custom_certificate.hashCode() : 0); - result = 31 * result + (pending_update_count != null ? pending_update_count.hashCode() : 0); - result = 31 * result + (last_error_date != null ? last_error_date.hashCode() : 0); - result = 31 * result + (last_error_message != null ? last_error_message.hashCode() : 0); - result = 31 * result + (max_connections != null ? max_connections.hashCode() : 0); - result = 31 * result + Arrays.hashCode(allowed_updates); - return result; - } - - @Override - public String toString() { - return "WebhookInfo{" + - "url='" + url + '\'' + - ", has_custom_certificate=" + has_custom_certificate + - ", pending_update_count=" + pending_update_count + - ", last_error_date=" + last_error_date + - ", last_error_message='" + last_error_message + '\'' + - ", max_connections=" + max_connections + - ", allowed_updates=" + Arrays.toString(allowed_updates) + - '}'; - } -} diff --git a/library/src/main/java/com/pengrad/telegrambot/model/WebhookInfo.kt b/library/src/main/java/com/pengrad/telegrambot/model/WebhookInfo.kt new file mode 100644 index 00000000..a12cc7b9 --- /dev/null +++ b/library/src/main/java/com/pengrad/telegrambot/model/WebhookInfo.kt @@ -0,0 +1,24 @@ +package com.pengrad.telegrambot.model + +import java.io.Serializable + +/** + * Stas Parshin + * 03 October 2016 + */ +data class WebhookInfo( + @get:JvmName("url") val url: String? = null, + @get:JvmName("hasCustomCertificate") val has_custom_certificate: Boolean? = null, + @get:JvmName("pendingUpdateCount") val pending_update_count: Int? = null, + @get:JvmName("lastErrorDate") val last_error_date: Int? = null, + @get:JvmName("lastErrorMessage") val last_error_message: String? = null, + @get:JvmName("maxConnections") val max_connections: Int? = null, + @get:JvmSynthetic val allowed_updates: List? = null +) : Serializable { + + fun allowedUpdates(): Array? = allowed_updates?.toTypedArray() + + companion object { + private const val serialVersionUID = 0L + } +} \ No newline at end of file diff --git a/library/src/test/java/com/pengrad/telegrambot/KotlinTest.kt b/library/src/test/java/com/pengrad/telegrambot/KotlinTest.kt new file mode 100644 index 00000000..3ebf048b --- /dev/null +++ b/library/src/test/java/com/pengrad/telegrambot/KotlinTest.kt @@ -0,0 +1,47 @@ +package com.pengrad.telegrambot + +import com.pengrad.telegrambot.TelegramBotTest.bot +import com.pengrad.telegrambot.checks.UpdateTest +import com.pengrad.telegrambot.model.Message +import com.pengrad.telegrambot.request.GetUpdates +import com.pengrad.telegrambot.request.KickChatMember +import okhttp3.OkHttpClient +import okhttp3.Request +import org.junit.Assert +import org.junit.Test + +/** + * Stas Parshin + * 15 March 2020 + */ +class KotlinTest { + + // test full jar compatibility (to make sure kotlin-stdlib included) + // java -cp hamcrest-core-1.3.jar:junit-4.12.jar:build/libs/java-telegram-bot-api-full.jar:build/classes/java/test/ org.junit.runner.JUnitCore com.pengrad.telegrambot.PaymentsTest + + + @Test + fun a() { + val getUpdates = GetUpdates() + .offset(874203684) + .allowedUpdates("") + .timeout(0) + .limit(100) + Assert.assertEquals(100, getUpdates.limit.toLong()) + val response = TelegramBotTest.bot.execute(getUpdates) + UpdateTest.check(response.updates()) + val m: Message? = response.updates()[0].message() + + bot.execute(KickChatMember().untilDate()) + + + val ok = OkHttpClient() + ok.newCall(Request.Builder().build()).execute().body()?. + } + +} + +private operator fun T?.invoke(): T? { + + TODO("Not yet implemented") +} diff --git a/library/src/test/java/com/pengrad/telegrambot/ModelTest.java b/library/src/test/java/com/pengrad/telegrambot/ModelTest.java index a1895fb2..430dfd79 100644 --- a/library/src/test/java/com/pengrad/telegrambot/ModelTest.java +++ b/library/src/test/java/com/pengrad/telegrambot/ModelTest.java @@ -1,29 +1,20 @@ package com.pengrad.telegrambot; -import com.pengrad.telegrambot.model.Animation; -import com.pengrad.telegrambot.model.CallbackQuery; -import com.pengrad.telegrambot.model.Message; -import com.pengrad.telegrambot.model.Update; -import com.pengrad.telegrambot.model.request.InlineKeyboardButton; -import com.pengrad.telegrambot.model.request.InlineKeyboardMarkup; -import com.pengrad.telegrambot.passport.Credentials; -import nl.jqno.equalsverifier.EqualsVerifier; -import nl.jqno.equalsverifier.Warning; -import org.junit.Before; -import org.junit.Test; -import org.reflections.Reflections; -import org.reflections.scanners.SubTypesScanner; +import com.pengrad.telegrambot.model.request.*; +import com.pengrad.telegrambot.passport.*; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Set; -import java.util.function.Supplier; -import java.util.stream.Collectors; +import org.junit.*; +import org.reflections.*; +import org.reflections.scanners.*; -import static org.junit.Assert.assertTrue; +import java.lang.reflect.*; +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + +import nl.jqno.equalsverifier.*; + +import static org.junit.Assert.*; /** * Stas Parshin @@ -36,9 +27,8 @@ public class ModelTest { @Before public void setClasses() { - String modelPackage = Animation.class.getPackage().getName(); String passportPackage = Credentials.class.getPackage().getName(); - List packages = Arrays.asList(modelPackage, passportPackage); + List packages = Collections.singletonList(passportPackage); classes = new Reflections(packages, new SubTypesScanner(false)) .getSubTypesOf(Object.class) @@ -57,27 +47,9 @@ public void setClasses() { @Test public void testEquals() throws IllegalAccessException, InstantiationException, NoSuchFieldException { - Object callbackQuery = CallbackQuery.class.newInstance(); - Field f = CallbackQuery.class.getDeclaredField("id"); - f.setAccessible(true); - f.set(callbackQuery, "2"); - - Object message = Message.class.newInstance(); - f = Message.class.getDeclaredField("message_id"); - f.setAccessible(true); - f.set(message, 11); - - Object update = Update.class.newInstance(); - f = Update.class.getDeclaredField("update_id"); - f.setAccessible(true); - f.set(update, 1); - for (Class c : classes) { EqualsVerifier.forClass(c) .usingGetClass() - .withPrefabValues(Update.class, Update.class.newInstance(), update) - .withPrefabValues(Message.class, Message.class.newInstance(), message) - .withPrefabValues(CallbackQuery.class, CallbackQuery.class.newInstance(), callbackQuery) .suppress(Warning.STRICT_HASHCODE) .suppress(Warning.NONFINAL_FIELDS) .verify(); diff --git a/library/src/test/java/com/pengrad/telegrambot/TelegramBotTest.java b/library/src/test/java/com/pengrad/telegrambot/TelegramBotTest.java index b61a921f..f40a577f 100644 --- a/library/src/test/java/com/pengrad/telegrambot/TelegramBotTest.java +++ b/library/src/test/java/com/pengrad/telegrambot/TelegramBotTest.java @@ -146,7 +146,7 @@ public void getMe() { @Test public void getUpdates() { GetUpdates getUpdates = new GetUpdates() - .offset(874203582) + .offset(874203684) .allowedUpdates("") .timeout(0) .limit(100); @@ -421,12 +421,28 @@ public void getChat() throws MalformedURLException, URISyntaxException { assertNull(chat.allMembersAreAdministrators()); assertNull(chat.stickerSetName()); assertNull(chat.canSetStickerSet()); + } - chat = bot.execute(new GetChat(chatId)).chat(); + @Test + public void getPrivateChat() { + Chat chat = bot.execute(new GetChat(chatId)).chat(); + ChatTest.checkChat(chat, true); + assertEquals(Chat.Type.Private, chat.type()); + assertEquals(chatId.intValue(), chat.id().intValue()); assertNotNull(chat.firstName()); assertNotNull(chat.lastName()); } + @Test + public void getGroupChat() { + Long groupId = -379852359L; + Chat chat = bot.execute(new GetChat(groupId)).chat(); + ChatTest.checkChat(chat); + assertEquals(Chat.Type.group, chat.type()); + assertEquals(groupId, chat.id()); + assertTrue(chat.allMembersAreAdministrators()); + } + @Test public void leaveChat() { BaseResponse response = bot.execute(new LeaveChat(chatId)); diff --git a/pom.xml b/pom.xml index cef04b50..4a709cb3 100644 --- a/pom.xml +++ b/pom.xml @@ -27,6 +27,12 @@ https://github.com/pengrad/java-telegram-bot-api/ + + org.jetbrains.kotlin + kotlin-stdlib + 1.3.70 + compile + com.google.code.gson gson