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

104 lines
3.3 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;
2020-10-31 14:41:05 +01:00
import lombok.AllArgsConstructor;
import lombok.Builder;
2020-11-01 23:46:36 +01:00
import lombok.EqualsAndHashCode;
import lombok.Getter;
2020-10-31 14:41:05 +01:00
import lombok.NoArgsConstructor;
import lombok.NonNull;
2020-10-31 18:43:32 +01:00
import lombok.RequiredArgsConstructor;
2020-11-01 23:46:36 +01:00
import lombok.Setter;
import lombok.ToString;
2018-07-08 01:41:21 +02:00
import org.telegram.telegrambots.meta.exceptions.TelegramApiValidationException;
2016-04-11 02:53:53 +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
* @author Ruben Bermudez
* @version 1.0
2020-10-31 14:41:05 +01:00
* @apiNote This will only work in Telegram versions released after 9 April, 2016. Older clients will
2016-04-11 02:53:53 +02:00
* ignore them.
*/
2019-06-08 21:33:28 +02:00
@JsonDeserialize
2020-11-01 23:46:36 +01:00
@EqualsAndHashCode(callSuper = false)
@Getter
@Setter
@ToString
2020-10-31 18:43:32 +01:00
@RequiredArgsConstructor
2020-10-31 14:41:05 +01:00
@NoArgsConstructor
@AllArgsConstructor
@Builder
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";
2020-11-01 23:46:36 +01:00
private static final String GOOGLEPLACEID_FIELD = "google_place_id";
private static final String GOOGLEPLACETYPE_FIELD = "google_place_type";
/**
* Latitude of the venue in degrees
*/
2016-04-11 02:53:53 +02:00
@JsonProperty(LATITUDE_FIELD)
2020-10-31 14:41:05 +01:00
@NonNull
private Float latitude;
/**
* Longitude of the venue in degrees
*/
2016-04-11 02:53:53 +02:00
@JsonProperty(LONGITUDE_FIELD)
2020-10-31 14:41:05 +01:00
@NonNull
private Float longitude;
/**
* Name of the venue
*/
2016-04-11 02:53:53 +02:00
@JsonProperty(TITLE_FIELD)
2020-10-31 14:41:05 +01:00
@NonNull
private String title;
/**
* Address of the venue
*/
2016-04-11 02:53:53 +02:00
@JsonProperty(ADDRESS_FIELD)
2020-10-31 14:41:05 +01:00
@NonNull
private String address;
/**
* Optional. Foursquare identifier of the venue, if known
*/
2018-07-27 00:27:26 +02:00
@JsonProperty(FOURSQUAREID_FIELD)
private String foursquareId;
/**
* Optional. Foursquare type of the venue, if known.
*/
2018-07-27 00:27:26 +02:00
@JsonProperty(FOURSQUARETYPE_FIELD)
private String foursquareType;
/**
* Optional. Google Places identifier of the venue
*/
2020-11-01 23:46:36 +01:00
@JsonProperty(GOOGLEPLACEID_FIELD)
private String googlePlaceId;
/**
* Optional. Google Places type of the venue. (See supported types.)
*/
2020-11-01 23:46:36 +01:00
@JsonProperty(GOOGLEPLACETYPE_FIELD)
private String googlePlaceType;
2018-07-27 00:27:26 +02:00
@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
}