Contact manages lists of events on associated contact on office365.
| 15 | |
| 16 | |
| 17 | class Contact(ApiComponent, AttachableMixin): |
| 18 | """ Contact manages lists of events on associated contact on office365. """ |
| 19 | |
| 20 | _endpoints = { |
| 21 | 'contact': '/contacts', |
| 22 | 'root_contact': '/contacts/{id}', |
| 23 | 'child_contact': '/contactFolders/{folder_id}/contacts', |
| 24 | 'photo': '/contacts/{id}/photo/$value', |
| 25 | 'photo_size': '/contacts/{id}/photos/{size}/$value', |
| 26 | } |
| 27 | |
| 28 | message_constructor = Message |
| 29 | |
| 30 | def __init__(self, *, parent=None, con=None, **kwargs): |
| 31 | """ Create a contact API component |
| 32 | |
| 33 | :param parent: parent account for this folder |
| 34 | :type parent: Account |
| 35 | :param Connection con: connection to use if no parent specified |
| 36 | :param Protocol protocol: protocol to use if no parent specified |
| 37 | (kwargs) |
| 38 | :param str main_resource: use this resource instead of parent resource |
| 39 | (kwargs) |
| 40 | """ |
| 41 | if parent and con: |
| 42 | raise ValueError('Need a parent or a connection but not both') |
| 43 | self.con = parent.con if parent else con |
| 44 | |
| 45 | # Choose the main_resource passed in kwargs over parent main_resource |
| 46 | main_resource = kwargs.pop('main_resource', None) or ( |
| 47 | getattr(parent, 'main_resource', None) if parent else None) |
| 48 | |
| 49 | super().__init__( |
| 50 | protocol=parent.protocol if parent else kwargs.get('protocol'), |
| 51 | main_resource=main_resource) |
| 52 | |
| 53 | cloud_data = kwargs.get(self._cloud_data_key, {}) |
| 54 | cc = self._cc # alias to shorten the code |
| 55 | |
| 56 | # internal to know which properties need to be updated on the server |
| 57 | self._track_changes = TrackerSet(casing=cc) |
| 58 | |
| 59 | self.object_id = cloud_data.get(cc('id'), None) |
| 60 | self.__created = cloud_data.get(cc('createdDateTime'), None) |
| 61 | self.__modified = cloud_data.get(cc('lastModifiedDateTime'), None) |
| 62 | |
| 63 | local_tz = self.protocol.timezone |
| 64 | self.__created = parse(self.__created).astimezone( |
| 65 | local_tz) if self.__created else None |
| 66 | self.__modified = parse(self.__modified).astimezone( |
| 67 | local_tz) if self.__modified else None |
| 68 | |
| 69 | self.__display_name = cloud_data.get(cc('displayName'), '') |
| 70 | self.__fileAs = cloud_data.get(cc('fileAs'), '') |
| 71 | self.__name = cloud_data.get(cc('givenName'), '') |
| 72 | self.__surname = cloud_data.get(cc('surname'), '') |
| 73 | |
| 74 | self.__title = cloud_data.get(cc('title'), '') |
no outgoing calls
no test coverage detected