vanitha commited on
Commit
a72f64e
·
1 Parent(s): fa87f9c

(employee)-implemented whatsapp integration in employee module

Browse files
app/employees/controllers/router.py CHANGED
@@ -31,7 +31,6 @@ router = APIRouter(
31
 
32
  @router.post(
33
  "",
34
- response_model=EmployeeResponse,
35
  status_code=status.HTTP_201_CREATED,
36
  summary="Create a new employee",
37
  description="""
 
31
 
32
  @router.post(
33
  "",
 
34
  status_code=status.HTTP_201_CREATED,
35
  summary="Create a new employee",
36
  description="""
app/utils/wati_service.py CHANGED
@@ -245,7 +245,7 @@ class WatiService:
245
  params = {"whatsappNumber": whatsapp_number}
246
 
247
  headers = {
248
- "Authorization": access_token.strip(), # remove Bearer
249
  "Content-Type": "application/json"
250
  }
251
 
@@ -274,7 +274,6 @@ class WatiService:
274
 
275
  logger.info(f"WATI Response: {response_data}")
276
 
277
- # ✅ NEW SUCCESS CHECK
278
  if (
279
  response_data.get("result") is True and
280
  response_data.get("validWhatsAppNumber") is True and
@@ -287,7 +286,6 @@ class WatiService:
287
  )
288
  return True, "Welcome message accepted", message_id
289
 
290
- # ❌ If opted-in is false
291
  contact = response_data.get("contact", {})
292
  if contact.get("optedIn") is False:
293
  return False, "User not opted-in to receive WhatsApp messages", None
 
245
  params = {"whatsappNumber": whatsapp_number}
246
 
247
  headers = {
248
+ "Authorization": f"Bearer {access_token.strip()}",
249
  "Content-Type": "application/json"
250
  }
251
 
 
274
 
275
  logger.info(f"WATI Response: {response_data}")
276
 
 
277
  if (
278
  response_data.get("result") is True and
279
  response_data.get("validWhatsAppNumber") is True and
 
286
  )
287
  return True, "Welcome message accepted", message_id
288
 
 
289
  contact = response_data.get("contact", {})
290
  if contact.get("optedIn") is False:
291
  return False, "User not opted-in to receive WhatsApp messages", None