(20260404) Team fixing on TCAOFF completed.
This commit is contained in:
+76
-1
@@ -531,7 +531,7 @@ class AsyncTheCAOffice:
|
||||
role: str,
|
||||
username: str,
|
||||
password: str,
|
||||
applicant_notes: dict | list | str = None,
|
||||
applicant_notes: dict | list = None,
|
||||
raise_exception: bool = False,
|
||||
) -> bool:
|
||||
|
||||
@@ -604,6 +604,81 @@ class AsyncTheCAOffice:
|
||||
# Done here:
|
||||
return success
|
||||
|
||||
async def team_update(
|
||||
self,
|
||||
user_id: int,
|
||||
dept_id: int,
|
||||
team_name: str,
|
||||
email: str,
|
||||
phone_no: str,
|
||||
role: str,
|
||||
applicant_notes: dict | list | str = None,
|
||||
raise_exception: bool = False,
|
||||
) -> bool:
|
||||
|
||||
"""
|
||||
Update an existing team member.
|
||||
:param user_id: The id of the team member.
|
||||
:param dept_id: The id of the department that this team member is working in.
|
||||
:param team_name: The name of the team member. This is the full display name. Can be the same as others.
|
||||
:param email: The email id of the team member.
|
||||
:param phone_no: The phone no. of the team member.
|
||||
:param role: The role of the team member in the organization.
|
||||
:param applicant_notes: Optional notes about the team member.
|
||||
:param raise_exception: Whether to raise any exceptions, or to suppress them.
|
||||
:return: True if successful, else False.
|
||||
"""
|
||||
|
||||
# Start by assuming failure:
|
||||
success = False
|
||||
|
||||
try:
|
||||
|
||||
# Make the API call:
|
||||
response = await self._http_client.post(
|
||||
url = self.TEAM_UPDATE_URL,
|
||||
headers = {"X-Session-Token": self.__session_token},
|
||||
json = {
|
||||
"idUser": user_id,
|
||||
"idDepartment": dept_id,
|
||||
"name": team_name,
|
||||
"email": email,
|
||||
"phoneNo": phone_no,
|
||||
"role": role,
|
||||
"hierarchy": 1,
|
||||
"applicantNotes": applicant_notes
|
||||
}
|
||||
)
|
||||
|
||||
# If the call succeeded:
|
||||
if response.status_code in [200]:
|
||||
self._printer(
|
||||
"Team updated.",
|
||||
user_id,
|
||||
team_name,
|
||||
)
|
||||
success = True
|
||||
|
||||
# If the call failed:
|
||||
else:
|
||||
response_json = response.json()
|
||||
self._err_printer(
|
||||
"Team NOT updated.",
|
||||
user_id,
|
||||
team_name,
|
||||
response_json
|
||||
)
|
||||
success = False
|
||||
|
||||
# If something goes wrong:
|
||||
except Exception as exception:
|
||||
self._err_printer("Team NOT updated.", exception)
|
||||
if raise_exception: raise
|
||||
success = False
|
||||
|
||||
# Done here:
|
||||
return success
|
||||
|
||||
# ┏┓ ┓
|
||||
# ┣┫╋╋┏┓┏┓┏┫┏┓┏┓┏┏┓
|
||||
# ┛┗┗┗┗ ┛┗┗┻┗┻┛┗┗┗
|
||||
|
||||
Reference in New Issue
Block a user