Merge pull request #45 from rubenlagus/dev

Fix venue problem and add info to exception toString
This commit is contained in:
Ruben Bermudez 2016-04-22 15:20:34 +02:00
commit fa39987a47
2 changed files with 17 additions and 9 deletions

View File

@ -26,5 +26,12 @@ public class TelegramApiException extends Exception {
return apiResponse; return apiResponse;
} }
@Override
public String toString() {
if (apiResponse == null) {
return super.toString();
} else {
return super.toString() + ": " + apiResponse;
}
}
} }

View File

@ -4,6 +4,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import org.json.JSONObject; import org.json.JSONObject;
import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent; import org.telegram.telegrambots.api.objects.inlinequery.inputmessagecontent.InputMessageContent;
import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup; import org.telegram.telegrambots.api.objects.replykeyboard.InlineKeyboardMarkup;
@ -40,9 +41,9 @@ public class InlineQueryResultVenue implements InlineQueryResult {
@JsonProperty(TITLE_FIELD) @JsonProperty(TITLE_FIELD)
private String title; ///< Optional. Location title private String title; ///< Optional. Location title
@JsonProperty(LATITUDE_FIELD) @JsonProperty(LATITUDE_FIELD)
private String latitude; ///< Venue latitude in degrees private Float latitude; ///< Venue latitude in degrees
@JsonProperty(LONGITUDE_FIELD) @JsonProperty(LONGITUDE_FIELD)
private String longitude; ///< Venue longitude in degrees private Float longitude; ///< Venue longitude in degrees
@JsonProperty(ADDRESS_FIELD) @JsonProperty(ADDRESS_FIELD)
private String address; ///< Address of the venue private String address; ///< Address of the venue
@JsonProperty(FOURSQUARE_ID_FIELD) @JsonProperty(FOURSQUARE_ID_FIELD)
@ -80,20 +81,20 @@ public class InlineQueryResultVenue implements InlineQueryResult {
return this; return this;
} }
public String getLatitude() { public Float getLatitude() {
return latitude; return latitude;
} }
public InlineQueryResultVenue setLatitude(String latitude) { public InlineQueryResultVenue setLatitude(Float latitude) {
this.latitude = latitude; this.latitude = latitude;
return this; return this;
} }
public String getLongitude() { public Float getLongitude() {
return longitude; return longitude;
} }
public InlineQueryResultVenue setLongitude(String longitude) { public InlineQueryResultVenue setLongitude(Float longitude) {
this.longitude = longitude; this.longitude = longitude;
return this; return this;
} }
@ -196,8 +197,8 @@ public class InlineQueryResultVenue implements InlineQueryResult {
gen.writeStartObject(); gen.writeStartObject();
gen.writeStringField(TYPE_FIELD, type); gen.writeStringField(TYPE_FIELD, type);
gen.writeStringField(ID_FIELD, id); gen.writeStringField(ID_FIELD, id);
gen.writeStringField(LONGITUDE_FIELD, longitude); gen.writeNumberField(LONGITUDE_FIELD, longitude);
gen.writeStringField(LATITUDE_FIELD, latitude); gen.writeNumberField(LATITUDE_FIELD, latitude);
gen.writeStringField(TITLE_FIELD, title); gen.writeStringField(TITLE_FIELD, title);
gen.writeStringField(ADDRESS_FIELD, address); gen.writeStringField(ADDRESS_FIELD, address);
if (foursquareId != null) { if (foursquareId != null) {