Skip to content

Commit

Permalink
release/0.0.8 (#69)
Browse files Browse the repository at this point in the history
* build: bump version to 0.0.8-SNAPSHOT

* add deployment configuration and plugins

* build: bump version to 0.0.8-SNAPSHOT

* add deployment configuration and plugins

* revert: remove maven central deployment plugins

Signed-off-by: jonathan zollinger <jonathan.zollinger@outlook.com>

* refactor: fix pom styling

Signed-off-by: jonathan zollinger <jonathan.zollinger@outlook.com>

* refactor(test): simplify data feed

Signed-off-by: jonathan zollinger <jonathan.zollinger@outlook.com>

* refactor(test): change input variable

change env variables for test seed data

Signed-off-by: jonathan zollinger <jonathan.zollinger@outlook.com>

* fix(client): include all params

include unnecessary params, set to default values if null.

Signed-off-by: jonathan zollinger <jonathan.zollinger@outlook.com>

* refactor: edit whitespace

Signed-off-by: jonathan zollinger <jonathan.zollinger@outlook.com>

* feature: query store information by ID

introduce support for sql test data source
fix store-location-root object child type
move test from threshrSpec to ... Controller spec

Signed-off-by: jonathan zollinger <jonathan.zollinger@outlook.com>

* fix(test): workaround junit-intellij bug

including "string(s)" in the test title make intellij think this test should be run with junit.

Signed-off-by: jonathan zollinger <jonathan.zollinger@outlook.com>

* fix(ci): set env vars from gh secrets

Signed-off-by: jonathan zollinger <jonathan.zollinger@outlook.com>

* feature(build): add version incrementer

Signed-off-by: jonathan zollinger <jonathan.zollinger@outlook.com>

* chore: bump version to 0.0.8

Signed-off-by: jonathan zollinger <jonathan.zollinger@outlook.com>

---------

Signed-off-by: jonathan zollinger <jonathan.zollinger@outlook.com>
  • Loading branch information
Jonathan-Zollinger authored Mar 1, 2024
1 parent d64b596 commit eef7470
Show file tree
Hide file tree
Showing 14 changed files with 278 additions and 86 deletions.
57 changes: 57 additions & 0 deletions .github/update-release.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

# verify tools are available
<#
.SYNOPSIS
adds latest tag to pom and readme in either current or provided directory. replaces the previous tag.
#>

$ErrorActionPreference = 'SilentlyContinue'
if (!$(git --version)){
$ErrorActionPreference = 'Continue'
Write-Error "git is not installed "
}
$ErrorActionPreference = 'Stop'
if ($null -ne $args[0] | Out-Null) {
Test-Path $args[0] -PathType Container | Out-Null
$path = $args[0]
}else {
$path = Get-Location
}
@("$($path)/pom.xml", "$($path)/README.md") | ForEach-Object {Test-Path -Path $_ -PathType Leaf} | Out-Null
Function checkforTagNull(){
<#
.SYNOPSIS
checks if a tag at a given index is null
.OUTPUTS
Stops script if null and prints error message.
Returns tag at given iteration.
.EXAMPLE
# When a repo has a plethora of tags and you want to get the latest tag.
$> checkForTagNull(-1)
2.8.45
.EXAMPLE
# When a repo doesn't have more than one tag and you query the second to last tag.
$> checkForTagNull(-2)
tag iteration -2 does not exist
#>
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[int]
$index
)
$tag = $(git tag --sort=taggerdate)[$index]
if($null -eq $tag | Out-Null){
Write-Error "tag iteration $($index) does not exist"
}
return $tag
}

$tags = @(-2, -1) | ForEach-Object {checkforTagNull $_} | ForEach-Object {$_.Replace("v","")}

@("$($path)/pom.xml", "$($path)/README.md") | ForEach-Object {
$(Get-Content $_).Replace($tags[0], $tags[1]).Replace("-SNAPSHOT", "") | Set-Content $_
}
3 changes: 2 additions & 1 deletion .github/workflows/mvn-test_push_all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ on:
jobs:
test:
env:
THRESHR_KEY: ${{ vars.THRESHR_KEY }}
THRESHR_KEY: ${{ secrets.THRESHR_KEY }}
THRESHR_CHANNEL: ${{ vars.THRESHR_CHANNEL }}
TEST_DATASOURCES_DEFAULT_URL: ${{ secrets.TEST_DATASOURCES_DEFAULT_URL }}

environment: redsky api
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ gradle projects.
<dependency>
<groupId>com.graqr</groupId>
<artifactId>threshr</artifactId>
<version>0.0.6</version>
<version>0.0.8</version>
</dependency>
```
#### Include as a Gradle dependency
```groovy
compile "com.graqr:threshr:0.0.6"
compile "com.graqr:threshr:0.0.8"
```

#### Environment Variables
Expand Down
82 changes: 76 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.${owner}</groupId>
<artifactId>threshr</artifactId>
<version>0.0.7</version>
<version>0.0.8</version>
<packaging>${packaging}</packaging>

<parent>
Expand All @@ -29,22 +29,19 @@
<url>https://www.linkedin.com/in/jonathan-zollinger/</url>
</developer>
</developers>

<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/${owner}/${project.artifactId}</url>
</repository>
</distributionManagement>

<repositories>
<repository>
<id>central</id>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>ch.qos.logback</groupId>
Expand Down Expand Up @@ -112,6 +109,19 @@
<version>2.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy-sql</artifactId>
<version>4.0.18</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.7.2</version>
<scope>test</scope>
</dependency>

</dependencies>
<build>
<plugins>
Expand All @@ -138,13 +148,11 @@
<artifactId>micronaut-maven-plugin</artifactId>
<version>3.5.4</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<useIncrementalCompilation>false</useIncrementalCompilation>

<annotationProcessorPaths combine.self="override">
<path>
<groupId>org.projectlombok</groupId>
Expand Down Expand Up @@ -196,6 +204,68 @@
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.3</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.3.0</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>central</publishingServerId>
<tokenAuth>true</tokenAuth>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.3</version>
<configuration>
<show>public</show>
</configuration>
</plugin>
</plugins>
</reporting>
</project>
49 changes: 39 additions & 10 deletions src/main/java/com/graqr/threshr/Threshr.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
package com.graqr.threshr;

import com.graqr.threshr.model.queryparam.Place;
import com.graqr.threshr.model.queryparam.TargetStore;
import com.graqr.threshr.model.queryparam.TargetStorePdpSearch;
import com.graqr.threshr.model.queryparam.Tcin;
import com.graqr.threshr.model.queryparam.*;
import com.graqr.threshr.model.redsky.product.Product;
import com.graqr.threshr.model.redsky.product.ProductSummary;
import com.graqr.threshr.model.redsky.store.NearbyStore;
import com.graqr.threshr.model.redsky.store.Store;
import io.micronaut.core.async.annotation.SingleResult;
import io.micronaut.http.HttpResponse;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
import jakarta.inject.Inject;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

@Controller()
public class Threshr {

@Setter
@Getter
private String channel = "WEB";

@Inject
ThreshrClient threshrClient;

Expand Down Expand Up @@ -64,6 +56,43 @@ public NearbyStore queryStoreLocations(int limit, int within, Place place) throw
.nearbyStores();
}

/**
* Get Store information by store ID.
* Assigns sensible default values of 'WEB' and '/c/root' for channel and page parameters.
*
* @param storeId 4-digit unique id for a target store
* @return Store object
* @throws ThreshrException if body of HttpResponse is null
*/
@Get("/stores/id")
@SingleResult
public Store getStore(String storeId) throws ThreshrException {
return getStore(storeId, "WEB", new Page("root"));
}

/**
* Get Store information by store ID.
*
* @param storeId 4-digit unique id for a target store
* @param channel communication through which this api is being called.
* @param page source web page on target.com where this api call originates
* @return Store object
* @throws ThreshrException if body of HttpResponse is null
*/
@Get("/stores/id")
@SingleResult
public Store getStore(String storeId, String channel, Page page) throws ThreshrException {
return checkForNull(threshrClient.getStore(storeId, channel, page.getPage())).data().store();
}

/**
* Checks if the provided HttpResponse object has a null body and throws a ThreshrException if it does.
*
* @param <T> The type of object expected in the response body.
* @param response The HttpResponse object to check.
* @return The body of the HttpResponse object if it's not null.
* @throws ThreshrException If the response body is null.
*/
private <T> T checkForNull(HttpResponse<T> response) throws ThreshrException {
if (null == response.body()) {
throw new ThreshrException(String.format("response body of HttpResponse<%s> is null", response
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/com/graqr/threshr/ThreshrClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import io.micronaut.http.HttpResponse;
import io.micronaut.http.annotation.Get;
import io.micronaut.http.annotation.Header;
import io.micronaut.http.annotation.QueryValue;
import io.micronaut.http.client.annotation.Client;
import io.micronaut.retry.annotation.Retryable;
import jakarta.validation.constraints.Pattern;
Expand Down Expand Up @@ -95,8 +96,9 @@ HttpResponse<PdpClientRoot> getProductDetails(
*/
@Get("store_location_v1" +
"?key=${threshr.key}" +
"{&storeId}" +
"{&channel}")
HttpResponse<StoreLocationRoot> getStoreInformation(String storeId, String channel, String page);
"{&store}" +
"{&channel}" +
"{&page}")
HttpResponse<StoreLocationRoot> getStore(@QueryValue("store_id") String store, String channel, String page);

}
17 changes: 8 additions & 9 deletions src/main/java/com/graqr/threshr/model/redsky/store/Store.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.graqr.threshr.model.redsky.store;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.micronaut.core.annotation.Introspected;
import io.micronaut.core.annotation.Nullable;
import io.micronaut.serde.annotation.Serdeable;

import java.util.List;

@Serdeable
@Introspected
public record Store(String status,
@JsonProperty("store_id") String storeId,
@JsonProperty("location_name") String locationName,
Expand All @@ -16,12 +18,9 @@ public record Store(String status,
@JsonProperty("rolling_operating_hours") RollingOperatingHours rollingOperatingHours,
@Nullable Geofence geofence,
@Nullable List<Capability> capabilities,
@Nullable @JsonProperty("drive_up")
DriveUp driveUp,
@Nullable @JsonProperty("contact_information")
List<ContactInformation> contactInformation,
@Nullable @JsonProperty("physical_specifications")
PhysicalSpecifications physicalSpecifications,
@Nullable @JsonProperty("geographic_specifications")
GeographicSpecifications geographicSpecifications,
@Nullable Miscellaneous miscellaneous) {}
@Nullable @JsonProperty("drive_up") DriveUp driveUp,
@Nullable @JsonProperty("contact_information") List<ContactInformation> contactInformation,
@Nullable @JsonProperty("physical_specifications") PhysicalSpecifications physicalSpecifications,
@Nullable @JsonProperty("geographic_specifications") GeographicSpecifications geographicSpecifications,
@Nullable Miscellaneous miscellaneous
){}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.graqr.threshr.model.redsky.store.location;

import com.graqr.threshr.model.redsky.store.nearby.Data;
import io.micronaut.serde.annotation.Serdeable;

@Serdeable
Expand Down
12 changes: 8 additions & 4 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ micronaut:
threshr:
key:
channel:
test:
data:
stores: ${TEST_DATA_STORES:nearby_stores.json}
categories: ${TEST_DATA_CATEGORIES:target_categories.txt}
---
test:
datasources:
default:
url:
file:
stores: ${:nearby_stores.json}
categories: ${:target_categories.txt}
Loading

0 comments on commit eef7470

Please sign in to comment.