def create_absence(self, absence: Absence) -> Absence: """ Creates an absence record on the Personio servers :param absence: The absence object to be created :raises PersonioError: If the absence could not be created on the Personio servers """ data = absence.to_body_params() response = self.request_json('company/time-offs', method='POST', data=data) if response['success']: absence.id_ = response['data']['attributes']['id'] return absence raise PersonioError("Could not create absence")
def create_absence(self, absence: Absence) -> bool: """ Creates an absence record on the Personio servers :param absence: The absence object to be created """ data = absence.to_body_params() response = self.request_json('company/time-offs', method='POST', data=data) if response['success']: absence.id_ = response['data']['attributes']['id'] return True return False