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

Eva bulider methods #50

Merged
merged 16 commits into from
Jun 25, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
sandbox.py
os.log

# mac
*.DS_Store
Expand Down
146 changes: 146 additions & 0 deletions odins_spear/methods/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,30 @@ def session_switch(self, username: str):
#DEPARTMENTS
#DEVICE POLICIES
#DEVICES

def group_device(self, service_provider_id: str, group_id: str, device_name: str, device_type: str, payload: dict ={}):
"""Adds a new device to a group.

Args:
service_provider_id (str): Service provider ID where the device should be built.
group_id (str): Group ID where the device should be built
device_name (str): Name of the new device
device_type (str): Type of device.
payload (dict, optional): Device configuration data.

Returns:
Dict: Returns the device profile.
"""

endpoint = "/groups/devices"

payload["serviceProviderId"] = service_provider_id
payload["groupId"] = group_id
payload["deviceName"] = device_name
payload["deviceType"] = device_type

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

#DIAL PLAN POLICY
#DIRECTED CALL PICKUP WITH BARGE IN
#DIRECTROUTE
Expand Down Expand Up @@ -246,6 +270,51 @@ def service_provider_dns(self, service_provider_id: str, start_of_range_number:
#HOTELING GUEST
#HOTELING HOST
#HUNT GROUPS

def group_hunt_group(self, service_provider_id: str, group_id: str, service_user_id: str,
clid_first_name: str, clid_last_name:str, extension: str, payload: dict={}, agents: list=[],
policy: str ="Regular", no_answer_number_of_rings: int=5, forward_timeout_seconds: int=0):
"""
Builds a hunt group (HG) in the specified group.

Args:
service_provider_id (str): The service provider ID in which the target group is built.
group_id (str): The group ID where the HG should be built.
service_user_id (str): The service user ID for the new HG. This must include the domain of the user.
clid_first_name (str): The Calling Line ID first name.
clid_last_name (str): The Calling Line ID last name.
extension (str): The extension number for the HG. This must be entered as a string.
payload (dict, optional): HG configuration data.
agents (list, optional): List of user IDs (str) that should be assigned to the new HG. The user(s) must already exist in the group.
policy (str, optional): Regular, Circular, Simultaneous, Uniform, Weighted. Defaults to Regular.
no_answer_number_of_rings (int, optional): Defaults to 5.
forward_timeout_seconds (int, optional): Defaults to 0.

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

endpoint = "/groups/hunt-groups"

payload["serviceProviderId"] = service_provider_id
payload["groupId"] = group_id
payload["serviceUserId"] = service_user_id
payload["policy"] = policy
payload["noAnswerNumberOfRings"] = no_answer_number_of_rings
payload["forwardTimeoutSeconds"] = forward_timeout_seconds

payload["agents"] = [{'userId': agent_id} for agent_id in agents]

if 'serviceInstanceProfile' not in payload:
payload.setdefault('serviceInstanceProfile', {})

payload["serviceInstanceProfile"]["callingLineIdFirstName"] = clid_first_name
payload["serviceInstanceProfile"]["callingLineIdLastName"] = clid_last_name
payload["serviceInstanceProfile"]["name"] = f"{clid_first_name} {clid_last_name}"
payload["serviceInstanceProfile"]["extension"] = extension

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

#IN CALL SERVICE ACTIVATION
#INSTANT GROUP CALL
#INTEGRATED IMP
Expand Down Expand Up @@ -307,6 +376,83 @@ def service_provider_dns(self, service_provider_id: str, start_of_range_number:
#THIRD PARTY EMERGENCY CALLING
#TIME ZONES
#TRUNK GROUPS

def group_trunk_group(self, service_provider_id: str, group_id: str, trunk_name: str, max_active_calls: int, payload: dict={},
sip_authentication_username: str="", sip_authentication_password: str=""):
"""
Builds a Trunk Group (TG) in the specified group.
Default fields:
"capacityExceededTrapInitialCalls":0,
"capacityExceededTrapOffsetCalls":0,
"clidSourceForScreenedCallsPolicy":"Profile Name Profile Number",
"continuousOptionsSendingIntervalSeconds":30,
"failureOptionsSendingIntervalSeconds":10,
"failureThresholdCounter":1,
"invitationTimeout":6,
"inviteFailureThresholdCounter":1,
"inviteFailureThresholdWindowSeconds":30,
"pilotUserCallOptimizationPolicy":"Optimize For User Services",
"pilotUserCallingLineAssertedIdentityPolicy":"Unscreened Originating Calls",
"pilotUserCallingLineIdentityForEmergencyCallsPolicy":"No Calls",
"pilotUserCallingLineIdentityForExternalCallsPolicy":"No Calls",
"pilotUserChargeNumberPolicy":"No Calls",
"requireAuthentication":"false",
"successThresholdCounter":1,
"useSystemUserLookupPolicy":"true",
"userLookupPolicy":"Basic"

Args:
service_provider_id (str): The service provider ID in which the target group is built.
group_id (str): The group ID where the HG should be built.
trunk_name (str): The name of the new TG.
max_active_calls (str): The maximum active calls to be set on the TG.
payload (dict, optional): Configuration for the TG.
sip_authentication_username (str, optional): The SIP authentication username for the TG. This field is required if "requireAuthentication" is set to "true".
sip_authentication_password (str, optional): The SIP authentication password for the TG. You can generate a password for this using get.sip_password_generator. This field is required if "requireAuthentication" is set to "true".

Note:
Several fields are set to have default values. Please refer to the online documentation.

Returns:
Dict: Returns the Trunk Group profile.
"""

endpoint = "/groups/trunk-groups"

payload["name"] = trunk_name
payload["maxActiveCalls"] = max_active_calls
payload["serviceProviderId"] = service_provider_id
payload["groupId"] = group_id

if payload["requireAuthentication"] == "true":
payload["sipAuthenticationUserName"] = sip_authentication_username
payload["sipAuthenticationPassword"] = sip_authentication_password

default_payload_values = {
"capacityExceededTrapInitialCalls": 0,
"capacityExceededTrapOffsetCalls": 0,
"clidSourceForScreenedCallsPolicy": "Profile Name Profile Number",
"continuousOptionsSendingIntervalSeconds": 30,
"failureOptionsSendingIntervalSeconds": 10,
"failureThresholdCounter": 1,
"invitationTimeout": 6,
"inviteFailureThresholdCounter": 1,
"inviteFailureThresholdWindowSeconds": 30,
"pilotUserCallOptimizationPolicy": "Optimize For User Services",
"pilotUserCallingLineAssertedIdentityPolicy": "Unscreened Originating Calls",
"pilotUserCallingLineIdentityForEmergencyCallsPolicy": "No Calls",
"pilotUserCallingLineIdentityForExternalCallsPolicy": "No Calls",
"pilotUserChargeNumberPolicy": "No Calls",
"successThresholdCounter": 1,
"useSystemUserLookupPolicy": "true",
"userLookupPolicy": "Basic",
"requireAuthentication": "false"
}
for key, default_value in default_payload_values.items():
payload.setdefault(key, default_value)

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

#TWO STAGE DIALING
#USERS

Expand Down
94 changes: 84 additions & 10 deletions odins_spear/methods/put.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,25 @@ def user_call_center_agent_sign_out(self, user_id: str):
#CALL PICKUP
#CALL POLICIES
#CALL PROCESSING POLICIES

def user_call_processing_policy(self, user_id: str, updates: dict):
Jordan-Prescott marked this conversation as resolved.
Show resolved Hide resolved
"""
Update the Call Processing Policies for a specified user.

Args:
user_id (str): The user ID of the user whose call processing policies need updating.
updates (dict): Updates to apply to the specified user.

Returns:
Dict: Returns the updated call processing policies.
"""

endpoint = '/users/call-processing-policy'

updates["userId"] = user_id

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

#CALL RECORDING
#CALL RECORDS
#CALL TRANSFER
Expand Down Expand Up @@ -1028,26 +1047,81 @@ def user_services(self, user_id: str, services: list =None, service_packs: list
#TIME ZONES
#TRUNK GROUPS

def service_providers_trunk_group_call_capacity(self, service_provider_id: str, max_active_calls: int, bursting_max_active_calls: int):
def group_trunk_groups_call_capacity(self, service_provider_id: str, group_id: str, max_active_calls: int=None,
max_available_active_calls: int=None, bursting_max_active_calls: int=None,
number_of_bursting_btlus: int=None):
"""
Updates the trunking call capacity in the specified group.

Args:
service_provider_id (str): Service provider ID where the target group is built
group_id (str): Group ID whose trunk group call capacity needs updating
max_active_calls (int, optional): The max active calls for the group.
max_available_active_calls (int, optional): The max available active calls for the group.
bursting_max_active_calls (int, optional): The bursting max active calls for the group.
number_of_bursting_btlus (int, optional): The number of Business Trunking License Units for bursting.

Returns:
Dict: Returns the updated state of the trunk group call capacity.
"""

endpoint = "/groups/trunk-groups/call-capacity"

updates = {
"serviceProviderId": service_provider_id,
"groupId": group_id
}

if max_active_calls:
updates["maxActiveCalls"] = max_active_calls
if max_available_active_calls:
updates["maxAvailableActiveCalls"] = max_available_active_calls
if bursting_max_active_calls:
updates["burstingMaxActiveCalls"] = bursting_max_active_calls
if number_of_bursting_btlus:
updates["numberOfBurstingBTLUs"] = number_of_bursting_btlus

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


def group_trunk_group(self, service_provider_id: str, group_id: str, updates: dict):
"""
Updates trunk group (TG) information.

Args:
service_provider_id (str): Service provider ID where the target group is built
group_id (str): Group ID whose trunk group call capacity needs updating
updates (dict): Updates to be applied to the TG.

Returns:
Dict: Returns the updated Trunk Group profile.
"""

endpoint = "/groups/trunk-groups"

updates["serviceProviderId"] = service_provider_id
updates["groupId"] = group_id

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


def service_providers_trunk_group_call_capacity(self, service_provider_id: str, updates: dict):
"""
Updates the max active calls and the bursting max active calls for the given service provider.

Args:
service_provider_id (str): service provider id for which the max active calls needs to be updated
max_active_calls (int): the updated number of max active calls
bursting_max_active_calls (int): the updated number of bursting max active calls
service_provider_id (str): Service provider ID for which the max active calls needs to be updated
updates (dict): The updates to be applied to the service provider's trunking call capacity

Jordan-Prescott marked this conversation as resolved.
Show resolved Hide resolved
Returns:
Dict: Returns the updated call capacity for the service provider.
"""

endpoint = "/service-providers/trunk-groups/call-capacity"

data = {
"serviceProviderId": service_provider_id,
"maxActiveCalls": max_active_calls,
"burstingMaxActiveCalls": bursting_max_active_calls
}
updates["serviceProviderId"] = service_provider_id

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

#TWO STAGE DIALING
#USERS
Expand Down