Created
September 1, 2021 19:30
-
-
Save kale-bogdanovs/73d4abe48bf7fc3896b4e56980a3f345 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const createRecord = (worker) => { | |
row = {} | |
//Map contact data - semistructured | |
const contact_data = worker.Worker_Data.Personal_Data.Contact_Data | |
contact_data.Address_Data.forEach(ad => { | |
const street_address_line_1 = ad.Address_Line_Data[0] | |
const street_address_line_2 = ad.Address_Line_Data[1] | |
const city = ad.Municipality | |
const state = ad["Country_Region_Reference_ISO_3166-2_Code"] | |
const zip = ad.Postal_Code | |
ad.Usage_Data.forEach(ud => { | |
ud.Type_Data.forEach(td => { | |
if (td.Type_Reference_Communication_Usage_Type_ID === "HOME") { | |
row.home_address_street_address_line_1 = street_address_line_1 | |
row.home_address_street_address_line_2 = street_address_line_2 | |
row.home_address_city = city | |
row.home_address_state = state | |
row.home_address_zip = zip | |
row.home_address_last_modified = last_modified | |
} | |
if (td.Type_Reference_Communication_Usage_Type_ID === "WORK") { | |
row.work_address_street_address_line_1 = street_address_line_1 | |
row.work_address_street_address_line_2 = street_address_line_2 | |
row.work_address_city = city | |
row.work_address_state = state | |
row.work_address_zip = zip | |
row.work_address_last_modified = last_modified | |
} | |
}) | |
}) | |
}) | |
return row | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment