Documentation ¶
Index ¶
- Constants
- type BaseResponse
- type DetailRequest
- type DetailResponse
- type GasPrices
- func (gp *GasPrices) Detail(query DetailRequest) (*DetailResponse, error)
- func (gp *GasPrices) PriceQuery(query PricesRequest) (*PricesResponse, error)
- func (gp *GasPrices) Search(query SearchRequest) (*SearchResponse, error)
- func (gp *GasPrices) SetBaseUrl(url string)
- func (gp *GasPrices) SetLicense(apiKey string)
- type PricesRequest
- type PricesResponse
- type SearchRequest
- type SearchResponse
- type Station
- type StationPrice
Constants ¶
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
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseResponse ¶
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 ¶
type DetailRequest struct {
ID string `url:"id"`
}
DetailRequest is used to get details about a gas station
type DetailResponse ¶
type DetailResponse struct { BaseResponse 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 ¶
type GasPrices struct {
// contains filtered or unexported fields
}
GasPrices is the main entrypoint of the library
func (*GasPrices) Detail ¶
func (gp *GasPrices) Detail(query DetailRequest) (*DetailResponse, error)
Detail returns details about a gas station
func (*GasPrices) PriceQuery ¶
func (gp *GasPrices) PriceQuery(query PricesRequest) (*PricesResponse, error)
PriceQuery returns prices found
func (*GasPrices) Search ¶
func (gp *GasPrices) Search(query SearchRequest) (*SearchResponse, error)
Search returns a list of stations
func (*GasPrices) SetBaseUrl ¶
SetBaseUrl can be used to override default api base
func (*GasPrices) SetLicense ¶
SetLicense allows to set an api key
type PricesRequest ¶
type PricesRequest struct {
IDs []string
}
PricesRequest request to get prices for stations listed by id
func (*PricesRequest) String ¶
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 ¶
type PricesResponse struct { BaseResponse License string `json:"license"` Data string `json:"data"` Prices map[string]StationPrice `json:"prices"` }
PricesResponse returns prices for gas stations
type SearchRequest ¶
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 ¶
type SearchResponse struct { BaseResponse 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 ¶
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 ¶
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 ¶
func (sp *StationPrice) GetDiesel() (float64, error)
GetDiesel returns the price for diesel
func (*StationPrice) GetE10 ¶
func (sp *StationPrice) GetE10() (float64, error)
GetE10 returns the price for E10
func (*StationPrice) GetE5 ¶
func (sp *StationPrice) GetE5() (float64, error)
GetE5 returns the price for E5
func (*StationPrice) HasDiesel ¶
func (sp *StationPrice) HasDiesel() bool
HasDiesel returns true if the station has type diesel
func (*StationPrice) HasE10 ¶
func (sp *StationPrice) HasE10() bool
HasE1 returns true if the station has type E5
func (*StationPrice) HasE5 ¶
func (sp *StationPrice) HasE5() bool
HasE5 returns true if the station has type E5
Source 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