Skip to content

Commit 62a8b50

Browse files
authored
feat: add new Places fields to Place Details (#889)
* feat: add new Places fields to Place Details * fix: place details tests * refactor: clean up sample response bodies * refactor: clean up migration from permanentlyClosed to businessStatus
1 parent ad782f3 commit 62a8b50

File tree

10 files changed

+495
-925
lines changed

10 files changed

+495
-925
lines changed

src/main/java/com/google/maps/PlaceDetailsRequest.java

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,29 @@ public PlaceDetailsRequest region(String region) {
7171
return param("region", region);
7272
}
7373

74+
/**
75+
* Specify reviews_no_translations=true to disable translation of reviews. Specify
76+
* reviews_no_translations=false (default) to enable translation of reviews.
77+
*
78+
* @param reviews_no_translations Whether to disable translation of reviews.
79+
* @return Returns this {@code PlaceDetailsRequest} for call chaining.
80+
*/
81+
public PlaceDetailsRequest reviewsNoTranslations(boolean reviewsNoTranslations) {
82+
return param("reviews_no_translations", String.valueOf(reviewsNoTranslations));
83+
}
84+
85+
/**
86+
* Specifies the sorting method to use when returning reviews. Can be set to most_relevant
87+
* (default) or newest. Google recommends that you display how the reviews are being sorted to the
88+
* end user.
89+
*
90+
* @param reviews_sort The sorting method to use when returning reviews.
91+
* @return Returns this {@code PlaceDetailsRequest} for call chaining.
92+
*/
93+
public PlaceDetailsRequest reviewsSort(String reviewsSort) {
94+
return param("reviews_sort", reviewsSort);
95+
}
96+
7497
/**
7598
* Specifies the field masks of the details to be returned by PlaceDetails.
7699
*
@@ -122,6 +145,10 @@ public enum FieldMask implements UrlValue {
122145
@Deprecated
123146
ALT_ID("alt_id"),
124147
BUSINESS_STATUS("business_status"),
148+
CURBSIDE_PICKUP("curbside_pickup"),
149+
DELIVERY("delivery"),
150+
DINE_IN("dine_in"),
151+
EDITORIAL_SUMMARY("editorial_summary"),
125152
FORMATTED_ADDRESS("formatted_address"),
126153
FORMATTED_PHONE_NUMBER("formatted_phone_number"),
127154
GEOMETRY("geometry"),
@@ -141,6 +168,8 @@ public enum FieldMask implements UrlValue {
141168
INTERNATIONAL_PHONE_NUMBER("international_phone_number"),
142169
NAME("name"),
143170
OPENING_HOURS("opening_hours"),
171+
CURRENT_OPENING_HOURS("current_opening_hours"),
172+
SECONDARY_OPENING_HOURS("secondary_opening_hours"),
144173
@Deprecated
145174
PERMANENTLY_CLOSED("permanently_closed"),
146175
USER_RATINGS_TOTAL("user_ratings_total"),
@@ -151,14 +180,26 @@ public enum FieldMask implements UrlValue {
151180
RATING("rating"),
152181
@Deprecated
153182
REFERENCE("reference"),
183+
RESERVABLE("reservable"),
184+
@Deprecated
154185
REVIEW("review"),
186+
REVIEWS("reviews"),
155187
@Deprecated
156188
SCOPE("scope"),
189+
SERVES_BEER("serves_beer"),
190+
SERVES_BREAKFAST("serves_breakfast"),
191+
SERVES_BRUNCH("serves_brunch"),
192+
SERVES_DINNER("serves_dinner"),
193+
SERVES_LUNCH("serves_lunch"),
194+
SERVES_VEGETARIAN_FOOD("serves_vegetarian_food"),
195+
SERVES_WINE("serves_wine"),
196+
TAKEOUT("takeout"),
157197
TYPES("types"),
158198
URL("url"),
159199
UTC_OFFSET("utc_offset"),
160200
VICINITY("vicinity"),
161-
WEBSITE("website");
201+
WEBSITE("website"),
202+
WHEELCHAIR_ACCESSIBLE_ENTRANCE("wheelchair_accessible_entrance");
162203

163204
private final String field;
164205

src/main/java/com/google/maps/model/OpeningHours.java

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
import java.util.Arrays;
2121

2222
/**
23-
* Opening hours for a Place Details result. Please see <a
24-
* href="https://developers.google.com/places/web-service/details#PlaceDetailsResults">Place Details
23+
* Opening hours for a Place Details result. Please see <a href=
24+
* "https://developers.google.com/places/web-service/details#PlaceDetailsResults">Place Details
2525
* Results</a> for more details.
2626
*/
2727
public class OpeningHours implements Serializable {
@@ -96,29 +96,68 @@ public String toString() {
9696
/** Opening periods covering seven days, starting from Sunday, in chronological order. */
9797
public Period[] periods;
9898

99+
/** An indicator of special hours for a Place for a single day. */
100+
public static class SpecialDay implements Serializable {
101+
102+
private static final long serialVersionUID = 1L;
103+
104+
/**
105+
* A date expressed in RFC3339 format in the local timezone for the place, for example
106+
* 2010-12-31.
107+
*/
108+
public String date;
109+
110+
/**
111+
* True if there are exceptional hours for this day. If true, this means that there is at least
112+
* one exception for this day. Exceptions cause different values to occur in the subfields of
113+
* currentOpeningHours and secondaryOpeningHours such as periods, DayOfWeek, openNow. The
114+
* exceptions apply to the hours, and the hours are used to generate the other fields.
115+
*/
116+
public Boolean exceptionalHours;
117+
118+
@Override
119+
public String toString() {
120+
StringBuilder sb = new StringBuilder("[Special Day: ");
121+
if (date != null) {
122+
sb.append(" (\"").append(date).append("\")");
123+
}
124+
if (exceptionalHours != null) {
125+
sb.append(" (\"").append(exceptionalHours).append("\")");
126+
}
127+
sb.append("]");
128+
return sb.toString();
129+
}
130+
}
131+
132+
/** An array of up to seven entries corresponding to the next seven days. */
133+
public SpecialDay[] specialDays;
134+
99135
/**
100-
* The formatted opening hours for each day of the week, as an array of seven strings; for
101-
* example, {@code "Monday: 8:30 am – 5:30 pm"}.
136+
* A type string used to identify the type of secondary hours (for example, DRIVE_THROUGH,
137+
* HAPPY_HOUR, DELIVERY, TAKEOUT, KITCHEN, BREAKFAST, LUNCH, DINNER, BRUNCH, PICKUP,
138+
* SENIOR_HOURS). Set for secondary_opening_hours only.
102139
*/
103-
public String[] weekdayText;
140+
public String type;
104141

105142
/**
106-
* Indicates that the place has permanently shut down.
107-
*
108-
* <p>Note: this field will be null if it isn't present in the response.
143+
* The formatted opening hours for each day of the week, as an array of seven strings; for
144+
* example, {@code "Monday: 8:30 am – 5:30 pm"}.
109145
*/
110-
public Boolean permanentlyClosed;
146+
public String[] weekdayText;
111147

112148
@Override
113149
public String toString() {
114150
StringBuilder sb = new StringBuilder("[OpeningHours:");
115-
if (permanentlyClosed != null && permanentlyClosed) {
116-
sb.append(" permanentlyClosed");
117-
}
118151
if (openNow != null && openNow) {
119152
sb.append(" openNow");
120153
}
121154
sb.append(" ").append(Arrays.toString(periods));
155+
if (specialDays != null) {
156+
sb.append(" (\"").append(specialDays).append("\")");
157+
}
158+
if (type != null) {
159+
sb.append(" (\"").append(type).append("\")");
160+
}
122161
return sb.toString();
123162
}
124163
}

0 commit comments

Comments
 (0)