diff --git a/README.md b/README.md index bc8c1cc..bafd5a0 100644 --- a/README.md +++ b/README.md @@ -39,72 +39,48 @@ ## Summary -Threshr is a wrapper library for Target Corporation's redsky api. The redsky api has endpoints for querying product and store information. This includes fulfillment options, pricing, vendors, etc. +Threshr is a wrapper library for various grocery store api's. This includes querying specific store pricing and product data. +### Projects using threshr + +Other projects using threshr include other graqr projects like the [threshr cli] and [harvester] ## Install -This project's artifacts are hosted on GitHub. Follow [these instructions] in order to include threshr in your maven or -gradle projects. - +Threshr is available to jvm projects via [maven central]. + +
Maven -#### Include as a Maven Dependency ```xml com.graqr threshr - 0.0.12 + 0.0.13 ``` -#### Include as a Gradle dependency -```groovy -compile "com.graqr:threshr:0.0.12" -``` - -#### Environment Variables - -You'll need to add api `key` and `CHANNEL` values to environment variables `THRESHR_KEY` and `THRESHR_CHANNEL`. I like using a `.env` file like the one below. -```properties -THRESHR_KEY=BatKey -THRESHR_CHANNEL=WEB -``` -> :warning: Environment Variables on windows must be assigned as an environment variable, ie `$env:foo`. -
How to find a key for the redsky api
-![redsky_network-tab_firefox.gif](media%2Fredsky_network-tab_firefox.gif) -
+
Gradle -## Usage +```groovy +implementation group: 'com.graqr', name: 'threshr', version: '0.0.13' +``` +
-Threshr doesn't support all redsky endpoints (not yet). There are three endpoints currently supported: +
Gradle Kotlin -```java -List fetchProductSummaries(TargetStore targetStore, Tcin tcin); -List fetchProductSummaries(TargetStore targetStore, String... tcin) throws ThreshrException; -``` -```java -Product fetchProductDetails(TargetStore targetStore, String tcin); -``` -```java -NearbyStores queryStoreLocations(Place place); // default values for limit and within -NearbyStores queryStoreLocations(int limit, int within, Place place); +```kotlin +implementation("com.graqr:threshr:0.0.13") ``` +
-___ +> [!NOTE] +> See the [testing README] for more information about all the needed environment variables, as well as tips and best practices. ### Want to get involved? -See our [contributing] doc before taking a whack at any [open issues]. Also be sure to read the [Testing README](src/test/groovy/com/graqr/threshr/README.md) for some tips and tricks. We'd love for you to work with us! +See our [contributing] doc before taking a whack at any [open issues]. Also be sure to read the [testing README] for some tips and tricks. We'd love for you to work with us! [Bugs]:https://sonarcloud.io/api/project_badges/measure?project=Graqr_Threshr&metric=bugs @@ -144,3 +120,7 @@ See our [contributing] doc before taking a whack at any [open issues]. Also be s [these instructions]:https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry +[testing README]:src\test\groovy\com\graqr\threshr\README.md +[maven central]:https://central.sonatype.com/artifact/com.graqr/threshr/overview +[threshr cli]:https://github.com/Graqr/threshr-cli +[harvester]:https://github.com/Graqr/Harvester diff --git a/pom.xml b/pom.xml index 3f3bdf1..5bb4589 100644 --- a/pom.xml +++ b/pom.xml @@ -4,20 +4,20 @@ 4.0.0 com.graqr threshr - 0.0.12 + 0.0.13 ${packaging} io.micronaut.platform micronaut-parent - 4.4.1 + 4.5.0 jar 17 17 - 4.2.0 + 4.5.0 graqr graqr https://sonarcloud.io @@ -131,6 +131,12 @@ + + maven-shade-plugin + + true + + io.micronaut.maven micronaut-maven-plugin diff --git a/src/main/java/com/graqr/threshr/Threshr.java b/src/main/java/com/graqr/threshr/Threshr.java index 914fad7..c71ba5c 100644 --- a/src/main/java/com/graqr/threshr/Threshr.java +++ b/src/main/java/com/graqr/threshr/Threshr.java @@ -142,10 +142,7 @@ public Store getStore(String storeId, String channel, Page page) throws ThreshrE */ private T checkForNull(HttpResponse response) throws ThreshrException { if (null == response.body()) { - throw new ThreshrException(String.format("response body of HttpResponse<%s> is null", response - .body() - .getClass() - .getName())); + throw new ThreshrException("response body is null or of an unexpected type.\n" + response); } return response.body(); } diff --git a/src/test/groovy/com/graqr/threshr/ThreshrControllerSpec.groovy b/src/test/groovy/com/graqr/threshr/ThreshrControllerSpec.groovy index c85f0f8..3823ffb 100644 --- a/src/test/groovy/com/graqr/threshr/ThreshrControllerSpec.groovy +++ b/src/test/groovy/com/graqr/threshr/ThreshrControllerSpec.groovy @@ -23,7 +23,14 @@ class ThreshrControllerSpec extends ThreshrSpec { sql = Sql.newInstance(url) } - // https://github.com/Graqr/Threshr/issues/67 + void "null-bodied response from redsky is handled gracefully"() { + when: "querying a non-existent tcin" + threshrController.fetchProductSummaries(targetStore, "imAFakeTcin") + + then: "Threshr exception thrown" + thrown(ThreshrException) + } + void "query pdp for #tcinArg tcin strings"() { when: if (count == 1){