-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: CHOPP3D <[email protected]>
- Loading branch information
1 parent
f15f575
commit 85293e7
Showing
4 changed files
with
71 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from exceptions import OSExtensionNotFound, OSRangeFault | ||
|
||
def retrieve_extensions( api, service_provider_id: str, group_id: str ) -> list: | ||
|
||
extensions = [] | ||
|
||
dataset = ( | ||
api.get.users( service_provider_id, group_id ) + | ||
api.get.group_hunt_groups( service_provider_id, group_id ) + | ||
api.get.group_call_centers( service_provider_id, group_id ) + | ||
api.get.auto_attendants( service_provider_id, group_id ) | ||
) | ||
|
||
for data in dataset: | ||
if not data['extension']: | ||
continue | ||
|
||
extensions.append( int(data['extension']) ) | ||
|
||
return extensions if extensions else None | ||
|
||
def main( api, service_provider_id: str, group_id: str, range_start: int, range_end: int ): | ||
'''Retrieves The Lowest Free Extension Available In The Designated Group Passed. | ||
''' | ||
|
||
if range_start > range_end: | ||
raise OSRangeFault | ||
|
||
# Retrieve List Of Occupied Extensions Within The Group | ||
extensions = retrieve_extensions( | ||
api, | ||
service_provider_id, | ||
group_id, | ||
) | ||
|
||
for extension in range(range_start, range_end + 1): | ||
if extension not in extensions: | ||
return {'extension': extension} | ||
|
||
raise OSExtensionNotFound |