diff --git a/core/models/Location.py b/core/models/Location.py index 87a2f91..3b3c06d 100644 --- a/core/models/Location.py +++ b/core/models/Location.py @@ -12,6 +12,7 @@ _table_definition: str = """ 'code' varchar, 'name' varchar, 'time_zone' varchar, + 'provider_name' varchar, UNIQUE(code, country_code) """ @@ -33,6 +34,10 @@ class Location(Model): metadata=config(exclude=Exclude.ALWAYS) ) time_zone: Optional[str] = None + provider_name: Optional[str] = field( + default=None, + metadata=config(exclude=Exclude.ALWAYS) + ) available: Optional[bool] = field( default=False, metadata=config(exclude=Exclude.ALWAYS) @@ -71,7 +76,7 @@ class Location(Model): @staticmethod def save_many(locations): Model._create_table_if_not_exists(table_name=_table_name, table_definition=_table_definition) - Model._insert_many('INSERT INTO locations VALUES(?, ?, ?, ?, ?, ?)', Location.tuple_factory, locations) + Model._insert_many('INSERT INTO locations VALUES(?, ?, ?, ?, ?, ?, ?)', Location.tuple_factory, locations) @staticmethod def factory(cursor, row): @@ -80,4 +85,4 @@ class Location(Model): @staticmethod def tuple_factory(location): - return location.id, location.country_code, location.country_name, location.code, location.name, location.time_zone + return location.id, location.country_code, location.country_name, location.code, location.name, location.time_zone, location.provider_name diff --git a/core/services/WebServiceApiService.py b/core/services/WebServiceApiService.py index a0903c4..c86ed59 100644 --- a/core/services/WebServiceApiService.py +++ b/core/services/WebServiceApiService.py @@ -59,7 +59,7 @@ class WebServiceApiService: if response.status_code == requests.codes.ok: for location in response.json()['data']: - locations.append(Location(location['country']['code'], location['code'], location['id'], location['country']['name'], location['name'], location['time_zone']['code'])) + locations.append(Location(location['country']['code'], location['code'], location['id'], location['country']['name'], location['name'], location['time_zone']['code'], location['provider']['name'])) return locations