Skip to content

Commit 87301d4

Browse files
committed
Added support for Foursquare venues: added the new field foursquare_type to the objects Venue, InlineQueryResultVenue and InputVenueMessageContent, and the parameter foursquare_type to the sendVenue method
1 parent c7775d8 commit 87301d4

File tree

5 files changed

+33
-6
lines changed

5 files changed

+33
-6
lines changed

library/src/main/java/com/pengrad/telegrambot/model/Venue.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class Venue implements Serializable {
1313
private String title;
1414
private String address;
1515
private String foursquare_id;
16+
private String foursquare_type;
1617

1718
public Location location() {
1819
return location;
@@ -30,6 +31,10 @@ public String foursquareId() {
3031
return foursquare_id;
3132
}
3233

34+
public String foursquareType() {
35+
return foursquare_type;
36+
}
37+
3338
@Override
3439
public boolean equals(Object o) {
3540
if (this == o) return true;
@@ -40,8 +45,8 @@ public boolean equals(Object o) {
4045
if (location != null ? !location.equals(venue.location) : venue.location != null) return false;
4146
if (title != null ? !title.equals(venue.title) : venue.title != null) return false;
4247
if (address != null ? !address.equals(venue.address) : venue.address != null) return false;
43-
return foursquare_id != null ? foursquare_id.equals(venue.foursquare_id) : venue.foursquare_id == null;
44-
48+
if (foursquare_id != null ? !foursquare_id.equals(venue.foursquare_id) : venue.foursquare_id != null) return false;
49+
return foursquare_type != null ? foursquare_type.equals(venue.foursquare_type) : venue.foursquare_type == null;
4550
}
4651

4752
@Override
@@ -50,6 +55,7 @@ public int hashCode() {
5055
result = 31 * result + (title != null ? title.hashCode() : 0);
5156
result = 31 * result + (address != null ? address.hashCode() : 0);
5257
result = 31 * result + (foursquare_id != null ? foursquare_id.hashCode() : 0);
58+
result = 31 * result + (foursquare_type != null ? foursquare_type.hashCode() : 0);
5359
return result;
5460
}
5561

@@ -60,6 +66,7 @@ public String toString() {
6066
", title='" + title + '\'' +
6167
", address='" + address + '\'' +
6268
", foursquare_id='" + foursquare_id + '\'' +
69+
", foursquare_type='" + foursquare_type + '\'' +
6370
'}';
6471
}
6572
}

library/src/main/java/com/pengrad/telegrambot/model/request/InlineQueryResultVenue.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class InlineQueryResultVenue extends InlineQueryResult<InlineQueryResultV
1515
private String address;
1616

1717
private String foursquare_id;
18+
private String foursquare_type;
1819
private String thumb_url;
1920
private Integer thumb_width;
2021
private Integer thumb_height;
@@ -32,6 +33,11 @@ public InlineQueryResultVenue foursquareId(String foursquareId) {
3233
return this;
3334
}
3435

36+
public InlineQueryResultVenue foursquareType(String foursquareType) {
37+
this.foursquare_type = foursquareType;
38+
return this;
39+
}
40+
3541
public InlineQueryResultVenue thumbUrl(String thumbUrl) {
3642
this.thumb_url = thumbUrl;
3743
return this;

library/src/main/java/com/pengrad/telegrambot/model/request/InputVenueMessageContent.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class InputVenueMessageContent extends InputMessageContent implements Ser
1414
private String title;
1515
private String address;
1616
private String foursquare_id;
17+
private String foursquare_type;
1718

1819
public InputVenueMessageContent(Float latitude, Float longitude, String title, String address) {
1920
this.latitude = latitude;
@@ -26,4 +27,9 @@ public InputVenueMessageContent foursquareId(String foursquareId) {
2627
this.foursquare_id = foursquareId;
2728
return this;
2829
}
30+
31+
public InputVenueMessageContent foursquareType(String foursquareType) {
32+
this.foursquare_type = foursquareType;
33+
return this;
34+
}
2935
}

library/src/main/java/com/pengrad/telegrambot/request/SendVenue.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,8 @@ public SendVenue(Object chatId, float latitude, float longitude, String title, S
1717
public SendVenue foursquareId(String foursquareId) {
1818
return add("foursquare_id", foursquareId);
1919
}
20+
21+
public SendVenue foursquareType(String foursquareType) {
22+
return add("foursquare_type", foursquareType);
23+
}
2024
}

library/src/test/java/com/pengrad/telegrambot/TelegramBotTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ public void answerInline() {
257257
new InputContactMessageContent("123123123", "na,e").lastName("lastName")),
258258
new InlineQueryResultArticle("3", "title", new InputLocationMessageContent(50f, 50f).livePeriod(60)),
259259
new InlineQueryResultArticle("4", "title",
260-
new InputVenueMessageContent(50f, 50f, "title", "address").foursquareId("sqrId")),
260+
new InputVenueMessageContent(50f, 50f, "title", "address").foursquareId("sqrId").foursquareType("frType")),
261261
new InlineQueryResultArticle("5", "title", "message"),
262262
new InlineQueryResultAudio("6", someUrl, "title").caption("cap <b>bold</b>").parseMode(ParseMode.HTML).performer("perf").audioDuration(100),
263263
new InlineQueryResultContact("7", "123123123", "name").lastName("lastName")
@@ -273,7 +273,7 @@ public void answerInline() {
273273
.mpeg4Height(100).mpeg4Width(100).mpeg4Duration(100),
274274
new InlineQueryResultPhoto("13", someUrl, someUrl).photoWidth(100).photoHeight(100).title("title")
275275
.description("desc").caption("cap <b>bold</b>").parseMode(ParseMode.HTML),
276-
new InlineQueryResultVenue("14", 54f, 55f, "title", "address").foursquareId("frsqrId")
276+
new InlineQueryResultVenue("14", 54f, 55f, "title", "address").foursquareId("frsqrId").foursquareType("frType")
277277
.thumbUrl(someUrl).thumbHeight(100).thumbWidth(100),
278278
new InlineQueryResultVideo("15", someUrl, VIDEO_MIME_TYPE, "text", someUrl, "title").caption("cap <b>bold</b>").parseMode(ParseMode.HTML)
279279
.videoWidth(100).videoHeight(100).videoDuration(100).description("desc"),
@@ -720,13 +720,17 @@ public void sendLocation() {
720720
@Test
721721
public void sendVenue() {
722722
Float lat = 21.999998f, lng = 105.2f;
723-
String title = "title", address = "addr", frsqrId = "asdfasdf";
724-
Venue venue = bot.execute(new SendVenue(chatId, lat, lng, title, address).foursquareId(frsqrId)).message().venue();
723+
String title = "title", address = "addr", frsqrId = "asdfasdf", frsqrType = "frType";
724+
Venue venue = bot.execute(new SendVenue(chatId, lat, lng, title, address)
725+
.foursquareId(frsqrId)
726+
.foursquareType(frsqrType)
727+
).message().venue();
725728
assertEquals(lat, venue.location().latitude());
726729
assertEquals(lng, venue.location().longitude());
727730
assertEquals(address, venue.address());
728731
assertEquals(title, venue.title());
729732
assertEquals(frsqrId, venue.foursquareId());
733+
assertEquals(frsqrType, venue.foursquareType());
730734
}
731735

732736
@Test

0 commit comments

Comments
 (0)