Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed put.group_hunt_group method #80

Merged
merged 4 commits into from
Aug 12, 2024
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions odins_spear/methods/put.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ def user_do_not_disturb(self, user_id: str, dnd_active: bool = False, ring_splas
#HOTELING HOST
#HUNT GROUPS

def group_hunt_groups_status(self, hunt_group_user_ids: list, status: bool =True):
def group_hunt_groups_status(self, service_user_ids: list, status: bool =True):
"""Updates a list of Hunt Groups (HG) status to either active or inactive.

Args:
Expand All @@ -889,18 +889,18 @@ def group_hunt_groups_status(self, hunt_group_user_ids: list, status: bool =True
endpoint = f"/groups/hunt-groups/status"

data = {
"instances": [{'serviceUserId': hunt_group_user_id, 'isActive': status}
for hunt_group_user_id in hunt_group_user_ids]
"instances": [{'serviceUserId': service_user_id, 'isActive': status}
for service_user_id in service_user_ids]
}

return self.requester.put(endpoint, data=data)


def group_hunt_group(self, service_provider_id: str, group_id: str, hunt_group_user_id: str, updates: dict):
"""Update a Hunt Groups (HG) settings.
def group_hunt_group(self, service_provider_id: str, group_id: str, service_user_id: str, updates: dict):
"""Update a Hunt Group's (HG) settings.

Args:
hunt_group_user_id (str): Service provider ID of where the group that hosts the HG is located.
service_provider_id (str): Service provider ID of where the group that hosts the HG is located.
group_id (str): Group ID of where the HG is located.
service_user_id (str): Target service user ID of the HG.
updates (dict): Updates to be applied to HG.
Expand All @@ -913,19 +913,21 @@ def group_hunt_group(self, service_provider_id: str, group_id: str, hunt_group_u

updates["serviceProviderId"] = service_provider_id
updates["groupId"] = group_id
updates["serviceUserId"] = hunt_group_user_id
updates["serviceUserId"] = service_user_id
if updates.get("serviceInstanceProfile") is None:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you can remove the 'is None' and add 'not'.

Explanation: In Python the If statement can be shortened to look at Boolean states, which it classes None as False. Therefore you can write and if statement like 'if not updates.get("serviceInstanceProfile"):' and this will trigger when that get method evaluates to a Boolean false.

updates["serviceInstanceProfile"] = {}

return self.requester.put(endpoint, data=updates)


def group_hunt_group_weighted_call_distribution(self, service_provider_id: str, group_id, hunt_group_user_id: str,
def group_hunt_group_weighted_call_distribution(self, service_provider_id: str, group_id, service_user_id: str,
agents: list):
"""Update the Weighted Call Distribution (WCD) between users in a Hunt Group (HG).

Args:
service_provider_id (str): Service provider ID where the group is located.
group_id (_type_): Group ID where the HG is located.
hunt_group_user_id (str): Service user ID of the target HG.
service_user_id (str): Service user ID of the target HG.
agents (list): Updates of WCD to be applied to HG.

Raises:
Expand All @@ -940,7 +942,7 @@ def group_hunt_group_weighted_call_distribution(self, service_provider_id: str,
data = {
"serviceProviderId": service_provider_id,
"groupId": group_id,
"serviceUserId": hunt_group_user_id,
"serviceUserId": service_user_id,
"agents": agents
}

Expand Down