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
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'
def get_custom_field_definitions(cls): return CRMConnector.get_custom_field_definitions('parties')
def all(cls): return CRMConnector.get_all_parties()
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()})
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'])
def create(self): return CRMConnector.add_party({'party': self.as_dict()})
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()})