@@ -70,12 +70,36 @@ def delete_contact(self, contact_id=None):
70
70
url = base_url + f"/contacts/{ contact_id } "
71
71
request = r .delete (url , headers = headers )
72
72
response = request .json ()
73
- if content ['meta' ]['httpStatus' ] == '200 - OK' :
73
+ if response ['meta' ]['httpStatus' ] == '200 - OK' :
74
74
print (f'Your XM Contact"{ contact_id } " has been deleted from the XM Directory.' )
75
75
except ContactIDError :
76
76
'Hey there! It looks like the Contact ID that was entered is incorrect. It should begin with "CID_". Please try again.'
77
77
return
78
78
79
+ def update_contact (self , contact_id = None , ** kwargs ):
80
+ '''This method will update a contact from your XMDirectory.
81
+
82
+ :param contact_id: The unique id associated with each contact in the XM Directory.
83
+ :type contact_id: str
84
+ :return: Nothing, but prints if successful, and if there was an error.
85
+ '''
86
+ assert len (contact_id ) == 19 , 'Hey, the parameter for "contact_id" that was passed is the wrong length. It should have 19 characters.'
87
+ assert contact_id [:4 ] == 'CID_' , 'Hey there! It looks like the Contact ID that was entered is incorrect. It should begin with "CID_". Please try again.'
88
+
89
+ try :
90
+ headers , base_url = self .header_setup ()
91
+ url = base_url + f"/contacts/{ contact_id } "
92
+ contact_data = {}
93
+ for key , value in kwargs .items ():
94
+ contact_data .update ({key : str (value )})
95
+ request = r .put (url , json = contact_data , headers = headers )
96
+ response = request .json ()
97
+ if response ['meta' ]['httpStatus' ] == '200 - OK' :
98
+ print (f'Your XM Contact"{ contact_id } " has been updated in your XM Directory.' )
99
+ except ContactIDError :
100
+ 'Hey there! It looks like the Contact ID that was entered is incorrect. It should begin with "CID_". Please try again.'
101
+ return
102
+
79
103
def list_contacts_in_directory (self , page_size = 100 , offset = 0 , to_df = True ):
80
104
'''This method will list the top-level information about the contacts in your XM Directory. Depending
81
105
on the argument that you pass to the parameter 'to_df', the method will either return a Pandas DataFrame
0 commit comments