MCPcopy Index your code
hub / github.com/O365/python-o365 / __init__

Method __init__

O365/address_book.py:30–112  ·  view source on GitHub ↗

Create a contact API component :param parent: parent account for this folder :type parent: Account :param Connection con: connection to use if no parent specified :param Protocol protocol: protocol to use if no parent specified (kwargs) :param str m

(self, *, parent=None, con=None, **kwargs)

Source from the content-addressed store, hash-verified

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'), '')
75 self.__job_title = cloud_data.get(cc('jobTitle'), '')
76 self.__company_name = cloud_data.get(cc('companyName'), '')
77 self.__department = cloud_data.get(cc('department'), '')
78 self.__office_location = cloud_data.get(cc('officeLocation'), '')
79 self.__business_phones = cloud_data.get(cc('businessPhones'), []) or []
80 self.__mobile_phone = cloud_data.get(cc('mobilePhone'), '')
81 self.__home_phones = cloud_data.get(cc('homePhones'), []) or []
82
83 emails = cloud_data.get(cc('emailAddresses'), [])
84 self.__emails = Recipients(
85 recipients=[(rcp.get(cc('name'), ''), rcp.get(cc('address'), ''))
86 for rcp in emails],
87 parent=self, field=cc('emailAddresses'))

Callers 2

__init__Method · 0.45
__init__Method · 0.45

Calls 4

TrackerSetClass · 0.85
RecipientsClass · 0.85
getMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected