def convert_contacts_to_workplace_search_documents()

in ees_microsoft_outlook/microsoft_outlook_contacts.py [0:0]


    def convert_contacts_to_workplace_search_documents(self, contact_obj):
        """Method is used to convert contact data into Workplace Search document
        :param contact_obj: Object of contact
        Returns:
            contact_document: Dictionary of contact
        """

        # Logic for contact email address
        contact_emails = ""
        if contact_obj.email_addresses:
            contact_emails_list = []
            for email in contact_obj.email_addresses:
                contact_emails_list.append(email.email)
            contact_emails = ", ".join(contact_emails_list)

        # Logic for contact phone number
        contact_numbers = ""
        if contact_obj.phone_numbers:
            contact_numbers_list = []
            for number in contact_obj.phone_numbers:
                contact_numbers_list.append(number.phone_number)
            contact_numbers = ", ".join(contact_numbers_list)

        # Logic for contact last modified time
        contact_created = ""
        if contact_obj.last_modified_time:
            contact_created = change_datetime_format(
                contact_obj.last_modified_time, self.time_zone
            )

        # Logic to remove year from birthdate if birth year is kept empty by the user
        if contact_obj.birthday:
            if DEFAULT_BIRTH_YEAR == contact_obj.birthday.year:
                contact_obj.birthday = contact_obj.birthday.strftime("%m-%d")

        # Logic to create document body
        contact_document = {
            "Id": contact_obj.id,
            "DisplayName": contact_obj.display_name,
            "Description": f"""Email Addresses: {contact_emails}