This commit is contained in:
debu-2 2026-10-14 06:32:25 +05:30
parent a109df2deb
commit 8901d99dd2
11 changed files with 380 additions and 13 deletions

View file

@ -1,6 +1,7 @@
from typing import Any
from fastapi import APIRouter, Depends, File, Form, UploadFile
from fastapi.responses import Response
from pydantic import BaseModel, Field
from sqlalchemy.orm import Session
@ -8,11 +9,13 @@ from .auth import current_user
from .database import get_db
from .models import UserAccount
from .whatsapp_template_service import (
attach_template_sample,
create_managed_template,
delete_managed_template,
get_managed_template,
language_catalog,
list_managed_templates,
read_template_sample,
resubmit_managed_template,
upload_header_media,
)
@ -79,6 +82,27 @@ async def whatsapp_template_create(
return await create_managed_template(db, user, payload.model_dump())
@router.post("/{template_id}/sample")
async def whatsapp_template_sample(
template_id: str,
file: UploadFile = File(),
db: Session = Depends(get_db),
user: UserAccount = Depends(current_user),
) -> dict:
data = await file.read()
return attach_template_sample(db, user, template_id, file.filename or "header", file.content_type or "", data)
@router.get("/{template_id}/sample")
def whatsapp_template_sample_file(
template_id: str,
db: Session = Depends(get_db),
user: UserAccount = Depends(current_user),
) -> Response:
data, mime, _name = read_template_sample(db, user, template_id)
return Response(content=data, media_type=mime)
@router.post("/{template_id}/resubmit")
async def whatsapp_template_resubmit(
template_id: str,