def get_arrive_stop(self, **kwargs): """Obtain bus arrival info in target stop. Args: stop_number (int): Stop number to query. lang (str): Language code (*es* or *en*). Returns: Status boolean and parsed response (list[Arrival]), or message string in case of error. """ # Endpoint parameters params = { 'idStop': kwargs.get('stop_number'), 'cultureInfo': util.language_code(kwargs.get('lang')) } # Request result = self.make_request('geo', 'get_arrive_stop', **params) # Funny endpoint, no status code if not util.check_result(result, 'arrives'): return False, 'UNKNOWN ERROR' # Parse values = util.response_list(result, 'arrives') return True, [emtype.Arrival(**a) for a in values]
def get_street(self, **kwargs): """Obtain a list of nodes related to a location within a given radius. Not sure of its use, but... Args: street_name (str): Name of the street to search. street_number (int): Street number to search. radius (int): Radius (in meters) of the search. stops (int): Number of the stop to search. lang (str): Language code (*es* or *en*). Returns: Status boolean and parsed response (list[Site]), or message string in case of error. """ # Endpoint parameters params = { 'description': kwargs.get('street_name'), 'streetNumber': kwargs.get('street_number'), 'Radius': kwargs.get('radius'), 'Stops': kwargs.get('stops'), 'cultureInfo': util.language_code(kwargs.get('lang')) } # Request result = self.make_request('geo', 'get_street', **params) # Funny endpoint, no status code if not util.check_result(result, 'site'): return False, 'UNKNOWN ERROR' # Parse values = util.response_list(result, 'site') return True, [emtype.Site(**a) for a in values]
def get_stops_line(self, **kwargs): """Obtain information on the stops of the given lines. Arguments: lines (list[int] | int): Lines to query, may be empty to get all the lines. direction (str): Optional, either *forward* or *backward*. lang (str): Language code (*es* or *en*). Returns: Status boolean and parsed response (list[Stop]), or message string in case of error. """ # Endpoint parameters params = { 'line': util.ints_to_string(kwargs.get('lines', [])), 'direction': util.direction_code(kwargs.get('direction', '')), 'cultureInfo': util.language_code(kwargs.get('lang')) } # Request result = self.make_request('geo', 'get_stops_line', **params) # Funny endpoint, no status code # Only interested in 'stop' if not util.check_result(result, 'stop'): return False, 'UNKNOWN ERROR' # Parse values = util.response_list(result, 'stop') return True, [emtype.Stop(**a) for a in values]
def get_stops_from_stop(self, **kwargs): """Obtain a list of stops within the given radius of the specified stop. Args: stop_number (int): Number of the stop to query. radius (int): Radius (in meters) of the search. lang (str): Language code (*es* or *en*). Returns: Status boolean and parsed response (list[Stop]), or message string in case of error. """ # Endpoint parameters params = { 'idStop': kwargs.get('stop_number'), 'Radius': kwargs.get('radius'), 'cultureInfo': util.language_code(kwargs.get('lang')) } # Request result = self.make_request('geo', 'get_stops_from_stop', **params) # Funny endpoint, no status code if not util.check_result(result, 'stops'): return False, 'UNKNOWN ERROR' # Parse values = util.response_list(result, 'stops') return True, [emtype.Stop(**a) for a in values]
def get_street_from_xy(self, **kwargs): """Obtain a list of streets around the specified point. Args: latitude (double): Latitude in decimal degrees. longitude (double): Longitude in decimal degrees. radius (int): Radius (in meters) of the search. lang (str): Language code (*es* or *en*). Returns: Status boolean and parsed response (list[Street]), or message string in case of error. """ # Endpoint parameters params = { 'coordinateX': kwargs.get('longitude'), 'coordinateY': kwargs.get('latitude'), 'Radius': kwargs.get('radius'), 'cultureInfo': util.language_code(kwargs.get('lang')) } # Request result = self.make_request('geo', 'get_street_from_xy', **params) # Funny endpoint, no status code if not util.check_result(result, 'site'): return False, 'UNKNOWN ERROR' # Parse values = util.response_list(result, 'site') return True, [emtype.Street(**a) for a in values]
def detail_poi(self, **kwargs): """Obtain detailed info of a given POI. Args: family (str): Family code of the POI (3 chars). lang (str): Language code (*es* or *en*). id (int): Optional, ID of the POI to query. Passing value -1 will result in information from all POIs. Returns: Status boolean and parsed response (list[PoiDetails]), or message string in case of error. """ # Endpoint parameters params = { 'language': util.language_code(kwargs.get('lang')), 'family': kwargs.get('family') } if kwargs.get('id'): params['id'] = kwargs['id'] # Request result = self.make_request('detail_poi', {}, **params) if not util.check_result(result): return False, result.get('message', 'UNKNOWN ERROR') # Parse values = util.response_list(result, 'Data') return True, [emtype.PoiDetails(**a) for a in values]
def get_poi(self, **kwargs): """Obtain a list of POI in the given radius. Args: latitude (double): Latitude in decimal degrees. longitude (double): Longitude in decimal degrees. types (list[int] | int): POI IDs (or empty list to get all). radius (int): Radius (in meters) of the search. lang (str): Language code (*es* or *en*). Returns: Status boolean and parsed response (list[Poi]), or message string in case of error. """ # Endpoint parameters params = { 'coordinateX': kwargs.get('longitude'), 'coordinateY': kwargs.get('latitude'), 'tipos': util.ints_to_string(kwargs.get('types')), 'Radius': kwargs.get('radius'), 'cultureInfo': util.language_code(kwargs.get('lang')) } # Request result = self.make_request('geo', 'get_poi', **params) # Funny endpoint, no status code if not util.check_result(result, 'poiList'): return False, 'UNKNOWN ERROR' # Parse values = util.response_list(result, 'poiList') return True, [emtype.Poi(**a) for a in values]
def get_poi(self, **kwargs): """Obtain a list of POI in the given radius. Args: latitude (double): Latitude in decimal degrees. longitude (double): Longitude in decimal degrees. types (list[int] | int): POI IDs (or empty list to get all). radius (int): Radius (in meters) of the search. lang (str): Language code (*es* or *en*). Returns: Status boolean and parsed response (list[Poi]), or message string in case of error. """ # Endpoint parameters params = { 'coordinateX': kwargs.get('longitude'), 'coordinateY': kwargs.get('latitude'), 'tipos': util.ints_to_string(kwargs.get('types')), 'Radius': kwargs.get('radius'), 'cultureInfo': util.language_code(kwargs.get('lang')) } # Request result = self.make_request('geo', 'get_poi', **params) # Funny endpoint, no status code if not util.check_result(result, 'poiList'): return False, 'UNKNOWN ERROR' # Parse values = util.response_list(result, 'poiList') return True, [emtype.Poi(**a) for a in values]
def list_street_poi_parking(self, **kwargs): """Obtain a list of addresses and POIs. This endpoint uses an address to perform the search Args: lang (str): Language code (*es* or *en*). address (str): Address in which to perform the search. Returns: Status boolean and parsed response (list[ParkingPoi]), or message string in case of error. """ # Endpoint parameters url_args = { 'language': util.language_code(kwargs.get('lang')), 'address': kwargs.get('address', '') } # Request result = self.make_request('list_street_poi_parking', url_args) if not util.check_result(result): return False, result.get('message', 'UNKNOWN ERROR') # Parse values = util.response_list(result, 'Data') return True, [emtype.ParkingPoi(**a) for a in values]
def get_stops_line(self, **kwargs): """Obtain information on the stops of the given lines. Arguments: lines (list[int] | int): Lines to query, may be empty to get all the lines. direction (str): Optional, either *forward* or *backward*. lang (str): Language code (*es* or *en*). Returns: Status boolean and parsed response (list[Stop]), or message string in case of error. """ # Endpoint parameters params = { 'line': util.ints_to_string(kwargs.get('lines', [])), 'direction': util.direction_code(kwargs.get('direction', '')), 'cultureInfo': util.language_code(kwargs.get('lang')) } # Request result = self.make_request('geo', 'get_stops_line', **params) # Funny endpoint, no status code # Only interested in 'stop' if not util.check_result(result, 'stop'): return False, 'UNKNOWN ERROR' # Parse values = util.response_list(result, 'stop') return True, [emtype.Stop(**a) for a in values]
def get_street_from_xy(self, **kwargs): """Obtain a list of streets around the specified point. Args: latitude (double): Latitude in decimal degrees. longitude (double): Longitude in decimal degrees. radius (int): Radius (in meters) of the search. lang (str): Language code (*es* or *en*). Returns: Status boolean and parsed response (list[Street]), or message string in case of error. """ # Endpoint parameters params = { 'coordinateX': kwargs.get('longitude'), 'coordinateY': kwargs.get('latitude'), 'Radius': kwargs.get('radius'), 'cultureInfo': util.language_code(kwargs.get('lang')) } # Request result = self.make_request('geo', 'get_street_from_xy', **params) # Funny endpoint, no status code if not util.check_result(result, 'site'): return False, 'UNKNOWN ERROR' # Parse values = util.response_list(result, 'site') return True, [emtype.Street(**a) for a in values]
def get_arrive_stop(self, **kwargs): """Obtain bus arrival info in target stop. Args: stop_number (int): Stop number to query. lang (str): Language code (*es* or *en*). Returns: Status boolean and parsed response (list[Arrival]), or message string in case of error. """ # Endpoint parameters params = { 'idStop': kwargs.get('stop_number'), 'cultureInfo': util.language_code(kwargs.get('lang')) } # Request result = self.make_request('geo', 'get_arrive_stop', **params) # Funny endpoint, no status code if not util.check_result(result, 'arrives'): return False, 'UNKNOWN ERROR' # Parse values = util.response_list(result, 'arrives') return True, [emtype.Arrival(**a) for a in values]
def list_features(self, **kwargs): """Obtain a list of parkings. Args: lang (str): Language code (*es* or *en*). Returns: Status boolean and parsed response (list[Parking]), or message string in case of error. """ # Endpoint parameters params = { 'language': util.language_code(kwargs.get('lang')), 'publicData': True } # Request result = self.make_request('list_features', {}, **params) if not util.check_result(result): return False, result.get('message', 'UNKNOWN ERROR') # Parse values = util.response_list(result, 'Data') return True, [emtype.ParkingFeature(**a) for a in values]
def detail_poi(self, **kwargs): """Obtain detailed info of a given POI. Args: family (str): Family code of the POI (3 chars). lang (str): Language code (*es* or *en*). id (int): Optional, ID of the POI to query. Passing value -1 will result in information from all POIs. Returns: Status boolean and parsed response (list[PoiDetails]), or message string in case of error. """ # Endpoint parameters params = { 'language': util.language_code(kwargs.get('lang')), 'family': kwargs.get('family') } if kwargs.get('id'): params['id'] = kwargs['id'] # Request result = self.make_request('detail_poi', {}, **params) if not util.check_result(result): return False, result.get('message', 'UNKNOWN ERROR') # Parse values = util.response_list(result, 'Data') return True, [emtype.PoiDetails(**a) for a in values]
def list_street_poi_parking(self, **kwargs): """Obtain a list of addresses and POIs. This endpoint uses an address to perform the search Args: lang (str): Language code (*es* or *en*). address (str): Address in which to perform the search. Returns: Status boolean and parsed response (list[ParkingPoi]), or message string in case of error. """ # Endpoint parameters url_args = { 'language': util.language_code(kwargs.get('lang')), 'address': kwargs.get('address', '') } # Request result = self.make_request('list_street_poi_parking', url_args) if not util.check_result(result): return False, result.get('message', 'UNKNOWN ERROR') # Parse values = util.response_list(result, 'Data') return True, [emtype.ParkingPoi(**a) for a in values]
def list_features(self, **kwargs): """Obtain a list of parkings. Args: lang (str): Language code (*es* or *en*). Returns: Status boolean and parsed response (list[Parking]), or message string in case of error. """ # Endpoint parameters params = { 'language': util.language_code(kwargs.get('lang')), 'publicData': True } # Request result = self.make_request('list_features', {}, **params) if not util.check_result(result): return False, result.get('message', 'UNKNOWN ERROR') # Parse values = util.response_list(result, 'Data') return True, [emtype.ParkingFeature(**a) for a in values]
def get_street(self, **kwargs): """Obtain a list of nodes related to a location within a given radius. Not sure of its use, but... Args: street_name (str): Name of the street to search. street_number (int): Street number to search. radius (int): Radius (in meters) of the search. stops (int): Number of the stop to search. lang (str): Language code (*es* or *en*). Returns: Status boolean and parsed response (list[Site]), or message string in case of error. """ # Endpoint parameters params = { 'description': kwargs.get('street_name'), 'streetNumber': kwargs.get('street_number'), 'Radius': kwargs.get('radius'), 'Stops': kwargs.get('stops'), 'cultureInfo': util.language_code(kwargs.get('lang')) } # Request result = self.make_request('geo', 'get_street', **params) # Funny endpoint, no status code if not util.check_result(result, 'site'): return False, 'UNKNOWN ERROR' # Parse values = util.response_list(result, 'site') return True, [emtype.Site(**a) for a in values]
def get_stops_from_stop(self, **kwargs): """Obtain a list of stops within the given radius of the specified stop. Args: stop_number (int): Number of the stop to query. radius (int): Radius (in meters) of the search. lang (str): Language code (*es* or *en*). Returns: Status boolean and parsed response (list[Stop]), or message string in case of error. """ # Endpoint parameters params = { 'idStop': kwargs.get('stop_number'), 'Radius': kwargs.get('radius'), 'cultureInfo': util.language_code(kwargs.get('lang')) } # Request result = self.make_request('geo', 'get_stops_from_stop', **params) # Funny endpoint, no status code if not util.check_result(result, 'stops'): return False, 'UNKNOWN ERROR' # Parse values = util.response_list(result, 'stops') return True, [emtype.Stop(**a) for a in values]
def detail_parking(self, **kwargs): """Obtain detailed info of a given parking. Args: lang (str): Language code (*es* or *en*). day (int): Day of the month in format DD. The number is automatically padded if it only has one digit. month (int): Month number in format MM. The number is automatically padded if it only has one digit. year (int): Year number in format YYYY. hour (int): Hour of the day in format hh. The number is automatically padded if it only has one digit. minute (int): Minute of the hour in format mm. The number is automatically padded if it only has one digit. parking (int): ID of the parking to query. family (str): Family code of the parking (3 chars). Returns: Status boolean and parsed response (list[ParkingDetails]), or message string in case of error. """ # Endpoint parameters date = util.datetime_string( kwargs.get('day', 1), kwargs.get('month', 1), kwargs.get('year', 1970), kwargs.get('hour', 0), kwargs.get('minute', 0) ) params = { 'language': util.language_code(kwargs.get('lang')), 'publicData': True, 'date': date, 'id': kwargs.get('parking'), 'family': kwargs.get('family') } # Request result = self.make_request('detail_parking', {}, **params) if not util.check_result(result): return False, result.get('message', 'UNKNOWN ERROR') # Parse values = util.response_list(result, 'Data') return True, [emtype.ParkingDetails(**a) for a in values]
def detail_parking(self, **kwargs): """Obtain detailed info of a given parking. Args: lang (str): Language code (*es* or *en*). day (int): Day of the month in format DD. The number is automatically padded if it only has one digit. month (int): Month number in format MM. The number is automatically padded if it only has one digit. year (int): Year number in format YYYY. hour (int): Hour of the day in format hh. The number is automatically padded if it only has one digit. minute (int): Minute of the hour in format mm. The number is automatically padded if it only has one digit. parking (int): ID of the parking to query. family (str): Family code of the parking (3 chars). Returns: Status boolean and parsed response (list[ParkingDetails]), or message string in case of error. """ # Endpoint parameters date = util.datetime_string(kwargs.get('day', 1), kwargs.get('month', 1), kwargs.get('year', 1970), kwargs.get('hour', 0), kwargs.get('minute', 0)) params = { 'language': util.language_code(kwargs.get('lang')), 'publicData': True, 'date': date, 'id': kwargs.get('parking'), 'family': kwargs.get('family') } # Request result = self.make_request('detail_parking', {}, **params) if not util.check_result(result): return False, result.get('message', 'UNKNOWN ERROR') # Parse values = util.response_list(result, 'Data') return True, [emtype.ParkingDetails(**a) for a in values]
def get_poi_types(self, **kwargs): """Obtain POI types. Args: lang (str): Language code (*es* or *en*). Returns: Status boolean and parsed response (list[PoiType]), or message string in case of error. """ # Endpoint parameters params = {'cultureInfo': util.language_code(kwargs.get('lang'))} # Request result = self.make_request('geo', 'get_poi_types', **params) # Parse values = result.get('types', []) return True, [emtype.PoiType(**a) for a in values]
def get_poi_types(self, **kwargs): """Obtain POI types. Args: lang (str): Language code (*es* or *en*). Returns: Status boolean and parsed response (list[PoiType]), or message string in case of error. """ # Endpoint parameters params = { 'cultureInfo': util.language_code(kwargs.get('lang')) } # Request result = self.make_request('geo', 'get_poi_types', **params) # Parse values = result.get('types', []) return True, [emtype.PoiType(**a) for a in values]
def get_info_line(self, **kwargs): """Obtain basic information on a bus line on a given date. Args: day (int): Day of the month in format DD. The number is automatically padded if it only has one digit. month (int): Month number in format MM. The number is automatically padded if it only has one digit. year (int): Year number in format YYYY. lines (list[int] | int): Lines to query, may be empty to get all the lines. lang (str): Language code (*es* or *en*). Returns: Status boolean and parsed response (list[Line]), or message string in case of error. """ # Endpoint parameters select_date = '%02d/%02d/%d' % ( kwargs.get('day', '01'), kwargs.get('month', '01'), kwargs.get('year', '1970') ) params = { 'fecha': select_date, 'line': util.ints_to_string(kwargs.get('lines', [])), 'cultureInfo': util.language_code(kwargs.get('lang')) } # Request result = self.make_request('geo', 'get_info_line', **params) # Funny endpoint, no status code if not util.check_result(result, 'Line'): return False, 'UNKNOWN ERROR' # Parse values = util.response_list(result, 'Line') return True, [emtype.Line(**a) for a in values]
def icon_description(self, **kwargs): """Obtain a list of elements that have an associated icon. Args: lang (str): Language code (*es* or *en*). Returns: Status boolean and parsed response (list[IconDescription]), or message string in case of error. """ # Endpoint parameters params = {'language': util.language_code(kwargs.get('lang'))} # Request result = self.make_request('icon_description', {}, **params) if not util.check_result(result): return False, result.get('message', 'UNKNOWN ERROR') # Parse values = util.response_list(result, 'Data') return True, [emtype.IconDescription(**a) for a in values]
def icon_description(self, **kwargs): """Obtain a list of elements that have an associated icon. Args: lang (str): Language code (*es* or *en*). Returns: Status boolean and parsed response (list[IconDescription]), or message string in case of error. """ # Endpoint parameters params = {'language': util.language_code(kwargs.get('lang'))} # Request result = self.make_request('icon_description', {}, **params) if not util.check_result(result): return False, result.get('message', 'UNKNOWN ERROR') # Parse values = util.response_list(result, 'Data') return True, [emtype.IconDescription(**a) for a in values]
def list_types_poi(self, **kwargs): """Obtain a list of families, types and categories of POI. Args: lang (str): Language code (*es* or *en*). Returns: Status boolean and parsed response (list[ParkingPoiType]), or message string in case of error. """ # Endpoint parameters url_args = {'language': util.language_code(kwargs.get('lang'))} # Request result = self.make_request('list_poi_types', url_args) if not util.check_result(result): return False, result.get('message', 'UNKNOWN ERROR') # Parse values = util.response_list(result, 'Data') return True, [emtype.ParkingPoiType(**a) for a in values]
def get_groups(self, **kwargs): """Obtain line types and details. Args: lang(str): Language code (*es* or *en*). Returns: Status boolean and parsed response (list[BusGroupItem]), or message string in case of error. """ # Endpoint parameters params = {'cultureInfo': util.language_code(kwargs.get('lang'))} # Request result = self.make_request('bus', 'get_groups', **params) if not util.check_result(result): return False, result.get('resultDescription', 'UNKNOWN ERROR') # Parse values = util.response_list(result, 'resultValues') return True, [emtype.BusGroupItem(**a) for a in values]
def get_groups(self, **kwargs): """Obtain line types and details. Args: lang(str): Language code (*es* or *en*). Returns: Status boolean and parsed response (list[BusGroupItem]), or message string in case of error. """ # Endpoint parameters params = {'cultureInfo': util.language_code(kwargs.get('lang'))} # Request result = self.make_request('bus', 'get_groups', **params) if not util.check_result(result): return False, result.get('resultDescription', 'UNKNOWN ERROR') # Parse values = util.response_list(result, 'resultValues') return True, [emtype.BusGroupItem(**a) for a in values]
def list_types_poi(self, **kwargs): """Obtain a list of families, types and categories of POI. Args: lang (str): Language code (*es* or *en*). Returns: Status boolean and parsed response (list[ParkingPoiType]), or message string in case of error. """ # Endpoint parameters url_args = {'language': util.language_code(kwargs.get('lang'))} # Request result = self.make_request('list_poi_types', url_args) if not util.check_result(result): return False, result.get('message', 'UNKNOWN ERROR') # Parse values = util.response_list(result, 'Data') return True, [emtype.ParkingPoiType(**a) for a in values]
def get_info_line(self, **kwargs): """Obtain basic information on a bus line on a given date. Args: day (int): Day of the month in format DD. The number is automatically padded if it only has one digit. month (int): Month number in format MM. The number is automatically padded if it only has one digit. year (int): Year number in format YYYY. lines (list[int] | int): Lines to query, may be empty to get all the lines. lang (str): Language code (*es* or *en*). Returns: Status boolean and parsed response (list[Line]), or message string in case of error. """ # Endpoint parameters select_date = '%02d/%02d/%d' % (kwargs.get( 'day', '01'), kwargs.get('month', '01'), kwargs.get( 'year', '1970')) params = { 'fecha': select_date, 'line': util.ints_to_string(kwargs.get('lines', [])), 'cultureInfo': util.language_code(kwargs.get('lang')) } # Request result = self.make_request('geo', 'get_info_line', **params) # Funny endpoint, no status code if not util.check_result(result, 'Line'): return False, 'UNKNOWN ERROR' # Parse values = util.response_list(result, 'Line') return True, [emtype.Line(**a) for a in values]
def info_parking_poi(self, **kwargs): """Obtain generic information on POIs and parkings. This returns a list of elements in a given radius from the coordinates. Args: radius (int): Radius of the search (in meters). latitude (double): Latitude in decimal degrees. longitude (double): Longitude in decimal degrees. lang (str): Language code (*es* or *en*). day (int): Day of the month in format DD. The number is automatically padded if it only has one digit. month (int): Month number in format MM. The number is automatically padded if it only has one digit. year (int): Year number in format YYYY. hour (int): Hour of the day in format hh. The number is automatically padded if it only has one digit. minute (int): Minute of the hour in format mm. The number is automatically padded if it only has one digit. poi_info (list[tuple]): List of tuples with the format ``(list[family], type, category)`` to query. Check the API documentation. min_free (list[int]): Number of free spaces to check. Must have the same length of ``poi_info``. field_codes (list[tuple]): List of tuples with the format ``(list[codes], name)``. Check the API documentation. Returns: Status boolean and parsed response (list[InfoParkingPoi]), or message string in case of error. """ # Endpoint parameters date = util.datetime_string(kwargs.get('day', 1), kwargs.get('month', 1), kwargs.get('year', 1970), kwargs.get('hour', 0), kwargs.get('minute', 0)) family_categories = [] for element in kwargs.get('poi_info', []): family_categories.append({ 'poiCategory': { 'lstCategoryTypes': element[0] }, 'poiFamily': element[1], 'poiType': element[2] }) field_codes = [] for element in kwargs.get('field_codes', []): field_codes.append({ 'codes': { 'lstCodes': element[0] }, 'nameField': element[1] }) params = { 'TFamilyTTypeTCategory': { 'lstFamilyTypeCategory': family_categories }, 'coordinate': { 'latitude': str(kwargs.get('latitude', '0.0')), 'longitude': str(kwargs.get('longitude', '0.0')) }, 'dateTimeUse': date, 'language': util.language_code(kwargs.get('lang')), 'minimumPlacesAvailable': { 'lstminimumPlacesAvailable': kwargs.get('min_free', []) }, 'nameFieldCodes': { 'lstNameFieldCodes': field_codes }, 'radius': str(kwargs.get('radius', '0')) } # Request result = self.make_request('info_parking_poi', {}, **params) if not util.check_result(result): return False, result.get('message', 'UNKNOWN ERROR') # Parse values = util.response_list(result, 'Data') return True, [emtype.InfoParkingPoi(**a) for a in values]
def info_parking_poi(self, **kwargs): """Obtain generic information on POIs and parkings. This returns a list of elements in a given radius from the coordinates. Args: radius (int): Radius of the search (in meters). latitude (double): Latitude in decimal degrees. longitude (double): Longitude in decimal degrees. lang (str): Language code (*es* or *en*). day (int): Day of the month in format DD. The number is automatically padded if it only has one digit. month (int): Month number in format MM. The number is automatically padded if it only has one digit. year (int): Year number in format YYYY. hour (int): Hour of the day in format hh. The number is automatically padded if it only has one digit. minute (int): Minute of the hour in format mm. The number is automatically padded if it only has one digit. poi_info (list[tuple]): List of tuples with the format ``(list[family], type, category)`` to query. Check the API documentation. min_free (list[int]): Number of free spaces to check. Must have the same length of ``poi_info``. field_codes (list[tuple]): List of tuples with the format ``(list[codes], name)``. Check the API documentation. Returns: Status boolean and parsed response (list[InfoParkingPoi]), or message string in case of error. """ # Endpoint parameters date = util.datetime_string( kwargs.get('day', 1), kwargs.get('month', 1), kwargs.get('year', 1970), kwargs.get('hour', 0), kwargs.get('minute', 0) ) family_categories = [] for element in kwargs.get('poi_info', []): family_categories.append({ 'poiCategory': { 'lstCategoryTypes': element[0] }, 'poiFamily': element[1], 'poiType': element[2] }) field_codes = [] for element in kwargs.get('field_codes', []): field_codes.append({ 'codes': { 'lstCodes': element[0] }, 'nameField': element[1] }) params = { 'TFamilyTTypeTCategory': { 'lstFamilyTypeCategory': family_categories }, 'coordinate': { 'latitude': str(kwargs.get('latitude', '0.0')), 'longitude': str(kwargs.get('longitude', '0.0')) }, 'dateTimeUse': date, 'language': util.language_code(kwargs.get('lang')), 'minimumPlacesAvailable': { 'lstminimumPlacesAvailable': kwargs.get('min_free', []) }, 'nameFieldCodes': { 'lstNameFieldCodes': field_codes }, 'radius': str(kwargs.get('radius', '0')) } # Request result = self.make_request('info_parking_poi', {}, **params) if not util.check_result(result): return False, result.get('message', 'UNKNOWN ERROR') # Parse values = util.response_list(result, 'Data') return True, [emtype.InfoParkingPoi(**a) for a in values]