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

127 auto attendant functionality #128

Merged
merged 10 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
40 changes: 40 additions & 0 deletions odins_spear/methods/delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,46 @@ def __init__(self, requester):
#ATTENDANT CONSOLE
#AUTHENTICATION
#AUTO ATTENDANTS

def auto_attendant(self, service_user_id: str):
"""Removes an Auto Attendant (AA) from a group.

Args:
service_user_id(str): The service user ID of the AA.

Returns:
Dict: Returns the profile of the deleted AA.
"""

endpoint = "/groups/auto-attendants"

params = {
"serviceUserId": service_user_id
}

return self.requester.delete(endpoint, params=params)


def auto_attendant_submenu(self, service_user_id: str, submenu_id: str):
"""Removes an Auto Attendant (AA) Submenu from the AA configuration. Submenus are only a feature of the 'Auto Attendant - Standard' service. These are not available on Basic AAs.

Args:
service_user_id(str): The service user ID of the AA.
submenu_id (str): The ID of the Submenu to be removed from the AA.

Returns:
None: This method does not return any specific value.
"""

endpoint = "/groups/auto-attendants/submenus"

params = {
"serviceUserId": service_user_id,
"submenuId": submenu_id
}

return self.requester.delete(endpoint, params=params)

#AUTOMATIC CALLBACK
#AUTOMATIC HOLD RETRIEVE
#BARGE IN EXEMPT
Expand Down
65 changes: 64 additions & 1 deletion odins_spear/methods/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def auto_attendants(self, service_provider_id: str, group_id: str):
return self.requester.get(endpoint, params=params)

def auto_attendant(self, service_user_id: str):
"""Returns detailed information of a singel Auto Attendant.
"""Returns detailed information of a single Auto Attendant.

Args:
service_user_id (str): User ID of target Auto Attendant.
Expand All @@ -88,6 +88,69 @@ def auto_attendant(self, service_user_id: str):
}

return self.requester.get(endpoint, params=params)


def auto_attendant_user(self, service_provider_id: str, group_id: str, user_id: str):
"""Returns detailed information about all Auto Attendants (AA) built in the same group as the specified user.

Args:
service_provider_id (str): Service Provider ID of the group where the user is built.
group_id (str): Group ID of the group where the user is built.
user_id (str): User ID of the user being queried.

Returns:
List: Returns a list of the AAs built in the group.
"""

endpoint = "/groups/auto-attendants/user"

params = {
"userId": user_id,
"serviceProviderId": service_provider_id,
"groupId": group_id
}

return self.requester.get(endpoint, params=params)


def auto_attendant_submenus(self, service_user_id: str):
"""Returns a list of the submenus of the specified Auto Attendant (AA). Works with Standard AAs only, basic AAs do not have submenus.

Args:
service_user_id (str): The service user ID of the AA

Returns:
List: Returns a list of the submenus associated with the AA.
"""

endpoint = "/groups/auto-attendants/submenus"

params = {
"serviceUserId": service_user_id
}

return self.requester.get(endpoint, params=params)


def auto_attendant_submenu_usage(self, service_user_id: str, submenu_id: str):
"""Returns the type of the specified Auto Attendant (AA) submenu. NOTE: This method does not return any usage data.

Args:
service_user_id (str): The service user ID of the AA being queried.
submenu_id (str): The submenu ID of the submenu being queried.

Returns:
List: Returns a list containing a single dict of the submenu.
"""

endpoint = "/groups/auto-attendants/submenus/usage"

params = {
"serviceUserId": service_user_id,
"submenuId": submenu_id
}

return self.requester.get(endpoint, params=params)

#AUTOMATIC CALLBACK
#AUTOMATIC HOLD RETRIEVE
Expand Down
86 changes: 86 additions & 0 deletions odins_spear/methods/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,92 @@ def group_admin(self, service_provider_id: str, group_id: str, user_id: str, pas
#ATTENDANT CONSOLE
#AUTHENTICATION
#AUTO ATTENDANTS

def auto_attendant(self, service_provider_id: str, group_id: str, service_user_id: str, aa_name: str, aa_type: str ="Basic", payload: dict ={}):
"""Builds an Auto Attendant (AA) from the given payload.

Args:
service_provider_id (str): Service Provider ID of the group where the AA should be built.
group_id (str): Group ID where the AA should be built.
service_user_id (str): Service User ID of the AA (including the domain).
aa_name (str): Name of the AA
aa_type (str, optional): Type of AA: "Basic" or "Standard". Will default to "Basic". NOTE: The "Auto Attendant - Standard" service must be enabled on the group in order for the aa_type to be set to "Standard".
payload (dict, optional): Additional AA configuration data.

Returns:
Dict: Returns the AA profile.
"""

endpoint = "/groups/auto-attendants"

Copy link
Owner

Choose a reason for hiding this comment

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

This needs update the existing payload otherwise your overwriting whatever is passed in the param.

Example:
payload['groupId'] = group_id

Copy link
Owner

Choose a reason for hiding this comment

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

Additionally things where you have hard coded like "nameDialingEntries":"LastName + FirstName" we need to check this is empty and not passed in by the user before editing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've resolved this and pushed new commits.

payload["serviceProviderId"] = service_provider_id
payload["groupId"] = group_id
payload["serviceUserId"] = service_user_id
payload["serviceInstanceProfile"]["name"] = aa_name
payload["type"] = aa_type

default_payload_values = {
"enableVideo": "false",
"extensionDialingScope":"Group",
"nameDialingScope":"Group",
"nameDialingEntries":"LastName + FirstName",
"firstDigitTimeoutSeconds":1
}

for key, default_value in default_payload_values.items():
payload.setdefault(key, default_value)

return self.requester.post(endpoint, data=payload)


def auto_attendant_remove_user(self, service_provider_id: str, group_id: str, user_id: str):
"""Returns a list of the available Auto Attendants (AAs) built in the same group as the specified user.

Args:
service_provider_id (str): Service Provider ID where the user is built.
group_id (str): Group ID where the user is built.
user_id (str): User ID of the user.

Returns:
List: List of the Service User IDs of the AAs in the group.
"""

endpoint = "/groups/auto-attendants/removeUser"

payload = {
"serviceProviderId": service_provider_id,
"groupId": group_id,
"userId": user_id
}

return self.requester.post(endpoint, data=payload)


def auto_attendant_submenu(self, service_user_id: str, submenu_id: str, announcement_selection: str="Default", extension_dialing: bool= True):
"""Posts a new submenu to the specified Auto Attendant (AA).

Args:
service_user_id (str): Service User ID of the AA.
submenu_id (str): ID of the submenu to be created.
announcement_selection (str, optional): "Default" or "Personal". Defaults to "Default".
extension_dialing (bool, optional): Whether Level Extension Dialing is enabled or not. Defaults to True.

Returns:
None: This method does not return any specific value.
"""

endpoint = "/groups/auto-attendants/submenus"

payload = {
"serviceUserId": service_user_id,
"submenuId": submenu_id,
"announcementSelection": announcement_selection,
"enableLevelExtensionDialing": extension_dialing
}

return self.requester.post(endpoint, data=payload)


#AUTOMATIC CALLBACK
#AUTOMATIC HOLD RETRIEVE
#BARGE IN EXEMPT
Expand Down