|
- """
- This file contains all the coerce methods applied to parameters for mapping.
- """
-
- def coerce_fn_to_microsip_firstname(value):
- value = value.split(" ", 1)[0]
- return value
-
- def coerce_fn_to_microsip_lastname(value):
- value = value.split(" ", 1)[1]
- return value
-
- def coerce_adr_to_microsip_address(value):
- if value['indirizzoEsteso']:
- value = value['indirizzoEsteso']
- else:
- value = value['indirizzo']
- return value
-
- def coerce_adr_to_microsip_city(value):
- if value['cittaRegioneCAP']:
- value = value['cittaRegioneCAP'].split(", ")[0]
- else:
- value = ""
- return value
-
- def coerce_adr_to_microsip_state(value):
- if value['stato']:
- value = value['stato']
- else:
- value = ""
- return value
-
- def coerce_adr_to_microsip_zip(value):
- if value['cittaRegioneCAP']:
- value = value['cittaRegioneCAP'].split(" ")[-1]
- else:
- value = ""
- return value
-
- def clean_phone_number_from_symbols(value):
- phoneNumber = ""
- for char in value:
- if char.isdigit():
- phoneNumber += char
- return phoneNumber
-
- def coerce_tel_homeVoice_to_phone_microsip(value):
- try:
- phone = value['homeVoice']
- except:
- phone = ""
- return clean_phone_number_from_symbols(phone)
-
- def coerce_tel_personalMobile_to_mobile_microsip(value):
- try:
- mobile = value['personalMobile']
- except:
- mobile = ""
- return clean_phone_number_from_symbols(mobile)
-
- def coerce_tel_workVoice_to_phone_microsip(value):
- try:
- phone = value['workVoice']
- except:
- phone = ""
- return clean_phone_number_from_symbols(phone)
-
- def coerce_tel_workMobile_to_mobile_microsip(value):
- try:
- mobile = value['workMobile']
- except:
- mobile = ""
- return clean_phone_number_from_symbols(mobile)
-
- def coerce_tel_to_phone_microsip(value):
- """
- This method tries to assign the workVoice number as 'phone' for microsip.
- If not phone number found in 'workVoice' then the 'homeVoice' will be taken.
- """
- phone = coerce_tel_workVoice_to_phone_microsip(value)
- if not phone:
- phone = coerce_tel_homeVoice_to_phone_microsip(value)
- return phone
-
- def coerce_tel_to_mobile_microsip(value):
- """
- This method tries to assign the workMobile number as 'mobile' for microsip.
- If not phone number found in 'workMobile' then the 'homeMobile' will be taken.
- """
- phone = coerce_tel_workMobile_to_mobile_microsip(value)
- if not phone:
- phone = coerce_tel_personalMobile_to_mobile_microsip(value)
- return phone
|