-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Sample Config Add CI Add Readme
- Loading branch information
Felix Dittrich
committed
Jan 28, 2023
1 parent
e4d9c7f
commit bf7d38c
Showing
22 changed files
with
1,866 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: ci-main | ||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/setup-java@v3 | ||
with: | ||
java-version: 17 | ||
distribution: temurin | ||
- uses: actions/checkout@v3 | ||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.m2/repository | ||
key: ${{ runner.os }}-${{ hashFiles('**/pom.xml') }} | ||
- name: version | ||
run: >- | ||
APP_SHA=$(git rev-parse --short ${GITHUB_SHA}); | ||
APP_REV=$(git rev-list --tags --max-count=1); | ||
APP_TAG=$(git describe --tags ${APP_REV} 2> /dev/null || echo 0.0.0); | ||
APP_VERSION=${APP_TAG}-${APP_SHA}; | ||
echo "APP_SHA=${APP_SHA}" >> ${GITHUB_ENV}; | ||
echo "APP_TAG=${APP_TAG}" >> ${GITHUB_ENV}; | ||
echo "APP_VERSION=${APP_VERSION}" >> ${GITHUB_ENV}; | ||
- name: Build Artifact and Docker Image | ||
run: >- | ||
mvn versions:set | ||
--batch-mode | ||
--file ./pom.xml | ||
--define newVersion="${APP_VERSION}"; | ||
mvn clean install spring-boot:build-image | ||
--batch-mode | ||
--file ./pom.xml | ||
--define app.packages.username="${APP_PACKAGES_USERNAME}" | ||
--define app.packages.password="${APP_PACKAGES_PASSWORD}" | ||
-Dspring-boot.build-image.imageName="ghcr.io/${{ github.repository }}:${APP_VERSION}"; | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Push Docker Image | ||
run: docker push ghcr.io/${{ github.repository }}:${APP_VERSION} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,3 +31,6 @@ build/ | |
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Customized Sample Confs ### | ||
sample-conf/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Polestar Order Tracker | ||
|
||
Automatically track the detailed OrderInformation of you Polestar order!<br /> | ||
Get notifications via E-Mail if anything happens regarding your future car! | ||
|
||
It checks every 6 hours if the OrderModel of the Polestar GRAPH API of your order has changed. If there are any changes | ||
it will send you an email with a detailed report of what has changed. | ||
|
||
The service uses an in-memory database to keep track of the "old" state of the order. On startup the OrderModel will be fetched | ||
and stored date will be used to detect the changes. It makes no sense to run this program just for a short time. I suggest | ||
to run it as a daemon on a server. | ||
|
||
## Disclaimer | ||
|
||
Polestar has not officially released the used APIs for consumers/ 3rd party apps. That's why I cannot guarantee that the usage | ||
of this service is allowed nor that the APIs will provide the required features in the future. | ||
|
||
## Contribution | ||
|
||
This is an OpenSource project. If you want to participate just clone the repository, do your changes and create a PullRequests. | ||
|
||
## Build | ||
|
||
To build the project on your own **Java 17+** is required. | ||
Open a shell within the project directory and execute the following command: | ||
|
||
```bash | ||
mvnw install | ||
``` | ||
|
||
You can find the resulting ```polestar-order-tracker-X.X.X.jar``` in the ```target``` directory. | ||
|
||
## Configure & Run | ||
|
||
### Direct | ||
|
||
Create a copy of the file ```application.yml``` from ```sample-conf``` directory and place it next to the | ||
```polestar-order-tracker-X.X.X.jar``` which you have build on your own or downloaded | ||
from [Releases](https://github.com/f11h/polestar-order-tracker/releases) page. | ||
|
||
Adjust the values in this file according to your needs (Setup E-Mail Server and your Polestar order details) | ||
|
||
| Property | Description | Possible Values/ Example | | ||
|----------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------| | ||
| polestar-order-tracker.order-configs[]enabled | Enable this order to keep track of it | true, false | | ||
| polestar-order-tracker.order-configs[]notify-email | Provide a list of E-Mail recipient, which will get notified about changes | [email protected] | | ||
| polestar-order-tracker.order-configs[]order-id | The UUID of your Polestar Order. Open your order via the Web-Portal. You will see an URL like ```https://www.polestar.com/de/order/424641db-6692-49a8-aa10-2fe970516404``` in your Browsers address bar. We need the ID from the end of the url. | 424641db-6692-49a8-aa10-2fe970516404 | | ||
| polestar-order-tracker.order-configs[]username | Your E-Mail of your Polestar ID | [email protected] | | ||
| polestar-order-tracker.order-configs[]password | Your Password of your Polestar ID | sup3rS3cur3 | | ||
|
||
Just start the service with the following command | ||
|
||
```bash | ||
java -jar polestar-order-tracker-X.X.X.jar | ||
``` | ||
|
||
### Docker | ||
|
||
The service can also started as Docker container. Therefore the configuration should be done via environment variables: | ||
|
||
| ENV | Description | Possible Values/ Example | | ||
|---------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------| | ||
| SPRING_MAIL_HOST | SMTP Server Host | smtp.example.org | | ||
| SPRING_MAIL_PORT | SMTP Server Port | 587 | | ||
| SPRING_MAIL_USERNAME | SMTP Username | [email protected] | | ||
| SPRING_MAIL_PASSWORD | SMTP User Password | sup3rS3cur3 | | ||
| POLESTARORDERTRACKER_ORDERCONFIGS_0_ENABLED | Enable this order to keep track of it | true, false | | ||
| POLESTARORDERTRACKER_ORDERCONFIGS_0_NOTIFYEMAIL_0 | Provide a E-Mail recipient, which will get notified about changes | [email protected] | | ||
| POLESTARORDERTRACKER_ORDERCONFIGS_0_ORDERID | The UUID of your Polestar Order. Open your order via the Web-Portal. You will see an URL like ```https://www.polestar.com/de/order/424641db-6692-49a8-aa10-2fe970516404``` in your Browsers address bar. We need the ID from the end of the url. | 424641db-6692-49a8-aa10-2fe970516404 | | ||
| POLESTARORDERTRACKER_ORDERCONFIGS_0_USERNAME | Your E-Mail of your Polestar ID | [email protected] | | ||
| POLESTARORDERTRACKER_ORDERCONFIGS_0_PASSWORD | Your Password of your Polestar ID | sup3rS3cur3 | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
spring: | ||
mail: | ||
host: smtp.gmail.com | ||
port: 587 | ||
username: [email protected] | ||
password: your-gmail-passowrd | ||
|
||
polestar-order-tracker: | ||
order-configs: | ||
- enabled: true | ||
notify-email: | ||
- [email protected] | ||
order-id: 424641db-6692-49a8-aa10-2fe970516404 | ||
username: [email protected] | ||
password: YourSuperSecurePolestarPassword |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/io/f11h/polestarordertracker/client/AccessTokenResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.f11h.polestarordertracker.client; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import lombok.Data; | ||
import lombok.Getter; | ||
|
||
@Data | ||
@Getter | ||
public | ||
class AccessTokenResponse { | ||
private Data data; | ||
|
||
@lombok.Data | ||
public static class Data { | ||
|
||
@JsonProperty("getAuthToken") | ||
private Data.AuthToken getAuthToken; | ||
|
||
@lombok.Data | ||
public static class AuthToken { | ||
@JsonProperty("id_token") | ||
private String idToken; | ||
@JsonProperty("access_token") | ||
private String accessToken; | ||
@JsonProperty("refresh_token") | ||
private String refreshToken; | ||
@JsonProperty("expires_in") | ||
private Integer expiresIn; | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/io/f11h/polestarordertracker/client/GetOrderModelRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.f11h.polestarordertracker.client; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
@Data | ||
@Builder | ||
public | ||
class GetOrderModelRequest { | ||
private String operationName; | ||
private String query; | ||
private Variables variables; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
public static class Variables { | ||
|
||
public Variables(String orderId) { | ||
request = new Request(orderId); | ||
} | ||
|
||
private Variables.Request request; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
public static class Request { | ||
private String id; | ||
} | ||
} | ||
} |
Oops, something went wrong.