Skip to content

Commit

Permalink
refactor: rename Place.place
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan-Zollinger committed Mar 24, 2024
1 parent 19d6581 commit 8a847ff
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/graqr/threshr/Threshr.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public NearbyStore queryStoreLocations(Place place) throws ThreshrException {
@Get("/stores/locations-query")
@SingleResult
public NearbyStore queryStoreLocations(int limit, int within, Place place) throws ThreshrException {
return checkForNull(threshrClient.getNearbyStores(limit, within, place.getPlace()))
return checkForNull(threshrClient.getNearbyStores(limit, within, place.getZipOrCityState()))
.data()
.nearbyStores();
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/graqr/threshr/model/queryparam/Place.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
@Serdeable
@Data
public class Place {
private final String place;
private final String zipOrCityState;
public Place(String zipcode) {
if (!String.valueOf(zipcode).matches("^\\d{5}(-|\\s*)?(\\d{4})?$")) {
throw new IllegalArgumentException("Invalid zipcode provided, \"" + zipcode + "\". Zipcode provided " +
"must match this regex: \"^\\d{5}(-|\\s*)?(\\d{4})?$\"");
}
place = zipcode;
zipOrCityState = zipcode;
}

public Place(String city, String state) {
Expand All @@ -32,6 +32,6 @@ public Place(String city, String state) {
if (!errorMessage.isEmpty()) {
throw new IllegalArgumentException(errorMessage);
}
place = String.format("%s, %s", city, state);
zipOrCityState = String.format("%s, %s", city, state);
}
}
4 changes: 2 additions & 2 deletions src/test/groovy/com/graqr/threshr/ThreshrClientSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ class ThreshrClientSpec extends ThreshrSpec {
null != response.body().data().product()
}

void 'querying "#place.getPlace()" returns the "#expectedLocationName" store'() {
void 'querying "#place.getZipOrCityState()" returns the "#expectedLocationName" store'() {
when:
HttpResponse<NearbyStoreRoot> response = threshrClient.getNearbyStores(5,100, place.getPlace())
HttpResponse<NearbyStoreRoot> response = threshrClient.getNearbyStores(5,100, place.getZipOrCityState())

then:
response.body().data().nearbyStores().stores()
Expand Down

0 comments on commit 8a847ff

Please sign in to comment.