Skip to content

Gas Stations endpoint

Flerex edited this page Jan 25, 2021 · 4 revisions

The GasStations endpoint is accesible through a class that implements the contract StationDetailsBuilder. An instance of this class is provided by GasApi::gasStations().

Methods available

This builder class has two type of available methods to use:

  • Filtering methods: Provide tools to customize the request, filtering the results according to the specified parameters.
  • get(): Performs the requests and returns the obtained values. This operation is slow, as it has to perform an HTTP request to provide the results.

Filtering methods

  • province(Province $province): Shows gas stations for the specified province. Provinces are static methods of the Province enum class. Take a look at that enum to see all available provinces. Take into account that they are methods, not properties! For example, to use the province of Zaragoza you would retrieve it like Province::ZARAGOZA().
  • town(int $town): Shows gas stations for the specified town. Due to some limitations by the API, the town's ID must be provided. You can find out about a town's ID by using the Towns endpoint.
  • fuel(Fuel $fuel): Shows gas stations with the provided fuel type. Provinces are static methods of the Fuel enum class. If a fuel filter is provided, its price is also returned.
  • serviceType(ServiceType $serviceType): Shows gas stations with the provided service type. Service types are static methods of the ServiceType enum class.
  • salesType(SalesType $salesType): Shows gas stations with the provided sales type. Sales types are static methods of the SalesType enum class.
  • from(float $latitude, float $longitude): Restricts the results to a given bounding box created from a starting geographical location (from) and an ending geographical location (to). In order for this to work, both from and to filters must be used.
  • to(float $latitude, float $longitude): Restricts the results to a given bounding box created from a starting geographical location (from) and an ending geographical location (to). In order for this to work, both from and to filters must be used.

Returned object

The returned object once get() is called is an instance of GasStation. The available properties are:

  • id: The internal ID used to identify this gas station.
  • label: The name of the gas station.
  • price: Price of the fuel. Only provided when filtering by fuel.
  • priceLastUpdatedAt: Last update of fuel prices.
  • owner: Owner of the gas station.
  • address: Address of the gas station. This object is an instance of Address and provides its own properties like line, town, postalCode and province.
  • salesType: Sales type of the gas station. Instance of SalesType.
  • location: Location of the gas station. See Location utilities to know more about the Location object.
  • bioethanolPercentage: The bioethanol percentage.
  • bioalcoholPercentage: The bioalcohol percentage.
  • hasCarWash: Whether the gas station has car washing service.
  • hasWaterAir: Whether the gas station has water and air (tires) supply.
  • hasStore: Whether the gas station has a store.
  • hasCoffeeShop: Whether the gas station has a coffee shop to rest.
  • schedule: The schedule of the coffee shop. Returns a string of the form L: 06:00-22:00.
  • averageRating: The average rating of the gas station.
  • numberRating: The amount of ratings the gas station has received to compute the averageRating.
Clone this wiki locally