Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(sdk): annotate list returns with typing.List in the Python resources
Yudhi Armyndharis47bd0611d658
diff --git a/sdk/python/openwa/resources/channels.py b/sdk/python/openwa/resources/channels.pyindex 0d763efd2..ece249723 100644--- a/sdk/python/openwa/resources/channels.py+++ b/sdk/python/openwa/resources/channels.py@@ -6,7 +6,7 @@ Backed by ``src/modules/channel/channel.controller.ts``from __future__ import annotations-from typing import TYPE_CHECKING+from typing import TYPE_CHECKING, Listfrom .._http import quote_segmentfrom ..types import (@@ -37,7 +37,7 @@ class ChannelsResource:def messages(self, session_id: str, channel_id: str, query: ChannelMessageQuery | None = None- ) -> list[ChannelMessageRecord]:+ ) -> List[ChannelMessageRecord]:return self._http.request("GET", f"/api/sessions/{quote_segment(session_id)}/channels/{quote_segment(channel_id)}/messages", query=query)diff --git a/sdk/python/openwa/resources/contacts.py b/sdk/python/openwa/resources/contacts.pyindex 41f6a2a97..798e3be8a 100644--- a/sdk/python/openwa/resources/contacts.py+++ b/sdk/python/openwa/resources/contacts.py@@ -5,7 +5,7 @@ Backed by ``src/modules/contact/contact.controller.ts``.from __future__ import annotations-from typing import TYPE_CHECKING, TypedDict+from typing import List, TYPE_CHECKING, TypedDictfrom .._http import quote_segmentfrom ..types import (@@ -31,7 +31,7 @@ class ContactsResource:def __init__(self, http: "HttpExecutor") -> None:self._http = http- def list(self, session_id: str, query: ListContactsQuery | None = None) -> list[ContactRecord]:+ def list(self, session_id: str, query: ListContactsQuery | None = None) -> List[ContactRecord]:return self._http.request("GET", f"/api/sessions/{quote_segment(session_id)}/contacts", query=query)def get(self, session_id: str, contact_id: str) -> ContactRecord:@@ -45,7 +45,7 @@ class ContactsResource:"GET", f"/api/sessions/{quote_segment(session_id)}/contacts/{quote_segment(contact_id)}/profile-picture")- def profile_pictures(self, session_id: str, ids: list[str]) -> ProfilePicturesResponse:+ def profile_pictures(self, session_id: str, ids: List[str]) -> ProfilePicturesResponse:"""Batch-resolve profile picture URLs for up to 50 contacts in one request.Returns a map of contact id → URL (None when a lookup fails)."""return self._http.request(@@ -73,7 +73,7 @@ class ContactsResource:def unblock(self, session_id: str, contact_id: str) -> SuccessResult:return self._http.request("DELETE", f"/api/sessions/{quote_segment(session_id)}/contacts/{quote_segment(contact_id)}/block")- def list_blocked(self, session_id: str) -> list[str]:+ def list_blocked(self, session_id: str) -> List[str]:"""List the JIDs this account has blocked.Session-wide, so it takes no contact id — unlike ``block`` and ``unblock``, which act on onediff --git a/sdk/python/openwa/resources/groups.py b/sdk/python/openwa/resources/groups.pyindex 24cd6dde2..3b6bc0692 100644--- a/sdk/python/openwa/resources/groups.py+++ b/sdk/python/openwa/resources/groups.py@@ -5,7 +5,7 @@ Backed by ``src/modules/group/group.controller.ts``.from __future__ import annotations-from typing import Any, TYPE_CHECKING, TypedDict+from typing import Any, List, TYPE_CHECKING, TypedDictfrom .._http import quote_segmentfrom ..types import (@@ -36,7 +36,7 @@ class GroupsResource:def __init__(self, http: "HttpExecutor") -> None:self._http = http- def list(self, session_id: str, query: ListGroupsQuery | None = None) -> list[GroupSummary]:+ def list(self, session_id: str, query: ListGroupsQuery | None = None) -> List[GroupSummary]:return self._http.request("GET", f"/api/sessions/{quote_segment(session_id)}/groups", query=query)def get(self, session_id: str, group_id: str) -> GroupInfo:@@ -50,25 +50,25 @@ class GroupsResource:"""return self._http.request("POST", f"/api/sessions/{quote_segment(session_id)}/groups", body=body)- def add_participants(self, session_id: str, group_id: str, participants: list[str]) -> ParticipantsResult:+ def add_participants(self, session_id: str, group_id: str, participants: List[str]) -> ParticipantsResult:return self._http.request("POST", f"/api/sessions/{quote_segment(session_id)}/groups/{quote_segment(group_id)}/participants",body={"participants": participants},)- def remove_participants(self, session_id: str, group_id: str, participants: list[str]) -> ParticipantsResult:+ def remove_participants(self, session_id: str, group_id: str, participants: List[str]) -> ParticipantsResult:return self._http.request("DELETE", f"/api/sessions/{quote_segment(session_id)}/groups/{quote_segment(group_id)}/participants",body={"participants": participants},)- def promote_participants(self, session_id: str, group_id: str, participants: list[str]) -> ParticipantsResult:+ def promote_participants(self, session_id: str, group_id: str, participants: List[str]) -> ParticipantsResult:return self._http.request("POST", f"/api/sessions/{quote_segment(session_id)}/groups/{quote_segment(group_id)}/participants/promote",body={"participants": participants},)- def demote_participants(self, session_id: str, group_id: str, participants: list[str]) -> ParticipantsResult:+ def demote_participants(self, session_id: str, group_id: str, participants: List[str]) -> ParticipantsResult:return self._http.request("POST", f"/api/sessions/{quote_segment(session_id)}/groups/{quote_segment(group_id)}/participants/demote",body={"participants": participants},@@ -146,7 +146,7 @@ class GroupsResource:"PUT", f"/api/sessions/{quote_segment(session_id)}/groups/{quote_segment(group_id)}/settings", body=body)- def get_membership_requests(self, session_id: str, group_id: str) -> list[GroupMembershipRequest]:+ def get_membership_requests(self, session_id: str, group_id: str) -> List[GroupMembershipRequest]:"""List a group's pending join requests. Requires the account to be a group admin.Only ``participantId`` is guaranteed on each entry — the rest is reported by the engine when@@ -158,7 +158,7 @@ class GroupsResource:)def approve_membership_requests(- self, session_id: str, group_id: str, participants: list[str] | None = None+ self, session_id: str, group_id: str, participants: List[str] | None = None) -> ParticipantsResult:"""Approve pending join requests. Omit ``participants`` to approve every pending request.@@ -174,7 +174,7 @@ class GroupsResource:)def reject_membership_requests(- self, session_id: str, group_id: str, participants: list[str] | None = None+ self, session_id: str, group_id: str, participants: List[str] | None = None) -> ParticipantsResult:"""Reject pending join requests. Omit ``participants`` to reject every pending request."""body: dict[str, object] = {} if participants is None else {"participants": participants}diff --git a/sdk/python/openwa/resources/labels.py b/sdk/python/openwa/resources/labels.pyindex b0b33043f..c2632a1d7 100644--- a/sdk/python/openwa/resources/labels.py+++ b/sdk/python/openwa/resources/labels.py@@ -7,7 +7,7 @@ feature; the session must be a business account.from __future__ import annotations-from typing import TYPE_CHECKING+from typing import List, TYPE_CHECKINGfrom .._http import quote_segmentfrom ..types import AddLabelRequest, ChatSummary, LabelRecord, SuccessResult, UpsertLabelRequest@@ -20,13 +20,13 @@ class LabelsResource:def __init__(self, http: "HttpExecutor") -> None:self._http = http- def list(self, session_id: str) -> list[LabelRecord]:+ def list(self, session_id: str) -> List[LabelRecord]:return self._http.request("GET", f"/api/sessions/{quote_segment(session_id)}/labels")def get(self, session_id: str, label_id: str) -> LabelRecord:return self._http.request("GET", f"/api/sessions/{quote_segment(session_id)}/labels/{quote_segment(label_id)}")- def chats(self, session_id: str, label_id: str) -> list[ChatSummary]:+ def chats(self, session_id: str, label_id: str) -> List[ChatSummary]:"""Every chat carrying a label.whatsapp-web.js only -- Baileys has label writes but no label query of any kind, and@@ -54,7 +54,7 @@ class LabelsResource:"DELETE", f"/api/sessions/{quote_segment(session_id)}/labels/{quote_segment(label_id)}")- def for_chat(self, session_id: str, chat_id: str) -> list[LabelRecord]:+ def for_chat(self, session_id: str, chat_id: str) -> List[LabelRecord]:return self._http.request("GET", f"/api/sessions/{quote_segment(session_id)}/labels/chat/{quote_segment(chat_id)}")def add_to_chat(self, session_id: str, chat_id: str, body: AddLabelRequest) -> SuccessResult:diff --git a/sdk/python/openwa/resources/messages.py b/sdk/python/openwa/resources/messages.pyindex d90fccef6..9fe9c5103 100644--- a/sdk/python/openwa/resources/messages.py+++ b/sdk/python/openwa/resources/messages.py@@ -6,7 +6,7 @@ NOTE: the real paths use the ``/send-`` prefix, e.g. ``/messages/send-text``.from __future__ import annotations-from typing import TYPE_CHECKING+from typing import List, TYPE_CHECKINGfrom .._http import quote_segmentfrom ..types import (@@ -102,12 +102,12 @@ class MessagesResource:def history(self, session_id: str, chat_id: str, query: MessageHistoryQuery | None = None- ) -> list[ChatHistoryMessage]:+ ) -> List[ChatHistoryMessage]:return self._http.request("GET", f"/api/sessions/{quote_segment(session_id)}/messages/{quote_segment(chat_id)}/history", query=query)- def reactions(self, session_id: str, chat_id: str, message_id: str) -> list[ReactionRecord]:+ def reactions(self, session_id: str, chat_id: str, message_id: str) -> List[ReactionRecord]:return self._http.request("GET", f"/api/sessions/{quote_segment(session_id)}/messages/{quote_segment(chat_id)}/{quote_segment(message_id)}/reactions")diff --git a/sdk/python/openwa/resources/status.py b/sdk/python/openwa/resources/status.pyindex 4bf842ef7..418fb721a 100644--- a/sdk/python/openwa/resources/status.py+++ b/sdk/python/openwa/resources/status.py@@ -6,7 +6,7 @@ NOTE: this is WhatsApp "Status/Stories", distinct from session lifecycle status.from __future__ import annotations-from typing import TYPE_CHECKING+from typing import List, TYPE_CHECKINGfrom .._http import quote_segmentfrom ..types import (@@ -27,10 +27,10 @@ class StatusResource:def __init__(self, http: "HttpExecutor") -> None:self._http = http- def list(self, session_id: str) -> dict[str, list[StatusRecord]]:+ 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]]:+ 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 media(self, session_id: str, status_id: str) -> StatusMedia: