Models & Enums
Table of contents
- Enumerations
- Core Models
- Location Models
- Search Criteria Models
- Detail Models
- Response Models
- Common Usage Patterns
This page documents the data models and enumerations used throughout mimitfuelpy.
Enumerations
FuelType
Available fuel types supported by the API.
from mimitfuelpy.models import FuelType
Values:
FuelType.ALL- All fuel types (‘0’)FuelType.PETROL- Petrol/Gasoline (‘1’)FuelType.DIESEL- Diesel (‘2’)FuelType.METHANE- Methane/CNG (‘3’)FuelType.GPL- LPG (‘4’)FuelType.GCN- Compressed Natural Gas (‘323’)FuelType.GNL- Liquefied Natural Gas (‘324’)
Example:
from mimitfuelpy.models import SearchByBrandCriteria
from mimitfuelpy.models import FuelType
criteria = SearchByBrandCriteria(
province="MI",
fuelType=FuelType.PETROL.value # Use .value to get the API string
)
ServiceType
Refueling service modes.
from mimitfuelpy.models import ServiceType
Values:
ServiceType.SELF- Self-service (‘1’)ServiceType.SERVED- Full service (‘0’)ServiceType.ALL- All service types (‘x’)
Example:
from mimitfuelpy.models import ServiceType
criteria = SearchByBrandCriteria(
province="MI",
serviceType=ServiceType.SELF.value # Self-service only
)
Core Models
Brand
Represents a fuel brand.
Attributes:
id(str): Unique brand identifiername(str): Brand display name
Example:
brand = Brand(id="1", name="ENI")
print(f"Brand: {brand.name} (ID: {brand.id})")
Fuel
Represents fuel pricing information.
Attributes:
id(str): Fuel type identifiername(str): Fuel type nameprice(float): Current price per literdate(str): Price date/time
Example:
# From service area details
if service_area.fuels:
for fuel in service_area.fuels:
print(f"{fuel.name}: €{fuel.price} (as of {fuel.date})")
ServiceArea
Represents a fuel station/service area.
Attributes:
id(str): Unique service area identifiername(str): Service area nameaddress(str): Full addressbrand(str): Associated brand namefuels(List[Fuel]): Available fuels and prices
Example:
# From search results
for station in results.results:
print(f"{station.name} ({station.brand})")
print(f"Address: {station.address}")
if station.fuels:
cheapest = min(station.fuels, key=lambda f: f.price)
print(f"Cheapest fuel: {cheapest.name} at €{cheapest.price}")
Location Models
Region
Represents an Italian region.
Attributes:
id(str): Region identifiername(str): Region name
Example:
regions = client.registry.regions()
lombardy = next(r for r in regions if r.name == "LOMBARDIA")
print(f"Lombardy ID: {lombardy.id}")
Province
Represents a province within a region.
Attributes:
id(str): Province identifiername(str): Province namecode(str): Province code (e.g., “MI” for Milan)
Example:
provinces = client.registry.provinces("03") # Lombardy
milan = next(p for p in provinces if p.code == "MI")
print(f"Milan: {milan.name} (Code: {milan.code})")
Town
Represents a town within a province.
Attributes:
id(str): Town identifiername(str): Town name
Highway
Represents a highway.
Attributes:
id(str): Highway identifiername(str): Highway namecode(str): Highway code
Search Criteria Models
SearchByBrandCriteria
Criteria for searching service areas by brand.
Attributes:
province(str, optional): Province code (e.g., “MI”)priceOrder(str, optional): Price ordering (“asc” or “desc”)fuelType(str, optional): Fuel type ID (use FuelType enum)serviceType(str, optional): Service type (use ServiceType enum)
Example:
from mimitfuelpy.models import SearchByBrandCriteria
from mimitfuelpy.models import FuelType
from mimitfuelpy.models import ServiceType
criteria = SearchByBrandCriteria(
province="MI", # Milan province
priceOrder="asc", # Cheapest first
fuelType=FuelType.PETROL.value, # Petrol only
serviceType=ServiceType.SELF.value # Self-service only
)
results = client.search.byBrand(criteria)
SearchByZoneCodeCriteria
Criteria for searching service areas by geographic zone.
Attributes:
zoneCode(str): Geographic zone codepriceOrder(str, optional): Price ordering (“asc” or “desc”)fuelType(str, optional): Fuel type ID
Example:
from mimitfuelpy.models import SearchByZoneCodeCriteria
criteria = SearchByZoneCodeCriteria(
zoneCode="12345",
priceOrder="asc",
fuelType=FuelType.DIESEL.value
)
results = client.search.byZone(criteria)
Detail Models
ServiceAreaDetail
Extended information about a service area.
Attributes:
id(str): Service area identifiername(str): Service area namenomeImpianto(str): Plant/facility nameaddress(str): Full addressbrand(str): Associated brandfuels(List[Fuel]): Available fuels and pricesphoneNumber(str): Contact phone numberemail(str): Contact email addresswebsite(str): Website URLcompany(str): Operating company nameservices(List[ServiceAreaService]): Available servicesorariapertura(List[OpeningHour]): Opening hours
ServiceAreaService
Represents a service offered at a service area.
Attributes:
name(str): Service namedescription(str): Service description
OpeningHour
Represents opening hours for a service area.
Attributes:
day(str): Day of the weekopening_time(str): Opening timeclosing_time(str): Closing time
Logo
Represents brand logo information.
Attributes:
brand(str): Brand nameurl(str): Logo image URLimages(List): Available image formats and sizes
Response Models
SearchResponse
Response wrapper for search operations.
Attributes:
success(bool): Whether the search was successfulresults(List[ServiceArea]): List of matching service areastotal(int): Total number of results
Example:
response = client.search.byBrand(criteria)
if response.success:
print(f"Found {len(response.results)} stations")
for station in response.results:
print(f" - {station.name}")
else:
print("Search failed")
Common Usage Patterns
Working with Enums
from mimitfuelpy.models import FuelType
from mimitfuelpy.models import ServiceType
# Get all enum values
all_fuel_types = [ft.value for ft in FuelType]
print(f"Supported fuel types: {all_fuel_types}")
# Use in search criteria
criteria = SearchByBrandCriteria(
fuelType=FuelType.PETROL.value,
serviceType=ServiceType.SELF.value
)
Processing Search Results
def analyze_results(results):
"""Analyze search results and extract insights."""
if not results.success:
return "Search failed"
stations = results.results
if not stations:
return "No stations found"
# Find price range
all_prices = []
for station in stations:
if station.fuels:
prices = [fuel.price for fuel in station.fuels]
all_prices.extend(prices)
if all_prices:
min_price = min(all_prices)
max_price = max(all_prices)
avg_price = sum(all_prices) / len(all_prices)
return {
'count': len(stations),
'price_range': f"€{min_price:.3f} - €{max_price:.3f}",
'average_price': f"€{avg_price:.3f}"
}
return f"Found {len(stations)} stations (no price data)"
# Usage
results = client.search.byBrand(criteria)
analysis = analyze_results(results)
print(analysis)