2018-07-08 01:41:21 +02:00
|
|
|
package org.telegram.telegrambots.meta.api.methods.send;
|
2016-01-14 01:14:53 +01:00
|
|
|
|
2016-11-17 02:41:12 +01:00
|
|
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
2020-11-01 23:46:36 +01:00
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
import lombok.Builder;
|
|
|
|
import lombok.EqualsAndHashCode;
|
|
|
|
import lombok.Getter;
|
|
|
|
import lombok.NoArgsConstructor;
|
|
|
|
import lombok.NonNull;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
import lombok.Setter;
|
|
|
|
import lombok.ToString;
|
2022-06-14 22:20:22 +02:00
|
|
|
import lombok.experimental.Tolerate;
|
2022-06-16 19:57:41 +02:00
|
|
|
import org.telegram.telegrambots.meta.api.methods.botapimethods.BotApiMethodMessage;
|
2018-07-08 01:41:21 +02:00
|
|
|
import org.telegram.telegrambots.meta.api.objects.replykeyboard.ReplyKeyboard;
|
|
|
|
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
|
2016-01-14 01:14:53 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Ruben Bermudez
|
|
|
|
* @version 1.0
|
2018-07-27 00:27:26 +02:00
|
|
|
* Use this method to send information about a venue. On success, the sent Message is
|
2016-04-11 02:53:53 +02:00
|
|
|
* returned.
|
2016-01-14 01:14:53 +01:00
|
|
|
*/
|
2020-11-01 23:46:36 +01:00
|
|
|
@EqualsAndHashCode(callSuper = false)
|
|
|
|
@Getter
|
|
|
|
@Setter
|
|
|
|
@ToString
|
|
|
|
@RequiredArgsConstructor
|
|
|
|
@NoArgsConstructor
|
|
|
|
@AllArgsConstructor
|
|
|
|
@Builder
|
2022-06-16 19:36:20 +02:00
|
|
|
public class SendVenue extends BotApiMethodMessage {
|
2016-04-11 02:53:53 +02:00
|
|
|
public static final String PATH = "sendVenue";
|
|
|
|
|
|
|
|
private static final String CHATID_FIELD = "chat_id";
|
2022-11-08 19:33:50 +01:00
|
|
|
private static final String MESSAGETHREADID_FIELD = "message_thread_id";
|
2016-04-11 02:53:53 +02:00
|
|
|
private static final String LATITUDE_FIELD = "latitude";
|
|
|
|
private static final String LONGITUDE_FIELD = "longitude";
|
|
|
|
private static final String TITLE_FIELD = "title";
|
|
|
|
private static final String DISABLENOTIFICATION_FIELD = "disable_notification";
|
|
|
|
private static final String ADDRESS_FIELD = "address";
|
2018-07-27 00:27:26 +02:00
|
|
|
private static final String FOURSQUAREID_FIELD = "foursquare_id";
|
2016-04-11 02:53:53 +02:00
|
|
|
private static final String REPLYTOMESSAGEID_FIELD = "reply_to_message_id";
|
|
|
|
private static final String REPLYMARKUP_FIELD = "reply_markup";
|
2018-07-27 00:27:26 +02:00
|
|
|
private static final String FOURSQUARETYPE_FIELD = "foursquare_type";
|
2020-11-01 23:46:36 +01:00
|
|
|
private static final String ALLOWSENDINGWITHOUTREPLY_FIELD = "allow_sending_without_reply";
|
|
|
|
private static final String GOOGLEPLACEID_FIELD = "google_place_id";
|
|
|
|
private static final String GOOGLEPLACETYPE_FIELD = "google_place_type";
|
2022-01-02 00:06:28 +01:00
|
|
|
private static final String PROTECTCONTENT_FIELD = "protect_content";
|
2016-11-17 02:41:12 +01:00
|
|
|
|
|
|
|
@JsonProperty(CHATID_FIELD)
|
2020-11-01 23:46:36 +01:00
|
|
|
@NonNull
|
2016-01-14 01:14:53 +01:00
|
|
|
private String chatId; ///< Unique identifier for the chat to send the message to (Or username for channels)
|
2022-11-08 19:33:50 +01:00
|
|
|
/**
|
|
|
|
* Unique identifier for the target message thread (topic) of the forum;
|
|
|
|
* for forum supergroups only
|
|
|
|
*/
|
|
|
|
@JsonProperty(MESSAGETHREADID_FIELD)
|
|
|
|
private Integer messageThreadId;
|
2016-11-17 02:41:12 +01:00
|
|
|
@JsonProperty(LATITUDE_FIELD)
|
2020-11-01 23:46:36 +01:00
|
|
|
@NonNull
|
|
|
|
private Double latitude; ///< Latitude of venue location
|
2016-11-17 02:41:12 +01:00
|
|
|
@JsonProperty(LONGITUDE_FIELD)
|
2020-11-01 23:46:36 +01:00
|
|
|
@NonNull
|
|
|
|
private Double longitude; ///< Longitude of venue location
|
2016-11-17 02:41:12 +01:00
|
|
|
@JsonProperty(TITLE_FIELD)
|
2020-11-01 23:46:36 +01:00
|
|
|
@NonNull
|
2016-04-11 02:53:53 +02:00
|
|
|
private String title; ///< Title of the venue
|
2016-11-17 02:41:12 +01:00
|
|
|
@JsonProperty(ADDRESS_FIELD)
|
2020-11-01 23:46:36 +01:00
|
|
|
@NonNull
|
2016-04-11 02:53:53 +02:00
|
|
|
private String address; ///< Address of the venue
|
2020-11-01 23:46:36 +01:00
|
|
|
@JsonProperty(DISABLENOTIFICATION_FIELD)
|
|
|
|
private Boolean disableNotification; ///< Optional. Sends the message silently. Users will receive a notification with no sound.
|
2018-07-27 00:27:26 +02:00
|
|
|
@JsonProperty(FOURSQUAREID_FIELD)
|
2016-04-11 02:53:53 +02:00
|
|
|
private String foursquareId; ///< Optional. Foursquare identifier of the venue
|
2016-11-17 02:41:12 +01:00
|
|
|
@JsonProperty(REPLYTOMESSAGEID_FIELD)
|
2016-06-20 20:50:03 +02:00
|
|
|
private Integer replyToMessageId; ///< Optional. If the message is a reply, ID of the original message
|
2016-11-17 02:41:12 +01:00
|
|
|
@JsonProperty(REPLYMARKUP_FIELD)
|
2016-06-20 20:50:03 +02:00
|
|
|
private ReplyKeyboard replyMarkup; ///< Optional. JSON-serialized object for a custom reply keyboard
|
2018-07-27 00:27:26 +02:00
|
|
|
@JsonProperty(FOURSQUARETYPE_FIELD)
|
|
|
|
private String foursquareType; ///< Optional. Foursquare type of the venue, if known.
|
2020-11-01 23:46:36 +01:00
|
|
|
@JsonProperty(ALLOWSENDINGWITHOUTREPLY_FIELD)
|
|
|
|
private Boolean allowSendingWithoutReply; ///< Optional Pass True, if the message should be sent even if the specified replied-to message is not found
|
|
|
|
@JsonProperty(GOOGLEPLACEID_FIELD)
|
|
|
|
private String googlePlaceId; ///< Optional. Google Places identifier of the venue
|
|
|
|
@JsonProperty(GOOGLEPLACETYPE_FIELD)
|
|
|
|
private String googlePlaceType; ///< Optional. Google Places type of the venue. (See supported types.)
|
2022-01-02 00:06:28 +01:00
|
|
|
@JsonProperty(PROTECTCONTENT_FIELD)
|
|
|
|
private Boolean protectContent; ///< Optional. Protects the contents of sent messages from forwarding and saving
|
2020-11-01 23:46:36 +01:00
|
|
|
|
2022-06-14 22:20:22 +02:00
|
|
|
@Tolerate
|
|
|
|
public void setChatId(@NonNull Long chatId) {
|
|
|
|
this.chatId = chatId.toString();
|
|
|
|
}
|
|
|
|
|
2020-11-01 23:46:36 +01:00
|
|
|
public void enableNotification() {
|
2016-02-27 03:17:06 +01:00
|
|
|
this.disableNotification = false;
|
|
|
|
}
|
|
|
|
|
2020-11-01 23:46:36 +01:00
|
|
|
public void disableNotification() {
|
2016-02-27 03:17:06 +01:00
|
|
|
this.disableNotification = true;
|
2018-07-27 00:27:26 +02:00
|
|
|
}
|
|
|
|
|
2016-01-14 01:14:53 +01:00
|
|
|
@Override
|
2016-11-17 02:41:12 +01:00
|
|
|
public String getMethod() {
|
2016-01-14 01:14:53 +01:00
|
|
|
return PATH;
|
|
|
|
}
|
|
|
|
|
2016-09-24 22:37:25 +02:00
|
|
|
@Override
|
|
|
|
public void validate() throws TelegramApiValidationException {
|
2022-06-14 22:20:22 +02:00
|
|
|
if (chatId.isEmpty()) {
|
2016-09-24 22:37:25 +02:00
|
|
|
throw new TelegramApiValidationException("ChatId parameter can't be empty", this);
|
|
|
|
}
|
2022-06-14 22:20:22 +02:00
|
|
|
if (title.isEmpty()) {
|
2016-09-24 22:37:25 +02:00
|
|
|
throw new TelegramApiValidationException("Title parameter can't be empty", this);
|
|
|
|
}
|
2016-06-20 20:50:03 +02:00
|
|
|
if (replyMarkup != null) {
|
2016-11-17 02:41:12 +01:00
|
|
|
replyMarkup.validate();
|
2016-01-14 01:14:53 +01:00
|
|
|
}
|
|
|
|
}
|
2022-06-14 22:20:22 +02:00
|
|
|
|
|
|
|
public static class SendVenueBuilder {
|
|
|
|
|
|
|
|
@Tolerate
|
|
|
|
public SendVenueBuilder chatId(@NonNull Long chatId) {
|
|
|
|
this.chatId = chatId.toString();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|
2016-01-14 01:14:53 +01:00
|
|
|
}
|