22
33from __future__ import annotations
44
5+ import typing_extensions
56from typing import Optional
67
78import httpx
1920)
2021from .._base_client import make_request_options
2122from ..types .contact_list_response import ContactListResponse
22- from ..types .api_response_of_contact import APIResponseOfContact
23- from ..types .api_response_of_contact_message_summary import APIResponseOfContactMessageSummary
23+ from ..types .contact_create_response import ContactCreateResponse
24+ from ..types .contact_update_response import ContactUpdateResponse
25+ from ..types .contact_retrieve_response import ContactRetrieveResponse
26+ from ..types .contact_retrieve_message_summary_response import ContactRetrieveMessageSummaryResponse
2427
2528__all__ = ["ContactsResource" , "AsyncContactsResource" ]
2629
2730
2831class ContactsResource (SyncAPIResource ):
29- """Create, update, and manage customer contact lists"""
32+ """The people you message, and their channel identities.
33+
34+ A contact holds one identity per channel — a phone number, a WhatsApp number — so routing can choose between them for the same person. Opt-out is recorded against the contact and honoured on every send, whichever channel it came through.
35+
36+ `GET /v3/contacts/{id}/message-summary` is the per-contact view of what you have sent and what happened to it.
37+ """
3038
3139 @cached_property
3240 def with_raw_response (self ) -> ContactsResourceWithRawResponse :
@@ -60,7 +68,7 @@ def create(
6068 extra_query : Query | None = None ,
6169 extra_body : Body | None = None ,
6270 timeout : float | httpx .Timeout | None | NotGiven = not_given ,
63- ) -> APIResponseOfContact :
71+ ) -> ContactCreateResponse :
6472 """
6573 Creates a new contact by phone number and associates it with the authenticated
6674 customer.
@@ -100,7 +108,7 @@ def create(
100108 options = make_request_options (
101109 extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
102110 ),
103- cast_to = APIResponseOfContact ,
111+ cast_to = ContactCreateResponse ,
104112 )
105113
106114 def retrieve (
@@ -114,7 +122,7 @@ def retrieve(
114122 extra_query : Query | None = None ,
115123 extra_body : Body | None = None ,
116124 timeout : float | httpx .Timeout | None | NotGiven = not_given ,
117- ) -> APIResponseOfContact :
125+ ) -> ContactRetrieveResponse :
118126 """Retrieves a specific contact by their unique identifier.
119127
120128 Returns detailed
@@ -138,7 +146,7 @@ def retrieve(
138146 options = make_request_options (
139147 extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
140148 ),
141- cast_to = APIResponseOfContact ,
149+ cast_to = ContactRetrieveResponse ,
142150 )
143151
144152 def update (
@@ -156,11 +164,9 @@ def update(
156164 extra_query : Query | None = None ,
157165 extra_body : Body | None = None ,
158166 timeout : float | httpx .Timeout | None | NotGiven = not_given ,
159- ) -> APIResponseOfContact :
160- """Updates a contact's default channel and/or opt-out status.
161-
162- Inherited contacts
163- cannot be updated.
167+ ) -> ContactUpdateResponse :
168+ """
169+ Updates a contact's default channel and/or opt-out status.
164170
165171 Args:
166172 default_channel: Default messaging channel: "sms" or "whatsapp"
@@ -203,7 +209,7 @@ def update(
203209 options = make_request_options (
204210 extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
205211 ),
206- cast_to = APIResponseOfContact ,
212+ cast_to = ContactUpdateResponse ,
207213 )
208214
209215 def list (
@@ -268,6 +274,7 @@ def list(
268274 cast_to = ContactListResponse ,
269275 )
270276
277+ @typing_extensions .deprecated ("deprecated" )
271278 def delete (
272279 self ,
273280 id : str ,
@@ -281,10 +288,17 @@ def delete(
281288 extra_body : Body | None = None ,
282289 timeout : float | httpx .Timeout | None | NotGiven = not_given ,
283290 ) -> None :
284- """Dissociates a contact from the authenticated customer.
291+ """
292+ **Deprecated.** Use `PATCH /v3/contacts/{id}` with `{"opt_out": true}` instead,
293+ and expect this to be removed in a future release. It still behaves exactly as
294+ before, so nothing needs to change today.
295+
296+ Opting a contact out stops every send to them, which is what deleting one was
297+ mostly used for — and it keeps the record of who they were and that they asked.
298+ A delete discards the consent history along with the contact, which is the part
299+ you need if anyone ever asks why you stopped, or why you started again.
285300
286- Inherited contacts cannot
287- be deleted.
301+ Dissociates a contact from the authenticated customer.
288302
289303 Args:
290304 sandbox: Sandbox flag - when true, the operation is simulated without side effects Useful
@@ -322,7 +336,7 @@ def retrieve_message_summary(
322336 extra_query : Query | None = None ,
323337 extra_body : Body | None = None ,
324338 timeout : float | httpx .Timeout | None | NotGiven = not_given ,
325- ) -> APIResponseOfContactMessageSummary :
339+ ) -> ContactRetrieveMessageSummaryResponse :
326340 """
327341 Returns aggregate message counts, time bounds, channels used, and per-channel
328342 success/fail scores (each as a percentage 0-100 of messages on that channel) for
@@ -346,12 +360,17 @@ def retrieve_message_summary(
346360 options = make_request_options (
347361 extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
348362 ),
349- cast_to = APIResponseOfContactMessageSummary ,
363+ cast_to = ContactRetrieveMessageSummaryResponse ,
350364 )
351365
352366
353367class AsyncContactsResource (AsyncAPIResource ):
354- """Create, update, and manage customer contact lists"""
368+ """The people you message, and their channel identities.
369+
370+ A contact holds one identity per channel — a phone number, a WhatsApp number — so routing can choose between them for the same person. Opt-out is recorded against the contact and honoured on every send, whichever channel it came through.
371+
372+ `GET /v3/contacts/{id}/message-summary` is the per-contact view of what you have sent and what happened to it.
373+ """
355374
356375 @cached_property
357376 def with_raw_response (self ) -> AsyncContactsResourceWithRawResponse :
@@ -385,7 +404,7 @@ async def create(
385404 extra_query : Query | None = None ,
386405 extra_body : Body | None = None ,
387406 timeout : float | httpx .Timeout | None | NotGiven = not_given ,
388- ) -> APIResponseOfContact :
407+ ) -> ContactCreateResponse :
389408 """
390409 Creates a new contact by phone number and associates it with the authenticated
391410 customer.
@@ -425,7 +444,7 @@ async def create(
425444 options = make_request_options (
426445 extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
427446 ),
428- cast_to = APIResponseOfContact ,
447+ cast_to = ContactCreateResponse ,
429448 )
430449
431450 async def retrieve (
@@ -439,7 +458,7 @@ async def retrieve(
439458 extra_query : Query | None = None ,
440459 extra_body : Body | None = None ,
441460 timeout : float | httpx .Timeout | None | NotGiven = not_given ,
442- ) -> APIResponseOfContact :
461+ ) -> ContactRetrieveResponse :
443462 """Retrieves a specific contact by their unique identifier.
444463
445464 Returns detailed
@@ -463,7 +482,7 @@ async def retrieve(
463482 options = make_request_options (
464483 extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
465484 ),
466- cast_to = APIResponseOfContact ,
485+ cast_to = ContactRetrieveResponse ,
467486 )
468487
469488 async def update (
@@ -481,11 +500,9 @@ async def update(
481500 extra_query : Query | None = None ,
482501 extra_body : Body | None = None ,
483502 timeout : float | httpx .Timeout | None | NotGiven = not_given ,
484- ) -> APIResponseOfContact :
485- """Updates a contact's default channel and/or opt-out status.
486-
487- Inherited contacts
488- cannot be updated.
503+ ) -> ContactUpdateResponse :
504+ """
505+ Updates a contact's default channel and/or opt-out status.
489506
490507 Args:
491508 default_channel: Default messaging channel: "sms" or "whatsapp"
@@ -528,7 +545,7 @@ async def update(
528545 options = make_request_options (
529546 extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
530547 ),
531- cast_to = APIResponseOfContact ,
548+ cast_to = ContactUpdateResponse ,
532549 )
533550
534551 async def list (
@@ -593,6 +610,7 @@ async def list(
593610 cast_to = ContactListResponse ,
594611 )
595612
613+ @typing_extensions .deprecated ("deprecated" )
596614 async def delete (
597615 self ,
598616 id : str ,
@@ -606,10 +624,17 @@ async def delete(
606624 extra_body : Body | None = None ,
607625 timeout : float | httpx .Timeout | None | NotGiven = not_given ,
608626 ) -> None :
609- """Dissociates a contact from the authenticated customer.
627+ """
628+ **Deprecated.** Use `PATCH /v3/contacts/{id}` with `{"opt_out": true}` instead,
629+ and expect this to be removed in a future release. It still behaves exactly as
630+ before, so nothing needs to change today.
631+
632+ Opting a contact out stops every send to them, which is what deleting one was
633+ mostly used for — and it keeps the record of who they were and that they asked.
634+ A delete discards the consent history along with the contact, which is the part
635+ you need if anyone ever asks why you stopped, or why you started again.
610636
611- Inherited contacts cannot
612- be deleted.
637+ Dissociates a contact from the authenticated customer.
613638
614639 Args:
615640 sandbox: Sandbox flag - when true, the operation is simulated without side effects Useful
@@ -647,7 +672,7 @@ async def retrieve_message_summary(
647672 extra_query : Query | None = None ,
648673 extra_body : Body | None = None ,
649674 timeout : float | httpx .Timeout | None | NotGiven = not_given ,
650- ) -> APIResponseOfContactMessageSummary :
675+ ) -> ContactRetrieveMessageSummaryResponse :
651676 """
652677 Returns aggregate message counts, time bounds, channels used, and per-channel
653678 success/fail scores (each as a percentage 0-100 of messages on that channel) for
@@ -671,7 +696,7 @@ async def retrieve_message_summary(
671696 options = make_request_options (
672697 extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
673698 ),
674- cast_to = APIResponseOfContactMessageSummary ,
699+ cast_to = ContactRetrieveMessageSummaryResponse ,
675700 )
676701
677702
@@ -691,8 +716,10 @@ def __init__(self, contacts: ContactsResource) -> None:
691716 self .list = to_raw_response_wrapper (
692717 contacts .list ,
693718 )
694- self .delete = to_raw_response_wrapper (
695- contacts .delete ,
719+ self .delete = ( # pyright: ignore[reportDeprecated]
720+ to_raw_response_wrapper (
721+ contacts .delete , # pyright: ignore[reportDeprecated],
722+ )
696723 )
697724 self .retrieve_message_summary = to_raw_response_wrapper (
698725 contacts .retrieve_message_summary ,
@@ -715,8 +742,10 @@ def __init__(self, contacts: AsyncContactsResource) -> None:
715742 self .list = async_to_raw_response_wrapper (
716743 contacts .list ,
717744 )
718- self .delete = async_to_raw_response_wrapper (
719- contacts .delete ,
745+ self .delete = ( # pyright: ignore[reportDeprecated]
746+ async_to_raw_response_wrapper (
747+ contacts .delete , # pyright: ignore[reportDeprecated],
748+ )
720749 )
721750 self .retrieve_message_summary = async_to_raw_response_wrapper (
722751 contacts .retrieve_message_summary ,
@@ -739,8 +768,10 @@ def __init__(self, contacts: ContactsResource) -> None:
739768 self .list = to_streamed_response_wrapper (
740769 contacts .list ,
741770 )
742- self .delete = to_streamed_response_wrapper (
743- contacts .delete ,
771+ self .delete = ( # pyright: ignore[reportDeprecated]
772+ to_streamed_response_wrapper (
773+ contacts .delete , # pyright: ignore[reportDeprecated],
774+ )
744775 )
745776 self .retrieve_message_summary = to_streamed_response_wrapper (
746777 contacts .retrieve_message_summary ,
@@ -763,8 +794,10 @@ def __init__(self, contacts: AsyncContactsResource) -> None:
763794 self .list = async_to_streamed_response_wrapper (
764795 contacts .list ,
765796 )
766- self .delete = async_to_streamed_response_wrapper (
767- contacts .delete ,
797+ self .delete = ( # pyright: ignore[reportDeprecated]
798+ async_to_streamed_response_wrapper (
799+ contacts .delete , # pyright: ignore[reportDeprecated],
800+ )
768801 )
769802 self .retrieve_message_summary = async_to_streamed_response_wrapper (
770803 contacts .retrieve_message_summary ,
0 commit comments