diff --git a/navitia_client/client/apis/public_transportation_apis/commercial_mode_apis.py b/navitia_client/client/apis/public_transportation_apis/commercial_mode_apis.py index 90c3137..f69fc3c 100644 --- a/navitia_client/client/apis/public_transportation_apis/commercial_mode_apis.py +++ b/navitia_client/client/apis/public_transportation_apis/commercial_mode_apis.py @@ -1,6 +1,7 @@ -from typing import Any, Optional, Sequence, Tuple +from typing import Any, Sequence, Tuple from navitia_client.client.apis.api_base_client import ApiBaseClient from navitia_client.client.apis.public_transportation_apis.entity_apis import EntityApi +from navitia_client.entities.request.base_entity_request import BasePTEntityRequest from navitia_client.entities.response import Pagination from navitia_client.entities.response.physical_mode import CommercialMode @@ -21,45 +22,21 @@ class CommercialModeApiClient(ApiBaseClient, EntityApi[CommercialMode]): list_entity_collection_from_region( region_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[CommercialMode], Pagination]: Lists commercial modes from a specified region. get_entity_by_id( region_id: str, object_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[CommercialMode], Pagination]: Retrieves a specific commercial mode by its ID from a specified region. list_entity_collection_from_coordinates( lon: float, lat: float, - start_page: int = 0, - count: int = 25, - depth: int = 1, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[CommercialMode], Pagination]: Lists commercial modes from specified coordinates. @@ -67,15 +44,7 @@ class CommercialModeApiClient(ApiBaseClient, EntityApi[CommercialMode]): lon: float, lat: float, object_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[CommercialMode], Pagination]: Retrieves a specific commercial mode by its ID from specified coordinates. """ @@ -102,67 +71,26 @@ def _get_entity_from_response(raw_entity_response: Any) -> Sequence[CommercialMo def list_entity_collection_from_region( self, region_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[CommercialMode], Pagination]: """ Lists commercial modes from a specified region. Parameters: region_id (str): The ID of the region. - start_page (int): The starting page for pagination. Defaults to 0. - count (int): The number of results per page. Defaults to 25. - depth (int): The depth of data to retrieve. Defaults to 1. - odt (str): The object detail type. Defaults to "all". - distance (int): The distance in meters for filtering. Defaults to 200. - headsign (Optional[str]): The headsign for filtering. Defaults to None. + request (BasePTEntityRequest): Request parameters for filtering. Returns: Tuple[Sequence[CommercialMode], Pagination]: A tuple containing a sequence of CommercialMode objects and Pagination object. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - if until is not None: - filters["until"] = until - if disable_disruption: - filters["disable_disruption"] = disable_disruption url = f"{self.base_navitia_url}/coverage/{region_id}/{self.entity_name}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def get_entity_by_id( self, region_id: str, object_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[CommercialMode], Pagination]: """ Retrieves a specific commercial mode by its ID from a specified region. @@ -170,54 +98,19 @@ def get_entity_by_id( Parameters: region_id (str): The ID of the region. object_id (str): The ID of the commercial mode. - start_page (int): The starting page for pagination. Defaults to 0. - count (int): The number of results per page. Defaults to 25. - depth (int): The depth of data to retrieve. Defaults to 1. - odt (str): The object detail type. Defaults to "all". - distance (int): The distance in meters for filtering. Defaults to 200. - headsign (Optional[str]): The headsign for filtering. Defaults to None. + request (BasePTEntityRequest): Request parameters for filtering. Returns: Tuple[Sequence[CommercialMode], Pagination]: A tuple containing a sequence of CommercialMode objects and Pagination object. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{region_id}/{self.entity_name}/{object_id}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def list_entity_collection_from_coordinates( self, lon: float, lat: float, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[CommercialMode], Pagination]: """ Lists commercial modes from specified coordinates. @@ -225,55 +118,20 @@ def list_entity_collection_from_coordinates( Parameters: lon (float): The longitude coordinate. lat (float): The latitude coordinate. - start_page (int): The starting page for pagination. Defaults to 0. - count (int): The number of results per page. Defaults to 25. - depth (int): The depth of data to retrieve. Defaults to 1. - odt (str): The object detail type. Defaults to "all". - distance (int): The distance in meters for filtering. Defaults to 200. - headsign (Optional[str]): The headsign for filtering. Defaults to None. + request (BasePTEntityRequest): Request parameters for filtering. Returns: Tuple[Sequence[CommercialMode], Pagination]: A tuple containing a sequence of CommercialMode objects and Pagination object. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{lon};{lat}/{self.entity_name}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def get_entity_by_id_and_coordinates( self, lon: float, lat: float, object_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[CommercialMode], Pagination]: """ Retrieves a specific commercial mode by its ID from specified coordinates. @@ -282,36 +140,10 @@ def get_entity_by_id_and_coordinates( lon (float): The longitude coordinate. lat (float): The latitude coordinate. object_id (str): The ID of the commercial mode. - start_page (int): The starting page for pagination. Defaults to 0. - count (int): The number of results per page. Defaults to 25. - depth (int): The depth of data to retrieve. Defaults to 1. - odt (str): The object detail type. Defaults to "all". - distance (int): The distance in meters for filtering. Defaults to 200. - headsign (Optional[str]): The headsign for filtering. Defaults to None. + request (BasePTEntityRequest): Request parameters for filtering. Returns: Tuple[Sequence[CommercialMode], Pagination]: A tuple containing a sequence of CommercialMode objects and Pagination object. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{lon};{lat}/{self.entity_name}/{object_id}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) diff --git a/navitia_client/client/apis/public_transportation_apis/company_apis.py b/navitia_client/client/apis/public_transportation_apis/company_apis.py index 61f0506..a021623 100644 --- a/navitia_client/client/apis/public_transportation_apis/company_apis.py +++ b/navitia_client/client/apis/public_transportation_apis/company_apis.py @@ -1,6 +1,7 @@ -from typing import Any, Optional, Sequence, Tuple +from typing import Any, Sequence, Tuple from navitia_client.client.apis.api_base_client import ApiBaseClient from navitia_client.client.apis.public_transportation_apis.entity_apis import EntityApi +from navitia_client.entities.request.base_entity_request import BasePTEntityRequest from navitia_client.entities.response.company import Company from navitia_client.entities.response import Pagination @@ -98,16 +99,7 @@ def _get_entity_from_response(raw_entity_response: Any) -> Sequence[Company]: def list_entity_collection_from_region( self, region_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[Company], Pagination]: """ List companies for a given region. @@ -142,41 +134,14 @@ def list_entity_collection_from_region( Tuple[Sequence[Company], Pagination] List of companies and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - if until is not None: - filters["until"] = until - if disable_disruption: - filters["disable_disruption"] = disable_disruption url = f"{self.base_navitia_url}/coverage/{region_id}/{self.entity_name}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def get_entity_by_id( self, region_id: str, object_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[Company], Pagination]: """ Get a company by its ID in a given region. @@ -213,44 +178,14 @@ def get_entity_by_id( Tuple[Sequence[Company], Pagination] List of companies and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{region_id}/{self.entity_name}/{object_id}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def list_entity_collection_from_coordinates( self, lon: float, lat: float, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[Company], Pagination]: """ List companies for given geographic coordinates. @@ -287,45 +222,15 @@ def list_entity_collection_from_coordinates( Tuple[Sequence[Company], Pagination] List of companies and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{lon};{lat}/{self.entity_name}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def get_entity_by_id_and_coordinates( self, lon: float, lat: float, object_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[Company], Pagination]: """ Get a company by its ID for given geographic coordinates. @@ -364,26 +269,5 @@ def get_entity_by_id_and_coordinates( Tuple[Sequence[Company], Pagination] List of companies and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{lon};{lat}/{self.entity_name}/{object_id}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) diff --git a/navitia_client/client/apis/public_transportation_apis/disruption_apis.py b/navitia_client/client/apis/public_transportation_apis/disruption_apis.py index 3fbd75a..e5a99c0 100644 --- a/navitia_client/client/apis/public_transportation_apis/disruption_apis.py +++ b/navitia_client/client/apis/public_transportation_apis/disruption_apis.py @@ -1,6 +1,7 @@ -from typing import Any, Optional, Sequence, Tuple +from typing import Any, Sequence, Tuple from navitia_client.client.apis.api_base_client import ApiBaseClient from navitia_client.client.apis.public_transportation_apis.entity_apis import EntityApi +from navitia_client.entities.request.base_entity_request import BasePTEntityRequest from navitia_client.entities.response.disruption import ( Disruption, ) @@ -100,16 +101,7 @@ def _get_entity_from_response(raw_entity_response: Any) -> Sequence[Disruption]: def list_entity_collection_from_region( self, region_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[Disruption], Pagination]: """ List disruptions for a given region. @@ -144,41 +136,14 @@ def list_entity_collection_from_region( Tuple[Sequence[Disruption], Pagination] List of disruptions and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - if until is not None: - filters["until"] = until - if disable_disruption: - filters["disable_disruption"] = disable_disruption url = f"{self.base_navitia_url}/coverage/{region_id}/{self.entity_name}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def get_entity_by_id( self, region_id: str, object_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[Disruption], Pagination]: """ Get a disruption by its ID in a given region. @@ -215,44 +180,14 @@ def get_entity_by_id( Tuple[Sequence[Disruption], Pagination] List of disruptions and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{region_id}/{self.entity_name}/{object_id}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def list_entity_collection_from_coordinates( self, lon: float, lat: float, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[Disruption], Pagination]: """ List disruptions for given geographic coordinates. @@ -289,45 +224,15 @@ def list_entity_collection_from_coordinates( Tuple[Sequence[Disruption], Pagination] List of disruptions and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{lon};{lat}/{self.entity_name}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def get_entity_by_id_and_coordinates( self, lon: float, lat: float, object_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[Disruption], Pagination]: """ Get a disruption by its ID for given geographic coordinates. @@ -366,26 +271,5 @@ def get_entity_by_id_and_coordinates( Tuple[Sequence[Disruption], Pagination] List of disruptions and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{lon};{lat}/{self.entity_name}/{object_id}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) diff --git a/navitia_client/client/apis/public_transportation_apis/entity_apis.py b/navitia_client/client/apis/public_transportation_apis/entity_apis.py index 4cfcd17..de5daef 100644 --- a/navitia_client/client/apis/public_transportation_apis/entity_apis.py +++ b/navitia_client/client/apis/public_transportation_apis/entity_apis.py @@ -1,6 +1,7 @@ from abc import ABC, abstractmethod -from typing import Any, Generic, Optional, Sequence, Tuple, TypeVar +from typing import Any, Generic, Sequence, Tuple, TypeVar +from navitia_client.entities.request.base_entity_request import BasePTEntityRequest from navitia_client.entities.response.company import Company from navitia_client.entities.response.disruption import Disruption from navitia_client.entities.response.line_and_route import Line, Route @@ -169,16 +170,7 @@ def _get_entity_results( def list_entity_collection_from_region( self, region_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[TEntity], Pagination]: """ List entities for a given region. @@ -187,18 +179,8 @@ def list_entity_collection_from_region( ---------- region_id : str ID of the region. - start_page : int, optional - Starting page number (default is 0). - count : int, optional - Number of items per page (default is 25). - depth : int, optional - Search depth (default is 1). - odt : str, optional - ODT type filter (default is "all"). - distance : int, optional - Maximum search distance (default is 200). - headsign : Optional[str], optional - Line headsign. + request : BasePTEntityRequest + Request parameters for filtering. Returns ------- @@ -212,16 +194,7 @@ def get_entity_by_id( self, region_id: str, object_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[TEntity], Pagination]: """ Get an entity by its ID in a given region. @@ -232,20 +205,8 @@ def get_entity_by_id( ID of the region. object_id : str ID of the entity. - start_page : int, optional - Starting page number (default is 0). - count : int, optional - Number of items per page (default is 25). - depth : int, optional - Search depth (default is 1). - disable_geojson : bool, optional - Whether to disable GeoJSON in the response (default is False). - odt : str, optional - ODT type filter (default is "all"). - distance : int, optional - Maximum search distance (default is 200). - headsign : Optional[str], optional - Line headsign. + request : BasePTEntityRequest + Request parameters for filtering. Returns ------- @@ -259,16 +220,7 @@ def list_entity_collection_from_coordinates( self, lon: float, lat: float, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[TEntity], Pagination]: """ List entities for given geographic coordinates. @@ -279,20 +231,8 @@ def list_entity_collection_from_coordinates( Longitude. lat : float Latitude. - start_page : int, optional - Starting page number (default is 0). - count : int, optional - Number of items per page (default is 25). - depth : int, optional - Search depth (default is 1). - disable_geojson : bool, optional - Whether to disable GeoJSON in the response (default is False). - odt : str, optional - ODT type filter (default is "all"). - distance : int, optional - Maximum search distance (default is 200). - headsign : Optional[str], optional - Line headsign. + request : BasePTEntityRequest + Request parameters for filtering. Returns ------- @@ -307,16 +247,7 @@ def get_entity_by_id_and_coordinates( lon: float, lat: float, object_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[TEntity], Pagination]: """ Get an entity by its ID for given geographic coordinates. @@ -329,20 +260,8 @@ def get_entity_by_id_and_coordinates( Latitude. object_id : str ID of the entity. - start_page : int, optional - Starting page number (default is 0). - count : int, optional - Number of items per page (default is 25). - depth : int, optional - Search depth (default is 1). - disable_geojson : bool, optional - Whether to disable GeoJSON in the response (default is False). - odt : str, optional - ODT type filter (default is "all"). - distance : int, optional - Maximum search distance (default is 200). - headsign : Optional[str], optional - Line headsign. + request : BasePTEntityRequest + Request parameters for filtering. Returns ------- diff --git a/navitia_client/client/apis/public_transportation_apis/line_apis.py b/navitia_client/client/apis/public_transportation_apis/line_apis.py index 0a9fae2..6321959 100644 --- a/navitia_client/client/apis/public_transportation_apis/line_apis.py +++ b/navitia_client/client/apis/public_transportation_apis/line_apis.py @@ -1,6 +1,7 @@ -from typing import Any, Optional, Sequence, Tuple +from typing import Any, Sequence, Tuple from navitia_client.client.apis.api_base_client import ApiBaseClient from navitia_client.client.apis.public_transportation_apis.entity_apis import EntityApi +from navitia_client.entities.request.base_entity_request import BasePTEntityRequest from navitia_client.entities.response.line_and_route import Line from navitia_client.entities.response import Pagination @@ -98,16 +99,7 @@ def _get_entity_from_response(raw_entity_response: Any) -> Sequence[Line]: def list_entity_collection_from_region( self, region_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[Line], Pagination]: """ List lines for a given region. @@ -142,41 +134,14 @@ def list_entity_collection_from_region( Tuple[Sequence[Line], Pagination] List of Line instances and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - if until is not None: - filters["until"] = until - if disable_disruption: - filters["disable_disruption"] = disable_disruption url = f"{self.base_navitia_url}/coverage/{region_id}/{self.entity_name}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def get_entity_by_id( self, region_id: str, object_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[Line], Pagination]: """ Get a line by its ID in a given region. @@ -213,44 +178,14 @@ def get_entity_by_id( Tuple[Sequence[Line], Pagination] List of Line instances and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{region_id}/{self.entity_name}/{object_id}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def list_entity_collection_from_coordinates( self, lon: float, lat: float, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[Line], Pagination]: """ List lines for given geographic coordinates. @@ -287,45 +222,15 @@ def list_entity_collection_from_coordinates( Tuple[Sequence[Line], Pagination] List of Line instances and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{lon};{lat}/{self.entity_name}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def get_entity_by_id_and_coordinates( self, lon: float, lat: float, object_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[Line], Pagination]: """ Get a line by its ID for given geographic coordinates. @@ -364,26 +269,5 @@ def get_entity_by_id_and_coordinates( Tuple[Sequence[Line], Pagination] List of Line instances and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{lon};{lat}/{self.entity_name}/{object_id}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) diff --git a/navitia_client/client/apis/public_transportation_apis/network_apis.py b/navitia_client/client/apis/public_transportation_apis/network_apis.py index 0fc1108..ef9ef8a 100644 --- a/navitia_client/client/apis/public_transportation_apis/network_apis.py +++ b/navitia_client/client/apis/public_transportation_apis/network_apis.py @@ -1,6 +1,7 @@ -from typing import Any, Optional, Sequence, Tuple +from typing import Any, Sequence, Tuple from navitia_client.client.apis.api_base_client import ApiBaseClient from navitia_client.client.apis.public_transportation_apis.entity_apis import EntityApi +from navitia_client.entities.request.base_entity_request import BasePTEntityRequest from navitia_client.entities.response import Network from navitia_client.entities.response import Pagination @@ -98,16 +99,7 @@ def _get_entity_from_response(raw_entity_response: Any) -> Sequence[Network]: def list_entity_collection_from_region( self, region_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[Network], Pagination]: """ List networks for a given region. @@ -142,41 +134,14 @@ def list_entity_collection_from_region( Tuple[Sequence[Network], Pagination] List of Network instances and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - if until is not None: - filters["until"] = until - if disable_disruption: - filters["disable_disruption"] = disable_disruption url = f"{self.base_navitia_url}/coverage/{region_id}/{self.entity_name}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def get_entity_by_id( self, region_id: str, object_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[Network], Pagination]: """ Get a network by its ID in a given region. @@ -213,44 +178,14 @@ def get_entity_by_id( Tuple[Sequence[Network], Pagination] List of Network instances and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{region_id}/{self.entity_name}/{object_id}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def list_entity_collection_from_coordinates( self, lon: float, lat: float, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[Network], Pagination]: """ List networks for given geographic coordinates. @@ -287,45 +222,15 @@ def list_entity_collection_from_coordinates( Tuple[Sequence[Network], Pagination] List of Network instances and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{lon};{lat}/{self.entity_name}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def get_entity_by_id_and_coordinates( self, lon: float, lat: float, object_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[Network], Pagination]: """ Get a network by its ID for given geographic coordinates. @@ -364,26 +269,5 @@ def get_entity_by_id_and_coordinates( Tuple[Sequence[Network], Pagination] List of Network instances and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{lon};{lat}/{self.entity_name}/{object_id}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) diff --git a/navitia_client/client/apis/public_transportation_apis/physical_mode_apis.py b/navitia_client/client/apis/public_transportation_apis/physical_mode_apis.py index 9c189b8..498d991 100644 --- a/navitia_client/client/apis/public_transportation_apis/physical_mode_apis.py +++ b/navitia_client/client/apis/public_transportation_apis/physical_mode_apis.py @@ -1,6 +1,7 @@ -from typing import Any, Optional, Sequence, Tuple +from typing import Any, Sequence, Tuple from navitia_client.client.apis.api_base_client import ApiBaseClient from navitia_client.client.apis.public_transportation_apis.entity_apis import EntityApi +from navitia_client.entities.request.base_entity_request import BasePTEntityRequest from navitia_client.entities.response import Pagination from navitia_client.entities.response.physical_mode import PhysicalMode @@ -98,16 +99,7 @@ def _get_entity_from_response(raw_entity_response: Any) -> Sequence[PhysicalMode def list_entity_collection_from_region( self, region_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[PhysicalMode], Pagination]: """ List physical modes for a given region. @@ -142,41 +134,14 @@ def list_entity_collection_from_region( Tuple[Sequence[PhysicalMode], Pagination] List of PhysicalMode instances and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - if until is not None: - filters["until"] = until - if disable_disruption: - filters["disable_disruption"] = disable_disruption url = f"{self.base_navitia_url}/coverage/{region_id}/{self.entity_name}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def get_entity_by_id( self, region_id: str, object_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[PhysicalMode], Pagination]: """ Get a physical mode by its ID in a given region. @@ -213,44 +178,14 @@ def get_entity_by_id( Tuple[Sequence[PhysicalMode], Pagination] List of PhysicalMode instances and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{region_id}/{self.entity_name}/{object_id}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def list_entity_collection_from_coordinates( self, lon: float, lat: float, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[PhysicalMode], Pagination]: """ List physical modes for given geographic coordinates. @@ -287,45 +222,15 @@ def list_entity_collection_from_coordinates( Tuple[Sequence[PhysicalMode], Pagination] List of PhysicalMode instances and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{lon};{lat}/{self.entity_name}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def get_entity_by_id_and_coordinates( self, lon: float, lat: float, object_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[PhysicalMode], Pagination]: """ Get a physical mode by its ID for given geographic coordinates. @@ -364,26 +269,5 @@ def get_entity_by_id_and_coordinates( Tuple[Sequence[PhysicalMode], Pagination] List of PhysicalMode instances and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{lon};{lat}/{self.entity_name}/{object_id}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) diff --git a/navitia_client/client/apis/public_transportation_apis/route_apis.py b/navitia_client/client/apis/public_transportation_apis/route_apis.py index a173343..6831a1b 100644 --- a/navitia_client/client/apis/public_transportation_apis/route_apis.py +++ b/navitia_client/client/apis/public_transportation_apis/route_apis.py @@ -1,6 +1,7 @@ -from typing import Any, Optional, Sequence, Tuple +from typing import Any, Sequence, Tuple from navitia_client.client.apis.api_base_client import ApiBaseClient from navitia_client.client.apis.public_transportation_apis.entity_apis import EntityApi +from navitia_client.entities.request.base_entity_request import BasePTEntityRequest from navitia_client.entities.response.line_and_route import Route from navitia_client.entities.response import Pagination @@ -98,16 +99,7 @@ def _get_entity_from_response(raw_entity_response: Any) -> Sequence[Route]: def list_entity_collection_from_region( self, region_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[Route], Pagination]: """ List routes for a given region. @@ -142,41 +134,14 @@ def list_entity_collection_from_region( Tuple[Sequence[Route], Pagination] List of Route instances and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - if until is not None: - filters["until"] = until - if disable_disruption: - filters["disable_disruption"] = disable_disruption url = f"{self.base_navitia_url}/coverage/{region_id}/{self.entity_name}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def get_entity_by_id( self, region_id: str, object_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[Route], Pagination]: """ Get a route by its ID in a given region. @@ -213,44 +178,14 @@ def get_entity_by_id( Tuple[Sequence[Route], Pagination] List of Route instances and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{region_id}/{self.entity_name}/{object_id}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def list_entity_collection_from_coordinates( self, lon: float, lat: float, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[Route], Pagination]: """ List routes for given geographic coordinates. @@ -287,45 +222,15 @@ def list_entity_collection_from_coordinates( Tuple[Sequence[Route], Pagination] List of Route instances and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{lon};{lat}/{self.entity_name}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def get_entity_by_id_and_coordinates( self, lon: float, lat: float, object_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[Route], Pagination]: """ Get a route by its ID for given geographic coordinates. @@ -364,26 +269,5 @@ def get_entity_by_id_and_coordinates( Tuple[Sequence[Route], Pagination] List of Route instances and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{lon};{lat}/{self.entity_name}/{object_id}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) diff --git a/navitia_client/client/apis/public_transportation_apis/stop_area_apis.py b/navitia_client/client/apis/public_transportation_apis/stop_area_apis.py index 8ed7c26..1985076 100644 --- a/navitia_client/client/apis/public_transportation_apis/stop_area_apis.py +++ b/navitia_client/client/apis/public_transportation_apis/stop_area_apis.py @@ -1,6 +1,7 @@ -from typing import Any, Optional, Sequence, Tuple +from typing import Any, Sequence, Tuple from navitia_client.client.apis.api_base_client import ApiBaseClient from navitia_client.client.apis.public_transportation_apis.entity_apis import EntityApi +from navitia_client.entities.request.base_entity_request import BasePTEntityRequest from navitia_client.entities.response import Pagination from navitia_client.entities.response.stop_area import StopArea @@ -98,16 +99,7 @@ def _get_entity_from_response(raw_entity_response: Any) -> Sequence[StopArea]: def list_entity_collection_from_region( self, region_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[StopArea], Pagination]: """ List stop areas for a given region. @@ -142,41 +134,14 @@ def list_entity_collection_from_region( Tuple[Sequence[StopArea], Pagination] List of StopArea instances and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - if until is not None: - filters["until"] = until - if disable_disruption: - filters["disable_disruption"] = disable_disruption url = f"{self.base_navitia_url}/coverage/{region_id}/{self.entity_name}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def get_entity_by_id( self, region_id: str, object_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[StopArea], Pagination]: """ Get a stop area by its ID in a given region. @@ -213,44 +178,14 @@ def get_entity_by_id( Tuple[Sequence[StopArea], Pagination] List of StopArea instances and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{region_id}/{self.entity_name}/{object_id}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def list_entity_collection_from_coordinates( self, lon: float, lat: float, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[StopArea], Pagination]: """ List stop areas for given geographic coordinates. @@ -287,45 +222,15 @@ def list_entity_collection_from_coordinates( Tuple[Sequence[StopArea], Pagination] List of StopArea instances and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{lon};{lat}/{self.entity_name}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def get_entity_by_id_and_coordinates( self, lon: float, lat: float, object_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[StopArea], Pagination]: """ Get a stop area by its ID for given geographic coordinates. @@ -364,26 +269,5 @@ def get_entity_by_id_and_coordinates( Tuple[Sequence[StopArea], Pagination] List of StopArea instances and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{lon};{lat}/{self.entity_name}/{object_id}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) diff --git a/navitia_client/client/apis/public_transportation_apis/stop_point_apis.py b/navitia_client/client/apis/public_transportation_apis/stop_point_apis.py index 484d89a..c4767c0 100644 --- a/navitia_client/client/apis/public_transportation_apis/stop_point_apis.py +++ b/navitia_client/client/apis/public_transportation_apis/stop_point_apis.py @@ -1,6 +1,7 @@ -from typing import Any, Optional, Sequence, Tuple +from typing import Any, Sequence, Tuple from navitia_client.client.apis.api_base_client import ApiBaseClient from navitia_client.client.apis.public_transportation_apis.entity_apis import EntityApi +from navitia_client.entities.request.base_entity_request import BasePTEntityRequest from navitia_client.entities.response import Pagination from navitia_client.entities.response.stop_area import StopPoint @@ -98,16 +99,7 @@ def _get_entity_from_response(raw_entity_response: Any) -> Sequence[StopPoint]: def list_entity_collection_from_region( self, region_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[StopPoint], Pagination]: """ List stop points for a given region. @@ -142,41 +134,14 @@ def list_entity_collection_from_region( Tuple[Sequence[StopPoint], Pagination] List of StopPoint instances and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - if until is not None: - filters["until"] = until - if disable_disruption: - filters["disable_disruption"] = disable_disruption url = f"{self.base_navitia_url}/coverage/{region_id}/{self.entity_name}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def get_entity_by_id( self, region_id: str, object_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[StopPoint], Pagination]: """ Get a stop point by its ID in a given region. @@ -213,44 +178,14 @@ def get_entity_by_id( Tuple[Sequence[StopPoint], Pagination] List of StopPoint instances and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{region_id}/{self.entity_name}/{object_id}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def list_entity_collection_from_coordinates( self, lon: float, lat: float, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[StopPoint], Pagination]: """ List stop points for given geographic coordinates. @@ -287,45 +222,15 @@ def list_entity_collection_from_coordinates( Tuple[Sequence[StopPoint], Pagination] List of StopPoint instances and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{lon};{lat}/{self.entity_name}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def get_entity_by_id_and_coordinates( self, lon: float, lat: float, object_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[StopPoint], Pagination]: """ Get a stop point by its ID for given geographic coordinates. @@ -364,26 +269,5 @@ def get_entity_by_id_and_coordinates( Tuple[Sequence[StopPoint], Pagination] List of StopPoint instances and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{lon};{lat}/{self.entity_name}/{object_id}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) diff --git a/navitia_client/client/apis/public_transportation_apis/vehicle_journey_apis.py b/navitia_client/client/apis/public_transportation_apis/vehicle_journey_apis.py index 161970a..aee94a4 100644 --- a/navitia_client/client/apis/public_transportation_apis/vehicle_journey_apis.py +++ b/navitia_client/client/apis/public_transportation_apis/vehicle_journey_apis.py @@ -1,6 +1,7 @@ -from typing import Any, Optional, Sequence, Tuple +from typing import Any, Sequence, Tuple from navitia_client.client.apis.api_base_client import ApiBaseClient from navitia_client.client.apis.public_transportation_apis.entity_apis import EntityApi +from navitia_client.entities.request.base_entity_request import BasePTEntityRequest from navitia_client.entities.response import Pagination from navitia_client.entities.response.vehicle_journey import VehicleJourney @@ -98,16 +99,7 @@ def _get_entity_from_response(raw_entity_response: Any) -> Sequence[VehicleJourn def list_entity_collection_from_region( self, region_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[VehicleJourney], Pagination]: """ List vehicle journeys for a given region. @@ -143,41 +135,14 @@ def list_entity_collection_from_region( List of VehicleJourney instances and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - if until is not None: - filters["until"] = until - if disable_disruption: - filters["disable_disruption"] = disable_disruption url = f"{self.base_navitia_url}/coverage/{region_id}/{self.entity_name}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def get_entity_by_id( self, region_id: str, object_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[VehicleJourney], Pagination]: """ Get a vehicle journey by its ID in a given region. @@ -214,44 +179,14 @@ def get_entity_by_id( Tuple[Sequence[VehicleJourney], Pagination] List of VehicleJourney instances and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{region_id}/{self.entity_name}/{object_id}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def list_entity_collection_from_coordinates( self, lon: float, lat: float, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[VehicleJourney], Pagination]: """ List vehicle journeys for given geographic coordinates. @@ -288,45 +223,15 @@ def list_entity_collection_from_coordinates( Tuple[Sequence[VehicleJourney], Pagination] List of VehicleJourney instances and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{lon};{lat}/{self.entity_name}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) def get_entity_by_id_and_coordinates( self, lon: float, lat: float, object_id: str, - start_page: int = 0, - count: int = 25, - depth: int = 1, - disable_geojson: bool = False, - odt: str = "all", - distance: int = 200, - headsign: Optional[str] = None, - since: Optional[str] = None, - until: Optional[str] = None, - disable_disruption: bool = False, + request: BasePTEntityRequest, ) -> Tuple[Sequence[VehicleJourney], Pagination]: """ Get a vehicle journey by its ID for given geographic coordinates. @@ -365,26 +270,5 @@ def get_entity_by_id_and_coordinates( Tuple[Sequence[VehicleJourney], Pagination] List of VehicleJourney instances and pagination information. """ - filters = { - "start_page": start_page, - "count": count, - "depth": depth, - "disable_geojson": disable_geojson, - "odt": odt, - "distance": distance, - } - - if headsign is not None: - filters["headsign"] = headsign - - if since is not None: - filters["since"] = since - - if until is not None: - filters["until"] = until - - if disable_disruption: - filters["disable_disruption"] = disable_disruption - url = f"{self.base_navitia_url}/coverage/{lon};{lat}/{self.entity_name}/{object_id}" - return self._get_entity_results(url, self.entity_name, filters) + return self._get_entity_results(url, self.entity_name, request.to_filters()) diff --git a/navitia_client/entities/request/base_entity_request.py b/navitia_client/entities/request/base_entity_request.py index 3f7a5a4..fd285c6 100644 --- a/navitia_client/entities/request/base_entity_request.py +++ b/navitia_client/entities/request/base_entity_request.py @@ -50,3 +50,33 @@ class BasePTEntityRequest(BaseEntityRequest): until: Optional[str] = None disable_geojson: bool = False disable_disruption: bool = False + + def to_filters(self) -> Dict[str, Any]: + """ + Convert the request parameters to a filter dictionary for API calls. + + Returns: + Dict[str, Any]: Dictionary of filter parameters. + """ + filters: Dict[str, Any] = { + "start_page": self.start_page, + "count": self.count, + "depth": self.depth, + "disable_geojson": self.disable_geojson, + "odt": self.odt, + "distance": self.distance, + } + + if self.headsign is not None: + filters["headsign"] = self.headsign + + if self.since is not None: + filters["since"] = self.since + + if self.until is not None: + filters["until"] = self.until + + if self.disable_disruption: + filters["disable_disruption"] = self.disable_disruption + + return filters diff --git a/navitia_client/entities/request/public_transportations/___init__.py b/navitia_client/entities/request/public_transportations/___init__.py new file mode 100644 index 0000000..4e2eacc --- /dev/null +++ b/navitia_client/entities/request/public_transportations/___init__.py @@ -0,0 +1,39 @@ +from navitia_client.entities.request.public_transportations.commercial_mode import ( + CommercialModeRequest, +) +from navitia_client.entities.request.public_transportations.company import ( + CompanyRequest, +) +from navitia_client.entities.request.public_transportations.disruption import ( + DisruptionRequest, +) +from navitia_client.entities.request.public_transportations.line import LineRequest +from navitia_client.entities.request.public_transportations.network import ( + NetworkRequest, +) +from navitia_client.entities.request.public_transportations.physical_mode import ( + PhysicalModeRequest, +) +from navitia_client.entities.request.public_transportations.route import RouteRequest +from navitia_client.entities.request.public_transportations.stop_area import ( + StopAreaRequest, +) +from navitia_client.entities.request.public_transportations.stop_point import ( + StopPointRequest, +) +from navitia_client.entities.request.public_transportations.vehicle_journey import ( + VehicleJourneyRequest, +) + +__all__ = [ + "CommercialModeRequest", + "CompanyRequest", + "DisruptionRequest", + "LineRequest", + "NetworkRequest", + "PhysicalModeRequest", + "RouteRequest", + "StopAreaRequest", + "StopPointRequest", + "VehicleJourneyRequest", +] diff --git a/navitia_client/entities/request/public_transportations/__init__.py b/navitia_client/entities/request/public_transportations/__init__.py new file mode 100644 index 0000000..4e2eacc --- /dev/null +++ b/navitia_client/entities/request/public_transportations/__init__.py @@ -0,0 +1,39 @@ +from navitia_client.entities.request.public_transportations.commercial_mode import ( + CommercialModeRequest, +) +from navitia_client.entities.request.public_transportations.company import ( + CompanyRequest, +) +from navitia_client.entities.request.public_transportations.disruption import ( + DisruptionRequest, +) +from navitia_client.entities.request.public_transportations.line import LineRequest +from navitia_client.entities.request.public_transportations.network import ( + NetworkRequest, +) +from navitia_client.entities.request.public_transportations.physical_mode import ( + PhysicalModeRequest, +) +from navitia_client.entities.request.public_transportations.route import RouteRequest +from navitia_client.entities.request.public_transportations.stop_area import ( + StopAreaRequest, +) +from navitia_client.entities.request.public_transportations.stop_point import ( + StopPointRequest, +) +from navitia_client.entities.request.public_transportations.vehicle_journey import ( + VehicleJourneyRequest, +) + +__all__ = [ + "CommercialModeRequest", + "CompanyRequest", + "DisruptionRequest", + "LineRequest", + "NetworkRequest", + "PhysicalModeRequest", + "RouteRequest", + "StopAreaRequest", + "StopPointRequest", + "VehicleJourneyRequest", +] diff --git a/navitia_client/entities/request/public_transportations/commercial_mode.py b/navitia_client/entities/request/public_transportations/commercial_mode.py new file mode 100644 index 0000000..642d702 --- /dev/null +++ b/navitia_client/entities/request/public_transportations/commercial_mode.py @@ -0,0 +1,24 @@ +from dataclasses import dataclass + +from navitia_client.entities.request.base_entity_request import BasePTEntityRequest + + +@dataclass +class CommercialModeRequest(BasePTEntityRequest): + """ + Request class for CommercialMode entity queries. + + Inherits all parameters from BasePTEntityRequest: + - count: Maximum number of results (default is 10) + - start_page: Page number to start from (default is 0) + - depth: Search depth (default is 1) + - odt: ODT type filter (default is "all") + - distance: Maximum search distance (default is 200) + - headsign: Optional line headsign + - since: Optional datetime filter (for vehicle_journeys and disruptions) + - until: Optional datetime filter (for vehicle_journeys and disruptions) + - disable_geojson: Whether to disable GeoJSON in response (default is False) + - disable_disruption: Whether to disable disruption info (default is False) + """ + + pass diff --git a/navitia_client/entities/request/public_transportations/company.py b/navitia_client/entities/request/public_transportations/company.py new file mode 100644 index 0000000..53c6c83 --- /dev/null +++ b/navitia_client/entities/request/public_transportations/company.py @@ -0,0 +1,25 @@ +from dataclasses import dataclass + + +from navitia_client.entities.request.base_entity_request import BasePTEntityRequest + + +@dataclass +class CompanyRequest(BasePTEntityRequest): + """ + Request class for Company entity queries. + + Inherits all parameters from BasePTEntityRequest: + - count: Maximum number of results (default is 10) + - start_page: Page number to start from (default is 0) + - depth: Search depth (default is 1) + - odt: ODT type filter (default is "all") + - distance: Maximum search distance (default is 200) + - headsign: Optional line headsign + - since: Optional datetime filter (for vehicle_journeys and disruptions) + - until: Optional datetime filter (for vehicle_journeys and disruptions) + - disable_geojson: Whether to disable GeoJSON in response (default is False) + - disable_disruption: Whether to disable disruption info (default is False) + """ + + pass diff --git a/navitia_client/entities/request/public_transportations/disruption.py b/navitia_client/entities/request/public_transportations/disruption.py new file mode 100644 index 0000000..e4bd8d4 --- /dev/null +++ b/navitia_client/entities/request/public_transportations/disruption.py @@ -0,0 +1,25 @@ +from dataclasses import dataclass + + +from navitia_client.entities.request.base_entity_request import BasePTEntityRequest + + +@dataclass +class DisruptionRequest(BasePTEntityRequest): + """ + Request class for Disruption entity queries. + + Inherits all parameters from BasePTEntityRequest: + - count: Maximum number of results (default is 10) + - start_page: Page number to start from (default is 0) + - depth: Search depth (default is 1) + - odt: ODT type filter (default is "all") + - distance: Maximum search distance (default is 200) + - headsign: Optional line headsign + - since: Optional datetime filter (for vehicle_journeys and disruptions) + - until: Optional datetime filter (for vehicle_journeys and disruptions) + - disable_geojson: Whether to disable GeoJSON in response (default is False) + - disable_disruption: Whether to disable disruption info (default is False) + """ + + pass diff --git a/navitia_client/entities/request/public_transportations/line.py b/navitia_client/entities/request/public_transportations/line.py new file mode 100644 index 0000000..dcb49fc --- /dev/null +++ b/navitia_client/entities/request/public_transportations/line.py @@ -0,0 +1,25 @@ +from dataclasses import dataclass + + +from navitia_client.entities.request.base_entity_request import BasePTEntityRequest + + +@dataclass +class LineRequest(BasePTEntityRequest): + """ + Request class for Line entity queries. + + Inherits all parameters from BasePTEntityRequest: + - count: Maximum number of results (default is 10) + - start_page: Page number to start from (default is 0) + - depth: Search depth (default is 1) + - odt: ODT type filter (default is "all") + - distance: Maximum search distance (default is 200) + - headsign: Optional line headsign + - since: Optional datetime filter (for vehicle_journeys and disruptions) + - until: Optional datetime filter (for vehicle_journeys and disruptions) + - disable_geojson: Whether to disable GeoJSON in response (default is False) + - disable_disruption: Whether to disable disruption info (default is False) + """ + + pass diff --git a/navitia_client/entities/request/public_transportations/network.py b/navitia_client/entities/request/public_transportations/network.py new file mode 100644 index 0000000..954b972 --- /dev/null +++ b/navitia_client/entities/request/public_transportations/network.py @@ -0,0 +1,25 @@ +from dataclasses import dataclass + + +from navitia_client.entities.request.base_entity_request import BasePTEntityRequest + + +@dataclass +class NetworkRequest(BasePTEntityRequest): + """ + Request class for Network entity queries. + + Inherits all parameters from BasePTEntityRequest: + - count: Maximum number of results (default is 10) + - start_page: Page number to start from (default is 0) + - depth: Search depth (default is 1) + - odt: ODT type filter (default is "all") + - distance: Maximum search distance (default is 200) + - headsign: Optional line headsign + - since: Optional datetime filter (for vehicle_journeys and disruptions) + - until: Optional datetime filter (for vehicle_journeys and disruptions) + - disable_geojson: Whether to disable GeoJSON in response (default is False) + - disable_disruption: Whether to disable disruption info (default is False) + """ + + pass diff --git a/navitia_client/entities/request/public_transportations/physical_mode.py b/navitia_client/entities/request/public_transportations/physical_mode.py new file mode 100644 index 0000000..9980f65 --- /dev/null +++ b/navitia_client/entities/request/public_transportations/physical_mode.py @@ -0,0 +1,25 @@ +from dataclasses import dataclass + + +from navitia_client.entities.request.base_entity_request import BasePTEntityRequest + + +@dataclass +class PhysicalModeRequest(BasePTEntityRequest): + """ + Request class for PhysicalMode entity queries. + + Inherits all parameters from BasePTEntityRequest: + - count: Maximum number of results (default is 10) + - start_page: Page number to start from (default is 0) + - depth: Search depth (default is 1) + - odt: ODT type filter (default is "all") + - distance: Maximum search distance (default is 200) + - headsign: Optional line headsign + - since: Optional datetime filter (for vehicle_journeys and disruptions) + - until: Optional datetime filter (for vehicle_journeys and disruptions) + - disable_geojson: Whether to disable GeoJSON in response (default is False) + - disable_disruption: Whether to disable disruption info (default is False) + """ + + pass diff --git a/navitia_client/entities/request/public_transportations/route.py b/navitia_client/entities/request/public_transportations/route.py new file mode 100644 index 0000000..aeab0ea --- /dev/null +++ b/navitia_client/entities/request/public_transportations/route.py @@ -0,0 +1,25 @@ +from dataclasses import dataclass + + +from navitia_client.entities.request.base_entity_request import BasePTEntityRequest + + +@dataclass +class RouteRequest(BasePTEntityRequest): + """ + Request class for Route entity queries. + + Inherits all parameters from BasePTEntityRequest: + - count: Maximum number of results (default is 10) + - start_page: Page number to start from (default is 0) + - depth: Search depth (default is 1) + - odt: ODT type filter (default is "all") + - distance: Maximum search distance (default is 200) + - headsign: Optional line headsign + - since: Optional datetime filter (for vehicle_journeys and disruptions) + - until: Optional datetime filter (for vehicle_journeys and disruptions) + - disable_geojson: Whether to disable GeoJSON in response (default is False) + - disable_disruption: Whether to disable disruption info (default is False) + """ + + pass diff --git a/navitia_client/entities/request/public_transportations/stop_area.py b/navitia_client/entities/request/public_transportations/stop_area.py new file mode 100644 index 0000000..d83c474 --- /dev/null +++ b/navitia_client/entities/request/public_transportations/stop_area.py @@ -0,0 +1,25 @@ +from dataclasses import dataclass + + +from navitia_client.entities.request.base_entity_request import BasePTEntityRequest + + +@dataclass +class StopAreaRequest(BasePTEntityRequest): + """ + Request class for StopArea entity queries. + + Inherits all parameters from BasePTEntityRequest: + - count: Maximum number of results (default is 10) + - start_page: Page number to start from (default is 0) + - depth: Search depth (default is 1) + - odt: ODT type filter (default is "all") + - distance: Maximum search distance (default is 200) + - headsign: Optional line headsign + - since: Optional datetime filter (for vehicle_journeys and disruptions) + - until: Optional datetime filter (for vehicle_journeys and disruptions) + - disable_geojson: Whether to disable GeoJSON in response (default is False) + - disable_disruption: Whether to disable disruption info (default is False) + """ + + pass diff --git a/navitia_client/entities/request/public_transportations/stop_point.py b/navitia_client/entities/request/public_transportations/stop_point.py new file mode 100644 index 0000000..0af7eb2 --- /dev/null +++ b/navitia_client/entities/request/public_transportations/stop_point.py @@ -0,0 +1,25 @@ +from dataclasses import dataclass + + +from navitia_client.entities.request.base_entity_request import BasePTEntityRequest + + +@dataclass +class StopPointRequest(BasePTEntityRequest): + """ + Request class for StopPoint entity queries. + + Inherits all parameters from BasePTEntityRequest: + - count: Maximum number of results (default is 10) + - start_page: Page number to start from (default is 0) + - depth: Search depth (default is 1) + - odt: ODT type filter (default is "all") + - distance: Maximum search distance (default is 200) + - headsign: Optional line headsign + - since: Optional datetime filter (for vehicle_journeys and disruptions) + - until: Optional datetime filter (for vehicle_journeys and disruptions) + - disable_geojson: Whether to disable GeoJSON in response (default is False) + - disable_disruption: Whether to disable disruption info (default is False) + """ + + pass diff --git a/navitia_client/entities/request/public_transportations/vehicle_journey.py b/navitia_client/entities/request/public_transportations/vehicle_journey.py new file mode 100644 index 0000000..d69d227 --- /dev/null +++ b/navitia_client/entities/request/public_transportations/vehicle_journey.py @@ -0,0 +1,25 @@ +from dataclasses import dataclass + + +from navitia_client.entities.request.base_entity_request import BasePTEntityRequest + + +@dataclass +class VehicleJourneyRequest(BasePTEntityRequest): + """ + Request class for VehicleJourney entity queries. + + Inherits all parameters from BasePTEntityRequest: + - count: Maximum number of results (default is 10) + - start_page: Page number to start from (default is 0) + - depth: Search depth (default is 1) + - odt: ODT type filter (default is "all") + - distance: Maximum search distance (default is 200) + - headsign: Optional line headsign + - since: Optional datetime filter (for vehicle_journeys and disruptions) + - until: Optional datetime filter (for vehicle_journeys and disruptions) + - disable_geojson: Whether to disable GeoJSON in response (default is False) + - disable_disruption: Whether to disable disruption info (default is False) + """ + + pass diff --git a/tests/client/apis/public_transportation_apis/test_commercial_mode_apis.py b/tests/client/apis/public_transportation_apis/test_commercial_mode_apis.py index 1ff8936..7652804 100644 --- a/tests/client/apis/public_transportation_apis/test_commercial_mode_apis.py +++ b/tests/client/apis/public_transportation_apis/test_commercial_mode_apis.py @@ -4,6 +4,7 @@ from unittest.mock import MagicMock, patch from navitia_client.entities.response.physical_mode import CommercialMode +from navitia_client.entities.request.public_transportations import CommercialModeRequest from navitia_client.client.apis.public_transportation_apis import ( CommercialModeApiClient, ) @@ -29,7 +30,7 @@ def test_list_entity_collection_from_region( # When commercial_modes, _ = commercial_modes_apis.list_entity_collection_from_region( - "tuz" + "tuz", CommercialModeRequest() ) # Then @@ -49,7 +50,9 @@ def test_get_entity_by_id( mock_get_navitia_api.return_value = mock_response # When - commercial_modes, _ = commercial_modes_apis.get_entity_by_id("tuz", "1") + commercial_modes, _ = commercial_modes_apis.get_entity_by_id( + "tuz", "1", CommercialModeRequest() + ) # Then assert len(commercial_modes) == 2 diff --git a/tests/client/apis/public_transportation_apis/test_company_apis.py b/tests/client/apis/public_transportation_apis/test_company_apis.py index 814d010..081ed4f 100644 --- a/tests/client/apis/public_transportation_apis/test_company_apis.py +++ b/tests/client/apis/public_transportation_apis/test_company_apis.py @@ -4,6 +4,7 @@ from unittest.mock import MagicMock, patch from navitia_client.entities.response.company import Company +from navitia_client.entities.request.public_transportations import CompanyRequest from navitia_client.client.apis.public_transportation_apis import CompanyApiClient @@ -26,7 +27,9 @@ def test_list_entity_collection_from_region( mock_get_navitia_api.return_value = mock_response # When - companies, _ = company_apis.list_entity_collection_from_region("tuz") + companies, _ = company_apis.list_entity_collection_from_region( + "tuz", CompanyRequest() + ) # Then assert len(companies) == 1 @@ -57,7 +60,7 @@ def test_get_entity_by_id( mock_get_navitia_api.return_value = mock_response # When - companies, _ = company_apis.get_entity_by_id("tuz", "1") + companies, _ = company_apis.get_entity_by_id("tuz", "1", CompanyRequest()) # Then assert len(companies) == 1 diff --git a/tests/client/apis/public_transportation_apis/test_disruption_apis.py b/tests/client/apis/public_transportation_apis/test_disruption_apis.py index 96cfe54..10f9503 100644 --- a/tests/client/apis/public_transportation_apis/test_disruption_apis.py +++ b/tests/client/apis/public_transportation_apis/test_disruption_apis.py @@ -4,6 +4,7 @@ from unittest.mock import MagicMock, patch from navitia_client.entities.response.disruption import Disruption +from navitia_client.entities.request.public_transportations import DisruptionRequest from navitia_client.client.apis.public_transportation_apis import DisruptionApiClient @@ -26,7 +27,9 @@ def test_list_entity_collection_from_region( mock_get_navitia_api.return_value = mock_response # When - disruptions, _ = disruption_apis.list_entity_collection_from_region("tuz") + disruptions, _ = disruption_apis.list_entity_collection_from_region( + "tuz", DisruptionRequest() + ) # Then assert len(disruptions) == 3 @@ -45,7 +48,7 @@ def test_get_entity_by_id( mock_get_navitia_api.return_value = mock_response # When - disruptions, _ = disruption_apis.get_entity_by_id("tuz", "1") + disruptions, _ = disruption_apis.get_entity_by_id("tuz", "1", DisruptionRequest()) # Then assert len(disruptions) == 3 diff --git a/tests/client/apis/public_transportation_apis/test_line_apis.py b/tests/client/apis/public_transportation_apis/test_line_apis.py index 2617afe..266b649 100644 --- a/tests/client/apis/public_transportation_apis/test_line_apis.py +++ b/tests/client/apis/public_transportation_apis/test_line_apis.py @@ -4,6 +4,7 @@ from unittest.mock import MagicMock, patch from navitia_client.entities.response.line_and_route import Line +from navitia_client.entities.request.public_transportations import LineRequest from navitia_client.client.apis.public_transportation_apis import LineApiClient @@ -26,7 +27,7 @@ def test_list_entity_collection_from_region( mock_get_navitia_api.return_value = mock_response # When - lines, _ = line_apis.list_entity_collection_from_region("tuz") + lines, _ = line_apis.list_entity_collection_from_region("tuz", LineRequest()) # Then assert len(lines) == 2 @@ -45,7 +46,7 @@ def test_get_entity_by_id( mock_get_navitia_api.return_value = mock_response # When - lines, _ = line_apis.get_entity_by_id("tuz", "1") + lines, _ = line_apis.get_entity_by_id("tuz", "1", LineRequest()) # Then assert len(lines) == 2 diff --git a/tests/client/apis/public_transportation_apis/test_network_apis.py b/tests/client/apis/public_transportation_apis/test_network_apis.py index abbb031..4c89ccf 100644 --- a/tests/client/apis/public_transportation_apis/test_network_apis.py +++ b/tests/client/apis/public_transportation_apis/test_network_apis.py @@ -4,6 +4,7 @@ from unittest.mock import MagicMock, patch from navitia_client.entities.response.network import Network +from navitia_client.entities.request.public_transportations import NetworkRequest from navitia_client.client.apis.public_transportation_apis import NetworkApiClient @@ -26,7 +27,9 @@ def test_list_entity_collection_from_region( mock_get_navitia_api.return_value = mock_response # When - networks, _ = network_apis.list_entity_collection_from_region("tuz") + networks, _ = network_apis.list_entity_collection_from_region( + "tuz", NetworkRequest() + ) # Then assert len(networks) == 2 @@ -45,7 +48,7 @@ def test_get_entity_by_id( mock_get_navitia_api.return_value = mock_response # When - networks, _ = network_apis.get_entity_by_id("tuz", "1") + networks, _ = network_apis.get_entity_by_id("tuz", "1", NetworkRequest()) # Then assert len(networks) == 2 diff --git a/tests/client/apis/public_transportation_apis/test_physical_mode_apis.py b/tests/client/apis/public_transportation_apis/test_physical_mode_apis.py index 8169a40..569be55 100644 --- a/tests/client/apis/public_transportation_apis/test_physical_mode_apis.py +++ b/tests/client/apis/public_transportation_apis/test_physical_mode_apis.py @@ -4,6 +4,7 @@ from unittest.mock import MagicMock, patch from navitia_client.entities.response.physical_mode import PhysicalMode +from navitia_client.entities.request.public_transportations import PhysicalModeRequest from navitia_client.client.apis.public_transportation_apis import ( PhysicalModeApiClient, ) @@ -28,7 +29,9 @@ def test_list_entity_collection_from_region( mock_get_navitia_api.return_value = mock_response # When - physical_modes, _ = physical_modes_apis.list_entity_collection_from_region("tuz") + physical_modes, _ = physical_modes_apis.list_entity_collection_from_region( + "tuz", PhysicalModeRequest() + ) # Then assert len(physical_modes) == 3 @@ -47,7 +50,9 @@ def test_get_entity_by_id( mock_get_navitia_api.return_value = mock_response # When - physical_modes, _ = physical_modes_apis.get_entity_by_id("tuz", "1") + physical_modes, _ = physical_modes_apis.get_entity_by_id( + "tuz", "1", PhysicalModeRequest() + ) # Then assert len(physical_modes) == 3 diff --git a/tests/client/apis/public_transportation_apis/test_route_apis.py b/tests/client/apis/public_transportation_apis/test_route_apis.py index aa38e2c..e08a027 100644 --- a/tests/client/apis/public_transportation_apis/test_route_apis.py +++ b/tests/client/apis/public_transportation_apis/test_route_apis.py @@ -4,6 +4,7 @@ from unittest.mock import MagicMock, patch from navitia_client.entities.response.line_and_route import Route +from navitia_client.entities.request.public_transportations import RouteRequest from navitia_client.client.apis.public_transportation_apis import RouteApiClient @@ -26,7 +27,7 @@ def test_list_entity_collection_from_region( mock_get_navitia_api.return_value = mock_response # When - routes, _ = route_apis.list_entity_collection_from_region("tuz") + routes, _ = route_apis.list_entity_collection_from_region("tuz", RouteRequest()) # Then assert len(routes) == 2 @@ -46,7 +47,7 @@ def test_get_entity_by_id( mock_get_navitia_api.return_value = mock_response # When - routes, _ = route_apis.get_entity_by_id("tuz", "1") + routes, _ = route_apis.get_entity_by_id("tuz", "1", RouteRequest()) # Then assert len(routes) == 2 diff --git a/tests/client/apis/public_transportation_apis/test_stop_area_apis.py b/tests/client/apis/public_transportation_apis/test_stop_area_apis.py index da38cae..f61b0bf 100644 --- a/tests/client/apis/public_transportation_apis/test_stop_area_apis.py +++ b/tests/client/apis/public_transportation_apis/test_stop_area_apis.py @@ -4,6 +4,7 @@ from unittest.mock import MagicMock, patch from navitia_client.entities.response.stop_area import StopArea +from navitia_client.entities.request.public_transportations import StopAreaRequest from navitia_client.client.apis.public_transportation_apis import StopAreaApiClient @@ -26,7 +27,9 @@ def test_list_entity_collection_from_region( mock_get_navitia_api.return_value = mock_response # When - physical_modes, _ = stop_area_apis.list_entity_collection_from_region("bar") + physical_modes, _ = stop_area_apis.list_entity_collection_from_region( + "bar", StopAreaRequest() + ) # Then assert len(physical_modes) == 3 @@ -45,7 +48,7 @@ def test_get_entity_by_id( mock_get_navitia_api.return_value = mock_response # When - physical_modes, _ = stop_area_apis.get_entity_by_id("tuz", "1") + physical_modes, _ = stop_area_apis.get_entity_by_id("tuz", "1", StopAreaRequest()) # Then assert len(physical_modes) == 3 diff --git a/tests/client/apis/public_transportation_apis/test_stop_point_apis.py b/tests/client/apis/public_transportation_apis/test_stop_point_apis.py index bbae423..d9cd344 100644 --- a/tests/client/apis/public_transportation_apis/test_stop_point_apis.py +++ b/tests/client/apis/public_transportation_apis/test_stop_point_apis.py @@ -4,6 +4,7 @@ from unittest.mock import MagicMock, patch from navitia_client.entities.response.stop_area import StopPoint +from navitia_client.entities.request.public_transportations import StopPointRequest from navitia_client.client.apis.public_transportation_apis import StopPointApiClient @@ -26,7 +27,9 @@ def test_list_entity_collection_from_region( mock_get_navitia_api.return_value = mock_response # When - physical_modes, _ = stop_point_apis.list_entity_collection_from_region("bar") + physical_modes, _ = stop_point_apis.list_entity_collection_from_region( + "bar", StopPointRequest() + ) # Then assert len(physical_modes) == 3 @@ -45,7 +48,7 @@ def test_get_entity_by_id( mock_get_navitia_api.return_value = mock_response # When - physical_modes, _ = stop_point_apis.get_entity_by_id("tuz", "1") + physical_modes, _ = stop_point_apis.get_entity_by_id("tuz", "1", StopPointRequest()) # Then assert len(physical_modes) == 3 diff --git a/tests/client/apis/public_transportation_apis/test_vehicle_journeys_apis.py b/tests/client/apis/public_transportation_apis/test_vehicle_journeys_apis.py index a5c7004..3945d1b 100644 --- a/tests/client/apis/public_transportation_apis/test_vehicle_journeys_apis.py +++ b/tests/client/apis/public_transportation_apis/test_vehicle_journeys_apis.py @@ -3,6 +3,7 @@ from unittest.mock import MagicMock, patch from navitia_client.entities.response.vehicle_journey import VehicleJourney +from navitia_client.entities.request.public_transportations import VehicleJourneyRequest from navitia_client.client.apis.public_transportation_apis import ( VehicleJourneyApiClient, ) @@ -264,7 +265,7 @@ def test_list_entity_collection_from_region( # When vehicle_journeys, _ = vehicle_journeys_apis.list_entity_collection_from_region( - "tuz" + "tuz", VehicleJourneyRequest() ) # Then @@ -443,7 +444,9 @@ def test_get_entity_by_id( mock_get_navitia_api.return_value = mock_response # When - vehicle_journeys, _ = vehicle_journeys_apis.get_entity_by_id("tuz", "1") + vehicle_journeys, _ = vehicle_journeys_apis.get_entity_by_id( + "tuz", "1", VehicleJourneyRequest() + ) # Then assert len(vehicle_journeys) == 1