tankerkoenig-fuel-machinery – Fetch gas stations from tankerkoenig api and persist them into an Orion Context Broker

Go Report Card
Contributor Covenant

Scope

This project aims to fetch gas stations with fuel prices from https://creativecommons.tankerkoenig.de api and persist the result into an orion context broker entity.

You should provide the api token and the api search parameters with env variables.

Visit https://creativecommons.tankerkoenig.de in order to obtain an api key.

Orion Data Model

The data model persisted on orion has that shape

    {
        "id": "FuelStation:d057546e-9c10-4a27-8b56-afaab22ee845",
        "type": "FuelStation",
        "TimeInstant": {
            "type": "DateTime",
            "value": "2022-02-10T13:11:26.671Z",
            "metadata": {}
        },
        "address": {
            "type": "Text",
            "value": "Delimbiyra Miraharice Straße, 29",
            "metadata": {}
        },
        "availableFuels": {
            "type": "StructuredValue",
            "value": [
                {
                    "fuelType": {
                        "type": "Text",
                        "value": "DIESEL"
                    },
                    "price": {
                        "type": "Number",
                        "value": 1.6
                    }
                },
                {
                    "fuelType": {
                        "type": "Text",
                        "value": "E10"
                    },
                    "price": {
                        "type": "Number",
                        "value": 1.83
                    }
                }
            ],
            "metadata": {}
        },
        "brand": {
            "type": "Text",
            "value": "Ghilanna Greneiros",
            "metadata": {}
        },
        "city": {
            "type": "Text",
            "value": "Wolfsburg",
            "metadata": {}
        },
        "isOpen": {
            "type": "Boolean",
            "value": false,
            "metadata": {}
        },
        "location": {
            "type": "geo:point",
            "value": "52.417333,10.805207,",
            "metadata": {}
        },
        "name": {
            "type": "Text",
            "value": "Shanyrria Umedan",
            "metadata": {}
        },
        "postcode": {
            "type": "Text",
            "value": "38446",
            "metadata": {}
        },
    }

Development

Prerequisites

Available tasks

    * build-and-push-docker-images:                 Build all images, then push to dockerhub
    * build-docker-images:                          Build all images
    * build-docker-tankerkoenig-fuel-machinery:     Build tankerkoenig-fuel-machinery prod container
    * build-tankerkoenig-fuel-machinery-dev:        Build tankerkoenig-fuel-machinery executable with support for debugging
    * build-tankerkoenig-fuel-machinery-prod:       Build tankerkoenig-fuel-machinery binary for production release
    * install-repo-hooks:                           Copy and enable the project hooks (linting, etc...)
    * lint:                                         lint the project
    * push-docker-images:                           Push all images to dockerhub
    * push-docker-tankerkoenig-fuel-machinery:      Push tankerkoenig-fuel-machinery prod container to dockerhub
    * run-tankerkoenig-fuel-machinery-dev:          Run tankerkoenig-fuel-machinery with air

Testing

Start docker-compose first.

go test -v ./...

The pipeline will run tests at each push and prior to the docker image building.

Interface mock generation

mockery --name <interface-name> --output ./internal/<package>/mocks --recursive

Attributions

www.tankerkoenig.de

The data is subject to the Creative Commons license “CC BY 4.0”, see https://creativecommons.org/licenses/by/4.0/deed.de, attribution is required in particular (e.g. a link to www.tankerkoenig.de ) For apps, this attribution must also be included in the info text in the store.