diff --git a/lib_afc_mosiac/universe_map_file.py b/lib_afc_mosiac/universe_map_file.py index 5ef1aff..932d34d 100644 --- a/lib_afc_mosiac/universe_map_file.py +++ b/lib_afc_mosiac/universe_map_file.py @@ -31,6 +31,7 @@ class AFCMUniverseMapFile: self.mosaic_head = {} self.metadata = {} self.mosaic_file_list = {} + self.voterset_key = None self.files = [] @@ -105,7 +106,7 @@ class AFCMUniverseMapFile: return data - def read_mosaic_map_dict( self, map_dict : dict ): + def read_mosaic_map_dict( self, voterset_key : str, map_dict : dict ): """ read_mosaic_map_dict """ @@ -116,6 +117,7 @@ class AFCMUniverseMapFile: self.mosaic_head = map_dict.get('mosaic', {}) self.metadata = map_dict.get('metadata', {}) self.mosaic_file_list = map_dict.get('files', {}) + self.voterset_key = voterset_key return None @@ -314,7 +316,7 @@ class AFCMUniverseMapFile: mapping[amplify_key]) if new_row['UID'] is None or new_row['UID'] == 'n/a': - new_row['UID'] = uuid.uuid4() + new_row['UID'] = str(uuid.uuid4()) new_row['Cell_Phone'] = formatted_number @@ -400,3 +402,32 @@ class AFCMUniverseMapFile: self.voterset_s3_connection.put_object(bucket=self.voterset_s3_bucket, key=s3_key, data=json_data) + + + def get_voter_object(self) -> dict: + """ + get_voter_object Get the voter to the API object + + :return Dictionary object of the AF-VOTER + """ + + # Check if there is data + if len(self.final_rows) < 1: + return None + + # Build the AF Voter object + voter_row = self.final_rows[0] + + filter_set = {'UID', 'FName', 'LName', 'Cell_Phone'} + data_fields_dict = {k:voter_row[k] for k in voter_row if k not in filter_set} + + voter_dict = { + "voter_id": voter_row['UID'], + "first_name": voter_row['FName'], + "last_name": voter_row['LName'], + "voterset_keys": [self.voterset_key], + "data_fields": data_fields_dict, + "cell_phone": voter_row['Cell_Phone'] + } + + return voter_dict diff --git a/setup.py b/setup.py index ad0313b..3f757c5 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ with open('README.md', 'r') as f: setup( name='lib_afc_mosiac', - version='0.1.3', + version='0.1.4', author='', author_email='', description='',