Fuel Pulse
A Java library to get the fuel prices in India by city.
Loading...
Searching...
No Matches
PriceAPI.java
Go to the documentation of this file.
1package io.github.amithkoujalgi.fuelprices;
2
3import io.github.amithkoujalgi.fuelprices.impl.GoodReturnsIn;
4import io.github.amithkoujalgi.fuelprices.impl.NDTV;
5import io.github.amithkoujalgi.fuelprices.types.FuelType;
6import io.github.amithkoujalgi.fuelprices.types.PriceSource;
7
8import java.io.IOException;
9
10public class PriceAPI {
11 private final PriceSource source;
12
13 public PriceAPI(PriceSource source) {
14 this.source = source;
15 }
16
17 public float fetch(String city, FuelType fuelType) throws IOException {
18 if (PriceSource.NDTV == source) {
19 return new NDTV().fetch(city, fuelType);
20 } else if (PriceSource.GOOD_RETURNS_IN == source) {
21 return new GoodReturnsIn().fetch(city, fuelType);
22 } else {
23 // use a default impl
24 return new NDTV().fetch(city, fuelType);
25 }
26 }
27}
float fetch(String city, FuelType fuelType)
Definition PriceAPI.java:17
float fetch(String city, FuelType fuelType)
float fetch(String city, FuelType fuelType)
Definition NDTV.java:11