tankpreise: github.com/sascha-andres/tankpreise Index | Files

package tankpreise

import "github.com/sascha-andres/tankpreise"


Package Files

gas_prices_detail.go gas_prices_do.go gas_prices_price_query.go gas_prices_search.go gas_prices_set_base_url.go gas_prices_set_license.go prices_request_string.go station_price_get_diesel.go station_price_get_e10.go station_price_get_e5.go station_price_has_diesel.go station_price_has_e10.go station_price_has_e5.go types.go


const DefaultBaseUrl = "https://creativecommons.tankerkoenig.de/json/"

DefaultBaseUrl is the URL where the api is hosted

const DemoAPIKey = "00000000-0000-0000-0000-000000000002"

DemoAPIKey is a key when used will return only dample data and no real data

type BaseResponse Uses

type BaseResponse struct {
    OK      bool   // OK denotes success of api call
    Message string // potential error message

BaseResponse contains all properties returned by every API call

type DetailRequest Uses

type DetailRequest struct {
    ID string `url:"id"`

DetailRequest is used to get details about a gas station

type DetailResponse Uses

type DetailResponse struct {
    License string  `json:"license"`
    Data    string  `json:"data"`
    Status  string  `json:"status"`
    Station Station `json:"station"`

DetailResponse contains data returned for a detail request

type GasPrices Uses

type GasPrices struct {
    // contains filtered or unexported fields

GasPrices is the main entrypoint of the library

func NewGasPrices Uses

func NewGasPrices() (*GasPrices, error)

NewGasPrices returns a new instance

func (*GasPrices) Detail Uses

func (gp *GasPrices) Detail(query DetailRequest) (*DetailResponse, error)

Detail returns details about a gas station

func (*GasPrices) PriceQuery Uses

func (gp *GasPrices) PriceQuery(query PricesRequest) (*PricesResponse, error)

PriceQuery returns prices found

func (*GasPrices) Search Uses

func (gp *GasPrices) Search(query SearchRequest) (*SearchResponse, error)

Search returns a list of stations

func (*GasPrices) SetBaseUrl Uses

func (gp *GasPrices) SetBaseUrl(url string)

SetBaseUrl can be used to override default api base

func (*GasPrices) SetLicense Uses

func (gp *GasPrices) SetLicense(apiKey string)

SetLicense allows to set an api key

type PricesRequest Uses

type PricesRequest struct {
    IDs []string

PricesRequest request to get prices for stations listed by id

func (*PricesRequest) String Uses

func (pr *PricesRequest) String() string

String method is used to print values passed as an operand to any format that accepts a string or to an unformatted printer such as Print.

type PricesResponse Uses

type PricesResponse struct {
    License string                  `json:"license"`
    Data    string                  `json:"data"`
    Prices  map[string]StationPrice `json:"prices"`

PricesResponse returns prices for gas stations

type SearchRequest Uses

type SearchRequest struct {
    Latitude  float64 `url:"lat"`  // geographic width of location
    Longitude float64 `url:"lng"`  // geographic height of location
    Radius    float64 `url:"rad"`  // Radius to search within
    GasType   string  `url:"type"` // GasType denotes which type of gas to lopok for (one of e5, e10, diesel or all)
    Sort      string  `url:"sort"` // Sort allows to specify whether to search by dist or price, no effect when GasType == all

SearchRequest lets you provide all parameters for a radius search

type SearchResponse Uses

type SearchResponse struct {
    License  string    `json:"license"`
    Data     string    `json:"data"`
    Status   string    `json:"status"`
    Stations []Station `json:"stations"`

SearchResponse contains all data returned by a radius search

type Station Uses

type Station struct {
    ID           string `json:"id"`
    Name         string `json:"name"`
    Brand        string `json:"brand"`
    Street       string `json:"street"`
    HouseNumber  string `json:"houseNumber"`
    PostCode     int    `json:"postCode"`
    Place        string `json:"place"`
    OpeningTimes []struct {
        Text  string `json:"text"`
        Start string `json:"start"`
        End   string `json:"end"`
    }   `json:"openingTimes"`
    Overrides []string `json:"overrides"`
    WholeDay  bool     `json:"wholeDay"`
    IsOpen    bool     `json:"isOpen"`
    E5        float64  `json:"e5"`
    E10       float64  `json:"e10"`
    Diesel    float64  `json:"diesel"`
    Lat       float64  `json:"lat"`
    Lng       float64  `json:"lng"`
    Dist      float64  `json:"dist"`
    State     string   `json:"state"`

Station describes a gas station

type StationPrice Uses

type StationPrice struct {
    Status string      `json:"status"`
    E5     interface{} `json:"e5"`
    E10    interface{} `json:"e10"`
    Diesel interface{} `json:"diesel"`

StationPrice contains prices for gas types

func (*StationPrice) GetDiesel Uses

func (sp *StationPrice) GetDiesel() (float64, error)

GetDiesel returns the price for diesel

func (*StationPrice) GetE10 Uses

func (sp *StationPrice) GetE10() (float64, error)

GetE10 returns the price for E10

func (*StationPrice) GetE5 Uses

func (sp *StationPrice) GetE5() (float64, error)

GetE5 returns the price for E5

func (*StationPrice) HasDiesel Uses

func (sp *StationPrice) HasDiesel() bool

HasDiesel returns true if the station has type diesel

func (*StationPrice) HasE10 Uses

func (sp *StationPrice) HasE10() bool

HasE1 returns true if the station has type E5

func (*StationPrice) HasE5 Uses

func (sp *StationPrice) HasE5() bool

HasE5 returns true if the station has type E5

Package tankpreise imports 6 packages (graph). Updated 2019-06-24. Refresh now. Tools for package owners.