4ce4204b6c
CI / Lint (push) Failing after 2s
CI / Build (push) Has been skipped
SDK CI / PHP SDK (push) Failing after 1s
Split PHP SDK / PHP SDK tests (push) Failing after 1s
CI / Test (push) Failing after 1s
CI / Dashboard (push) Failing after 0s
SDK CI / JavaScript SDK (push) Failing after 0s
SDK CI / Python SDK (push) Failing after 2s
SDK CI / Java SDK (push) Failing after 1s
Split PHP SDK / Mirror sdk/php -> rmyndharis/openwa-php (push) Has been skipped
CI / Test (PostgreSQL migrations) (push) Failing after 7m47s
CI / Docker Build (push) Has been skipped
39 lines
1.7 KiB
Python
39 lines
1.7 KiB
Python
"""Status (Stories) resource — WhatsApp status updates.
|
|
|
|
Backed by ``src/modules/status/status.controller.ts``.
|
|
NOTE: this is WhatsApp "Status/Stories", distinct from session lifecycle status.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
from .._http import quote_segment
|
|
from ..types import SendImageStatusRequest, SendTextStatusRequest, SendVideoStatusRequest, StatusRecord
|
|
|
|
if TYPE_CHECKING:
|
|
from .._http import HttpExecutor
|
|
|
|
|
|
class StatusResource:
|
|
def __init__(self, http: "HttpExecutor") -> None:
|
|
self._http = http
|
|
|
|
def list(self, session_id: str) -> dict[str, list[StatusRecord]]:
|
|
return self._http.request("GET", f"/api/sessions/{quote_segment(session_id)}/status")
|
|
|
|
def from_contact(self, session_id: str, contact_id: str) -> dict[str, list[StatusRecord]]:
|
|
return self._http.request("GET", f"/api/sessions/{quote_segment(session_id)}/status/{quote_segment(contact_id)}")
|
|
|
|
def send_text(self, session_id: str, body: SendTextStatusRequest) -> StatusRecord:
|
|
return self._http.request("POST", f"/api/sessions/{quote_segment(session_id)}/status/send-text", body=body)
|
|
|
|
def send_image(self, session_id: str, body: SendImageStatusRequest) -> StatusRecord:
|
|
return self._http.request("POST", f"/api/sessions/{quote_segment(session_id)}/status/send-image", body=body)
|
|
|
|
def send_video(self, session_id: str, body: SendVideoStatusRequest) -> StatusRecord:
|
|
return self._http.request("POST", f"/api/sessions/{quote_segment(session_id)}/status/send-video", body=body)
|
|
|
|
def delete(self, session_id: str, status_id: str) -> None:
|
|
self._http.request("DELETE", f"/api/sessions/{quote_segment(session_id)}/status/{quote_segment(status_id)}")
|