You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

94 rivejä
2.6 KiB

  1. """
  2. This file contains all the coerce methods applied to parameters for mapping.
  3. """
  4. def coerce_fn_to_microsip_firstname(value):
  5. value = value.split(" ", 1)[0]
  6. return value
  7. def coerce_fn_to_microsip_lastname(value):
  8. value = value.split(" ", 1)[1]
  9. return value
  10. def coerce_adr_to_microsip_address(value):
  11. if value['indirizzoEsteso']:
  12. value = value['indirizzoEsteso']
  13. else:
  14. value = value['indirizzo']
  15. return value
  16. def coerce_adr_to_microsip_city(value):
  17. if value['cittaRegioneCAP']:
  18. value = value['cittaRegioneCAP'].split(", ")[0]
  19. else:
  20. value = ""
  21. return value
  22. def coerce_adr_to_microsip_state(value):
  23. if value['stato']:
  24. value = value['stato']
  25. else:
  26. value = ""
  27. return value
  28. def coerce_adr_to_microsip_zip(value):
  29. if value['cittaRegioneCAP']:
  30. value = value['cittaRegioneCAP'].split(" ")[-1]
  31. else:
  32. value = ""
  33. return value
  34. def clean_phone_number_from_symbols(value):
  35. phoneNumber = ""
  36. for char in value:
  37. if char.isdigit():
  38. phoneNumber += char
  39. return phoneNumber
  40. def coerce_tel_homeVoice_to_phone_microsip(value):
  41. try:
  42. phone = value['homeVoice']
  43. except:
  44. phone = ""
  45. return clean_phone_number_from_symbols(phone)
  46. def coerce_tel_personalMobile_to_mobile_microsip(value):
  47. try:
  48. mobile = value['personalMobile']
  49. except:
  50. mobile = ""
  51. return clean_phone_number_from_symbols(mobile)
  52. def coerce_tel_workVoice_to_phone_microsip(value):
  53. try:
  54. phone = value['workVoice']
  55. except:
  56. phone = ""
  57. return clean_phone_number_from_symbols(phone)
  58. def coerce_tel_workMobile_to_mobile_microsip(value):
  59. try:
  60. mobile = value['workMobile']
  61. except:
  62. mobile = ""
  63. return clean_phone_number_from_symbols(mobile)
  64. def coerce_tel_to_phone_microsip(value):
  65. """
  66. This method tries to assign the workVoice number as 'phone' for microsip.
  67. If not phone number found in 'workVoice' then the 'homeVoice' will be taken.
  68. """
  69. phone = coerce_tel_workVoice_to_phone_microsip(value)
  70. if not phone:
  71. phone = coerce_tel_homeVoice_to_phone_microsip(value)
  72. return phone
  73. def coerce_tel_to_mobile_microsip(value):
  74. """
  75. This method tries to assign the workMobile number as 'mobile' for microsip.
  76. If not phone number found in 'workMobile' then the 'homeMobile' will be taken.
  77. """
  78. phone = coerce_tel_workMobile_to_mobile_microsip(value)
  79. if not phone:
  80. phone = coerce_tel_personalMobile_to_mobile_microsip(value)
  81. return phone