def update_employee(self, id, employee): """ API method for updating an existing employee from a dictionary. http://www.bamboohr.com/api/documentation/employees.php#updateEmployee @param id: String of containing the employee id you want to update. @param employee: Dictionary containing employee information. @return: Boolean of request success (Status Code == 200). """ employee = utils.camelcase_keys(employee) xml = self._format_employee_xml(employee) url = self.base_url + 'employees/{0}'.format(id) r = requests.post(url, data=xml, headers=self.headers, auth=(self.api_key, 'x')) r.raise_for_status() return True
def add_row(self, table_name, employee_id, row): """ API method for adding a row to a table http://www.bamboohr.com/api/documentation/tables.php @param table_name: string of table's name @param employee_id: string of employee id @param row: dictionary containing row information """ row = utils.camelcase_keys(row) xml = self._format_row_xml(row) url = self.base_url + \ "employees/{0}/tables/{1}/".format(employee_id, table_name) r = requests.post(url, data=xml, headers=self.headers, auth=(self.api_key, 'x')) r.raise_for_status() return True
def add_employee(self, employee): """ API method for creating a new employee from a dictionary. http://www.bamboohr.com/api/documentation/employees.php#addEmployee @param employee: Dictionary containing employee information. @return: Dictionary contianing new employee URL and ID. """ employee = utils.camelcase_keys(employee) if not employee.get('firstName') or not employee.get('lastName'): raise UserWarning("The 'firstName' and 'lastName' keys are required.") xml = self._format_employee_xml(employee) url = self.base_url + 'employees/' r = requests.post(url, data=xml, headers=self.headers, auth=(self.api_key, 'x')) r.raise_for_status() return {'url': r.headers['location'], 'id': r.headers['location'].replace(url, "")}