feat: fcm apis
feat: push notification api
This commit is contained in:
+3
-1
@@ -5,7 +5,7 @@ from fastapi.security import HTTPBearer
|
||||
# Import the security scheme
|
||||
bearer_scheme = HTTPBearer(scheme_name="Bearer Authentication")
|
||||
|
||||
from .endpoints import clinics, doctors, calender, appointments, patients, admin, auth, s3, users, clinicDoctor, dashboard, call_transcripts
|
||||
from .endpoints import clinics, doctors, calender, appointments, patients, admin, auth, s3, users, clinicDoctor, dashboard, call_transcripts, notifications
|
||||
|
||||
api_router = APIRouter()
|
||||
# api_router.include_router(twilio.router, prefix="/twilio")
|
||||
@@ -37,3 +37,5 @@ api_router.include_router(clinicDoctor.router, prefix="/clinic-doctors", tags=["
|
||||
api_router.include_router(dashboard.router, prefix="/dashboard", tags=["dashboard"], dependencies=[Depends(auth_required)])
|
||||
|
||||
api_router.include_router(call_transcripts.router, prefix="/call-transcripts", tags=["call-transcripts"], dependencies=[Depends(auth_required)])
|
||||
|
||||
api_router.include_router(notifications.router, prefix="/notifications", tags=["notifications"], dependencies=[Depends(auth_required)])
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
from fastapi import APIRouter
|
||||
from utils.constants import DEFAULT_LIMIT, DEFAULT_PAGE
|
||||
from services.notificationServices import NotificationServices
|
||||
from schemas.ApiResponse import ApiResponse
|
||||
from fastapi import Request
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.get("/")
|
||||
def get_notifications(request: Request, limit: int = DEFAULT_LIMIT, page: int = DEFAULT_PAGE):
|
||||
if page <0:
|
||||
page = 1
|
||||
|
||||
offset = (page - 1) * limit
|
||||
|
||||
notifications = NotificationServices().getNotifications(request.state.user["id"], limit, offset)
|
||||
return ApiResponse(data=notifications, message="Notifications retrieved successfully")
|
||||
|
||||
@router.delete("/")
|
||||
def delete_notification(notification_id: int):
|
||||
NotificationServices().deleteNotification(notification_id)
|
||||
return ApiResponse(data="OK", message="Notification deleted successfully")
|
||||
|
||||
@router.put("/")
|
||||
def update_notification_status(notification_id: int):
|
||||
NotificationServices().updateNotificationStatus(notification_id)
|
||||
return ApiResponse(data="OK", message="Notification status updated successfully")
|
||||
|
||||
@router.post("/")
|
||||
def send_notification(title: str, message: str, sender_id: int, receiver_id: int):
|
||||
NotificationServices().createNotification(title, message, sender_id, receiver_id)
|
||||
return ApiResponse(data="OK", message="Notification sent successfully")
|
||||
|
||||
@router.post("/fcm")
|
||||
def send_fcm_notification(req: Request, token: str):
|
||||
NotificationServices().createOrUpdateFCMToken(req.state.user["id"], token)
|
||||
return ApiResponse(data="OK", message="FCM Notification sent successfully")
|
||||
Reference in New Issue
Block a user