示例#1
0
 def get(self):
     remote_party = CRMConnector.search_party_by_email(
         self.emailAddresses[0]['address'])
     if remote_party:
         self.__capsule_party = remote_party
     else:
         self.__capsule_party = None
     return remote_party
示例#2
0
 def find_and_delete(self):
     from .exceptions import CRMdeletePartyException
     self.get()
     try:
         if self.__capsule_party:
             return CRMConnector.delete_party(self.__capsule_party['id'])
     except:
         raise CRMdeletePartyException
     # @TODO : write error/exception
     return 'error'
示例#3
0
 def get_custom_field_definitions(cls):
     return CRMConnector.get_custom_field_definitions('parties')
示例#4
0
 def all(cls):
     return CRMConnector.get_all_parties()
示例#5
0
 def safe_update(self):
     self.emailAddresses[0]['address'] in self.__capsule_party[
         'emailAddresses'] and self.emailAddresses.pop(0)
     self.__exclude_custom_fields()
     return CRMConnector.update_party(self.__capsule_party['id'],
                                      {'party': self.as_dict()})
示例#6
0
 def delete(self):
     if not self.__capsule_party:
         # @TODO : write error/exception
         return 'No remote id set'
     return CRMConnector.delete_party(self.__capsule_party['id'])
示例#7
0
 def create(self):
     return CRMConnector.add_party({'party': self.as_dict()})
示例#8
0
 def update(self):
     self.__capsule_party and self.get()
     # print json.dumps(self.as_dict(), indent=1)
     return CRMConnector.update_party(self.__capsule_party['id'],
                                      {'party': self.as_dict()})