diff --git a/CHANGES.md b/CHANGES.md index b76a6331b..bdff14792 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,12 @@ twilio-python Changelog Here you can see the full list of changes between each twilio-python release. +[2024-06-21] Version 9.2.1 +-------------------------- +**Api** +- Add beta feature request managed cert + + [2024-06-18] Version 9.2.0 -------------------------- **Library - Chore** diff --git a/twilio/rest/content/v1/content/__init__.py b/twilio/rest/content/v1/content/__init__.py index 8a1c4212d..6dd0978f3 100644 --- a/twilio/rest/content/v1/content/__init__.py +++ b/twilio/rest/content/v1/content/__init__.py @@ -25,6 +25,22 @@ class ContentInstance(InstanceResource): + + class AuthenticationActionType(object): + COPY_CODE = "COPY_CODE" + + class CallToActionActionType(object): + URL = "URL" + PHONE_NUMBER = "PHONE_NUMBER" + + class CardActionType(object): + URL = "URL" + PHONE_NUMBER = "PHONE_NUMBER" + QUICK_REPLY = "QUICK_REPLY" + + class QuickReplyActionType(object): + QUICK_REPLY = "QUICK_REPLY" + """ :ivar date_created: The date and time in GMT that the resource was created specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. :ivar date_updated: The date and time in GMT that the resource was last updated specified in [RFC 2822](https://www.ietf.org/rfc/rfc2822.txt) format. @@ -33,7 +49,7 @@ class ContentInstance(InstanceResource): :ivar friendly_name: A string name used to describe the Content resource. Not visible to the end recipient. :ivar language: Two-letter (ISO 639-1) language code (e.g., en) identifying the language the Content resource is in. :ivar variables: Defines the default placeholder values for variables included in the Content resource. e.g. {\"1\": \"Customer_Name\"}. - :ivar types: The [Content types](https://www.twilio.com/docs/content/content-types-overview) (e.g. twilio/text) for this Content resource. + :ivar types: The [Content types](https://www.twilio.com/docs/content-api/content-types-overview) (e.g. twilio/text) for this Content resource. :ivar url: The URL of the resource, relative to `https://content.twilio.com`. :ivar links: A list of links related to the Content resource, such as approval_fetch and approval_create """ @@ -275,6 +291,451 @@ def __repr__(self) -> str: class ContentList(ListResource): + class AuthenticationAction(object): + """ + :ivar type: + :ivar copy_code_text: + """ + + def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + + self.type: Optional["ContentInstance.AuthenticationActionType"] = ( + payload.get("type") + ) + self.copy_code_text: Optional[str] = payload.get("copy_code_text") + + def to_dict(self): + return { + "type": self.type.to_dict(), + "copy_code_text": self.copy_code_text, + } + + class CallToActionAction(object): + """ + :ivar type: + :ivar title: + :ivar url: + :ivar phone: + :ivar id: + """ + + def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + + self.type: Optional["ContentInstance.CallToActionActionType"] = payload.get( + "type" + ) + self.title: Optional[str] = payload.get("title") + self.url: Optional[str] = payload.get("url") + self.phone: Optional[str] = payload.get("phone") + self.id: Optional[str] = payload.get("id") + + def to_dict(self): + return { + "type": self.type.to_dict(), + "title": self.title, + "url": self.url, + "phone": self.phone, + "id": self.id, + } + + class CardAction(object): + """ + :ivar type: + :ivar title: + :ivar url: + :ivar phone: + :ivar id: + """ + + def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + + self.type: Optional["ContentInstance.CardActionType"] = payload.get("type") + self.title: Optional[str] = payload.get("title") + self.url: Optional[str] = payload.get("url") + self.phone: Optional[str] = payload.get("phone") + self.id: Optional[str] = payload.get("id") + + def to_dict(self): + return { + "type": self.type.to_dict(), + "title": self.title, + "url": self.url, + "phone": self.phone, + "id": self.id, + } + + class CatalogItem(object): + """ + :ivar id: + :ivar section_title: + :ivar name: + :ivar media_url: + :ivar price: + :ivar description: + """ + + def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + + self.id: Optional[str] = payload.get("id") + self.section_title: Optional[str] = payload.get("section_title") + self.name: Optional[str] = payload.get("name") + self.media_url: Optional[str] = payload.get("media_url") + self.price: Optional[float] = payload.get("price") + self.description: Optional[str] = payload.get("description") + + def to_dict(self): + return { + "id": self.id, + "section_title": self.section_title, + "name": self.name, + "media_url": self.media_url, + "price": self.price, + "description": self.description, + } + + class ContentCreateRequest(object): + """ + :ivar friendly_name: User defined name of the content + :ivar variables: Key value pairs of variable name to value + :ivar language: Language code for the content + :ivar types: + """ + + def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.variables: Optional[dict[str, str]] = payload.get("variables") + self.language: Optional[str] = payload.get("language") + self.types: Optional[ContentList.Types] = payload.get("types") + + def to_dict(self): + return { + "friendly_name": self.friendly_name, + "variables": self.variables, + "language": self.language, + "types": self.types.to_dict(), + } + + class ListItem(object): + """ + :ivar id: + :ivar item: + :ivar description: + """ + + def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + + self.id: Optional[str] = payload.get("id") + self.item: Optional[str] = payload.get("item") + self.description: Optional[str] = payload.get("description") + + def to_dict(self): + return { + "id": self.id, + "item": self.item, + "description": self.description, + } + + class QuickReplyAction(object): + """ + :ivar type: + :ivar title: + :ivar id: + """ + + def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + + self.type: Optional["ContentInstance.QuickReplyActionType"] = payload.get( + "type" + ) + self.title: Optional[str] = payload.get("title") + self.id: Optional[str] = payload.get("id") + + def to_dict(self): + return { + "type": self.type.to_dict(), + "title": self.title, + "id": self.id, + } + + class TwilioCallToAction(object): + """ + :ivar body: + :ivar actions: + """ + + def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + + self.body: Optional[str] = payload.get("body") + self.actions: Optional[List[ContentList.CallToActionAction]] = payload.get( + "actions" + ) + + def to_dict(self): + return { + "body": self.body, + "actions": [actions.to_dict() for actions in self.actions], + } + + class TwilioCard(object): + """ + :ivar title: + :ivar subtitle: + :ivar media: + :ivar actions: + """ + + def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + + self.title: Optional[str] = payload.get("title") + self.subtitle: Optional[str] = payload.get("subtitle") + self.media: Optional[List[str]] = payload.get("media") + self.actions: Optional[List[ContentList.CardAction]] = payload.get( + "actions" + ) + + def to_dict(self): + return { + "title": self.title, + "subtitle": self.subtitle, + "media": self.media, + "actions": [actions.to_dict() for actions in self.actions], + } + + class TwilioCatalog(object): + """ + :ivar title: + :ivar body: + :ivar subtitle: + :ivar id: + :ivar items: + :ivar dynamic_items: + """ + + def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + + self.title: Optional[str] = payload.get("title") + self.body: Optional[str] = payload.get("body") + self.subtitle: Optional[str] = payload.get("subtitle") + self.id: Optional[str] = payload.get("id") + self.items: Optional[List[ContentList.CatalogItem]] = payload.get("items") + self.dynamic_items: Optional[str] = payload.get("dynamic_items") + + def to_dict(self): + return { + "title": self.title, + "body": self.body, + "subtitle": self.subtitle, + "id": self.id, + "items": [items.to_dict() for items in self.items], + "dynamic_items": self.dynamic_items, + } + + class TwilioListPicker(object): + """ + :ivar body: + :ivar button: + :ivar items: + """ + + def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + + self.body: Optional[str] = payload.get("body") + self.button: Optional[str] = payload.get("button") + self.items: Optional[List[ContentList.ListItem]] = payload.get("items") + + def to_dict(self): + return { + "body": self.body, + "button": self.button, + "items": [items.to_dict() for items in self.items], + } + + class TwilioLocation(object): + """ + :ivar latitude: + :ivar longitude: + :ivar label: + """ + + def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + + self.latitude: Optional[float] = payload.get("latitude") + self.longitude: Optional[float] = payload.get("longitude") + self.label: Optional[str] = payload.get("label") + + def to_dict(self): + return { + "latitude": self.latitude, + "longitude": self.longitude, + "label": self.label, + } + + class TwilioMedia(object): + """ + :ivar body: + :ivar media: + """ + + def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + + self.body: Optional[str] = payload.get("body") + self.media: Optional[List[str]] = payload.get("media") + + def to_dict(self): + return { + "body": self.body, + "media": self.media, + } + + class TwilioQuickReply(object): + """ + :ivar body: + :ivar actions: + """ + + def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + + self.body: Optional[str] = payload.get("body") + self.actions: Optional[List[ContentList.QuickReplyAction]] = payload.get( + "actions" + ) + + def to_dict(self): + return { + "body": self.body, + "actions": [actions.to_dict() for actions in self.actions], + } + + class TwilioText(object): + """ + :ivar body: + """ + + def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + + self.body: Optional[str] = payload.get("body") + + def to_dict(self): + return { + "body": self.body, + } + + class Types(object): + """ + :ivar twilio_text: + :ivar twilio_media: + :ivar twilio_location: + :ivar twilio_list_picker: + :ivar twilio_call_to_action: + :ivar twilio_quick_reply: + :ivar twilio_card: + :ivar twilio_catalog: + :ivar whatsapp_card: + :ivar whatsapp_authentication: + """ + + def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + + self.twilio_text: Optional[ContentList.TwilioText] = payload.get( + "twilio_text" + ) + self.twilio_media: Optional[ContentList.TwilioMedia] = payload.get( + "twilio_media" + ) + self.twilio_location: Optional[ContentList.TwilioLocation] = payload.get( + "twilio_location" + ) + self.twilio_list_picker: Optional[ContentList.TwilioListPicker] = ( + payload.get("twilio_list_picker") + ) + self.twilio_call_to_action: Optional[ContentList.TwilioCallToAction] = ( + payload.get("twilio_call_to_action") + ) + self.twilio_quick_reply: Optional[ContentList.TwilioQuickReply] = ( + payload.get("twilio_quick_reply") + ) + self.twilio_card: Optional[ContentList.TwilioCard] = payload.get( + "twilio_card" + ) + self.twilio_catalog: Optional[ContentList.TwilioCatalog] = payload.get( + "twilio_catalog" + ) + self.whatsapp_card: Optional[ContentList.WhatsappCard] = payload.get( + "whatsapp_card" + ) + self.whatsapp_authentication: Optional[ + ContentList.WhatsappAuthentication + ] = payload.get("whatsapp_authentication") + + def to_dict(self): + return { + "twilio_text": self.twilio_text.to_dict(), + "twilio_media": self.twilio_media.to_dict(), + "twilio_location": self.twilio_location.to_dict(), + "twilio_list_picker": self.twilio_list_picker.to_dict(), + "twilio_call_to_action": self.twilio_call_to_action.to_dict(), + "twilio_quick_reply": self.twilio_quick_reply.to_dict(), + "twilio_card": self.twilio_card.to_dict(), + "twilio_catalog": self.twilio_catalog.to_dict(), + "whatsapp_card": self.whatsapp_card.to_dict(), + "whatsapp_authentication": self.whatsapp_authentication.to_dict(), + } + + class WhatsappAuthentication(object): + """ + :ivar add_security_recommendation: + :ivar code_expiration_minutes: + :ivar actions: + """ + + def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + + self.add_security_recommendation: Optional[bool] = payload.get( + "add_security_recommendation" + ) + self.code_expiration_minutes: Optional[float] = payload.get( + "code_expiration_minutes" + ) + self.actions: Optional[List[ContentList.AuthenticationAction]] = ( + payload.get("actions") + ) + + def to_dict(self): + return { + "add_security_recommendation": self.add_security_recommendation, + "code_expiration_minutes": self.code_expiration_minutes, + "actions": [actions.to_dict() for actions in self.actions], + } + + class WhatsappCard(object): + """ + :ivar body: + :ivar footer: + :ivar media: + :ivar header_text: + :ivar actions: + """ + + def __init__(self, payload: Dict[str, Any], sid: Optional[str] = None): + + self.body: Optional[str] = payload.get("body") + self.footer: Optional[str] = payload.get("footer") + self.media: Optional[List[str]] = payload.get("media") + self.header_text: Optional[str] = payload.get("header_text") + self.actions: Optional[List[ContentList.CardAction]] = payload.get( + "actions" + ) + + def to_dict(self): + return { + "body": self.body, + "footer": self.footer, + "media": self.media, + "header_text": self.header_text, + "actions": [actions.to_dict() for actions in self.actions], + } + def __init__(self, version: Version): """ Initialize the ContentList @@ -286,15 +747,15 @@ def __init__(self, version: Version): self._uri = "/Content" - def create(self, body: Union[object, object] = values.unset) -> ContentInstance: + def create(self, content_create_request: ContentCreateRequest) -> ContentInstance: """ Create the ContentInstance - :param body: + :param content_create_request: :returns: The created ContentInstance """ - data = body.to_dict() + data = content_create_request.to_dict() headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) headers["Content-Type"] = "application/json" @@ -306,16 +767,16 @@ def create(self, body: Union[object, object] = values.unset) -> ContentInstance: return ContentInstance(self._version, payload) async def create_async( - self, body: Union[object, object] = values.unset + self, content_create_request: ContentCreateRequest ) -> ContentInstance: """ Asynchronously create the ContentInstance - :param body: + :param content_create_request: :returns: The created ContentInstance """ - data = body.to_dict() + data = content_create_request.to_dict() headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) headers["Content-Type"] = "application/json" diff --git a/twilio/rest/content/v1/content/approval_create.py b/twilio/rest/content/v1/content/approval_create.py index 137c0a6d0..6e28052e0 100644 --- a/twilio/rest/content/v1/content/approval_create.py +++ b/twilio/rest/content/v1/content/approval_create.py @@ -12,7 +12,7 @@ Do not edit the class manually. """ -from typing import Any, Dict, Optional, Union +from typing import Any, Dict, Optional from twilio.base import values from twilio.base.instance_resource import InstanceResource @@ -30,7 +30,7 @@ class ApprovalCreateInstance(InstanceResource): :ivar allow_category_change: """ - def __init__(self, version: Version, payload: Dict[str, Any], sid: str): + def __init__(self, version: Version, payload: Dict[str, Any], content_sid: str): super().__init__(version) self.name: Optional[str] = payload.get("name") @@ -43,7 +43,7 @@ def __init__(self, version: Version, payload: Dict[str, Any], sid: str): ) self._solution = { - "sid": sid, + "content_sid": content_sid, } def __repr__(self) -> str: @@ -58,33 +58,52 @@ def __repr__(self) -> str: class ApprovalCreateList(ListResource): - def __init__(self, version: Version, sid: str): + class ContentApprovalRequest(object): + """ + :ivar name: Name of the template. + :ivar category: A WhatsApp recognized template category. + """ + + def __init__(self, payload: Dict[str, Any], content_sid: str): + + self.name: Optional[str] = payload.get("name") + self.category: Optional[str] = payload.get("category") + + def to_dict(self): + return { + "name": self.name, + "category": self.category, + } + + def __init__(self, version: Version, content_sid: str): """ Initialize the ApprovalCreateList :param version: Version that contains the resource - :param sid: + :param content_sid: """ super().__init__(version) # Path Solution self._solution = { - "sid": sid, + "content_sid": content_sid, } - self._uri = "/Content/{sid}/ApprovalRequests/whatsapp".format(**self._solution) + self._uri = "/Content/{content_sid}/ApprovalRequests/whatsapp".format( + **self._solution + ) def create( - self, body: Union[object, object] = values.unset + self, content_approval_request: ContentApprovalRequest ) -> ApprovalCreateInstance: """ Create the ApprovalCreateInstance - :param body: + :param content_approval_request: :returns: The created ApprovalCreateInstance """ - data = body.to_dict() + data = content_approval_request.to_dict() headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) headers["Content-Type"] = "application/json" @@ -93,19 +112,21 @@ def create( method="POST", uri=self._uri, data=data, headers=headers ) - return ApprovalCreateInstance(self._version, payload, sid=self._solution["sid"]) + return ApprovalCreateInstance( + self._version, payload, content_sid=self._solution["content_sid"] + ) async def create_async( - self, body: Union[object, object] = values.unset + self, content_approval_request: ContentApprovalRequest ) -> ApprovalCreateInstance: """ Asynchronously create the ApprovalCreateInstance - :param body: + :param content_approval_request: :returns: The created ApprovalCreateInstance """ - data = body.to_dict() + data = content_approval_request.to_dict() headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) headers["Content-Type"] = "application/json" @@ -114,7 +135,9 @@ async def create_async( method="POST", uri=self._uri, data=data, headers=headers ) - return ApprovalCreateInstance(self._version, payload, sid=self._solution["sid"]) + return ApprovalCreateInstance( + self._version, payload, content_sid=self._solution["content_sid"] + ) def __repr__(self) -> str: """ diff --git a/twilio/rest/content/v1/content/approval_fetch.py b/twilio/rest/content/v1/content/approval_fetch.py index f35ef6a48..f679a920a 100644 --- a/twilio/rest/content/v1/content/approval_fetch.py +++ b/twilio/rest/content/v1/content/approval_fetch.py @@ -27,7 +27,7 @@ class ApprovalFetchInstance(InstanceResource): :ivar url: The URL of the resource, relative to `https://content.twilio.com`. """ - def __init__(self, version: Version, payload: Dict[str, Any], sid: str): + def __init__(self, version: Version, payload: Dict[str, Any], content_sid: str): super().__init__(version) self.sid: Optional[str] = payload.get("sid") @@ -36,7 +36,7 @@ def __init__(self, version: Version, payload: Dict[str, Any], sid: str): self.url: Optional[str] = payload.get("url") self._solution = { - "sid": sid, + "content_sid": content_sid, } self._context: Optional[ApprovalFetchContext] = None @@ -51,7 +51,7 @@ def _proxy(self) -> "ApprovalFetchContext": if self._context is None: self._context = ApprovalFetchContext( self._version, - sid=self._solution["sid"], + content_sid=self._solution["content_sid"], ) return self._context @@ -85,20 +85,20 @@ def __repr__(self) -> str: class ApprovalFetchContext(InstanceContext): - def __init__(self, version: Version, sid: str): + def __init__(self, version: Version, content_sid: str): """ Initialize the ApprovalFetchContext :param version: Version that contains the resource - :param sid: The Twilio-provided string that uniquely identifies the Content resource whose approval information to fetch. + :param content_sid: The Twilio-provided string that uniquely identifies the Content resource whose approval information to fetch. """ super().__init__(version) # Path Solution self._solution = { - "sid": sid, + "content_sid": content_sid, } - self._uri = "/Content/{sid}/ApprovalRequests".format(**self._solution) + self._uri = "/Content/{content_sid}/ApprovalRequests".format(**self._solution) def fetch(self) -> ApprovalFetchInstance: """ @@ -116,7 +116,7 @@ def fetch(self) -> ApprovalFetchInstance: return ApprovalFetchInstance( self._version, payload, - sid=self._solution["sid"], + content_sid=self._solution["content_sid"], ) async def fetch_async(self) -> ApprovalFetchInstance: @@ -135,7 +135,7 @@ async def fetch_async(self) -> ApprovalFetchInstance: return ApprovalFetchInstance( self._version, payload, - sid=self._solution["sid"], + content_sid=self._solution["content_sid"], ) def __repr__(self) -> str: @@ -150,19 +150,19 @@ def __repr__(self) -> str: class ApprovalFetchList(ListResource): - def __init__(self, version: Version, sid: str): + def __init__(self, version: Version, content_sid: str): """ Initialize the ApprovalFetchList :param version: Version that contains the resource - :param sid: The Twilio-provided string that uniquely identifies the Content resource whose approval information to fetch. + :param content_sid: The Twilio-provided string that uniquely identifies the Content resource whose approval information to fetch. """ super().__init__(version) # Path Solution self._solution = { - "sid": sid, + "content_sid": content_sid, } def get(self) -> ApprovalFetchContext: @@ -170,14 +170,18 @@ def get(self) -> ApprovalFetchContext: Constructs a ApprovalFetchContext """ - return ApprovalFetchContext(self._version, sid=self._solution["sid"]) + return ApprovalFetchContext( + self._version, content_sid=self._solution["content_sid"] + ) def __call__(self) -> ApprovalFetchContext: """ Constructs a ApprovalFetchContext """ - return ApprovalFetchContext(self._version, sid=self._solution["sid"]) + return ApprovalFetchContext( + self._version, content_sid=self._solution["content_sid"] + ) def __repr__(self) -> str: """