Skip to content

Commit

Permalink
feat: add new Places fields to Place Details (#889)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
wangela committed Mar 29, 2023
1 parent ad782f3 commit 62a8b50
Show file tree
Hide file tree
Showing 10 changed files with 495 additions and 925 deletions.
43 changes: 42 additions & 1 deletion src/main/java/com/google/maps/PlaceDetailsRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,29 @@ public PlaceDetailsRequest region(String region) {
return param("region", region);
}

/**
* Specify reviews_no_translations=true to disable translation of reviews. Specify
* reviews_no_translations=false (default) to enable translation of reviews.
*
* @param reviews_no_translations Whether to disable translation of reviews.
* @return Returns this {@code PlaceDetailsRequest} for call chaining.
*/
public PlaceDetailsRequest reviewsNoTranslations(boolean reviewsNoTranslations) {
return param("reviews_no_translations", String.valueOf(reviewsNoTranslations));
}

/**
* Specifies the sorting method to use when returning reviews. Can be set to most_relevant
* (default) or newest. Google recommends that you display how the reviews are being sorted to the
* end user.
*
* @param reviews_sort The sorting method to use when returning reviews.
* @return Returns this {@code PlaceDetailsRequest} for call chaining.
*/
public PlaceDetailsRequest reviewsSort(String reviewsSort) {
return param("reviews_sort", reviewsSort);
}

/**
* Specifies the field masks of the details to be returned by PlaceDetails.
*
Expand Down Expand Up @@ -122,6 +145,10 @@ public enum FieldMask implements UrlValue {
@Deprecated
ALT_ID("alt_id"),
BUSINESS_STATUS("business_status"),
CURBSIDE_PICKUP("curbside_pickup"),
DELIVERY("delivery"),
DINE_IN("dine_in"),
EDITORIAL_SUMMARY("editorial_summary"),
FORMATTED_ADDRESS("formatted_address"),
FORMATTED_PHONE_NUMBER("formatted_phone_number"),
GEOMETRY("geometry"),
Expand All @@ -141,6 +168,8 @@ public enum FieldMask implements UrlValue {
INTERNATIONAL_PHONE_NUMBER("international_phone_number"),
NAME("name"),
OPENING_HOURS("opening_hours"),
CURRENT_OPENING_HOURS("current_opening_hours"),
SECONDARY_OPENING_HOURS("secondary_opening_hours"),
@Deprecated
PERMANENTLY_CLOSED("permanently_closed"),
USER_RATINGS_TOTAL("user_ratings_total"),
Expand All @@ -151,14 +180,26 @@ public enum FieldMask implements UrlValue {
RATING("rating"),
@Deprecated
REFERENCE("reference"),
RESERVABLE("reservable"),
@Deprecated
REVIEW("review"),
REVIEWS("reviews"),
@Deprecated
SCOPE("scope"),
SERVES_BEER("serves_beer"),
SERVES_BREAKFAST("serves_breakfast"),
SERVES_BRUNCH("serves_brunch"),
SERVES_DINNER("serves_dinner"),
SERVES_LUNCH("serves_lunch"),
SERVES_VEGETARIAN_FOOD("serves_vegetarian_food"),
SERVES_WINE("serves_wine"),
TAKEOUT("takeout"),
TYPES("types"),
URL("url"),
UTC_OFFSET("utc_offset"),
VICINITY("vicinity"),
WEBSITE("website");
WEBSITE("website"),
WHEELCHAIR_ACCESSIBLE_ENTRANCE("wheelchair_accessible_entrance");

private final String field;

Expand Down
63 changes: 51 additions & 12 deletions src/main/java/com/google/maps/model/OpeningHours.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import java.util.Arrays;

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

/** An indicator of special hours for a Place for a single day. */
public static class SpecialDay implements Serializable {

private static final long serialVersionUID = 1L;

/**
* A date expressed in RFC3339 format in the local timezone for the place, for example
* 2010-12-31.
*/
public String date;

/**
* True if there are exceptional hours for this day. If true, this means that there is at least
* one exception for this day. Exceptions cause different values to occur in the subfields of
* currentOpeningHours and secondaryOpeningHours such as periods, DayOfWeek, openNow. The
* exceptions apply to the hours, and the hours are used to generate the other fields.
*/
public Boolean exceptionalHours;

@Override
public String toString() {
StringBuilder sb = new StringBuilder("[Special Day: ");
if (date != null) {
sb.append(" (\"").append(date).append("\")");
}
if (exceptionalHours != null) {
sb.append(" (\"").append(exceptionalHours).append("\")");
}
sb.append("]");
return sb.toString();
}
}

/** An array of up to seven entries corresponding to the next seven days. */
public SpecialDay[] specialDays;

/**
* The formatted opening hours for each day of the week, as an array of seven strings; for
* example, {@code "Monday: 8:30 am – 5:30 pm"}.
* A type string used to identify the type of secondary hours (for example, DRIVE_THROUGH,
* HAPPY_HOUR, DELIVERY, TAKEOUT, KITCHEN, BREAKFAST, LUNCH, DINNER, BRUNCH, PICKUP,
* SENIOR_HOURS). Set for secondary_opening_hours only.
*/
public String[] weekdayText;
public String type;

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

@Override
public String toString() {
StringBuilder sb = new StringBuilder("[OpeningHours:");
if (permanentlyClosed != null && permanentlyClosed) {
sb.append(" permanentlyClosed");
}
if (openNow != null && openNow) {
sb.append(" openNow");
}
sb.append(" ").append(Arrays.toString(periods));
if (specialDays != null) {
sb.append(" (\"").append(specialDays).append("\")");
}
if (type != null) {
sb.append(" (\"").append(type).append("\")");
}
return sb.toString();
}
}

0 comments on commit 62a8b50

Please sign in to comment.