Skip to content

Commit c102c66

Browse files
committed
feat: introduce retrieve contacts API with pagination and contact lookup support
1 parent f06af5c commit c102c66

File tree

6 files changed

+565
-106
lines changed

6 files changed

+565
-106
lines changed

app/bss/adapters/__init__.py

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22
from abc import ABC, abstractmethod
33
from datetime import datetime
4-
from typing import List, Dict, Optional, Callable, Union, Iterator, Tuple
4+
from typing import List, Dict, Optional, Callable, Iterator, Tuple
55

66
from pydantic import BaseModel
77

@@ -224,7 +224,12 @@ def retrieve_voicemail_message_details(self, session: SessionInfo, user: UserInf
224224
"""Obtain user's voicemail message details information"""
225225
raise NotImplementedError("Override this method in your sub-class")
226226

227-
def retrieve_voicemail_message_attachment(self, session: SessionInfo, message_id: str, file_format: str) -> tuple[str, Iterator]:
227+
def retrieve_voicemail_message_attachment(
228+
self,
229+
session: SessionInfo,
230+
message_id: str,
231+
file_format: str,
232+
) -> tuple[str, Iterator]:
228233
"""Obtain the media file for a user's voicemail message"""
229234
raise NotImplementedError("Override this method in your sub-class")
230235

@@ -236,8 +241,15 @@ def patch_voicemail_message(self, session: SessionInfo, message_id: str,
236241
def delete_voicemail_message(self, session: SessionInfo, message_id: str) -> None:
237242
"""Delete an existing user's voicemail message"""
238243
raise NotImplementedError("Override this method in your sub-class")
239-
240-
def create_user_event(self, user: UserInfo, timestamp: datetime, group: UserEventGroup, type: UserEventType, data: Optional[dict] = None) -> None:
244+
245+
def create_user_event(
246+
self,
247+
user: UserInfo,
248+
timestamp: datetime,
249+
group: UserEventGroup,
250+
type: UserEventType,
251+
data: Optional[dict] = None,
252+
) -> None:
241253
"""Create user's event"""
242254
raise NotImplementedError("Override this method in your sub-class")
243255

@@ -246,6 +258,16 @@ def retrieve_contacts(self, session: SessionInfo, user: UserInfo) -> List[Contac
246258
"""List of other extensions in the PBX"""
247259
raise NotImplementedError("Override this method in your sub-class")
248260

261+
def retrieve_contacts_v2(
262+
self, session: SessionInfo,
263+
user: UserInfo,
264+
search: Optional[str] = None,
265+
page: Optional[int] = 1,
266+
items_per_page: Optional[int] = 100,
267+
) -> tuple[List[ContactInfo], int]:
268+
"""List of other extensions in the PBX"""
269+
raise NotImplementedError("Override this method in your sub-class")
270+
249271
def retrieve_contact_by_user_id(self, session: SessionInfo, user: UserInfo, user_id: str) -> ContactInfo:
250272
"""Retrieve extension by User ID in the PBX"""
251273
raise NotImplementedError("Override this method in your sub-class")
@@ -295,6 +317,7 @@ def default_id_if_none(self, tenant_id: str) -> str:
295317
"""Provide a defaut value for tenant ID if none is supplied in HTTP headers"""
296318
return tenant_id if tenant_id else "default"
297319

320+
298321
class BSSAdapterExternalDB(BSSAdapter, SampleOTPHandler):
299322
"""Supply to WebTrit core information about
300323
VoIP users (only their SIP credentials) and the list of
@@ -401,6 +424,16 @@ def retrieve_contacts(self, session: SessionInfo, user: UserInfo) -> List[Contac
401424
"""List of other extensions in the PBX"""
402425
raise NotImplementedError("Override this method in your sub-class")
403426

427+
def retrieve_contacts_v2(
428+
self, session: SessionInfo,
429+
user: UserInfo,
430+
search: Optional[str] = None,
431+
page: Optional[int] = 1,
432+
items_per_page: Optional[int] = 100,
433+
) -> tuple[List[ContactInfo], int]:
434+
"""List of other extensions in the PBX"""
435+
raise NotImplementedError("Override this method in your sub-class")
436+
404437
@abstractmethod
405438
def retrieve_calls(
406439
self,

0 commit comments

Comments
 (0)