Skip to content

Commit 1784b28

Browse files
committed
Added the fields google_place_id and google_place_type to the classes Venue, InlineQueryResultVenue, InputVenueMessageContent and the optional parameters google_place_id and google_place_type to the method sendVenue to support Google Places as a venue API provider.
1 parent 5275105 commit 1784b28

File tree

4 files changed

+53
-13
lines changed

4 files changed

+53
-13
lines changed

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

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.pengrad.telegrambot.model;
22

33
import java.io.Serializable;
4+
import java.util.Objects;
45

56
/**
67
* stas
@@ -14,6 +15,8 @@ public class Venue implements Serializable {
1415
private String address;
1516
private String foursquare_id;
1617
private String foursquare_type;
18+
private String google_place_id;
19+
private String google_place_type;
1720

1821
public Location location() {
1922
return location;
@@ -35,28 +38,31 @@ public String foursquareType() {
3538
return foursquare_type;
3639
}
3740

41+
public String googlePlaceId() {
42+
return google_place_id;
43+
}
44+
45+
public String googlePlaceType() {
46+
return google_place_type;
47+
}
48+
3849
@Override
3950
public boolean equals(Object o) {
4051
if (this == o) return true;
4152
if (o == null || getClass() != o.getClass()) return false;
42-
4353
Venue venue = (Venue) o;
44-
45-
if (location != null ? !location.equals(venue.location) : venue.location != null) return false;
46-
if (title != null ? !title.equals(venue.title) : venue.title != null) return false;
47-
if (address != null ? !address.equals(venue.address) : venue.address != null) return false;
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;
54+
return Objects.equals(location, venue.location) &&
55+
Objects.equals(title, venue.title) &&
56+
Objects.equals(address, venue.address) &&
57+
Objects.equals(foursquare_id, venue.foursquare_id) &&
58+
Objects.equals(foursquare_type, venue.foursquare_type) &&
59+
Objects.equals(google_place_id, venue.google_place_id) &&
60+
Objects.equals(google_place_type, venue.google_place_type);
5061
}
5162

5263
@Override
5364
public int hashCode() {
54-
int result = location != null ? location.hashCode() : 0;
55-
result = 31 * result + (title != null ? title.hashCode() : 0);
56-
result = 31 * result + (address != null ? address.hashCode() : 0);
57-
result = 31 * result + (foursquare_id != null ? foursquare_id.hashCode() : 0);
58-
result = 31 * result + (foursquare_type != null ? foursquare_type.hashCode() : 0);
59-
return result;
65+
return Objects.hash(location, title, address, foursquare_id, foursquare_type, google_place_id, google_place_type);
6066
}
6167

6268
@Override
@@ -67,6 +73,8 @@ public String toString() {
6773
", address='" + address + '\'' +
6874
", foursquare_id='" + foursquare_id + '\'' +
6975
", foursquare_type='" + foursquare_type + '\'' +
76+
", google_place_id='" + google_place_id + '\'' +
77+
", google_place_type='" + google_place_type + '\'' +
7078
'}';
7179
}
7280
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ public class InlineQueryResultVenue extends InlineQueryResult<InlineQueryResultV
1616

1717
private String foursquare_id;
1818
private String foursquare_type;
19+
private String google_place_id;
20+
private String google_place_type;
1921
private String thumb_url;
2022
private Integer thumb_width;
2123
private Integer thumb_height;
@@ -38,6 +40,16 @@ public InlineQueryResultVenue foursquareType(String foursquareType) {
3840
return this;
3941
}
4042

43+
public InlineQueryResultVenue googlePlaceId(String googlePlaceId) {
44+
this.google_place_id = googlePlaceId;
45+
return this;
46+
}
47+
48+
public InlineQueryResultVenue googlePlaceType(String googlePlaceType) {
49+
this.google_place_type = googlePlaceType;
50+
return this;
51+
}
52+
4153
public InlineQueryResultVenue thumbUrl(String thumbUrl) {
4254
this.thumb_url = thumbUrl;
4355
return this;

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public class InputVenueMessageContent extends InputMessageContent implements Ser
1515
private String address;
1616
private String foursquare_id;
1717
private String foursquare_type;
18+
private String google_place_id;
19+
private String google_place_type;
1820

1921
public InputVenueMessageContent(Float latitude, Float longitude, String title, String address) {
2022
this.latitude = latitude;
@@ -32,4 +34,14 @@ public InputVenueMessageContent foursquareType(String foursquareType) {
3234
this.foursquare_type = foursquareType;
3335
return this;
3436
}
37+
38+
public InputVenueMessageContent googlePlaceId(String googlePlaceId) {
39+
this.google_place_id = googlePlaceId;
40+
return this;
41+
}
42+
43+
public InputVenueMessageContent googlePlaceType(String googlePlaceType) {
44+
this.google_place_type = googlePlaceType;
45+
return this;
46+
}
3547
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,12 @@ public SendVenue foursquareId(String foursquareId) {
2121
public SendVenue foursquareType(String foursquareType) {
2222
return add("foursquare_type", foursquareType);
2323
}
24+
25+
public SendVenue googlePlaceId(String googlePlaceId) {
26+
return add("google_place_id", googlePlaceId);
27+
}
28+
29+
public SendVenue googlePlaceType(String googlePlaceType) {
30+
return add("google_place_type", googlePlaceType);
31+
}
2432
}

0 commit comments

Comments
 (0)