def get_status_by_country_name(self, country_name) -> dict: """Method fetches and returns specific country information related to coronavirus Args: country (str): Country name e.g. "sweden" Returns: dict: Country related information regarding Coronavirus example: { 'country': 'Sweden', 'confirmed': 355, 'active': 334, 'deaths': 0, 'recovered': 1, 'latitude': 63.0, 'longitude': 16.0, 'last_update': 1583893094000 } """ country = filter( lambda country: country["name"].lower() == country_name.lower(), self.list_countries(), ) try: country = next(country) except StopIteration: raise ValueError( f"There is no country called '{country_name}', to check available country names use `list_countries()`" ) case = self.__get_total_cases_by_country_id(country["id"]) return CovidModel(**case).dict()
def get_status_by_country_id(self, country_id) -> dict: """Method fetches and returns specific country information related to coronavirus Args: country (str): Country name e.g. "sweden" Returns: dict: Country related information regarding Coronavirus example: { 'country': 'Sweden', 'confirmed': 355, 'active': 334, 'deaths': 0, 'recovered': 1, 'latitude': 63.0, 'longitude': 16.0, 'last_update': 1583893094000 } """ case = self.__get_total_cases_by_country_id(country_id) return CovidModel(**case).dict()
def get_data(self) -> list: """Method fetches all data related to Covid """ cases = self.__get_all_cases() return [CovidModel(**case["attributes"]).dict() for case in cases]