TDLightTelegramBots/telegrambots-meta/src/main/java/org/telegram/telegrambots/meta/api/objects/inlinequery/inputmessagecontent/InputVenueMessageContent.java

125 lines
3.9 KiB
Java
Raw Normal View History

2018-07-08 01:41:21 +02:00
package org.telegram.telegrambots.meta.api.objects.inlinequery.inputmessagecontent;
2016-04-11 02:53:53 +02:00
import com.fasterxml.jackson.annotation.JsonProperty;
2019-06-08 21:33:28 +02:00
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
2018-07-08 01:41:21 +02:00
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
2016-04-11 02:53:53 +02:00
/**
* @author Ruben Bermudez
* @version 1.0
2018-07-27 00:27:26 +02:00
* Represents the content of a venue message to be sent as the result of an inline query.
2016-04-11 02:53:53 +02:00
* @note This will only work in Telegram versions released after 9 April, 2016. Older clients will
* ignore them.
*/
2019-06-08 21:33:28 +02:00
@JsonDeserialize
2016-04-11 02:53:53 +02:00
public class InputVenueMessageContent implements InputMessageContent {
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 ADDRESS_FIELD = "address";
2018-07-27 00:27:26 +02:00
private static final String FOURSQUAREID_FIELD = "foursquare_id";
private static final String FOURSQUARETYPE_FIELD = "foursquare_type";
2016-04-11 02:53:53 +02:00
@JsonProperty(LATITUDE_FIELD)
private Float latitude; ///< Latitude of the venue in degrees
@JsonProperty(LONGITUDE_FIELD)
private Float longitude; ///< Longitude of the venue in degrees
@JsonProperty(TITLE_FIELD)
private String title; ///< Name of the venue
@JsonProperty(ADDRESS_FIELD)
private String address; ///< Address of the venue
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, if known
2018-07-27 00:27:26 +02:00
@JsonProperty(FOURSQUARETYPE_FIELD)
private String foursquareType; ///< Optional. Foursquare type of the venue, if known.
2016-04-11 02:53:53 +02:00
public InputVenueMessageContent() {
super();
}
public Float getLatitude() {
return latitude;
}
public InputVenueMessageContent setLatitude(Float latitude) {
2016-04-11 02:53:53 +02:00
this.latitude = latitude;
return this;
2016-04-11 02:53:53 +02:00
}
public Float getLongitude() {
return longitude;
}
public InputVenueMessageContent setLongitude(Float longitude) {
2016-04-11 02:53:53 +02:00
this.longitude = longitude;
return this;
2016-04-11 02:53:53 +02:00
}
public String getTitle() {
return title;
}
public InputVenueMessageContent setTitle(String title) {
2016-04-11 02:53:53 +02:00
this.title = title;
return this;
2016-04-11 02:53:53 +02:00
}
public String getAddress() {
return address;
}
public InputVenueMessageContent setAddress(String address) {
2016-04-11 02:53:53 +02:00
this.address = address;
return this;
2016-04-11 02:53:53 +02:00
}
public String getFoursquareId() {
return foursquareId;
}
public InputVenueMessageContent setFoursquareId(String foursquareId) {
2016-04-11 02:53:53 +02:00
this.foursquareId = foursquareId;
return this;
2016-04-11 02:53:53 +02:00
}
2018-07-27 00:27:26 +02:00
public String getFoursquareType() {
return foursquareType;
}
public InputVenueMessageContent setFoursquareType(String foursquareType) {
this.foursquareType = foursquareType;
return this;
}
@Override
public void validate() throws TelegramApiValidationException {
if (latitude == null) {
throw new TelegramApiValidationException("Latitude parameter can't be empty", this);
}
if (longitude == null) {
throw new TelegramApiValidationException("Longitude parameter can't be empty", this);
}
if (title == null || title.isEmpty()) {
throw new TelegramApiValidationException("Title parameter can't be empty", this);
}
if (address == null || address.isEmpty()) {
throw new TelegramApiValidationException("Address parameter can't be empty", this);
}
}
2016-04-11 02:53:53 +02:00
@Override
public String toString() {
return "InputVenueMessageContent{" +
2018-07-27 00:27:26 +02:00
"latitude=" + latitude +
", longitude=" + longitude +
2016-04-11 02:53:53 +02:00
", title='" + title + '\'' +
", address='" + address + '\'' +
", foursquareId='" + foursquareId + '\'' +
2018-07-27 00:27:26 +02:00
", foursquareType='" + foursquareType + '\'' +
2016-04-11 02:53:53 +02:00
'}';
}
}