diff --git a/CHANGES.md b/CHANGES.md index d7b92d664..a03e6dcee 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,82 @@ twilio-python Changelog Here you can see the full list of changes between each twilio-python release. +[2026-10-12] Version 9.12.0 +--------------------------- +**Audiences** +- ## 2026-10-06 +- Minor updates (formatting, metadata) +- ## 2026-10-05 +- Minor updates (formatting, metadata) +- ## 2026-10-02 +- **Added 1 new path(s)**: +- `/preview/Cohorts/{cohortId}/Operations` (AdminListCohortOperations) +- ## 2026-10-01 +- **Content updates**: +- Updated description for `AdminListSnapshotOperations` +- ## 2026-09-28 +- **Content updates**: +- Updated description for `AdminListCohortSnapshots` +- Updated description for `AdminFetchCohortSnapshot` +- Updated schema description for `Criteria` +- Added properties to `OperationPayload`: cohortId +- Removed properties from `OperationPayload`: audienceId +- Updated schema description for `OperationResult` +- Added properties to `OperationResult`: cohortId +- Removed properties from `OperationResult`: audienceId +- Updated schema description for `Record` +- Updated schema description for `Cohort` +- ...and 3 more changes +- ## 2026-10-01 +- Minor updates (formatting, metadata) +- ## 2026-09-28 +- **Content updates**: +- Updated schema description for `CohortOperationResult` +- Updated schema description for `PartitionCount` + +**Conversations** +- Add PATCH /v2/Imports/{id} to cancel an import, and the `CANCELED` import status (dev-us1 and stage-us1) +- Add Imports endpoints for 1console (private visibility, dev-us1 and stage-us1) +- Add `traitExtractionStrategyIds` and `observationExtractionStrategyIds` to the Conversations v2 Admin Configuration schema. +- Align the Conversations v2 Capabilities list and create contracts with the backend `domainId` field. + +**Data-ingress** +- ## 2026-10-01 +- Minor updates (formatting, metadata) +- ## 2026-09-17 +- Add support for Hubspot connector +- ## 2026-10-01 +- Minor updates (formatting, metadata) +- ## 2026-09-17 +- Add support for Hubspot connector + +**Events** +- Remove the Replays API (`/v1/Replays`, beta feature `api.eventstreams.replay`); the feature was never GA and is being sunset **(breaking change)** + +**Knowledge** +- ## 2026-09-24 +- **Routing updates**: +- Changed `downstreamServiceName` from `memora-domain` to `enterprise-knowledge-domain` for all operations + +**Memory** +- ## 2026-09-30 +- The `source` field on observations and conversation summaries, and the `source` filter +- on `ListProfileObservations`, now also accept forward slashes (`/`). The pattern is +- `^[a-zA-Z0-9 _./-]+$`. This is additive and backwards compatible: every previously +- valid value is still accepted. +- `UpdateStore`, `UpdateTraitGroup`, and `UpdateDataMapping` now require a body with at least one property. An empty `{}` gets a 400. + +**Messaging** +- Add opt-out configuration admin endpoints (`GET/PUT/DELETE /v1/Accounts/{AccountSid}/OptOuts/{OptOutSid}/...`) to the messaging admin-api (dev-us1 and stage-us1 only) +- Add create opt-out configuration endpoint (`POST /v1/Accounts/{AccountSid}/OptOuts`) to the messaging admin-api (dev-us1 and stage-us1 only) +- Add update messaging service endpoint (`PUT /v1/Accounts/{AccountSid}/Services/{MessagingServiceSid}`) to the messaging admin-api (dev-us1 and stage-us1 only) +- Enable messaging service add-ons, update messaging service, and opt-out configuration admin endpoints in prod-us1 and prod-ie1 +- Add WhatsApp display name change support to Sender API: `pending_display_name`, `pending_display_name_status` and `pending_display_name_status_date` on fetch, and `display_name_status` on update and partial update + +**Routes** +- Set SDK and docs visibility of `GET`/`POST` `/v3/ShortCodes/{isoCountryCode}/{shortCode}` to `public`, maturity to `ga` + + [2026-09-28] Version 9.11.2 --------------------------- **Twiml** diff --git a/setup.py b/setup.py index 949cb38de..1c9c72eec 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ setup( name="twilio", - version="9.11.2", + version="9.12.0", description="Twilio API client and TwiML generator", author="Twilio", help_center="https://www.twilio.com/help/contact", diff --git a/twilio/__init__.py b/twilio/__init__.py index 3ff49ac6e..c22a33dc3 100644 --- a/twilio/__init__.py +++ b/twilio/__init__.py @@ -1,2 +1,2 @@ -__version_info__ = ("9", "11", "2") +__version_info__ = ("9", "12", "0") __version__ = ".".join(__version_info__) diff --git a/twilio/rest/api/v2010/account/conference/__init__.py b/twilio/rest/api/v2010/account/conference/__init__.py index 9edc8ce21..03cc250b7 100644 --- a/twilio/rest/api/v2010/account/conference/__init__.py +++ b/twilio/rest/api/v2010/account/conference/__init__.py @@ -642,7 +642,7 @@ def stream( :param date date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param date date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param str friendly_name: The string that identifies the Conference resources to read. - :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. + :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. Starting from September 30th, 2026, the default is `in-progress`. To read completed conferences, set `Status` to `completed`. :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param page_size: Number of records to fetch per request, when not set will use @@ -693,7 +693,7 @@ async def stream_async( :param date date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param date date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param str friendly_name: The string that identifies the Conference resources to read. - :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. + :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. Starting from September 30th, 2026, the default is `in-progress`. To read completed conferences, set `Status` to `completed`. :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param page_size: Number of records to fetch per request, when not set will use @@ -742,7 +742,7 @@ def stream_with_http_info( :param date date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param date date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param str friendly_name: The string that identifies the Conference resources to read. - :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. + :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. Starting from September 30th, 2026, the default is `in-progress`. To read completed conferences, set `Status` to `completed`. :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param page_size: Number of records to fetch per request, when not set will use @@ -792,7 +792,7 @@ async def stream_with_http_info_async( :param date date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param date date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param str friendly_name: The string that identifies the Conference resources to read. - :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. + :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. Starting from September 30th, 2026, the default is `in-progress`. To read completed conferences, set `Status` to `completed`. :param limit: Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit :param page_size: Number of records to fetch per request, when not set will use @@ -843,7 +843,7 @@ def list( :param date date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param date date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param str friendly_name: The string that identifies the Conference resources to read. - :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. + :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. Starting from September 30th, 2026, the default is `in-progress`. To read completed conferences, set `Status` to `completed`. :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param page_size: Number of records to fetch per request, when not set will use @@ -894,7 +894,7 @@ async def list_async( :param date date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param date date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param str friendly_name: The string that identifies the Conference resources to read. - :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. + :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. Starting from September 30th, 2026, the default is `in-progress`. To read completed conferences, set `Status` to `completed`. :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param page_size: Number of records to fetch per request, when not set will use @@ -945,7 +945,7 @@ def list_with_http_info( :param date date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param date date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param str friendly_name: The string that identifies the Conference resources to read. - :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. + :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. Starting from September 30th, 2026, the default is `in-progress`. To read completed conferences, set `Status` to `completed`. :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param page_size: Number of records to fetch per request, when not set will use @@ -994,7 +994,7 @@ async def list_with_http_info_async( :param date date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param date date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param str friendly_name: The string that identifies the Conference resources to read. - :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. + :param "ConferenceInstance.Status" status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. Starting from September 30th, 2026, the default is `in-progress`. To read completed conferences, set `Status` to `completed`. :param limit: Upper limit for the number of records to return. list() guarantees never to return more than limit. Default is no limit :param page_size: Number of records to fetch per request, when not set will use @@ -1044,7 +1044,7 @@ def page( :param date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param friendly_name: The string that identifies the Conference resources to read. - :param status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. + :param status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. Starting from September 30th, 2026, the default is `in-progress`. To read completed conferences, set `Status` to `completed`. :param page_token: PageToken provided by the API :param page_number: Page Number, this value is simply for client state :param page_size: Number of records to return, defaults to 50 @@ -1101,7 +1101,7 @@ async def page_async( :param date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param friendly_name: The string that identifies the Conference resources to read. - :param status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. + :param status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. Starting from September 30th, 2026, the default is `in-progress`. To read completed conferences, set `Status` to `completed`. :param page_token: PageToken provided by the API :param page_number: Page Number, this value is simply for client state :param page_size: Number of records to return, defaults to 50 @@ -1158,7 +1158,7 @@ def page_with_http_info( :param date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param friendly_name: The string that identifies the Conference resources to read. - :param status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. + :param status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. Starting from September 30th, 2026, the default is `in-progress`. To read completed conferences, set `Status` to `completed`. :param page_token: PageToken provided by the API :param page_number: Page Number, this value is simply for client state :param page_size: Number of records to return, defaults to 50 @@ -1216,7 +1216,7 @@ async def page_with_http_info_async( :param date_updated_before: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param date_updated_after: Only include conferences that were last updated on this date. Specify a date as `YYYY-MM-DD` in UTC, for example: `2009-07-06`, to read only conferences that were last updated on this date. You can also specify an inequality, such as `DateUpdated<=YYYY-MM-DD`, to read conferences that were last updated on or before midnight of this date, and `DateUpdated>=YYYY-MM-DD` to read conferences that were last updated on or after midnight of this date. :param friendly_name: The string that identifies the Conference resources to read. - :param status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. + :param status: The status of the resources to read. Can be: `init`, `in-progress`, or `completed`. Starting from September 30th, 2026, the default is `in-progress`. To read completed conferences, set `Status` to `completed`. :param page_token: PageToken provided by the API :param page_number: Page Number, this value is simply for client state :param page_size: Number of records to return, defaults to 50 diff --git a/twilio/rest/content/v1/content/__init__.py b/twilio/rest/content/v1/content/__init__.py index c0673c70a..73b512fb6 100644 --- a/twilio/rest/content/v1/content/__init__.py +++ b/twilio/rest/content/v1/content/__init__.py @@ -217,8 +217,8 @@ def __init__(self, payload: Dict[str, Any]): self.language: Optional[str] = payload.get("language") self.types: Optional[ContentList.Types] = ( ContentList.Types(payload.get("types")) - if payload.get("types") is not None - else None + if isinstance(payload.get("types"), dict) + else payload.get("types") ) def to_dict(self): @@ -244,8 +244,8 @@ def __init__(self, payload: Dict[str, Any]): self.language: Optional[str] = payload.get("language") self.types: Optional[ContentList.Types] = ( ContentList.Types(payload.get("types")) - if payload.get("types") is not None - else None + if isinstance(payload.get("types"), dict) + else payload.get("types") ) def to_dict(self): @@ -647,13 +647,13 @@ def __init__(self, payload: Dict[str, Any]): self.id: Optional[str] = payload.get("id") self.title: Optional[str] = payload.get("title") - self.time_slots: Optional[str] = payload.get("timeSlots") + self.time_slots: Optional[str] = payload.get("time_slots") def to_dict(self): return { "id": self.id, "title": self.title, - "timeSlots": self.time_slots, + "time_slots": self.time_slots, } class TwilioText(object): @@ -692,63 +692,63 @@ def __init__(self, payload: Dict[str, Any]): self.twilio_text: Optional[ContentList.TwilioText] = ( ContentList.TwilioText(payload.get("twilio/text")) - if payload.get("twilio/text") is not None - else None + if isinstance(payload.get("twilio/text"), dict) + else payload.get("twilio/text") ) self.twilio_media: Optional[ContentList.TwilioMedia] = ( ContentList.TwilioMedia(payload.get("twilio/media")) - if payload.get("twilio/media") is not None - else None + if isinstance(payload.get("twilio/media"), dict) + else payload.get("twilio/media") ) self.twilio_location: Optional[ContentList.TwilioLocation] = ( ContentList.TwilioLocation(payload.get("twilio/location")) - if payload.get("twilio/location") is not None - else None + if isinstance(payload.get("twilio/location"), dict) + else payload.get("twilio/location") ) self.twilio_list_picker: Optional[ContentList.TwilioListPicker] = ( ContentList.TwilioListPicker(payload.get("twilio/list-picker")) - if payload.get("twilio/list-picker") is not None - else None + if isinstance(payload.get("twilio/list-picker"), dict) + else payload.get("twilio/list-picker") ) self.twilio_call_to_action: Optional[ContentList.TwilioCallToAction] = ( ContentList.TwilioCallToAction(payload.get("twilio/call-to-action")) - if payload.get("twilio/call-to-action") is not None - else None + if isinstance(payload.get("twilio/call-to-action"), dict) + else payload.get("twilio/call-to-action") ) self.twilio_quick_reply: Optional[ContentList.TwilioQuickReply] = ( ContentList.TwilioQuickReply(payload.get("twilio/quick-reply")) - if payload.get("twilio/quick-reply") is not None - else None + if isinstance(payload.get("twilio/quick-reply"), dict) + else payload.get("twilio/quick-reply") ) self.twilio_card: Optional[ContentList.TwilioCard] = ( ContentList.TwilioCard(payload.get("twilio/card")) - if payload.get("twilio/card") is not None - else None + if isinstance(payload.get("twilio/card"), dict) + else payload.get("twilio/card") ) self.twilio_catalog: Optional[ContentList.TwilioCatalog] = ( ContentList.TwilioCatalog(payload.get("twilio/catalog")) - if payload.get("twilio/catalog") is not None - else None + if isinstance(payload.get("twilio/catalog"), dict) + else payload.get("twilio/catalog") ) self.twilio_carousel: Optional[ContentList.TwilioCarousel] = ( ContentList.TwilioCarousel(payload.get("twilio/carousel")) - if payload.get("twilio/carousel") is not None - else None + if isinstance(payload.get("twilio/carousel"), dict) + else payload.get("twilio/carousel") ) self.twilio_flows: Optional[ContentList.TwilioFlows] = ( ContentList.TwilioFlows(payload.get("twilio/flows")) - if payload.get("twilio/flows") is not None - else None + if isinstance(payload.get("twilio/flows"), dict) + else payload.get("twilio/flows") ) self.twilio_schedule: Optional[ContentList.TwilioSchedule] = ( ContentList.TwilioSchedule(payload.get("twilio/schedule")) - if payload.get("twilio/schedule") is not None - else None + if isinstance(payload.get("twilio/schedule"), dict) + else payload.get("twilio/schedule") ) self.whatsapp_card: Optional[ContentList.WhatsappCard] = ( ContentList.WhatsappCard(payload.get("whatsapp/card")) - if payload.get("whatsapp/card") is not None - else None + if isinstance(payload.get("whatsapp/card"), dict) + else payload.get("whatsapp/card") ) self.whatsapp_authentication: Optional[ ContentList.WhatsappAuthentication @@ -756,13 +756,13 @@ def __init__(self, payload: Dict[str, Any]): ContentList.WhatsappAuthentication( payload.get("whatsapp/authentication") ) - if payload.get("whatsapp/authentication") is not None - else None + if isinstance(payload.get("whatsapp/authentication"), dict) + else payload.get("whatsapp/authentication") ) self.whatsapp_flows: Optional[ContentList.WhatsappFlows] = ( ContentList.WhatsappFlows(payload.get("whatsapp/flows")) - if payload.get("whatsapp/flows") is not None - else None + if isinstance(payload.get("whatsapp/flows"), dict) + else payload.get("whatsapp/flows") ) def to_dict(self): @@ -1376,8 +1376,8 @@ def __init__(self, payload: Dict[str, Any]): self.language: Optional[str] = payload.get("language") self.types: Optional[ContentList.Types] = ( ContentList.Types(payload.get("types")) - if payload.get("types") is not None - else None + if isinstance(payload.get("types"), dict) + else payload.get("types") ) def to_dict(self): @@ -1403,8 +1403,8 @@ def __init__(self, payload: Dict[str, Any]): self.language: Optional[str] = payload.get("language") self.types: Optional[ContentList.Types] = ( ContentList.Types(payload.get("types")) - if payload.get("types") is not None - else None + if isinstance(payload.get("types"), dict) + else payload.get("types") ) def to_dict(self): @@ -1806,13 +1806,13 @@ def __init__(self, payload: Dict[str, Any]): self.id: Optional[str] = payload.get("id") self.title: Optional[str] = payload.get("title") - self.time_slots: Optional[str] = payload.get("timeSlots") + self.time_slots: Optional[str] = payload.get("time_slots") def to_dict(self): return { "id": self.id, "title": self.title, - "timeSlots": self.time_slots, + "time_slots": self.time_slots, } class TwilioText(object): @@ -1851,63 +1851,63 @@ def __init__(self, payload: Dict[str, Any]): self.twilio_text: Optional[ContentList.TwilioText] = ( ContentList.TwilioText(payload.get("twilio/text")) - if payload.get("twilio/text") is not None - else None + if isinstance(payload.get("twilio/text"), dict) + else payload.get("twilio/text") ) self.twilio_media: Optional[ContentList.TwilioMedia] = ( ContentList.TwilioMedia(payload.get("twilio/media")) - if payload.get("twilio/media") is not None - else None + if isinstance(payload.get("twilio/media"), dict) + else payload.get("twilio/media") ) self.twilio_location: Optional[ContentList.TwilioLocation] = ( ContentList.TwilioLocation(payload.get("twilio/location")) - if payload.get("twilio/location") is not None - else None + if isinstance(payload.get("twilio/location"), dict) + else payload.get("twilio/location") ) self.twilio_list_picker: Optional[ContentList.TwilioListPicker] = ( ContentList.TwilioListPicker(payload.get("twilio/list-picker")) - if payload.get("twilio/list-picker") is not None - else None + if isinstance(payload.get("twilio/list-picker"), dict) + else payload.get("twilio/list-picker") ) self.twilio_call_to_action: Optional[ContentList.TwilioCallToAction] = ( ContentList.TwilioCallToAction(payload.get("twilio/call-to-action")) - if payload.get("twilio/call-to-action") is not None - else None + if isinstance(payload.get("twilio/call-to-action"), dict) + else payload.get("twilio/call-to-action") ) self.twilio_quick_reply: Optional[ContentList.TwilioQuickReply] = ( ContentList.TwilioQuickReply(payload.get("twilio/quick-reply")) - if payload.get("twilio/quick-reply") is not None - else None + if isinstance(payload.get("twilio/quick-reply"), dict) + else payload.get("twilio/quick-reply") ) self.twilio_card: Optional[ContentList.TwilioCard] = ( ContentList.TwilioCard(payload.get("twilio/card")) - if payload.get("twilio/card") is not None - else None + if isinstance(payload.get("twilio/card"), dict) + else payload.get("twilio/card") ) self.twilio_catalog: Optional[ContentList.TwilioCatalog] = ( ContentList.TwilioCatalog(payload.get("twilio/catalog")) - if payload.get("twilio/catalog") is not None - else None + if isinstance(payload.get("twilio/catalog"), dict) + else payload.get("twilio/catalog") ) self.twilio_carousel: Optional[ContentList.TwilioCarousel] = ( ContentList.TwilioCarousel(payload.get("twilio/carousel")) - if payload.get("twilio/carousel") is not None - else None + if isinstance(payload.get("twilio/carousel"), dict) + else payload.get("twilio/carousel") ) self.twilio_flows: Optional[ContentList.TwilioFlows] = ( ContentList.TwilioFlows(payload.get("twilio/flows")) - if payload.get("twilio/flows") is not None - else None + if isinstance(payload.get("twilio/flows"), dict) + else payload.get("twilio/flows") ) self.twilio_schedule: Optional[ContentList.TwilioSchedule] = ( ContentList.TwilioSchedule(payload.get("twilio/schedule")) - if payload.get("twilio/schedule") is not None - else None + if isinstance(payload.get("twilio/schedule"), dict) + else payload.get("twilio/schedule") ) self.whatsapp_card: Optional[ContentList.WhatsappCard] = ( ContentList.WhatsappCard(payload.get("whatsapp/card")) - if payload.get("whatsapp/card") is not None - else None + if isinstance(payload.get("whatsapp/card"), dict) + else payload.get("whatsapp/card") ) self.whatsapp_authentication: Optional[ ContentList.WhatsappAuthentication @@ -1915,13 +1915,13 @@ def __init__(self, payload: Dict[str, Any]): ContentList.WhatsappAuthentication( payload.get("whatsapp/authentication") ) - if payload.get("whatsapp/authentication") is not None - else None + if isinstance(payload.get("whatsapp/authentication"), dict) + else payload.get("whatsapp/authentication") ) self.whatsapp_flows: Optional[ContentList.WhatsappFlows] = ( ContentList.WhatsappFlows(payload.get("whatsapp/flows")) - if payload.get("whatsapp/flows") is not None - else None + if isinstance(payload.get("whatsapp/flows"), dict) + else payload.get("whatsapp/flows") ) def to_dict(self): @@ -2627,8 +2627,8 @@ def __init__(self, payload: Dict[str, Any]): self.language: Optional[str] = payload.get("language") self.types: Optional[ContentList.Types] = ( ContentList.Types(payload.get("types")) - if payload.get("types") is not None - else None + if isinstance(payload.get("types"), dict) + else payload.get("types") ) def to_dict(self): @@ -2654,8 +2654,8 @@ def __init__(self, payload: Dict[str, Any]): self.language: Optional[str] = payload.get("language") self.types: Optional[ContentList.Types] = ( ContentList.Types(payload.get("types")) - if payload.get("types") is not None - else None + if isinstance(payload.get("types"), dict) + else payload.get("types") ) def to_dict(self): @@ -3057,13 +3057,13 @@ def __init__(self, payload: Dict[str, Any]): self.id: Optional[str] = payload.get("id") self.title: Optional[str] = payload.get("title") - self.time_slots: Optional[str] = payload.get("timeSlots") + self.time_slots: Optional[str] = payload.get("time_slots") def to_dict(self): return { "id": self.id, "title": self.title, - "timeSlots": self.time_slots, + "time_slots": self.time_slots, } class TwilioText(object): @@ -3102,63 +3102,63 @@ def __init__(self, payload: Dict[str, Any]): self.twilio_text: Optional[ContentList.TwilioText] = ( ContentList.TwilioText(payload.get("twilio/text")) - if payload.get("twilio/text") is not None - else None + if isinstance(payload.get("twilio/text"), dict) + else payload.get("twilio/text") ) self.twilio_media: Optional[ContentList.TwilioMedia] = ( ContentList.TwilioMedia(payload.get("twilio/media")) - if payload.get("twilio/media") is not None - else None + if isinstance(payload.get("twilio/media"), dict) + else payload.get("twilio/media") ) self.twilio_location: Optional[ContentList.TwilioLocation] = ( ContentList.TwilioLocation(payload.get("twilio/location")) - if payload.get("twilio/location") is not None - else None + if isinstance(payload.get("twilio/location"), dict) + else payload.get("twilio/location") ) self.twilio_list_picker: Optional[ContentList.TwilioListPicker] = ( ContentList.TwilioListPicker(payload.get("twilio/list-picker")) - if payload.get("twilio/list-picker") is not None - else None + if isinstance(payload.get("twilio/list-picker"), dict) + else payload.get("twilio/list-picker") ) self.twilio_call_to_action: Optional[ContentList.TwilioCallToAction] = ( ContentList.TwilioCallToAction(payload.get("twilio/call-to-action")) - if payload.get("twilio/call-to-action") is not None - else None + if isinstance(payload.get("twilio/call-to-action"), dict) + else payload.get("twilio/call-to-action") ) self.twilio_quick_reply: Optional[ContentList.TwilioQuickReply] = ( ContentList.TwilioQuickReply(payload.get("twilio/quick-reply")) - if payload.get("twilio/quick-reply") is not None - else None + if isinstance(payload.get("twilio/quick-reply"), dict) + else payload.get("twilio/quick-reply") ) self.twilio_card: Optional[ContentList.TwilioCard] = ( ContentList.TwilioCard(payload.get("twilio/card")) - if payload.get("twilio/card") is not None - else None + if isinstance(payload.get("twilio/card"), dict) + else payload.get("twilio/card") ) self.twilio_catalog: Optional[ContentList.TwilioCatalog] = ( ContentList.TwilioCatalog(payload.get("twilio/catalog")) - if payload.get("twilio/catalog") is not None - else None + if isinstance(payload.get("twilio/catalog"), dict) + else payload.get("twilio/catalog") ) self.twilio_carousel: Optional[ContentList.TwilioCarousel] = ( ContentList.TwilioCarousel(payload.get("twilio/carousel")) - if payload.get("twilio/carousel") is not None - else None + if isinstance(payload.get("twilio/carousel"), dict) + else payload.get("twilio/carousel") ) self.twilio_flows: Optional[ContentList.TwilioFlows] = ( ContentList.TwilioFlows(payload.get("twilio/flows")) - if payload.get("twilio/flows") is not None - else None + if isinstance(payload.get("twilio/flows"), dict) + else payload.get("twilio/flows") ) self.twilio_schedule: Optional[ContentList.TwilioSchedule] = ( ContentList.TwilioSchedule(payload.get("twilio/schedule")) - if payload.get("twilio/schedule") is not None - else None + if isinstance(payload.get("twilio/schedule"), dict) + else payload.get("twilio/schedule") ) self.whatsapp_card: Optional[ContentList.WhatsappCard] = ( ContentList.WhatsappCard(payload.get("whatsapp/card")) - if payload.get("whatsapp/card") is not None - else None + if isinstance(payload.get("whatsapp/card"), dict) + else payload.get("whatsapp/card") ) self.whatsapp_authentication: Optional[ ContentList.WhatsappAuthentication @@ -3166,13 +3166,13 @@ def __init__(self, payload: Dict[str, Any]): ContentList.WhatsappAuthentication( payload.get("whatsapp/authentication") ) - if payload.get("whatsapp/authentication") is not None - else None + if isinstance(payload.get("whatsapp/authentication"), dict) + else payload.get("whatsapp/authentication") ) self.whatsapp_flows: Optional[ContentList.WhatsappFlows] = ( ContentList.WhatsappFlows(payload.get("whatsapp/flows")) - if payload.get("whatsapp/flows") is not None - else None + if isinstance(payload.get("whatsapp/flows"), dict) + else payload.get("whatsapp/flows") ) def to_dict(self): diff --git a/twilio/rest/conversations/v2/action.py b/twilio/rest/conversations/v2/action.py index b09e961c2..edc1b95d9 100644 --- a/twilio/rest/conversations/v2/action.py +++ b/twilio/rest/conversations/v2/action.py @@ -41,13 +41,14 @@ class ConversationsV2Channel(object): """ :ivar id: Unique identifier for this Action. - :ivar type: The type of action. Accepted values: SEND_MESSAGE. + :ivar type: The type of action: action-send-message or action-start-flow. :ivar status: :ivar conversation_id: The conversation this action belongs to. - :ivar related: Named identifiers from downstream. For SEND_MESSAGE: - messageSid: The downstream message SID (present when PENDING or COMPLETED) - communicationId: The Communication ID (present when COMPLETED) + :ivar related: Named identifiers from downstream. For SEND_MESSAGE: - messageSid: The downstream message SID (present when PENDING or COMPLETED) - communicationId: The Communication ID (present when COMPLETED) For START_FLOW: - executionSid: The Studio Flow execution SID (present when COMPLETED) :ivar created_at: Timestamp when the action was created. :ivar updated_at: Timestamp when the action was last updated. :ivar completed_at: Timestamp when the action reached a terminal status. + :ivar failure_reason: Human-readable failure reason. Null unless status is FAILED. """ def __init__( @@ -75,6 +76,7 @@ def __init__( self.completed_at: Optional[datetime] = deserialize.iso8601_datetime( payload.get("completedAt") ) + self.failure_reason: Optional[str] = payload.get("failureReason") # Only set _solution if path params are provided (not None) if conversation_id is not None or action_id is not None: @@ -331,8 +333,8 @@ def __init__(self, payload: Dict[str, Any]): self._from: Optional[ActionList.ConversationsV2SendMessageParticipant] = ( ActionList.ConversationsV2SendMessageParticipant(payload.get("from")) - if payload.get("from") is not None - else None + if isinstance(payload.get("from"), dict) + else payload.get("from") ) self.to: Optional[ List[ActionList.ConversationsV2SendMessageParticipant] @@ -350,8 +352,8 @@ def __init__(self, payload: Dict[str, Any]): ) self.content: Optional[ActionList.ConversationsV2SendMessageContent] = ( ActionList.ConversationsV2SendMessageContent(payload.get("content")) - if payload.get("content") is not None - else None + if isinstance(payload.get("content"), dict) + else payload.get("content") ) self.channel_settings: Optional[Dict[str, Dict[str, object]]] = payload.get( "channelSettings" @@ -376,8 +378,8 @@ def __init__(self, payload: Dict[str, Any]): self.type: Optional[str] = payload.get("type") self.payload: Optional[ActionList.ConversationsV2SendMessagePayload] = ( ActionList.ConversationsV2SendMessagePayload(payload.get("payload")) - if payload.get("payload") is not None - else None + if isinstance(payload.get("payload"), dict) + else payload.get("payload") ) def to_dict(self): diff --git a/twilio/rest/conversations/v2/communication.py b/twilio/rest/conversations/v2/communication.py index 299490962..770ef7e76 100644 --- a/twilio/rest/conversations/v2/communication.py +++ b/twilio/rest/conversations/v2/communication.py @@ -389,6 +389,7 @@ class CreateCommunicationInConversationRequest(object): :ivar author: :ivar content: :ivar channel_id: + :ivar resource_id: External resource identifier for this Communication (e.g. MessageSid for SMS/RCS/WhatsApp, TranscriptionSid + MessageIndex for Voice). If a Communication with the same resourceId already exists in the Conversation, it is updated instead of a new one being created. :ivar recipients: :ivar occurred_at: Timestamp when this Communication occurred. If omitted, the server uses the current time. """ @@ -401,8 +402,8 @@ def __init__(self, payload: Dict[str, Any]): CommunicationList.CreateCommunicationInConversationRequestAuthor( payload.get("author") ) - if payload.get("author") is not None - else None + if isinstance(payload.get("author"), dict) + else payload.get("author") ) self.content: Optional[ CommunicationList.CreateCommunicationInConversationRequestContent @@ -410,10 +411,11 @@ def __init__(self, payload: Dict[str, Any]): CommunicationList.CreateCommunicationInConversationRequestContent( payload.get("content") ) - if payload.get("content") is not None - else None + if isinstance(payload.get("content"), dict) + else payload.get("content") ) self.channel_id: Optional[str] = payload.get("channelId") + self.resource_id: Optional[str] = payload.get("resourceId") self.recipients: Optional[ List[ CommunicationList.CreateCommunicationInConversationRequestRecipients @@ -439,6 +441,7 @@ def to_dict(self): "author": self.author.to_dict() if self.author is not None else None, "content": self.content.to_dict() if self.content is not None else None, "channelId": self.channel_id, + "resourceId": self.resource_id, "recipients": ( [recipients.to_dict() for recipients in self.recipients] if self.recipients is not None @@ -484,8 +487,8 @@ def __init__(self, payload: Dict[str, Any]): CommunicationList.ContentTranscriptionTranscription( payload.get("transcription") ) - if payload.get("transcription") is not None - else None + if isinstance(payload.get("transcription"), dict) + else payload.get("transcription") ) def to_dict(self): diff --git a/twilio/rest/conversations/v2/configuration.py b/twilio/rest/conversations/v2/configuration.py index 84a67a9b4..8b17f29c8 100644 --- a/twilio/rest/conversations/v2/configuration.py +++ b/twilio/rest/conversations/v2/configuration.py @@ -35,8 +35,6 @@ class ConversationsV2ConversationGroupingType(object): ) """ - :ivar status_url: URL to poll for operation status. - :ivar related: Named resource identifiers associated with this operation. Keys depend on the operation type: - config-create, config-update, config-delete: configurationId - conversation-delete: conversationId :ivar id: Configuration ID. :ivar display_name: A human-readable name for the configuration. Limited to 32 characters. :ivar description: Human-readable description for the Configuration. Allows spaces and special characters, typically limited to a paragraph of text. This serves as a descriptive field rather than just a name. @@ -45,11 +43,15 @@ class ConversationsV2ConversationGroupingType(object): :ivar channel_settings: Channel-specific configuration settings by channel type. Keys should be valid channel types (`VOICE`, `SMS`, `RCS`, `WHATSAPP`, `CHAT`). :ivar status_callbacks: List of default webhook configurations applied to Conversations under this Configuration. :ivar intelligence_configuration_ids: A list of Conversational Intelligence configuration IDs. + :ivar trait_extraction_strategy_ids: A list of Trait Extraction Strategy IDs. + :ivar observation_extraction_strategy_ids: A list of Observation Extraction Strategy IDs. :ivar memory_extraction_enabled: Whether memory extraction is enabled for conversations under this configuration. Defaults to false. :ivar conversations_v1_bridge: :ivar created_at: Timestamp when this Configuration was created. :ivar updated_at: Timestamp when this Configuration was last updated. :ivar version: Version number used for optimistic locking. + :ivar status_url: URL to poll for operation status. + :ivar related: Named resource identifiers associated with this operation. Keys depend on the operation type: - config-create, config-update, config-delete: configurationId - conversation-delete: conversationId """ def __init__( @@ -57,8 +59,6 @@ def __init__( ): super().__init__(version) - self.status_url: Optional[str] = payload.get("statusUrl") - self.related: Optional[Dict[str, str]] = payload.get("related") self.id: Optional[str] = payload.get("id") self.display_name: Optional[str] = payload.get("displayName") self.description: Optional[str] = payload.get("description") @@ -75,6 +75,12 @@ def __init__( self.intelligence_configuration_ids: Optional[List[str]] = payload.get( "intelligenceConfigurationIds" ) + self.trait_extraction_strategy_ids: Optional[List[str]] = payload.get( + "traitExtractionStrategyIds" + ) + self.observation_extraction_strategy_ids: Optional[List[str]] = payload.get( + "observationExtractionStrategyIds" + ) self.memory_extraction_enabled: Optional[bool] = payload.get( "memoryExtractionEnabled" ) @@ -88,6 +94,8 @@ def __init__( payload.get("updatedAt") ) self.version: Optional[int] = payload.get("version") + self.status_url: Optional[str] = payload.get("statusUrl") + self.related: Optional[Dict[str, str]] = payload.get("related") # Only set _solution if path params are provided (not None) if id is not None: @@ -901,8 +909,8 @@ def __init__(self, payload: Dict[str, Any]): self.status_timeouts: Optional[ConversationsV2StatusTimeouts] = ( ConversationsV2StatusTimeouts(payload.get("statusTimeouts")) - if payload.get("statusTimeouts") is not None - else None + if isinstance(payload.get("statusTimeouts"), dict) + else payload.get("statusTimeouts") ) self.capture_rules: Optional[List[ConversationsV2CaptureRule]] = ( [ @@ -1043,8 +1051,8 @@ def __init__(self, payload: Dict[str, Any]): ConfigurationList.CreateConfigurationRequestConversationsV1Bridge( payload.get("conversationsV1Bridge") ) - if payload.get("conversationsV1Bridge") is not None - else None + if isinstance(payload.get("conversationsV1Bridge"), dict) + else payload.get("conversationsV1Bridge") ) def to_dict(self): @@ -1089,8 +1097,8 @@ def __init__(self, payload: Dict[str, Any]): ConfigurationList.CreateConfigurationRequestChannelSettingsValueStatusTimeouts( payload.get("statusTimeouts") ) - if payload.get("statusTimeouts") is not None - else None + if isinstance(payload.get("statusTimeouts"), dict) + else payload.get("statusTimeouts") ) self.capture_rules: Optional[ List[ @@ -1260,8 +1268,8 @@ def __init__(self, payload: Dict[str, Any]): ConfigurationList.PatchConfigurationRequestConversationsV1Bridge( payload.get("conversationsV1Bridge") ) - if payload.get("conversationsV1Bridge") is not None - else None + if isinstance(payload.get("conversationsV1Bridge"), dict) + else payload.get("conversationsV1Bridge") ) def to_dict(self): @@ -1306,8 +1314,8 @@ def __init__(self, payload: Dict[str, Any]): ConfigurationList.UpdateConfigurationRequestChannelSettingsValueStatusTimeouts( payload.get("statusTimeouts") ) - if payload.get("statusTimeouts") is not None - else None + if isinstance(payload.get("statusTimeouts"), dict) + else payload.get("statusTimeouts") ) self.capture_rules: Optional[ List[ @@ -1424,8 +1432,8 @@ def __init__(self, payload: Dict[str, Any]): ConfigurationList.CreateConfigurationRequestConversationsV1Bridge( payload.get("conversationsV1Bridge") ) - if payload.get("conversationsV1Bridge") is not None - else None + if isinstance(payload.get("conversationsV1Bridge"), dict) + else payload.get("conversationsV1Bridge") ) def to_dict(self): @@ -1470,8 +1478,8 @@ def __init__(self, payload: Dict[str, Any]): ConfigurationList.UpdateConfigurationRequestChannelSettingsValueStatusTimeouts( payload.get("statusTimeouts") ) - if payload.get("statusTimeouts") is not None - else None + if isinstance(payload.get("statusTimeouts"), dict) + else payload.get("statusTimeouts") ) self.capture_rules: Optional[ List[ diff --git a/twilio/rest/conversations/v2/conversation.py b/twilio/rest/conversations/v2/conversation.py index 9b80ae4af..2d3358292 100644 --- a/twilio/rest/conversations/v2/conversation.py +++ b/twilio/rest/conversations/v2/conversation.py @@ -824,8 +824,8 @@ def __init__(self, payload: Dict[str, Any]): self.channel: Optional[ConversationsV2Channel] = ( ConversationsV2Channel(payload.get("channel")) - if payload.get("channel") is not None - else None + if isinstance(payload.get("channel"), dict) + else payload.get("channel") ) self.address: Optional[str] = payload.get("address") self.channel_id: Optional[str] = payload.get("channelId") @@ -887,8 +887,8 @@ def __init__(self, payload: Dict[str, Any]): ConversationList.CreateConversationWithConfigRequestConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) self.participants: Optional[ List[ConversationList.CreateConversationWithConfigRequestParticipants] @@ -928,6 +928,8 @@ def to_dict(self): class CreateConversationWithConfigRequestConfiguration(object): """ :ivar intelligence_configuration_ids: A list of Conversational Intelligence configuration IDs. + :ivar trait_extraction_strategy_ids: A list of Trait Extraction Strategy IDs. + :ivar observation_extraction_strategy_ids: A list of Observation Extraction Strategy IDs. :ivar workflows: The Workflows to associate with this Conversation. Overrides the Configuration's own. """ @@ -936,6 +938,12 @@ def __init__(self, payload: Dict[str, Any]): self.intelligence_configuration_ids: Optional[List[str]] = payload.get( "intelligenceConfigurationIds" ) + self.trait_extraction_strategy_ids: Optional[List[str]] = payload.get( + "traitExtractionStrategyIds" + ) + self.observation_extraction_strategy_ids: Optional[List[str]] = payload.get( + "observationExtractionStrategyIds" + ) self.workflows: Optional[List[ConversationList.ConversationWorkflow]] = ( [ ( @@ -952,6 +960,8 @@ def __init__(self, payload: Dict[str, Any]): def to_dict(self): return { "intelligenceConfigurationIds": self.intelligence_configuration_ids, + "traitExtractionStrategyIds": self.trait_extraction_strategy_ids, + "observationExtractionStrategyIds": self.observation_extraction_strategy_ids, "workflows": ( [workflows.to_dict() for workflows in self.workflows] if self.workflows is not None @@ -1041,8 +1051,8 @@ def __init__(self, payload: Dict[str, Any]): ConversationList.PatchConversationByIdRequestConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) self.metadata: Optional[Dict[str, Optional[str]]] = payload.get("metadata") diff --git a/twilio/rest/iam/v1/o_auth_app.py b/twilio/rest/iam/v1/o_auth_app.py index 67c96df8a..506d1f422 100644 --- a/twilio/rest/iam/v1/o_auth_app.py +++ b/twilio/rest/iam/v1/o_auth_app.py @@ -52,8 +52,8 @@ def __init__(self, payload: Dict[str, Any]): OAuthAppList.IamV1OrganizationVendoroauthappPolicy( payload.get("policy") ) - if payload.get("policy") is not None - else None + if isinstance(payload.get("policy"), dict) + else payload.get("policy") ) self.access_token_ttl: Optional[int] = payload.get("access_token_ttl") @@ -89,8 +89,8 @@ def __init__(self, payload: Dict[str, Any]): OAuthAppList.IamV1OrganizationVendorOauthAppUpdateRequestPolicy( payload.get("policy") ) - if payload.get("policy") is not None - else None + if isinstance(payload.get("policy"), dict) + else payload.get("policy") ) self.access_token_ttl: Optional[int] = payload.get("access_token_ttl") @@ -335,8 +335,8 @@ def __init__(self, payload: Dict[str, Any]): OAuthAppList.IamV1OrganizationVendoroauthappPolicy( payload.get("policy") ) - if payload.get("policy") is not None - else None + if isinstance(payload.get("policy"), dict) + else payload.get("policy") ) self.access_token_ttl: Optional[int] = payload.get("access_token_ttl") @@ -372,8 +372,8 @@ def __init__(self, payload: Dict[str, Any]): OAuthAppList.IamV1OrganizationVendorOauthAppUpdateRequestPolicy( payload.get("policy") ) - if payload.get("policy") is not None - else None + if isinstance(payload.get("policy"), dict) + else payload.get("policy") ) self.access_token_ttl: Optional[int] = payload.get("access_token_ttl") @@ -657,8 +657,8 @@ def __init__(self, payload: Dict[str, Any]): OAuthAppList.IamV1OrganizationVendoroauthappPolicy( payload.get("policy") ) - if payload.get("policy") is not None - else None + if isinstance(payload.get("policy"), dict) + else payload.get("policy") ) self.access_token_ttl: Optional[int] = payload.get("access_token_ttl") @@ -694,8 +694,8 @@ def __init__(self, payload: Dict[str, Any]): OAuthAppList.IamV1OrganizationVendorOauthAppUpdateRequestPolicy( payload.get("policy") ) - if payload.get("policy") is not None - else None + if isinstance(payload.get("policy"), dict) + else payload.get("policy") ) self.access_token_ttl: Optional[int] = payload.get("access_token_ttl") diff --git a/twilio/rest/insights/v1/call/call_summary.py b/twilio/rest/insights/v1/call/call_summary.py index 4d1e0d94d..628cb7153 100644 --- a/twilio/rest/insights/v1/call/call_summary.py +++ b/twilio/rest/insights/v1/call/call_summary.py @@ -78,7 +78,7 @@ class ProcessingState(object): :ivar client_edge: `object` Contains metrics and properties for the Twilio media gateway of a Client call. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#edges-and-their-properties) for the object properties. :ivar sdk_edge: `object` Contains metrics and properties for the SDK sensor library for Client calls. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#edges-and-their-properties) for the object properties. :ivar sip_edge: `object` Contains metrics and properties for the Twilio media gateway of a SIP Interface or Trunking call. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#edges-and-their-properties) for the object properties. - :ivar tags: Tags applied to calls by Voice Insights analysis indicating a condition that could result in subjective degradation of the call quality. + :ivar tags: [Tags](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-tags) that Voice Insights analysis applies to calls. They indicate a condition that may influence the subjective experience of call audio quality. :ivar url: The URL of this resource. :ivar attributes: `object` Attributes capturing call-flow-specific details. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#attributes-object) for the object properties. :ivar properties: `object` Contains edge-agnostic call-level details. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#properties-object) for the object properties. diff --git a/twilio/rest/insights/v1/call_summaries.py b/twilio/rest/insights/v1/call_summaries.py index 1f66d767e..accf7159c 100644 --- a/twilio/rest/insights/v1/call_summaries.py +++ b/twilio/rest/insights/v1/call_summaries.py @@ -89,7 +89,7 @@ class CallSummaryCrelaySessionState(object): :ivar client_edge: `object` Contains metrics and properties for the Twilio media gateway of a Client call. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#edges-and-their-properties) for the object properties. :ivar sdk_edge: `object` Contains metrics and properties for the SDK sensor library for Client calls. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#edges-and-their-properties) for the object properties. :ivar sip_edge: `object` Contains metrics and properties for the Twilio media gateway of a SIP Interface or Trunking call. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#edges-and-their-properties) for the object properties. - :ivar tags: Tags applied to calls by Voice Insights analysis indicating a condition that could result in subjective degradation of the call quality. + :ivar tags: [Tags](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-tags) that Voice Insights analysis applies to calls. They indicate a condition that may influence the subjective experience of call audio quality. :ivar url: The URL of this resource. :ivar attributes: `object` Attributes capturing call-flow-specific details. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#attributes-object) for the object properties. :ivar properties: `object` Contains edge-agnostic call-level details. See [Details: Call Summary](https://www.twilio.com/docs/voice/voice-insights/api/call/details-call-summary#properties-object) for the object properties. diff --git a/twilio/rest/insights/v2/inbound_report.py b/twilio/rest/insights/v2/inbound_report.py index 18f45a0dd..64ad4d4f3 100644 --- a/twilio/rest/insights/v2/inbound_report.py +++ b/twilio/rest/insights/v2/inbound_report.py @@ -39,8 +39,8 @@ def __init__(self, payload: Dict[str, Any]): InboundReportList.InsightsV2CreatePhoneNumbersReportRequestTimeRange( payload.get("time_range") ) - if payload.get("time_range") is not None - else None + if isinstance(payload.get("time_range"), dict) + else payload.get("time_range") ) self.filters: Optional[List[InboundReportList.PhoneNumberReportFilter]] = ( [ @@ -171,8 +171,8 @@ def __init__(self, payload: Dict[str, Any]): InboundReportList.InsightsV2CreatePhoneNumbersReportRequestTimeRange( payload.get("time_range") ) - if payload.get("time_range") is not None - else None + if isinstance(payload.get("time_range"), dict) + else payload.get("time_range") ) self.filters: Optional[List[InboundReportList.PhoneNumberReportFilter]] = ( [ diff --git a/twilio/rest/insights/v2/outbound_report.py b/twilio/rest/insights/v2/outbound_report.py index c79d3b6f7..d944b639f 100644 --- a/twilio/rest/insights/v2/outbound_report.py +++ b/twilio/rest/insights/v2/outbound_report.py @@ -38,8 +38,8 @@ def __init__(self, payload: Dict[str, Any]): InboundReportList.InsightsV2CreatePhoneNumbersReportRequestTimeRange( payload.get("time_range") ) - if payload.get("time_range") is not None - else None + if isinstance(payload.get("time_range"), dict) + else payload.get("time_range") ) self.filters: Optional[List[InboundReportList.PhoneNumberReportFilter]] = ( [ @@ -136,8 +136,8 @@ def __init__(self, payload: Dict[str, Any]): InboundReportList.InsightsV2CreatePhoneNumbersReportRequestTimeRange( payload.get("time_range") ) - if payload.get("time_range") is not None - else None + if isinstance(payload.get("time_range"), dict) + else payload.get("time_range") ) self.filters: Optional[List[InboundReportList.PhoneNumberReportFilter]] = ( [ diff --git a/twilio/rest/insights/v2/report.py b/twilio/rest/insights/v2/report.py index 1ade17bec..7ed49c093 100644 --- a/twilio/rest/insights/v2/report.py +++ b/twilio/rest/insights/v2/report.py @@ -130,8 +130,8 @@ def __init__(self, payload: Dict[str, Any]): AccountReportKYTOutboundCarrierCalling( payload.get("outbound_carrier_calling") ) - if payload.get("outbound_carrier_calling") is not None - else None + if isinstance(payload.get("outbound_carrier_calling"), dict) + else payload.get("outbound_carrier_calling") ) def to_dict(self): @@ -183,18 +183,18 @@ def __init__(self, payload: Dict[str, Any]): ) self.branded_calling: Optional[BrandedCalling] = ( BrandedCalling(payload.get("branded_calling")) - if payload.get("branded_calling") is not None - else None + if isinstance(payload.get("branded_calling"), dict) + else payload.get("branded_calling") ) self.voice_integrity: Optional[VoiceIntegrity] = ( VoiceIntegrity(payload.get("voice_integrity")) - if payload.get("voice_integrity") is not None - else None + if isinstance(payload.get("voice_integrity"), dict) + else payload.get("voice_integrity") ) self.stir_shaken: Optional[StirShaken] = ( StirShaken(payload.get("stir_shaken")) - if payload.get("stir_shaken") is not None - else None + if isinstance(payload.get("stir_shaken"), dict) + else payload.get("stir_shaken") ) def to_dict(self): @@ -237,13 +237,13 @@ def __init__(self, payload: Dict[str, Any]): self.sdk: Optional[AccountReportNetworkIssuesSdk] = ( AccountReportNetworkIssuesSdk(payload.get("sdk")) - if payload.get("sdk") is not None - else None + if isinstance(payload.get("sdk"), dict) + else payload.get("sdk") ) self.twilio_gateway: Optional[AccountReportNetworkIssuesTwilioGateway] = ( AccountReportNetworkIssuesTwilioGateway(payload.get("twilio_gateway")) - if payload.get("twilio_gateway") is not None - else None + if isinstance(payload.get("twilio_gateway"), dict) + else payload.get("twilio_gateway") ) def to_dict(self): @@ -425,8 +425,8 @@ def __init__(self, payload: Dict[str, Any]): ReportList.InsightsV2CreateAccountReportRequestTimeRange( payload.get("time_range") ) - if payload.get("time_range") is not None - else None + if isinstance(payload.get("time_range"), dict) + else payload.get("time_range") ) self.filters: Optional[List[ReportList.ReportFilter]] = ( [ @@ -494,18 +494,18 @@ def __init__(self, payload: Dict[str, Any]): self.call_count: Optional[StirShakenCallCount] = ( StirShakenCallCount(payload.get("call_count")) - if payload.get("call_count") is not None - else None + if isinstance(payload.get("call_count"), dict) + else payload.get("call_count") ) self.percentage: Optional[StirShakenPercentage] = ( StirShakenPercentage(payload.get("percentage")) - if payload.get("percentage") is not None - else None + if isinstance(payload.get("percentage"), dict) + else payload.get("percentage") ) self.answer_rate: Optional[StirShakenAnswerRate] = ( StirShakenAnswerRate(payload.get("answer_rate")) - if payload.get("answer_rate") is not None - else None + if isinstance(payload.get("answer_rate"), dict) + else payload.get("answer_rate") ) def to_dict(self): @@ -850,8 +850,8 @@ def __init__(self, payload: Dict[str, Any]): AccountReportKYTOutboundCarrierCalling( payload.get("outbound_carrier_calling") ) - if payload.get("outbound_carrier_calling") is not None - else None + if isinstance(payload.get("outbound_carrier_calling"), dict) + else payload.get("outbound_carrier_calling") ) def to_dict(self): @@ -903,18 +903,18 @@ def __init__(self, payload: Dict[str, Any]): ) self.branded_calling: Optional[BrandedCalling] = ( BrandedCalling(payload.get("branded_calling")) - if payload.get("branded_calling") is not None - else None + if isinstance(payload.get("branded_calling"), dict) + else payload.get("branded_calling") ) self.voice_integrity: Optional[VoiceIntegrity] = ( VoiceIntegrity(payload.get("voice_integrity")) - if payload.get("voice_integrity") is not None - else None + if isinstance(payload.get("voice_integrity"), dict) + else payload.get("voice_integrity") ) self.stir_shaken: Optional[StirShaken] = ( StirShaken(payload.get("stir_shaken")) - if payload.get("stir_shaken") is not None - else None + if isinstance(payload.get("stir_shaken"), dict) + else payload.get("stir_shaken") ) def to_dict(self): @@ -957,13 +957,13 @@ def __init__(self, payload: Dict[str, Any]): self.sdk: Optional[AccountReportNetworkIssuesSdk] = ( AccountReportNetworkIssuesSdk(payload.get("sdk")) - if payload.get("sdk") is not None - else None + if isinstance(payload.get("sdk"), dict) + else payload.get("sdk") ) self.twilio_gateway: Optional[AccountReportNetworkIssuesTwilioGateway] = ( AccountReportNetworkIssuesTwilioGateway(payload.get("twilio_gateway")) - if payload.get("twilio_gateway") is not None - else None + if isinstance(payload.get("twilio_gateway"), dict) + else payload.get("twilio_gateway") ) def to_dict(self): @@ -1145,8 +1145,8 @@ def __init__(self, payload: Dict[str, Any]): ReportList.InsightsV2CreateAccountReportRequestTimeRange( payload.get("time_range") ) - if payload.get("time_range") is not None - else None + if isinstance(payload.get("time_range"), dict) + else payload.get("time_range") ) self.filters: Optional[List[ReportList.ReportFilter]] = ( [ @@ -1214,18 +1214,18 @@ def __init__(self, payload: Dict[str, Any]): self.call_count: Optional[StirShakenCallCount] = ( StirShakenCallCount(payload.get("call_count")) - if payload.get("call_count") is not None - else None + if isinstance(payload.get("call_count"), dict) + else payload.get("call_count") ) self.percentage: Optional[StirShakenPercentage] = ( StirShakenPercentage(payload.get("percentage")) - if payload.get("percentage") is not None - else None + if isinstance(payload.get("percentage"), dict) + else payload.get("percentage") ) self.answer_rate: Optional[StirShakenAnswerRate] = ( StirShakenAnswerRate(payload.get("answer_rate")) - if payload.get("answer_rate") is not None - else None + if isinstance(payload.get("answer_rate"), dict) + else payload.get("answer_rate") ) def to_dict(self): @@ -1590,8 +1590,8 @@ def __init__(self, payload: Dict[str, Any]): AccountReportKYTOutboundCarrierCalling( payload.get("outbound_carrier_calling") ) - if payload.get("outbound_carrier_calling") is not None - else None + if isinstance(payload.get("outbound_carrier_calling"), dict) + else payload.get("outbound_carrier_calling") ) def to_dict(self): @@ -1643,18 +1643,18 @@ def __init__(self, payload: Dict[str, Any]): ) self.branded_calling: Optional[BrandedCalling] = ( BrandedCalling(payload.get("branded_calling")) - if payload.get("branded_calling") is not None - else None + if isinstance(payload.get("branded_calling"), dict) + else payload.get("branded_calling") ) self.voice_integrity: Optional[VoiceIntegrity] = ( VoiceIntegrity(payload.get("voice_integrity")) - if payload.get("voice_integrity") is not None - else None + if isinstance(payload.get("voice_integrity"), dict) + else payload.get("voice_integrity") ) self.stir_shaken: Optional[StirShaken] = ( StirShaken(payload.get("stir_shaken")) - if payload.get("stir_shaken") is not None - else None + if isinstance(payload.get("stir_shaken"), dict) + else payload.get("stir_shaken") ) def to_dict(self): @@ -1697,13 +1697,13 @@ def __init__(self, payload: Dict[str, Any]): self.sdk: Optional[AccountReportNetworkIssuesSdk] = ( AccountReportNetworkIssuesSdk(payload.get("sdk")) - if payload.get("sdk") is not None - else None + if isinstance(payload.get("sdk"), dict) + else payload.get("sdk") ) self.twilio_gateway: Optional[AccountReportNetworkIssuesTwilioGateway] = ( AccountReportNetworkIssuesTwilioGateway(payload.get("twilio_gateway")) - if payload.get("twilio_gateway") is not None - else None + if isinstance(payload.get("twilio_gateway"), dict) + else payload.get("twilio_gateway") ) def to_dict(self): @@ -1885,8 +1885,8 @@ def __init__(self, payload: Dict[str, Any]): ReportList.InsightsV2CreateAccountReportRequestTimeRange( payload.get("time_range") ) - if payload.get("time_range") is not None - else None + if isinstance(payload.get("time_range"), dict) + else payload.get("time_range") ) self.filters: Optional[List[ReportList.ReportFilter]] = ( [ @@ -1954,18 +1954,18 @@ def __init__(self, payload: Dict[str, Any]): self.call_count: Optional[StirShakenCallCount] = ( StirShakenCallCount(payload.get("call_count")) - if payload.get("call_count") is not None - else None + if isinstance(payload.get("call_count"), dict) + else payload.get("call_count") ) self.percentage: Optional[StirShakenPercentage] = ( StirShakenPercentage(payload.get("percentage")) - if payload.get("percentage") is not None - else None + if isinstance(payload.get("percentage"), dict) + else payload.get("percentage") ) self.answer_rate: Optional[StirShakenAnswerRate] = ( StirShakenAnswerRate(payload.get("answer_rate")) - if payload.get("answer_rate") is not None - else None + if isinstance(payload.get("answer_rate"), dict) + else payload.get("answer_rate") ) def to_dict(self): diff --git a/twilio/rest/insights/v3/__init__.py b/twilio/rest/insights/v3/__init__.py index 5be71a8ae..45e7908a4 100644 --- a/twilio/rest/insights/v3/__init__.py +++ b/twilio/rest/insights/v3/__init__.py @@ -15,8 +15,10 @@ from typing import Optional from twilio.base.version import Version from twilio.base.domain import Domain -from twilio.rest.insights.v3.capacity import CapacityList from twilio.rest.insights.v3.custom_field_mapping import CustomFieldMappingList +from twilio.rest.insights.v3.custom_field_mappings_capacity import ( + CustomFieldMappingsCapacityList, +) from twilio.rest.insights.v3.metadata import MetadataList from twilio.rest.insights.v3.query import QueryList from twilio.rest.insights.v3.query_job import QueryJobList @@ -31,24 +33,26 @@ def __init__(self, domain: Domain): :param domain: The Twilio.insights domain """ super().__init__(domain, "v3") - self._capacity: Optional[CapacityList] = None self._custom_field_mappings: Optional[CustomFieldMappingList] = None + self._custom_field_mappings_capacity: Optional[ + CustomFieldMappingsCapacityList + ] = None self._metadata: Optional[MetadataList] = None self._query: Optional[QueryList] = None self._query_jobs: Optional[QueryJobList] = None - @property - def capacity(self) -> CapacityList: - if self._capacity is None: - self._capacity = CapacityList(self) - return self._capacity - @property def custom_field_mappings(self) -> CustomFieldMappingList: if self._custom_field_mappings is None: self._custom_field_mappings = CustomFieldMappingList(self) return self._custom_field_mappings + @property + def custom_field_mappings_capacity(self) -> CustomFieldMappingsCapacityList: + if self._custom_field_mappings_capacity is None: + self._custom_field_mappings_capacity = CustomFieldMappingsCapacityList(self) + return self._custom_field_mappings_capacity + @property def metadata(self) -> MetadataList: if self._metadata is None: diff --git a/twilio/rest/insights/v3/custom_field_mapping.py b/twilio/rest/insights/v3/custom_field_mapping.py index 5dc658057..8f56740cf 100644 --- a/twilio/rest/insights/v3/custom_field_mapping.py +++ b/twilio/rest/insights/v3/custom_field_mapping.py @@ -15,13 +15,14 @@ from __future__ import annotations from datetime import datetime -from typing import Any, Dict, List, Optional +from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator from twilio.base import deserialize, values from twilio.base.api_response import ApiResponse - +from twilio.base.instance_context import InstanceContext from twilio.base.instance_resource import InstanceResource from twilio.base.list_resource import ListResource from twilio.base.version import Version +from twilio.base.token_pagination import TokenPagination class CustomFieldMappingInstance(InstanceResource): @@ -33,17 +34,21 @@ class SourceType(object): INTELLIGENCE_OPERATOR = "INTELLIGENCE_OPERATOR" """ - :ivar id: TTID for conversation insights custom field mapping + :ivar id: The unique identifier of the custom field mapping. :ivar category: - :ivar name: + :ivar name: Name of the custom field, unique within the account. :ivar description: Optional, free-text description supplied at registration time. Display-only — not part of any uniqueness check. :ivar entity_metadata: :ivar created_at: When the mapping was registered. - :ivar updated_at: When the mapping was last materially modified in-place. Null until the first update-in-place. - :ivar mappings: + :ivar updated_at: When the mapping was last modified via `PATCH`. Null until the first update. """ - def __init__(self, version: Version, payload: Dict[str, Any]): + def __init__( + self, + version: Version, + payload: Dict[str, Any], + mapping_id: Optional[str] = None, + ): super().__init__(version) self.id: Optional[str] = payload.get("id") @@ -59,18 +64,391 @@ def __init__(self, version: Version, payload: Dict[str, Any]): self.updated_at: Optional[datetime] = deserialize.iso8601_datetime( payload.get("updatedAt") ) - self.mappings: Optional[List[CustomFieldMappingResponse]] = payload.get( - "mappings" + + # Only set _solution if path params are provided (not None) + if mapping_id is not None: + self._solution = { + "mapping_id": mapping_id, + } + + self._context: Optional[CustomFieldMappingContext] = None + + @property + def _proxy(self) -> "CustomFieldMappingContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: CustomFieldMappingContext for this CustomFieldMappingInstance + """ + if self._context is None: + self._context = CustomFieldMappingContext( + self._version, + mapping_id=self._solution["mapping_id"], + ) + return self._context + + def fetch(self) -> "CustomFieldMappingInstance": + """ + Fetch the CustomFieldMappingInstance + + + :returns: The fetched CustomFieldMappingInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "CustomFieldMappingInstance": + """ + Asynchronous coroutine to fetch the CustomFieldMappingInstance + + + :returns: The fetched CustomFieldMappingInstance + """ + return await self._proxy.fetch_async() + + def fetch_with_http_info(self) -> ApiResponse: + """ + Fetch the CustomFieldMappingInstance with HTTP info + + + :returns: ApiResponse with instance, status code, and headers + """ + return self._proxy.fetch_with_http_info() + + async def fetch_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine to fetch the CustomFieldMappingInstance with HTTP info + + + :returns: ApiResponse with instance, status code, and headers + """ + return await self._proxy.fetch_with_http_info_async() + + def patch( + self, + custom_field_mapping_update_request: CustomFieldMappingUpdateRequest, + if_match: Union[str, object] = values.unset, + ) -> "CustomFieldMappingInstance": + """ + Patch the CustomFieldMappingInstance + + :param custom_field_mapping_update_request: + :param if_match: ETag of the custom field mapping, as returned in the `ETag` response header. When supplied, the update is applied only if the mapping has not changed since that ETag was issued; otherwise `412` is returned. + + :returns: The patched CustomFieldMappingInstance + """ + return self._proxy.patch( + custom_field_mapping_update_request=custom_field_mapping_update_request, + if_match=if_match, + ) + + async def patch_async( + self, + custom_field_mapping_update_request: CustomFieldMappingUpdateRequest, + if_match: Union[str, object] = values.unset, + ) -> "CustomFieldMappingInstance": + """ + Asynchronous coroutine to patch the CustomFieldMappingInstance + + :param custom_field_mapping_update_request: + :param if_match: ETag of the custom field mapping, as returned in the `ETag` response header. When supplied, the update is applied only if the mapping has not changed since that ETag was issued; otherwise `412` is returned. + + :returns: The patched CustomFieldMappingInstance + """ + return await self._proxy.patch_async( + custom_field_mapping_update_request=custom_field_mapping_update_request, + if_match=if_match, + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class CustomFieldMappingContext(InstanceContext): + + def __init__(self, version: Version, mapping_id: str): + """ + Initialize the CustomFieldMappingContext + + :param version: Version that contains the resource + :param mapping_id: The unique identifier of the custom field mapping, as returned in `id` when the mapping was created. + """ + super().__init__(version) + + # Path Solution + self._solution = { + "mapping_id": mapping_id, + } + self._uri = "/ControlPlane/ConversationInsights/CustomFieldMappings/{mapping_id}".format( + **self._solution + ) + + def _fetch(self) -> tuple: + """ + Internal helper for fetch operation + + Returns: + tuple: (payload, status_code, headers) + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + return self._version.fetch_with_response_info( + method="GET", uri=self._uri, headers=headers + ) + + def fetch(self) -> CustomFieldMappingInstance: + """ + Fetch the CustomFieldMappingInstance + + + :returns: The fetched CustomFieldMappingInstance + """ + payload, _, _ = self._fetch() + return CustomFieldMappingInstance( + self._version, + payload, + mapping_id=self._solution["mapping_id"], + ) + + def fetch_with_http_info(self) -> ApiResponse: + """ + Fetch the CustomFieldMappingInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._fetch() + instance = CustomFieldMappingInstance( + self._version, + payload, + mapping_id=self._solution["mapping_id"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _fetch_async(self) -> tuple: + """ + Internal async helper for fetch operation + + Returns: + tuple: (payload, status_code, headers) + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + return await self._version.fetch_with_response_info_async( + method="GET", uri=self._uri, headers=headers + ) + + async def fetch_async(self) -> CustomFieldMappingInstance: + """ + Asynchronous coroutine to fetch the CustomFieldMappingInstance + + + :returns: The fetched CustomFieldMappingInstance + """ + payload, _, _ = await self._fetch_async() + return CustomFieldMappingInstance( + self._version, + payload, + mapping_id=self._solution["mapping_id"], ) + async def fetch_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine to fetch the CustomFieldMappingInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._fetch_async() + instance = CustomFieldMappingInstance( + self._version, + payload, + mapping_id=self._solution["mapping_id"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def _patch( + self, + custom_field_mapping_update_request: CustomFieldMappingUpdateRequest, + if_match: Union[str, object] = values.unset, + ) -> tuple: + """ + Internal helper for patch operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = custom_field_mapping_update_request.to_dict() + + headers = values.of({}) + + if not ( + if_match is values.unset or (isinstance(if_match, str) and not if_match) + ): + headers["If-Match"] = if_match + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + return self._version.patch_with_response_info( + method="PATCH", uri=self._uri, data=data, headers=headers + ) + + def patch( + self, + custom_field_mapping_update_request: CustomFieldMappingUpdateRequest, + if_match: Union[str, object] = values.unset, + ) -> CustomFieldMappingInstance: + """ + Patch the CustomFieldMappingInstance + + :param custom_field_mapping_update_request: + :param if_match: ETag of the custom field mapping, as returned in the `ETag` response header. When supplied, the update is applied only if the mapping has not changed since that ETag was issued; otherwise `412` is returned. + + :returns: The patched CustomFieldMappingInstance + """ + payload, _, _ = self._patch( + custom_field_mapping_update_request=custom_field_mapping_update_request, + if_match=if_match, + ) + return CustomFieldMappingInstance( + self._version, payload, mapping_id=self._solution["mapping_id"] + ) + + def patch_with_http_info( + self, + custom_field_mapping_update_request: CustomFieldMappingUpdateRequest, + if_match: Union[str, object] = values.unset, + ) -> ApiResponse: + """ + Patch the CustomFieldMappingInstance and return response metadata + + :param custom_field_mapping_update_request: + :param if_match: ETag of the custom field mapping, as returned in the `ETag` response header. When supplied, the update is applied only if the mapping has not changed since that ETag was issued; otherwise `412` is returned. + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._patch( + custom_field_mapping_update_request=custom_field_mapping_update_request, + if_match=if_match, + ) + instance = CustomFieldMappingInstance( + self._version, payload, mapping_id=self._solution["mapping_id"] + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _patch_async( + self, + custom_field_mapping_update_request: CustomFieldMappingUpdateRequest, + if_match: Union[str, object] = values.unset, + ) -> tuple: + """ + Internal async helper for patch operation + + Returns: + tuple: (payload, status_code, headers) + """ + data = custom_field_mapping_update_request.to_dict() + + headers = values.of({}) + + if not ( + if_match is values.unset or (isinstance(if_match, str) and not if_match) + ): + headers["If-Match"] = if_match + + headers["Content-Type"] = "application/json" + + headers["Accept"] = "application/json" + + return await self._version.patch_with_response_info_async( + method="PATCH", uri=self._uri, data=data, headers=headers + ) + + async def patch_async( + self, + custom_field_mapping_update_request: CustomFieldMappingUpdateRequest, + if_match: Union[str, object] = values.unset, + ) -> CustomFieldMappingInstance: + """ + Asynchronous coroutine to patch the CustomFieldMappingInstance + + :param custom_field_mapping_update_request: + :param if_match: ETag of the custom field mapping, as returned in the `ETag` response header. When supplied, the update is applied only if the mapping has not changed since that ETag was issued; otherwise `412` is returned. + + :returns: The patched CustomFieldMappingInstance + """ + payload, _, _ = await self._patch_async( + custom_field_mapping_update_request=custom_field_mapping_update_request, + if_match=if_match, + ) + return CustomFieldMappingInstance( + self._version, payload, mapping_id=self._solution["mapping_id"] + ) + + async def patch_with_http_info_async( + self, + custom_field_mapping_update_request: CustomFieldMappingUpdateRequest, + if_match: Union[str, object] = values.unset, + ) -> ApiResponse: + """ + Asynchronous coroutine to patch the CustomFieldMappingInstance and return response metadata + + :param custom_field_mapping_update_request: + :param if_match: ETag of the custom field mapping, as returned in the `ETag` response header. When supplied, the update is applied only if the mapping has not changed since that ETag was issued; otherwise `412` is returned. + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._patch_async( + custom_field_mapping_update_request=custom_field_mapping_update_request, + if_match=if_match, + ) + instance = CustomFieldMappingInstance( + self._version, payload, mapping_id=self._solution["mapping_id"] + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + def __repr__(self) -> str: """ Provide a friendly representation :returns: Machine friendly representation """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class CustomFieldMappingPage(TokenPagination): + + def get_instance(self, payload: Dict[str, Any]) -> CustomFieldMappingInstance: + """ + Build an instance of CustomFieldMappingInstance - return "" + :param payload: Payload response from the API + """ + + return CustomFieldMappingInstance(self._version, payload) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" class CustomFieldMappingList(ListResource): @@ -78,8 +456,8 @@ class CustomFieldMappingList(ListResource): class CustomFieldMappingRequest(object): """ :ivar category: - :ivar name: Customer-facing name for the field; becomes the ClickHouse Map key and the platform field alias. Unique per account across every `sourceType` — the Map key namespace is account-global. - :ivar description: Optional, free-text description of this custom field mapping. Display-only — not part of any uniqueness check. + :ivar name: Name of the custom field, used to reference it in Insights queries. Contains only letters, digits and `_`, and must not be empty. Must be unique within the account across every `sourceType`; registering an existing name returns `409`. Cannot be changed after registration. + :ivar description: Optional, free-text description of this custom field mapping, up to 150 characters. Display-only — not part of any uniqueness check. :ivar entity_metadata: """ @@ -90,14 +468,10 @@ def __init__(self, payload: Dict[str, Any]): ) self.name: Optional[str] = payload.get("name") self.description: Optional[str] = payload.get("description") - self.entity_metadata: Optional[ - CustomFieldMappingList.IntelligenceOperatorEntityMetadata - ] = ( - CustomFieldMappingList.IntelligenceOperatorEntityMetadata( - payload.get("entityMetadata") - ) - if payload.get("entityMetadata") is not None - else None + self.entity_metadata: Optional[CustomFieldMappingList.EntityMetadata] = ( + CustomFieldMappingList.EntityMetadata(payload.get("entityMetadata")) + if isinstance(payload.get("entityMetadata"), dict) + else payload.get("entityMetadata") ) def to_dict(self): @@ -112,58 +486,67 @@ def to_dict(self): ), } - class CustomFieldMappingResponse(object): + class CustomFieldMappingUpdateRequest(object): """ - :ivar id: TTID for conversation insights custom field mapping - :ivar category: - :ivar name: - :ivar description: Optional, free-text description supplied at registration time. Display-only — not part of any uniqueness check. :ivar entity_metadata: - :ivar created_at: When the mapping was registered. - :ivar updated_at: When the mapping was last materially modified in-place. Null until the first update-in-place. """ def __init__(self, payload: Dict[str, Any]): - self.id: Optional[str] = payload.get("id") - self.category: Optional["CustomFieldMappingInstance.MappingCategory"] = ( - payload.get("category") - ) - self.name: Optional[str] = payload.get("name") - self.description: Optional[str] = payload.get("description") - self.entity_metadata: Optional[IntelligenceOperatorEntityMetadata] = ( - IntelligenceOperatorEntityMetadata(payload.get("entityMetadata")) - if payload.get("entityMetadata") is not None - else None - ) - self.created_at: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("createdAt") - ) - self.updated_at: Optional[datetime] = deserialize.iso8601_datetime( - payload.get("updatedAt") + self.entity_metadata: Optional[ + CustomFieldMappingList.EntityMetadataUpdate + ] = ( + CustomFieldMappingList.EntityMetadataUpdate( + payload.get("entityMetadata") + ) + if isinstance(payload.get("entityMetadata"), dict) + else payload.get("entityMetadata") ) def to_dict(self): return { - "id": self.id, - "category": self.category, - "name": self.name, - "description": self.description, "entityMetadata": ( self.entity_metadata.to_dict() if self.entity_metadata is not None else None ), - "createdAt": self.created_at, - "updatedAt": self.updated_at, } - class IntelligenceOperatorEntityMetadata(object): + class EntityMetadata(object): + """ + :ivar source_type: + :ivar intelligence_operator: + """ + + def __init__(self, payload: Dict[str, Any]): + + self.source_type: Optional["CustomFieldMappingInstance.SourceType"] = ( + payload.get("sourceType") + ) + self.intelligence_operator: Optional[ + CustomFieldMappingList.IntelligenceOperatorSource + ] = ( + CustomFieldMappingList.IntelligenceOperatorSource( + payload.get("intelligenceOperator") + ) + if isinstance(payload.get("intelligenceOperator"), dict) + else payload.get("intelligenceOperator") + ) + + def to_dict(self): + return { + "sourceType": self.source_type, + "intelligenceOperator": ( + self.intelligence_operator.to_dict() + if self.intelligence_operator is not None + else None + ), + } + + class EntityMetadataUpdate(object): """ :ivar source_type: - :ivar operator_id: The Intelligence operator ID. Part of the owner check for idempotent upserts — a mismatch against the existing registration's `(sourceType, operatorId)` returns `409`. - :ivar operator_name: Optional, display-only name of the operator as supplied at registration time. Not part of any uniqueness or validation logic. - :ivar field: Annotation fieldPath key; generic identifier that determines the output-schema field. Resolved against the operator identified by `operatorId`. + :ivar intelligence_operator: """ def __init__(self, payload: Dict[str, Any]): @@ -171,18 +554,60 @@ def __init__(self, payload: Dict[str, Any]): self.source_type: Optional["CustomFieldMappingInstance.SourceType"] = ( payload.get("sourceType") ) + self.intelligence_operator: Optional[ + CustomFieldMappingList.IntelligenceOperatorSourceUpdate + ] = ( + CustomFieldMappingList.IntelligenceOperatorSourceUpdate( + payload.get("intelligenceOperator") + ) + if isinstance(payload.get("intelligenceOperator"), dict) + else payload.get("intelligenceOperator") + ) + + def to_dict(self): + return { + "sourceType": self.source_type, + "intelligenceOperator": ( + self.intelligence_operator.to_dict() + if self.intelligence_operator is not None + else None + ), + } + + class IntelligenceOperatorSource(object): + """ + :ivar operator_id: The ID of the Conversational Intelligence operator whose output supplies this field's value. Must match `^intelligence_operator_[0-7][0-9a-z]{25}$`. Cannot be changed after registration. + :ivar operator_name: Optional, display-only name of the operator. Stored as supplied and not validated against the operator. + :ivar field: Path to the property in the operator's output schema that supplies this field's value. Rules: - one or two segments separated by `.` — a top-level property (`leadScore`) or one level of nesting (`scores.leadScore`); - each segment contains only letters, digits and `_`; array indexing (such as `items[0]`) is not supported; - the path must exist in the output schema of the operator's latest active version and resolve to a property of type `number` or `integer`. + """ + + def __init__(self, payload: Dict[str, Any]): + self.operator_id: Optional[str] = payload.get("operatorId") self.operator_name: Optional[str] = payload.get("operatorName") self.field: Optional[str] = payload.get("field") def to_dict(self): return { - "sourceType": self.source_type, "operatorId": self.operator_id, "operatorName": self.operator_name, "field": self.field, } + class IntelligenceOperatorSourceUpdate(object): + """ + :ivar field: New path to the property in the operator's output schema. Follows the same rules as `field` at registration: one or two `.`-separated segments of letters, digits and `_`, resolving to a `number` or `integer` property on the operator's latest active version. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.field: Optional[str] = payload.get("field") + + def to_dict(self): + return { + "field": self.field, + } + def __init__(self, version: Version): """ Initialize the CustomFieldMappingList @@ -296,77 +721,410 @@ async def create_with_http_info_async( instance = CustomFieldMappingInstance(self._version, payload) return ApiResponse(data=instance, status_code=status_code, headers=headers) - def _fetch(self) -> tuple: + def stream( + self, + page_token: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> Iterator[CustomFieldMappingInstance]: """ - Internal helper for fetch operation + Streams CustomFieldMappingInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param str page_token: Token for pagination + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = self.page(page_token=page_token, page_size=limits["page_size"]) - Returns: - tuple: (payload, status_code, headers) + return self._version.stream(page, limits["limit"]) + + async def stream_async( + self, + page_token: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> AsyncIterator[CustomFieldMappingInstance]: + """ + Asynchronously streams CustomFieldMappingInstance records from the API as a generator stream. + This operation lazily loads records as efficiently as possible until the limit + is reached. + The results are returned as a generator, so this operation is memory efficient. + + :param str page_token: Token for pagination + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: Generator that will yield up to limit results + """ + limits = self._version.read_limits(limit, page_size) + page = await self.page_async( + page_token=page_token, page_size=limits["page_size"] + ) + + return self._version.stream_async(page, limits["limit"]) + + def stream_with_http_info( + self, + page_token: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> tuple: + """ + Streams CustomFieldMappingInstance and returns headers from first page + + + :param str page_token: Token for pagination + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: tuple of (generator, status_code, headers) where generator yields instances + """ + limits = self._version.read_limits(limit, page_size) + page_response = self.page_with_http_info( + page_token=page_token, page_size=limits["page_size"] + ) + + generator = self._version.stream(page_response.data, limits["limit"]) + return (generator, page_response.status_code, page_response.headers) + + async def stream_with_http_info_async( + self, + page_token: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> tuple: """ + Asynchronously streams CustomFieldMappingInstance and returns headers from first page + + + :param str page_token: Token for pagination + :param limit: Upper limit for the number of records to return. stream() + guarantees to never return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, stream() will attempt to read the + limit with the most efficient page size, i.e. min(limit, 1000) + + :returns: tuple of (generator, status_code, headers) where generator yields instances + """ + limits = self._version.read_limits(limit, page_size) + page_response = await self.page_with_http_info_async( + page_token=page_token, page_size=limits["page_size"] + ) + + generator = self._version.stream_async(page_response.data, limits["limit"]) + return (generator, page_response.status_code, page_response.headers) + + def list( + self, + page_token: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[CustomFieldMappingInstance]: + """ + Lists CustomFieldMappingInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str page_token: Token for pagination + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + + return list( + self.stream( + page_token=page_token, + limit=limit, + page_size=page_size, + ) + ) + + async def list_async( + self, + page_token: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[CustomFieldMappingInstance]: + """ + Asynchronously lists CustomFieldMappingInstance records from the API as a list. + Unlike stream(), this operation is eager and will load `limit` records into + memory before returning. + + :param str page_token: Token for pagination + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: list that will contain up to limit results + """ + + return [ + record + async for record in await self.stream_async( + page_token=page_token, + limit=limit, + page_size=page_size, + ) + ] + + def list_with_http_info( + self, + page_token: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ApiResponse: + """ + Lists CustomFieldMappingInstance and returns headers from first page + + + :param str page_token: Token for pagination + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: ApiResponse with list of instances, status code, and headers + """ + generator, status_code, headers = self.stream_with_http_info( + page_token=page_token, + limit=limit, + page_size=page_size, + ) + items = list(generator) + return ApiResponse(data=items, status_code=status_code, headers=headers) + + async def list_with_http_info_async( + self, + page_token: Union[str, object] = values.unset, + limit: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ApiResponse: + """ + Asynchronously lists CustomFieldMappingInstance and returns headers from first page + + + :param str page_token: Token for pagination + :param limit: Upper limit for the number of records to return. list() guarantees + never to return more than limit. Default is no limit + :param page_size: Number of records to fetch per request, when not set will use + the default value of 50 records. If no page_size is defined + but a limit is defined, list() will attempt to read the limit + with the most efficient page size, i.e. min(limit, 1000) + + :returns: ApiResponse with list of instances, status code, and headers + """ + generator, status_code, headers = await self.stream_with_http_info_async( + page_token=page_token, + limit=limit, + page_size=page_size, + ) + items = [record async for record in generator] + return ApiResponse(data=items, status_code=status_code, headers=headers) + + def page( + self, + page_size: Union[int, object] = values.unset, + page_token: Union[str, object] = values.unset, + ) -> CustomFieldMappingPage: + """ + Retrieve a single page of CustomFieldMappingInstance records from the API. + Request is executed immediately + + :param page_size: The maximum number of resources to return + :param page_token: Token for pagination + :returns: Page of CustomFieldMappingInstance + """ + data = values.of( + { + "pageSize": page_size, + "pageToken": page_token, + } + ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) headers["Accept"] = "application/json" - return self._version.fetch_with_response_info( - method="GET", uri=self._uri, headers=headers + response = self._version.page( + method="GET", uri=self._uri, params=data, headers=headers + ) + return CustomFieldMappingPage( + self._version, response, uri=self._uri, params=data ) - def fetch(self) -> CustomFieldMappingInstance: + async def page_async( + self, + page_size: Union[int, object] = values.unset, + page_token: Union[str, object] = values.unset, + ) -> CustomFieldMappingPage: """ - Fetch the CustomFieldMappingInstance - + Asynchronously retrieve a single page of CustomFieldMappingInstance records from the API. + Request is executed immediately - :returns: The fetched CustomFieldMappingInstance + :param page_size: The maximum number of resources to return + :param page_token: Token for pagination + :returns: Page of CustomFieldMappingInstance """ - payload, _, _ = self._fetch() - return CustomFieldMappingInstance(self._version, payload) + data = values.of( + { + "pageSize": page_size, + "pageToken": page_token, + } + ) - def fetch_with_http_info(self) -> ApiResponse: + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response = await self._version.page_async( + method="GET", uri=self._uri, params=data, headers=headers + ) + return CustomFieldMappingPage( + self._version, response, uri=self._uri, params=data + ) + + def page_with_http_info( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> ApiResponse: """ - Fetch the CustomFieldMappingInstance and return response metadata + Retrieve a single page with response metadata - :returns: ApiResponse with instance, status code, and headers + :param page_token: Token for pagination + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: ApiResponse with CustomFieldMappingPage, status code, and headers """ - payload, status_code, headers = self._fetch() - instance = CustomFieldMappingInstance(self._version, payload) - return ApiResponse(data=instance, status_code=status_code, headers=headers) + data = values.of( + { + "pageToken": page_token, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) - async def _fetch_async(self) -> tuple: + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + + headers["Accept"] = "application/json" + + response, status_code, response_headers = self._version.page_with_response_info( + method="GET", uri=self._uri, params=data, headers=headers + ) + page = CustomFieldMappingPage(self._version, response, uri=self._uri) + return ApiResponse(data=page, status_code=status_code, headers=response_headers) + + async def page_with_http_info_async( + self, + page_token: Union[str, object] = values.unset, + page_number: Union[int, object] = values.unset, + page_size: Union[int, object] = values.unset, + ) -> ApiResponse: """ - Internal async helper for fetch operation + Asynchronously retrieve a single page with response metadata - Returns: - tuple: (payload, status_code, headers) + + :param page_token: Token for pagination + :param page_token: PageToken provided by the API + :param page_number: Page Number, this value is simply for client state + :param page_size: Number of records to return, defaults to 50 + + :returns: ApiResponse with CustomFieldMappingPage, status code, and headers """ + data = values.of( + { + "pageToken": page_token, + "PageToken": page_token, + "Page": page_number, + "PageSize": page_size, + } + ) + headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) headers["Accept"] = "application/json" - return await self._version.fetch_with_response_info_async( - method="GET", uri=self._uri, headers=headers + response, status_code, response_headers = ( + await self._version.page_with_response_info_async( + method="GET", uri=self._uri, params=data, headers=headers + ) ) + page = CustomFieldMappingPage(self._version, response) + return ApiResponse(data=page, status_code=status_code, headers=response_headers) - async def fetch_async(self) -> CustomFieldMappingInstance: + def get_page(self, target_url: str) -> CustomFieldMappingPage: """ - Asynchronously fetch the CustomFieldMappingInstance + Retrieve a specific page of CustomFieldMappingInstance records from the API. + Request is executed immediately + :param target_url: API-generated URL for the requested results page - :returns: The fetched CustomFieldMappingInstance + :returns: Page of CustomFieldMappingInstance """ - payload, _, _ = await self._fetch_async() - return CustomFieldMappingInstance(self._version, payload) + response = self._version.domain.twilio.request("GET", target_url) + return CustomFieldMappingPage(self._version, response) - async def fetch_with_http_info_async(self) -> ApiResponse: + async def get_page_async(self, target_url: str) -> CustomFieldMappingPage: """ - Asynchronously fetch the CustomFieldMappingInstance and return response metadata + Asynchronously retrieve a specific page of CustomFieldMappingInstance records from the API. + Request is executed immediately + :param target_url: API-generated URL for the requested results page - :returns: ApiResponse with instance, status code, and headers + :returns: Page of CustomFieldMappingInstance """ - payload, status_code, headers = await self._fetch_async() - instance = CustomFieldMappingInstance(self._version, payload) - return ApiResponse(data=instance, status_code=status_code, headers=headers) + response = await self._version.domain.twilio.request_async("GET", target_url) + return CustomFieldMappingPage(self._version, response) + + def get(self, mapping_id: str) -> CustomFieldMappingContext: + """ + Constructs a CustomFieldMappingContext + + :param mapping_id: The unique identifier of the custom field mapping, as returned in `id` when the mapping was created. + """ + return CustomFieldMappingContext(self._version, mapping_id=mapping_id) + + def __call__(self, mapping_id: str) -> CustomFieldMappingContext: + """ + Constructs a CustomFieldMappingContext + + :param mapping_id: The unique identifier of the custom field mapping, as returned in `id` when the mapping was created. + """ + return CustomFieldMappingContext(self._version, mapping_id=mapping_id) def __repr__(self) -> str: """ diff --git a/twilio/rest/insights/v3/capacity.py b/twilio/rest/insights/v3/custom_field_mappings_capacity.py similarity index 73% rename from twilio/rest/insights/v3/capacity.py rename to twilio/rest/insights/v3/custom_field_mappings_capacity.py index 69b51d8ab..6d65182c9 100644 --- a/twilio/rest/insights/v3/capacity.py +++ b/twilio/rest/insights/v3/custom_field_mappings_capacity.py @@ -23,7 +23,7 @@ from twilio.base.version import Version -class CapacityInstance(InstanceResource): +class CustomFieldMappingsCapacityInstance(InstanceResource): """ :ivar measure: """ @@ -40,21 +40,21 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" -class CapacityList(ListResource): +class CustomFieldMappingsCapacityList(ListResource): def __init__(self, version: Version): """ - Initialize the CapacityList + Initialize the CustomFieldMappingsCapacityList :param version: Version that contains the resource """ super().__init__(version) - self._uri = "/ControlPlane/ConversationInsights/CustomFieldMappings/Capacity" + self._uri = "/ControlPlane/ConversationInsights/CustomFieldMappingsCapacity" def _fetch(self) -> tuple: """ @@ -71,25 +71,25 @@ def _fetch(self) -> tuple: method="GET", uri=self._uri, headers=headers ) - def fetch(self) -> CapacityInstance: + def fetch(self) -> CustomFieldMappingsCapacityInstance: """ - Fetch the CapacityInstance + Fetch the CustomFieldMappingsCapacityInstance - :returns: The fetched CapacityInstance + :returns: The fetched CustomFieldMappingsCapacityInstance """ payload, _, _ = self._fetch() - return CapacityInstance(self._version, payload) + return CustomFieldMappingsCapacityInstance(self._version, payload) def fetch_with_http_info(self) -> ApiResponse: """ - Fetch the CapacityInstance and return response metadata + Fetch the CustomFieldMappingsCapacityInstance and return response metadata :returns: ApiResponse with instance, status code, and headers """ payload, status_code, headers = self._fetch() - instance = CapacityInstance(self._version, payload) + instance = CustomFieldMappingsCapacityInstance(self._version, payload) return ApiResponse(data=instance, status_code=status_code, headers=headers) async def _fetch_async(self) -> tuple: @@ -107,25 +107,25 @@ async def _fetch_async(self) -> tuple: method="GET", uri=self._uri, headers=headers ) - async def fetch_async(self) -> CapacityInstance: + async def fetch_async(self) -> CustomFieldMappingsCapacityInstance: """ - Asynchronously fetch the CapacityInstance + Asynchronously fetch the CustomFieldMappingsCapacityInstance - :returns: The fetched CapacityInstance + :returns: The fetched CustomFieldMappingsCapacityInstance """ payload, _, _ = await self._fetch_async() - return CapacityInstance(self._version, payload) + return CustomFieldMappingsCapacityInstance(self._version, payload) async def fetch_with_http_info_async(self) -> ApiResponse: """ - Asynchronously fetch the CapacityInstance and return response metadata + Asynchronously fetch the CustomFieldMappingsCapacityInstance and return response metadata :returns: ApiResponse with instance, status code, and headers """ payload, status_code, headers = await self._fetch_async() - instance = CapacityInstance(self._version, payload) + instance = CustomFieldMappingsCapacityInstance(self._version, payload) return ApiResponse(data=instance, status_code=status_code, headers=headers) def __repr__(self) -> str: @@ -134,4 +134,4 @@ def __repr__(self) -> str: :returns: Machine friendly representation """ - return "" + return "" diff --git a/twilio/rest/insights/v3/query.py b/twilio/rest/insights/v3/query.py index 35b079ccc..44e740de5 100644 --- a/twilio/rest/insights/v3/query.py +++ b/twilio/rest/insights/v3/query.py @@ -62,8 +62,8 @@ def __init__(self, payload: Dict[str, Any]): self.domain: Optional[str] = payload.get("domain") self.query: Optional[QueryList.QueryDefinition] = ( QueryList.QueryDefinition(payload.get("query")) - if payload.get("query") is not None - else None + if isinstance(payload.get("query"), dict) + else payload.get("query") ) def to_dict(self): diff --git a/twilio/rest/insights/v3/query_job.py b/twilio/rest/insights/v3/query_job.py index 66c25e084..6827e4afe 100644 --- a/twilio/rest/insights/v3/query_job.py +++ b/twilio/rest/insights/v3/query_job.py @@ -293,8 +293,8 @@ def __init__(self, payload: Dict[str, Any]): self.domain: Optional[str] = payload.get("domain") self.query: Optional[QueryList.QueryDefinition] = ( QueryList.QueryDefinition(payload.get("query")) - if payload.get("query") is not None - else None + if isinstance(payload.get("query"), dict) + else payload.get("query") ) def to_dict(self): diff --git a/twilio/rest/intelligence/v3/configuration.py b/twilio/rest/intelligence/v3/configuration.py index 882848272..449c7e88f 100644 --- a/twilio/rest/intelligence/v3/configuration.py +++ b/twilio/rest/intelligence/v3/configuration.py @@ -575,13 +575,13 @@ def __init__(self, payload: Dict[str, Any]): self.memory: Optional[ConfigurationList.ContextMemory] = ( ConfigurationList.ContextMemory(payload.get("memory")) - if payload.get("memory") is not None - else None + if isinstance(payload.get("memory"), dict) + else payload.get("memory") ) self.knowledge: Optional[ConfigurationList.ContextKnowledge] = ( ConfigurationList.ContextKnowledge(payload.get("knowledge")) - if payload.get("knowledge") is not None - else None + if isinstance(payload.get("knowledge"), dict) + else payload.get("knowledge") ) def to_dict(self): @@ -711,8 +711,8 @@ def __init__(self, payload: Dict[str, Any]): ) self.context: Optional[ConfigurationList.Context] = ( ConfigurationList.Context(payload.get("context")) - if payload.get("context") is not None - else None + if isinstance(payload.get("context"), dict) + else payload.get("context") ) def to_dict(self): @@ -773,8 +773,8 @@ def __init__(self, payload: Dict[str, Any]): ) self.context: Optional[ConfigurationList.Context] = ( ConfigurationList.Context(payload.get("context")) - if payload.get("context") is not None - else None + if isinstance(payload.get("context"), dict) + else payload.get("context") ) def to_dict(self): @@ -809,8 +809,8 @@ def __init__(self, payload: Dict[str, Any]): self.on: Optional[str] = payload.get("on") self.parameters: Optional[ConfigurationList.TriggerParameters] = ( ConfigurationList.TriggerParameters(payload.get("parameters")) - if payload.get("parameters") is not None - else None + if isinstance(payload.get("parameters"), dict) + else payload.get("parameters") ) def to_dict(self): diff --git a/twilio/rest/intelligence/v3/operator.py b/twilio/rest/intelligence/v3/operator.py index 64fc9f1cf..fb1b40f91 100644 --- a/twilio/rest/intelligence/v3/operator.py +++ b/twilio/rest/intelligence/v3/operator.py @@ -645,8 +645,8 @@ def __init__(self, payload: Dict[str, Any]): ) self.context: Optional[OperatorList.OperatorContext] = ( OperatorList.OperatorContext(payload.get("context")) - if payload.get("context") is not None - else None + if isinstance(payload.get("context"), dict) + else payload.get("context") ) self.parameters: Optional[Dict[str, OperatorList.OperatorParameter]] = ( { @@ -693,13 +693,13 @@ def __init__(self, payload: Dict[str, Any]): self.memory: Optional[OperatorList.OperatorContextMemory] = ( OperatorList.OperatorContextMemory(payload.get("memory")) - if payload.get("memory") is not None - else None + if isinstance(payload.get("memory"), dict) + else payload.get("memory") ) self.knowledge: Optional[OperatorList.OperatorContextKnowledge] = ( OperatorList.OperatorContextKnowledge(payload.get("knowledge")) - if payload.get("knowledge") is not None - else None + if isinstance(payload.get("knowledge"), dict) + else payload.get("knowledge") ) def to_dict(self): diff --git a/twilio/rest/intelligence/v3/rule_execution.py b/twilio/rest/intelligence/v3/rule_execution.py index 550491f86..833f9a459 100644 --- a/twilio/rest/intelligence/v3/rule_execution.py +++ b/twilio/rest/intelligence/v3/rule_execution.py @@ -70,8 +70,8 @@ def __init__(self, payload: Dict[str, Any]): self.conversation_id: Optional[str] = payload.get("conversationId") self.rule: Optional[RuleExecutionList.RuleOverride] = ( RuleExecutionList.RuleOverride(payload.get("rule")) - if payload.get("rule") is not None - else None + if isinstance(payload.get("rule"), dict) + else payload.get("rule") ) def to_dict(self): diff --git a/twilio/rest/knowledge/v1/knowledge/__init__.py b/twilio/rest/knowledge/v1/knowledge/__init__.py index 568850ebc..96aff9e5a 100644 --- a/twilio/rest/knowledge/v1/knowledge/__init__.py +++ b/twilio/rest/knowledge/v1/knowledge/__init__.py @@ -50,8 +50,8 @@ def __init__(self, payload: Dict[str, Any]): KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest( payload.get("policy") ) - if payload.get("policy") is not None - else None + if isinstance(payload.get("policy"), dict) + else payload.get("policy") ) self.type: Optional[str] = payload.get("type") self.embedding_model: Optional[str] = payload.get("embedding_model") @@ -117,8 +117,8 @@ def __init__(self, payload: Dict[str, Any]): KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest( payload.get("policy") ) - if payload.get("policy") is not None - else None + if isinstance(payload.get("policy"), dict) + else payload.get("policy") ) self.type: Optional[str] = payload.get("type") self.embedding_model: Optional[str] = payload.get("embedding_model") @@ -380,8 +380,8 @@ def __init__(self, payload: Dict[str, Any]): KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest( payload.get("policy") ) - if payload.get("policy") is not None - else None + if isinstance(payload.get("policy"), dict) + else payload.get("policy") ) self.type: Optional[str] = payload.get("type") self.embedding_model: Optional[str] = payload.get("embedding_model") @@ -447,8 +447,8 @@ def __init__(self, payload: Dict[str, Any]): KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest( payload.get("policy") ) - if payload.get("policy") is not None - else None + if isinstance(payload.get("policy"), dict) + else payload.get("policy") ) self.type: Optional[str] = payload.get("type") self.embedding_model: Optional[str] = payload.get("embedding_model") @@ -840,8 +840,8 @@ def __init__(self, payload: Dict[str, Any]): KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest( payload.get("policy") ) - if payload.get("policy") is not None - else None + if isinstance(payload.get("policy"), dict) + else payload.get("policy") ) self.type: Optional[str] = payload.get("type") self.embedding_model: Optional[str] = payload.get("embedding_model") @@ -907,8 +907,8 @@ def __init__(self, payload: Dict[str, Any]): KnowledgeList.KnowledgeV1ServiceCreatePolicyRequest( payload.get("policy") ) - if payload.get("policy") is not None - else None + if isinstance(payload.get("policy"), dict) + else payload.get("policy") ) self.type: Optional[str] = payload.get("type") self.embedding_model: Optional[str] = payload.get("embedding_model") diff --git a/twilio/rest/knowledge/v2/knowledge.py b/twilio/rest/knowledge/v2/knowledge.py index 1f5fedbe6..f4a934ddb 100644 --- a/twilio/rest/knowledge/v2/knowledge.py +++ b/twilio/rest/knowledge/v2/knowledge.py @@ -632,8 +632,8 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.source: Optional[KnowledgeList.KnowledgeSourceTypes] = ( KnowledgeList.KnowledgeSourceTypes(payload.get("source")) - if payload.get("source") is not None - else None + if isinstance(payload.get("source"), dict) + else payload.get("source") ) def to_dict(self): diff --git a/twilio/rest/lookups/v2/query.py b/twilio/rest/lookups/v2/query.py index c421107cc..d58702b7b 100644 --- a/twilio/rest/lookups/v2/query.py +++ b/twilio/rest/lookups/v2/query.py @@ -108,18 +108,18 @@ def __init__(self, payload: Dict[str, Any]): self.country_code: Optional[str] = payload.get("country_code") self.identity_match: Optional[QueryList.IdentityMatchParameters] = ( QueryList.IdentityMatchParameters(payload.get("identity_match")) - if payload.get("identity_match") is not None - else None + if isinstance(payload.get("identity_match"), dict) + else payload.get("identity_match") ) self.reassigned_number: Optional[QueryList.ReassignedNumberParameters] = ( QueryList.ReassignedNumberParameters(payload.get("reassigned_number")) - if payload.get("reassigned_number") is not None - else None + if isinstance(payload.get("reassigned_number"), dict) + else payload.get("reassigned_number") ) self.sms_pumping_risk: Optional[QueryList.RiskParameters] = ( QueryList.RiskParameters(payload.get("sms_pumping_risk")) - if payload.get("sms_pumping_risk") is not None - else None + if isinstance(payload.get("sms_pumping_risk"), dict) + else payload.get("sms_pumping_risk") ) def to_dict(self): @@ -307,18 +307,18 @@ def __init__(self, payload: Dict[str, Any]): self.country_code: Optional[str] = payload.get("country_code") self.identity_match: Optional[QueryList.IdentityMatchParameters] = ( QueryList.IdentityMatchParameters(payload.get("identity_match")) - if payload.get("identity_match") is not None - else None + if isinstance(payload.get("identity_match"), dict) + else payload.get("identity_match") ) self.reassigned_number: Optional[QueryList.ReassignedNumberParameters] = ( QueryList.ReassignedNumberParameters(payload.get("reassigned_number")) - if payload.get("reassigned_number") is not None - else None + if isinstance(payload.get("reassigned_number"), dict) + else payload.get("reassigned_number") ) self.sms_pumping_risk: Optional[QueryList.RiskParameters] = ( QueryList.RiskParameters(payload.get("sms_pumping_risk")) - if payload.get("sms_pumping_risk") is not None - else None + if isinstance(payload.get("sms_pumping_risk"), dict) + else payload.get("sms_pumping_risk") ) def to_dict(self): diff --git a/twilio/rest/memory/v1/conversation_summary.py b/twilio/rest/memory/v1/conversation_summary.py index a53ba66c0..16933d864 100644 --- a/twilio/rest/memory/v1/conversation_summary.py +++ b/twilio/rest/memory/v1/conversation_summary.py @@ -27,14 +27,14 @@ class ConversationSummaryInstance(InstanceResource): """ - :ivar source: The source system that generated the summary. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :ivar message: + :ivar source: The source system that generated the summary. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :ivar content: The main content of the summary. :ivar occurred_at: The timestamp when the summary was originally created. :ivar conversation_id: A unique identifier for the conversation using Twilio Type ID (TTID) format. :ivar id: A unique identifier for the summary using Twilio Type ID (TTID) format. :ivar created_at: The timestamp when the summary was created. :ivar updated_at: The timestamp when the summary was last updated. - :ivar message: """ def __init__( @@ -47,6 +47,7 @@ def __init__( ): super().__init__(version) + self.message: Optional[str] = payload.get("message") self.source: Optional[str] = payload.get("source") self.content: Optional[str] = payload.get("content") self.occurred_at: Optional[datetime] = deserialize.iso8601_datetime( @@ -60,7 +61,6 @@ def __init__( self.updated_at: Optional[datetime] = deserialize.iso8601_datetime( payload.get("updatedAt") ) - self.message: Optional[str] = payload.get("message") # Only set _solution if path params are provided (not None) if store_id is not None or profile_id is not None or summary_id is not None: @@ -580,7 +580,7 @@ def to_dict(self): class SummaryCore(object): """ - :ivar source: The source system that generated the summary. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :ivar source: The source system that generated the summary. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :ivar content: The main content of the summary. :ivar occurred_at: The timestamp when the summary was originally created. :ivar conversation_id: A unique identifier for the conversation using Twilio Type ID (TTID) format. @@ -603,7 +603,7 @@ def to_dict(self): class SummaryCorePatch(object): """ - :ivar source: The source system that generated the summary. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :ivar source: The source system that generated the summary. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :ivar content: The main content of the summary. :ivar occurred_at: The timestamp when the summary was originally created. If not provided, defaults to the time the summary was received. :ivar conversation_id: A unique identifier for the conversation using Twilio Type ID (TTID) format. diff --git a/twilio/rest/memory/v1/data_mapping.py b/twilio/rest/memory/v1/data_mapping.py index 151a63c6a..70ea91252 100644 --- a/twilio/rest/memory/v1/data_mapping.py +++ b/twilio/rest/memory/v1/data_mapping.py @@ -603,13 +603,13 @@ def __init__(self, payload: Dict[str, Any]): self.is_enabled: Optional[bool] = payload.get("isEnabled") self.mapping_to: Optional[DataMappingList.DataMappingToTraits] = ( DataMappingList.DataMappingToTraits(payload.get("mappingTo")) - if payload.get("mappingTo") is not None - else None + if isinstance(payload.get("mappingTo"), dict) + else payload.get("mappingTo") ) self.mapping_from: Optional[DataMappingList.DataMappingFromTypes] = ( DataMappingList.DataMappingFromTypes(payload.get("mappingFrom")) - if payload.get("mappingFrom") is not None - else None + if isinstance(payload.get("mappingFrom"), dict) + else payload.get("mappingFrom") ) def to_dict(self): @@ -642,8 +642,8 @@ def __init__(self, payload: Dict[str, Any]): self.is_enabled: Optional[bool] = payload.get("isEnabled") self.mapping_to: Optional[DataMappingList.DataMappingToTraits] = ( DataMappingList.DataMappingToTraits(payload.get("mappingTo")) - if payload.get("mappingTo") is not None - else None + if isinstance(payload.get("mappingTo"), dict) + else payload.get("mappingTo") ) def to_dict(self): diff --git a/twilio/rest/memory/v1/observation.py b/twilio/rest/memory/v1/observation.py index c24f89897..c4e1473f5 100644 --- a/twilio/rest/memory/v1/observation.py +++ b/twilio/rest/memory/v1/observation.py @@ -30,7 +30,7 @@ class ObservationInstance(InstanceResource): :ivar message: :ivar content: The main content of the observation. :ivar occurred_at: The timestamp when the observation originally occurred. - :ivar source: The source system that generated this observation. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :ivar source: The source system that generated this observation. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :ivar conversation_ids: Array of conversation IDs associated with this observation. :ivar id: A unique identifier for the observation using Twilio Type ID (TTID) format. :ivar created_at: The timestamp when the observation was created. @@ -578,7 +578,7 @@ class ObservationBase(object): """ :ivar content: The main content of the observation. :ivar occurred_at: The timestamp when the observation originally occurred. - :ivar source: The source system that generated this observation. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :ivar source: The source system that generated this observation. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :ivar conversation_ids: Array of conversation IDs associated with this observation. """ @@ -601,7 +601,7 @@ class ObservationCreateRequest(object): """ :ivar content: The main content of the observation. :ivar occurred_at: The timestamp when the observation originally occurred. - :ivar source: The source system that generated this observation. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :ivar source: The source system that generated this observation. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :ivar conversation_ids: Array of conversation IDs associated with this observation. """ @@ -830,7 +830,7 @@ def stream( :param str page_token: The token for the page of results to retrieve. :param str order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. - :param str source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :param str source: Filter by source. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :param datetime created_after: Filter observations created after this timestamp (inclusive). :param datetime created_before: Filter observations created before this timestamp (exclusive). :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. @@ -878,7 +878,7 @@ async def stream_async( :param str page_token: The token for the page of results to retrieve. :param str order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. - :param str source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :param str source: Filter by source. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :param datetime created_after: Filter observations created after this timestamp (inclusive). :param datetime created_before: Filter observations created before this timestamp (exclusive). :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. @@ -924,7 +924,7 @@ def stream_with_http_info( :param str page_token: The token for the page of results to retrieve. :param str order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. - :param str source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :param str source: Filter by source. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :param datetime created_after: Filter observations created after this timestamp (inclusive). :param datetime created_before: Filter observations created before this timestamp (exclusive). :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. @@ -971,7 +971,7 @@ async def stream_with_http_info_async( :param str page_token: The token for the page of results to retrieve. :param str order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. - :param str source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :param str source: Filter by source. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :param datetime created_after: Filter observations created after this timestamp (inclusive). :param datetime created_before: Filter observations created before this timestamp (exclusive). :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. @@ -1019,7 +1019,7 @@ def list( :param str page_token: The token for the page of results to retrieve. :param str order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. - :param str source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :param str source: Filter by source. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :param datetime created_after: Filter observations created after this timestamp (inclusive). :param datetime created_before: Filter observations created before this timestamp (exclusive). :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. @@ -1067,7 +1067,7 @@ async def list_async( :param str page_token: The token for the page of results to retrieve. :param str order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. - :param str source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :param str source: Filter by source. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :param datetime created_after: Filter observations created after this timestamp (inclusive). :param datetime created_before: Filter observations created before this timestamp (exclusive). :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. @@ -1115,7 +1115,7 @@ def list_with_http_info( :param str page_token: The token for the page of results to retrieve. :param str order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. - :param str source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :param str source: Filter by source. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :param datetime created_after: Filter observations created after this timestamp (inclusive). :param datetime created_before: Filter observations created before this timestamp (exclusive). :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. @@ -1161,7 +1161,7 @@ async def list_with_http_info_async( :param str page_token: The token for the page of results to retrieve. :param str order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. - :param str source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :param str source: Filter by source. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :param datetime created_after: Filter observations created after this timestamp (inclusive). :param datetime created_before: Filter observations created before this timestamp (exclusive). :param str conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. @@ -1207,7 +1207,7 @@ def page( :param page_size: The maximum number of items to return per page, maximum of 1000. :param page_token: The token for the page of results to retrieve. :param order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. - :param source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :param source: Filter by source. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :param created_after: Filter observations created after this timestamp (inclusive). :param created_before: Filter observations created before this timestamp (exclusive). :param conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. @@ -1261,7 +1261,7 @@ async def page_async( :param page_size: The maximum number of items to return per page, maximum of 1000. :param page_token: The token for the page of results to retrieve. :param order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. - :param source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :param source: Filter by source. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :param created_after: Filter observations created after this timestamp (inclusive). :param created_before: Filter observations created before this timestamp (exclusive). :param conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. @@ -1315,7 +1315,7 @@ def page_with_http_info( :param page_token: The token for the page of results to retrieve. :param order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. - :param source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :param source: Filter by source. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :param created_after: Filter observations created after this timestamp (inclusive). :param created_before: Filter observations created before this timestamp (exclusive). :param conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. @@ -1376,7 +1376,7 @@ async def page_with_http_info_async( :param page_token: The token for the page of results to retrieve. :param order_by: Either 'ASC' or 'DESC' to sort results ascending or descending respectively. - :param source: Filter by source. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :param source: Filter by source. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :param created_after: Filter observations created after this timestamp (inclusive). :param created_before: Filter observations created before this timestamp (exclusive). :param conversation_id: Filter by conversation ID. Returns only items associated with the specified conversation. diff --git a/twilio/rest/memory/v1/recall.py b/twilio/rest/memory/v1/recall.py index d04f56a39..ee536d074 100644 --- a/twilio/rest/memory/v1/recall.py +++ b/twilio/rest/memory/v1/recall.py @@ -100,8 +100,8 @@ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.type: Optional[ParticipantType] = ( ParticipantType(payload.get("type")) - if payload.get("type") is not None - else None + if isinstance(payload.get("type"), dict) + else payload.get("type") ) self.profile_id: Optional[str] = payload.get("profileId") self.address: Optional[str] = payload.get("address") @@ -174,8 +174,8 @@ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.type: Optional[ParticipantType] = ( ParticipantType(payload.get("type")) - if payload.get("type") is not None - else None + if isinstance(payload.get("type"), dict) + else payload.get("type") ) self.profile_id: Optional[str] = payload.get("profileId") self.address: Optional[str] = payload.get("address") diff --git a/twilio/rest/memory/v1/revision.py b/twilio/rest/memory/v1/revision.py index 34684c408..5f9a41745 100644 --- a/twilio/rest/memory/v1/revision.py +++ b/twilio/rest/memory/v1/revision.py @@ -29,7 +29,7 @@ class RevisionInstance(InstanceResource): """ :ivar content: The main content of the observation. :ivar occurred_at: The timestamp when the observation originally occurred. - :ivar source: The source system that generated this observation. Allows letters, numbers, spaces, and URL-safe symbols. Excludes URL-unsafe characters like quotes, angle brackets, and control characters. + :ivar source: The source system that generated this observation. Allows letters, numbers, spaces, periods, underscores, hyphens, and forward slashes. :ivar conversation_ids: Array of conversation IDs associated with this observation. :ivar id: A unique identifier for the observation using Twilio Type ID (TTID) format. :ivar created_at: The timestamp when the observation was created. diff --git a/twilio/rest/memory/v1/trait_group.py b/twilio/rest/memory/v1/trait_group.py index 30dbd279d..32f65284a 100644 --- a/twilio/rest/memory/v1/trait_group.py +++ b/twilio/rest/memory/v1/trait_group.py @@ -785,8 +785,8 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.validation_rule: Optional[TraitGroupList.ValidationRule] = ( TraitGroupList.ValidationRule(payload.get("validationRule")) - if payload.get("validationRule") is not None - else None + if isinstance(payload.get("validationRule"), dict) + else payload.get("validationRule") ) self.id_type_promotion: Optional[str] = payload.get("idTypePromotion") @@ -850,8 +850,8 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.validation_rule: Optional[ValidationRule] = ( ValidationRule(payload.get("validationRule")) - if payload.get("validationRule") is not None - else None + if isinstance(payload.get("validationRule"), dict) + else payload.get("validationRule") ) self.id_type_promotion: Optional[str] = payload.get("idTypePromotion") @@ -916,8 +916,8 @@ def __init__(self, payload: Dict[str, Any]): self.description: Optional[str] = payload.get("description") self.validation_rule: Optional[TraitGroupList.ValidationRule] = ( TraitGroupList.ValidationRule(payload.get("validationRule")) - if payload.get("validationRule") is not None - else None + if isinstance(payload.get("validationRule"), dict) + else payload.get("validationRule") ) self.id_type_promotion: Optional[str] = payload.get("idTypePromotion") diff --git a/twilio/rest/messaging/v2/channels_sender.py b/twilio/rest/messaging/v2/channels_sender.py index 23462b7d0..6bf5c0bf7 100644 --- a/twilio/rest/messaging/v2/channels_sender.py +++ b/twilio/rest/messaging/v2/channels_sender.py @@ -12,8 +12,9 @@ Do not edit the class manually. """ +from datetime import datetime from typing import Any, Dict, List, Optional, Union, Iterator, AsyncIterator -from twilio.base import values +from twilio.base import deserialize, values from twilio.base.api_response import ApiResponse from twilio.base.instance_context import InstanceContext from twilio.base.instance_resource import InstanceResource @@ -54,7 +55,7 @@ def to_dict(self): class MessagingV2ChannelsSenderProfile(object): """ - :ivar name: The name of the sender. Required for WhatsApp senders and must follow [Meta's display name guidelines](https://www.facebook.com/business/help/757569725593362). + :ivar name: The name of the sender. Required for WhatsApp senders and must follow [Meta's display name guidelines](https://www.facebook.com/business/help/757569725593362). On update, a WhatsApp sender's name is not changed synchronously: it is submitted to Meta for review, and `profile.name` continues to report the current active name until Meta approves the new one and the sender is automatically re-registered. Track progress with `pending_display_name_status` on Fetch Sender, and see `display_name_status` on the update response for the immediate outcome. Re-submitting the same name is how you retry applying a name Meta has already approved, for example after correcting the sender's two-step verification PIN. Meta permits a limited number of display name changes per 30-day period. :ivar about: The profile about text for the sender. :ivar address: The address of the sender. :ivar description: The description of the sender. @@ -179,8 +180,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) self.webhook: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderWebhook @@ -188,8 +189,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderWebhook( payload.get("webhook") ) - if payload.get("webhook") is not None - else None + if isinstance(payload.get("webhook"), dict) + else payload.get("webhook") ) self.profile: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderProfile @@ -197,8 +198,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderProfile( payload.get("profile") ) - if payload.get("profile") is not None - else None + if isinstance(payload.get("profile"), dict) + else payload.get("profile") ) def to_dict(self): @@ -231,8 +232,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) self.webhook: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderWebhook @@ -240,8 +241,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderWebhook( payload.get("webhook") ) - if payload.get("webhook") is not None - else None + if isinstance(payload.get("webhook"), dict) + else payload.get("webhook") ) self.profile: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderProfile @@ -249,8 +250,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderProfile( payload.get("profile") ) - if payload.get("profile") is not None - else None + if isinstance(payload.get("profile"), dict) + else payload.get("profile") ) def to_dict(self): @@ -307,8 +308,8 @@ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.status: Optional[MessagingV2RcsCarrierStatus] = ( MessagingV2RcsCarrierStatus(payload.get("status")) - if payload.get("status") is not None - else None + if isinstance(payload.get("status"), dict) + else payload.get("status") ) def to_dict(self): @@ -331,8 +332,8 @@ def __init__(self, payload: Dict[str, Any]): self.registration_sid: Optional[str] = payload.get("registration_sid") self.status: Optional[MessagingV2RcsCountryStatus] = ( MessagingV2RcsCountryStatus(payload.get("status")) - if payload.get("status") is not None - else None + if isinstance(payload.get("status"), dict) + else payload.get("status") ) self.carriers: Optional[List[MessagingV2RcsCarrier]] = ( [ @@ -388,10 +389,14 @@ class MessagingV2RcsCountryStatus(object): :ivar configuration: :ivar webhook: :ivar profile: + :ivar pending_display_name: WhatsApp only. The display name the most recent change applies to — awaiting Meta review, approved by Meta and awaiting re-registration, or, once `pending_display_name_status` is `COMPLETED`, the name now in effect (identical to `name`). Absent when no display name change has been made, and once a completed change stops being reported. + :ivar pending_display_name_status: WhatsApp only. The status of the most recent display name change. `PENDING_REVIEW`, `APPROVED` and `DECLINED` are reported by Meta. `PIN_MISMATCH` and `REGISTRATION_FAILED` mean Meta approved the name but it could not be applied; `EXPIRED` means Meta's 14-day window to apply an approved name elapsed. In all three cases, re-submit the same `profile.name` to retry. `COMPLETED` means the name was approved and applied — `name` now returns it. A `COMPLETED` change is reported for 14 days after it completes and is absent afterwards, so treat its presence as \"recently completed\" rather than a permanent flag; use `pending_display_name_status_date` to tell how recent. Absent when no display name change has been made. + :ivar pending_display_name_status_date: WhatsApp only. The date and time in UTC when `pending_display_name_status` last changed, specified in ISO 8601 format. Absent whenever `pending_display_name_status` is absent, so the three `pending_display_name*` fields are always present or absent together. :ivar properties: :ivar offline_reasons: The reasons why the sender is offline. :ivar compliance: :ivar url: The URL of the resource. + :ivar display_name_status: WhatsApp only. The outcome of the display name operation in this request. Present only when the request included `profile.name`. `updating` — accepted; either submitted to Meta for review, or, when Meta had already approved this exact name, routed straight to re-registration. `no_change` — the name already matches the sender's active display name; nothing was submitted to Meta. `pending_review` — the same name is already under review at Meta; the existing request continues unchanged. `error` — the display name could not be processed, while other profile fields in the same request were still applied. Returned with a 202 and carries no error code or message. This covers every failure mode, including the case where Meta accepted the name but tracking could not be started — poll `pending_display_name_status` to establish the real state rather than assuming the name was rejected. When `profile.name` is the only field in the request, the failure is returned as an error response with a specific code instead of this status. """ def __init__( @@ -406,10 +411,20 @@ def __init__( self.configuration: Optional[str] = payload.get("configuration") self.webhook: Optional[str] = payload.get("webhook") self.profile: Optional[str] = payload.get("profile") + self.pending_display_name: Optional[str] = payload.get("pending_display_name") + self.pending_display_name_status: Optional[str] = payload.get( + "pending_display_name_status" + ) + self.pending_display_name_status_date: Optional[datetime] = ( + deserialize.iso8601_datetime( + payload.get("pending_display_name_status_date") + ) + ) self.properties: Optional[str] = payload.get("properties") self.offline_reasons: Optional[List[str]] = payload.get("offline_reasons") self.compliance: Optional[str] = payload.get("compliance") self.url: Optional[str] = payload.get("url") + self.display_name_status: Optional[str] = payload.get("display_name_status") self._solution = { "sid": sid or self.sid, @@ -614,7 +629,7 @@ def to_dict(self): class MessagingV2ChannelsSenderProfile(object): """ - :ivar name: The name of the sender. Required for WhatsApp senders and must follow [Meta's display name guidelines](https://www.facebook.com/business/help/757569725593362). + :ivar name: The name of the sender. Required for WhatsApp senders and must follow [Meta's display name guidelines](https://www.facebook.com/business/help/757569725593362). On update, a WhatsApp sender's name is not changed synchronously: it is submitted to Meta for review, and `profile.name` continues to report the current active name until Meta approves the new one and the sender is automatically re-registered. Track progress with `pending_display_name_status` on Fetch Sender, and see `display_name_status` on the update response for the immediate outcome. Re-submitting the same name is how you retry applying a name Meta has already approved, for example after correcting the sender's two-step verification PIN. Meta permits a limited number of display name changes per 30-day period. :ivar about: The profile about text for the sender. :ivar address: The address of the sender. :ivar description: The description of the sender. @@ -739,8 +754,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) self.webhook: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderWebhook @@ -748,8 +763,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderWebhook( payload.get("webhook") ) - if payload.get("webhook") is not None - else None + if isinstance(payload.get("webhook"), dict) + else payload.get("webhook") ) self.profile: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderProfile @@ -757,8 +772,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderProfile( payload.get("profile") ) - if payload.get("profile") is not None - else None + if isinstance(payload.get("profile"), dict) + else payload.get("profile") ) def to_dict(self): @@ -791,8 +806,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) self.webhook: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderWebhook @@ -800,8 +815,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderWebhook( payload.get("webhook") ) - if payload.get("webhook") is not None - else None + if isinstance(payload.get("webhook"), dict) + else payload.get("webhook") ) self.profile: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderProfile @@ -809,8 +824,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderProfile( payload.get("profile") ) - if payload.get("profile") is not None - else None + if isinstance(payload.get("profile"), dict) + else payload.get("profile") ) def to_dict(self): @@ -867,8 +882,8 @@ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.status: Optional[MessagingV2RcsCarrierStatus] = ( MessagingV2RcsCarrierStatus(payload.get("status")) - if payload.get("status") is not None - else None + if isinstance(payload.get("status"), dict) + else payload.get("status") ) def to_dict(self): @@ -891,8 +906,8 @@ def __init__(self, payload: Dict[str, Any]): self.registration_sid: Optional[str] = payload.get("registration_sid") self.status: Optional[MessagingV2RcsCountryStatus] = ( MessagingV2RcsCountryStatus(payload.get("status")) - if payload.get("status") is not None - else None + if isinstance(payload.get("status"), dict) + else payload.get("status") ) self.carriers: Optional[List[MessagingV2RcsCarrier]] = ( [ @@ -1276,7 +1291,7 @@ def to_dict(self): class MessagingV2ChannelsSenderProfile(object): """ - :ivar name: The name of the sender. Required for WhatsApp senders and must follow [Meta's display name guidelines](https://www.facebook.com/business/help/757569725593362). + :ivar name: The name of the sender. Required for WhatsApp senders and must follow [Meta's display name guidelines](https://www.facebook.com/business/help/757569725593362). On update, a WhatsApp sender's name is not changed synchronously: it is submitted to Meta for review, and `profile.name` continues to report the current active name until Meta approves the new one and the sender is automatically re-registered. Track progress with `pending_display_name_status` on Fetch Sender, and see `display_name_status` on the update response for the immediate outcome. Re-submitting the same name is how you retry applying a name Meta has already approved, for example after correcting the sender's two-step verification PIN. Meta permits a limited number of display name changes per 30-day period. :ivar about: The profile about text for the sender. :ivar address: The address of the sender. :ivar description: The description of the sender. @@ -1401,8 +1416,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) self.webhook: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderWebhook @@ -1410,8 +1425,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderWebhook( payload.get("webhook") ) - if payload.get("webhook") is not None - else None + if isinstance(payload.get("webhook"), dict) + else payload.get("webhook") ) self.profile: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderProfile @@ -1419,8 +1434,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderProfile( payload.get("profile") ) - if payload.get("profile") is not None - else None + if isinstance(payload.get("profile"), dict) + else payload.get("profile") ) def to_dict(self): @@ -1453,8 +1468,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) self.webhook: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderWebhook @@ -1462,8 +1477,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderWebhook( payload.get("webhook") ) - if payload.get("webhook") is not None - else None + if isinstance(payload.get("webhook"), dict) + else payload.get("webhook") ) self.profile: Optional[ ChannelsSenderList.MessagingV2ChannelsSenderProfile @@ -1471,8 +1486,8 @@ def __init__(self, payload: Dict[str, Any]): ChannelsSenderList.MessagingV2ChannelsSenderProfile( payload.get("profile") ) - if payload.get("profile") is not None - else None + if isinstance(payload.get("profile"), dict) + else payload.get("profile") ) def to_dict(self): @@ -1529,8 +1544,8 @@ def __init__(self, payload: Dict[str, Any]): self.name: Optional[str] = payload.get("name") self.status: Optional[MessagingV2RcsCarrierStatus] = ( MessagingV2RcsCarrierStatus(payload.get("status")) - if payload.get("status") is not None - else None + if isinstance(payload.get("status"), dict) + else payload.get("status") ) def to_dict(self): @@ -1553,8 +1568,8 @@ def __init__(self, payload: Dict[str, Any]): self.registration_sid: Optional[str] = payload.get("registration_sid") self.status: Optional[MessagingV2RcsCountryStatus] = ( MessagingV2RcsCountryStatus(payload.get("status")) - if payload.get("status") is not None - else None + if isinstance(payload.get("status"), dict) + else payload.get("status") ) self.carriers: Optional[List[MessagingV2RcsCarrier]] = ( [ diff --git a/twilio/rest/numbers/v1/__init__.py b/twilio/rest/numbers/v1/__init__.py index 59dd3d522..2ca3e1151 100644 --- a/twilio/rest/numbers/v1/__init__.py +++ b/twilio/rest/numbers/v1/__init__.py @@ -37,7 +37,6 @@ from twilio.rest.numbers.v1.sms_verification import SmsVerificationList from twilio.rest.numbers.v1.sms_verification_check import SmsVerificationCheckList from twilio.rest.numbers.v1.voice_verification import VoiceVerificationList -from twilio.rest.numbers.v1.voice_verification_check import VoiceVerificationCheckList from twilio.rest.numbers.v1.webhook import WebhookList @@ -71,7 +70,6 @@ def __init__(self, domain: Domain): self._sms_verifications: Optional[SmsVerificationList] = None self._sms_verification_checks: Optional[SmsVerificationCheckList] = None self._voice_verifications: Optional[VoiceVerificationList] = None - self._voice_verification_checks: Optional[VoiceVerificationCheckList] = None self._webhook: Optional[WebhookList] = None @property @@ -170,12 +168,6 @@ def voice_verifications(self) -> VoiceVerificationList: self._voice_verifications = VoiceVerificationList(self) return self._voice_verifications - @property - def voice_verification_checks(self) -> VoiceVerificationCheckList: - if self._voice_verification_checks is None: - self._voice_verification_checks = VoiceVerificationCheckList(self) - return self._voice_verification_checks - @property def webhook(self) -> WebhookList: if self._webhook is None: diff --git a/twilio/rest/numbers/v1/porting_port_in.py b/twilio/rest/numbers/v1/porting_port_in.py index 9824148a0..3d16cfc94 100644 --- a/twilio/rest/numbers/v1/porting_port_in.py +++ b/twilio/rest/numbers/v1/porting_port_in.py @@ -79,8 +79,8 @@ def __init__(self, payload: Dict[str, Any]): self.address_sid: Optional[str] = payload.get("address_sid") self.address: Optional[PortingPortInList.NumbersV1PortingAddress] = ( PortingPortInList.NumbersV1PortingAddress(payload.get("address")) - if payload.get("address") is not None - else None + if isinstance(payload.get("address"), dict) + else payload.get("address") ) self.authorized_representative: Optional[str] = payload.get( "authorized_representative" @@ -151,8 +151,8 @@ def __init__(self, payload: Dict[str, Any]): PortingPortInList.NumbersV1PortingLosingCarrierInformation( payload.get("losing_carrier_information") ) - if payload.get("losing_carrier_information") is not None - else None + if isinstance(payload.get("losing_carrier_information"), dict) + else payload.get("losing_carrier_information") ) self.notification_emails: Optional[List[str]] = payload.get( "notification_emails" @@ -444,8 +444,8 @@ def __init__(self, payload: Dict[str, Any]): self.address_sid: Optional[str] = payload.get("address_sid") self.address: Optional[PortingPortInList.NumbersV1PortingAddress] = ( PortingPortInList.NumbersV1PortingAddress(payload.get("address")) - if payload.get("address") is not None - else None + if isinstance(payload.get("address"), dict) + else payload.get("address") ) self.authorized_representative: Optional[str] = payload.get( "authorized_representative" @@ -516,8 +516,8 @@ def __init__(self, payload: Dict[str, Any]): PortingPortInList.NumbersV1PortingLosingCarrierInformation( payload.get("losing_carrier_information") ) - if payload.get("losing_carrier_information") is not None - else None + if isinstance(payload.get("losing_carrier_information"), dict) + else payload.get("losing_carrier_information") ) self.notification_emails: Optional[List[str]] = payload.get( "notification_emails" @@ -819,8 +819,8 @@ def __init__(self, payload: Dict[str, Any]): self.address_sid: Optional[str] = payload.get("address_sid") self.address: Optional[PortingPortInList.NumbersV1PortingAddress] = ( PortingPortInList.NumbersV1PortingAddress(payload.get("address")) - if payload.get("address") is not None - else None + if isinstance(payload.get("address"), dict) + else payload.get("address") ) self.authorized_representative: Optional[str] = payload.get( "authorized_representative" @@ -891,8 +891,8 @@ def __init__(self, payload: Dict[str, Any]): PortingPortInList.NumbersV1PortingLosingCarrierInformation( payload.get("losing_carrier_information") ) - if payload.get("losing_carrier_information") is not None - else None + if isinstance(payload.get("losing_carrier_information"), dict) + else payload.get("losing_carrier_information") ) self.notification_emails: Optional[List[str]] = payload.get( "notification_emails" diff --git a/twilio/rest/numbers/v1/sms_verification.py b/twilio/rest/numbers/v1/sms_verification.py index 71d0d2215..d673b039c 100644 --- a/twilio/rest/numbers/v1/sms_verification.py +++ b/twilio/rest/numbers/v1/sms_verification.py @@ -22,6 +22,27 @@ class SmsVerificationInstance(InstanceResource): + + class NumbersV1SmsVerificationRequest(object): + """ + :ivar to: The phone number to verify in E.164 format. + :ivar locale: The locale for the verification SMS message. + :ivar friendly_name: A human-readable name for the caller ID. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.to: Optional[str] = payload.get("to") + self.locale: Optional[str] = payload.get("locale") + self.friendly_name: Optional[str] = payload.get("friendly_name") + + def to_dict(self): + return { + "to": self.to, + "locale": self.locale, + "friendly_name": self.friendly_name, + } + """ :ivar to: The phone number being verified in E.164 format. :ivar verification_sid: The unique SID of this verification resource. @@ -47,6 +68,26 @@ def __repr__(self) -> str: class SmsVerificationList(ListResource): + class NumbersV1SmsVerificationRequest(object): + """ + :ivar to: The phone number to verify in E.164 format. + :ivar locale: The locale for the verification SMS message. + :ivar friendly_name: A human-readable name for the caller ID. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.to: Optional[str] = payload.get("to") + self.locale: Optional[str] = payload.get("locale") + self.friendly_name: Optional[str] = payload.get("friendly_name") + + def to_dict(self): + return { + "to": self.to, + "locale": self.locale, + "friendly_name": self.friendly_name, + } + def __init__(self, version: Version): """ Initialize the SmsVerificationList @@ -58,77 +99,107 @@ def __init__(self, version: Version): self._uri = "/CallerIds/SmsVerifications" - def _create(self) -> tuple: + def _create( + self, numbers_v1_sms_verification_request: NumbersV1SmsVerificationRequest + ) -> tuple: """ Internal helper for create operation Returns: tuple: (payload, status_code, headers) """ + data = numbers_v1_sms_verification_request.to_dict() headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + headers["Content-Type"] = "application/json" + headers["Accept"] = "application/json" return self._version.create_with_response_info( - method="POST", uri=self._uri, headers=headers + method="POST", uri=self._uri, data=data, headers=headers ) - def create(self) -> SmsVerificationInstance: + def create( + self, numbers_v1_sms_verification_request: NumbersV1SmsVerificationRequest + ) -> SmsVerificationInstance: """ Create the SmsVerificationInstance + :param numbers_v1_sms_verification_request: :returns: The created SmsVerificationInstance """ - payload, _, _ = self._create() + payload, _, _ = self._create( + numbers_v1_sms_verification_request=numbers_v1_sms_verification_request + ) return SmsVerificationInstance(self._version, payload) - def create_with_http_info(self) -> ApiResponse: + def create_with_http_info( + self, numbers_v1_sms_verification_request: NumbersV1SmsVerificationRequest + ) -> ApiResponse: """ Create the SmsVerificationInstance and return response metadata + :param numbers_v1_sms_verification_request: :returns: ApiResponse with instance, status code, and headers """ - payload, status_code, headers = self._create() + payload, status_code, headers = self._create( + numbers_v1_sms_verification_request=numbers_v1_sms_verification_request + ) instance = SmsVerificationInstance(self._version, payload) return ApiResponse(data=instance, status_code=status_code, headers=headers) - async def _create_async(self) -> tuple: + async def _create_async( + self, numbers_v1_sms_verification_request: NumbersV1SmsVerificationRequest + ) -> tuple: """ Internal async helper for create operation Returns: tuple: (payload, status_code, headers) """ + data = numbers_v1_sms_verification_request.to_dict() headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + headers["Content-Type"] = "application/json" + headers["Accept"] = "application/json" return await self._version.create_with_response_info_async( - method="POST", uri=self._uri, headers=headers + method="POST", uri=self._uri, data=data, headers=headers ) - async def create_async(self) -> SmsVerificationInstance: + async def create_async( + self, numbers_v1_sms_verification_request: NumbersV1SmsVerificationRequest + ) -> SmsVerificationInstance: """ Asynchronously create the SmsVerificationInstance + :param numbers_v1_sms_verification_request: :returns: The created SmsVerificationInstance """ - payload, _, _ = await self._create_async() + payload, _, _ = await self._create_async( + numbers_v1_sms_verification_request=numbers_v1_sms_verification_request + ) return SmsVerificationInstance(self._version, payload) - async def create_with_http_info_async(self) -> ApiResponse: + async def create_with_http_info_async( + self, numbers_v1_sms_verification_request: NumbersV1SmsVerificationRequest + ) -> ApiResponse: """ Asynchronously create the SmsVerificationInstance and return response metadata + :param numbers_v1_sms_verification_request: :returns: ApiResponse with instance, status code, and headers """ - payload, status_code, headers = await self._create_async() + payload, status_code, headers = await self._create_async( + numbers_v1_sms_verification_request=numbers_v1_sms_verification_request + ) instance = SmsVerificationInstance(self._version, payload) return ApiResponse(data=instance, status_code=status_code, headers=headers) diff --git a/twilio/rest/numbers/v1/sms_verification_check.py b/twilio/rest/numbers/v1/sms_verification_check.py index f57035319..1bba87b5f 100644 --- a/twilio/rest/numbers/v1/sms_verification_check.py +++ b/twilio/rest/numbers/v1/sms_verification_check.py @@ -22,6 +22,27 @@ class SmsVerificationCheckInstance(InstanceResource): + + class NumbersV1SmsVerificationCheckRequest(object): + """ + :ivar to: The phone number being verified in E.164 format. + :ivar verification_code: The 6 character verification code to check. + :ivar friendly_name: A human-readable name for the caller ID. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.to: Optional[str] = payload.get("to") + self.verification_code: Optional[str] = payload.get("verification_code") + self.friendly_name: Optional[str] = payload.get("friendly_name") + + def to_dict(self): + return { + "to": self.to, + "verification_code": self.verification_code, + "friendly_name": self.friendly_name, + } + """ :ivar to: The phone number that was verified in E.164 format. :ivar verification_sid: The unique SID of this verification resource. @@ -49,6 +70,26 @@ def __repr__(self) -> str: class SmsVerificationCheckList(ListResource): + class NumbersV1SmsVerificationCheckRequest(object): + """ + :ivar to: The phone number being verified in E.164 format. + :ivar verification_code: The 6 character verification code to check. + :ivar friendly_name: A human-readable name for the caller ID. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.to: Optional[str] = payload.get("to") + self.verification_code: Optional[str] = payload.get("verification_code") + self.friendly_name: Optional[str] = payload.get("friendly_name") + + def to_dict(self): + return { + "to": self.to, + "verification_code": self.verification_code, + "friendly_name": self.friendly_name, + } + def __init__(self, version: Version): """ Initialize the SmsVerificationCheckList @@ -60,77 +101,113 @@ def __init__(self, version: Version): self._uri = "/CallerIds/SmsVerificationChecks" - def _create(self) -> tuple: + def _create( + self, + numbers_v1_sms_verification_check_request: NumbersV1SmsVerificationCheckRequest, + ) -> tuple: """ Internal helper for create operation Returns: tuple: (payload, status_code, headers) """ + data = numbers_v1_sms_verification_check_request.to_dict() headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + headers["Content-Type"] = "application/json" + headers["Accept"] = "application/json" return self._version.create_with_response_info( - method="POST", uri=self._uri, headers=headers + method="POST", uri=self._uri, data=data, headers=headers ) - def create(self) -> SmsVerificationCheckInstance: + def create( + self, + numbers_v1_sms_verification_check_request: NumbersV1SmsVerificationCheckRequest, + ) -> SmsVerificationCheckInstance: """ Create the SmsVerificationCheckInstance + :param numbers_v1_sms_verification_check_request: :returns: The created SmsVerificationCheckInstance """ - payload, _, _ = self._create() + payload, _, _ = self._create( + numbers_v1_sms_verification_check_request=numbers_v1_sms_verification_check_request + ) return SmsVerificationCheckInstance(self._version, payload) - def create_with_http_info(self) -> ApiResponse: + def create_with_http_info( + self, + numbers_v1_sms_verification_check_request: NumbersV1SmsVerificationCheckRequest, + ) -> ApiResponse: """ Create the SmsVerificationCheckInstance and return response metadata + :param numbers_v1_sms_verification_check_request: :returns: ApiResponse with instance, status code, and headers """ - payload, status_code, headers = self._create() + payload, status_code, headers = self._create( + numbers_v1_sms_verification_check_request=numbers_v1_sms_verification_check_request + ) instance = SmsVerificationCheckInstance(self._version, payload) return ApiResponse(data=instance, status_code=status_code, headers=headers) - async def _create_async(self) -> tuple: + async def _create_async( + self, + numbers_v1_sms_verification_check_request: NumbersV1SmsVerificationCheckRequest, + ) -> tuple: """ Internal async helper for create operation Returns: tuple: (payload, status_code, headers) """ + data = numbers_v1_sms_verification_check_request.to_dict() headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + headers["Content-Type"] = "application/json" + headers["Accept"] = "application/json" return await self._version.create_with_response_info_async( - method="POST", uri=self._uri, headers=headers + method="POST", uri=self._uri, data=data, headers=headers ) - async def create_async(self) -> SmsVerificationCheckInstance: + async def create_async( + self, + numbers_v1_sms_verification_check_request: NumbersV1SmsVerificationCheckRequest, + ) -> SmsVerificationCheckInstance: """ Asynchronously create the SmsVerificationCheckInstance + :param numbers_v1_sms_verification_check_request: :returns: The created SmsVerificationCheckInstance """ - payload, _, _ = await self._create_async() + payload, _, _ = await self._create_async( + numbers_v1_sms_verification_check_request=numbers_v1_sms_verification_check_request + ) return SmsVerificationCheckInstance(self._version, payload) - async def create_with_http_info_async(self) -> ApiResponse: + async def create_with_http_info_async( + self, + numbers_v1_sms_verification_check_request: NumbersV1SmsVerificationCheckRequest, + ) -> ApiResponse: """ Asynchronously create the SmsVerificationCheckInstance and return response metadata + :param numbers_v1_sms_verification_check_request: :returns: ApiResponse with instance, status code, and headers """ - payload, status_code, headers = await self._create_async() + payload, status_code, headers = await self._create_async( + numbers_v1_sms_verification_check_request=numbers_v1_sms_verification_check_request + ) instance = SmsVerificationCheckInstance(self._version, payload) return ApiResponse(data=instance, status_code=status_code, headers=headers) diff --git a/twilio/rest/numbers/v1/voice_verification.py b/twilio/rest/numbers/v1/voice_verification.py index 5e41647d7..e4c3b2fcb 100644 --- a/twilio/rest/numbers/v1/voice_verification.py +++ b/twilio/rest/numbers/v1/voice_verification.py @@ -22,6 +22,46 @@ class VoiceVerificationInstance(InstanceResource): + + class NumbersV1VoiceVerificationRequest(object): + """ + :ivar phone_number: The phone number to verify in E.164 format. + :ivar friendly_name: A human-readable name for the caller ID. + :ivar custom_code: A custom verification code to use instead of a generated one. + :ivar call_delay: Number of seconds to delay the verification call (0-60). + :ivar status_callback: URL to receive status callback events. + :ivar status_callback_method: HTTP method for status callback requests. + :ivar extension: Phone extension to dial after connecting. + :ivar custom_success_message: Custom message to play after successful verification. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.phone_number: Optional[str] = payload.get("phone_number") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.custom_code: Optional[str] = payload.get("custom_code") + self.call_delay: Optional[str] = payload.get("call_delay") + self.status_callback: Optional[str] = payload.get("status_callback") + self.status_callback_method: Optional[str] = payload.get( + "status_callback_method" + ) + self.extension: Optional[str] = payload.get("extension") + self.custom_success_message: Optional[str] = payload.get( + "custom_success_message" + ) + + def to_dict(self): + return { + "phone_number": self.phone_number, + "friendly_name": self.friendly_name, + "custom_code": self.custom_code, + "call_delay": self.call_delay, + "status_callback": self.status_callback, + "status_callback_method": self.status_callback_method, + "extension": self.extension, + "custom_success_message": self.custom_success_message, + } + """ :ivar account_sid: The Account SID that owns this verification. :ivar phone_number: The phone number being verified in E.164 format. @@ -51,6 +91,45 @@ def __repr__(self) -> str: class VoiceVerificationList(ListResource): + class NumbersV1VoiceVerificationRequest(object): + """ + :ivar phone_number: The phone number to verify in E.164 format. + :ivar friendly_name: A human-readable name for the caller ID. + :ivar custom_code: A custom verification code to use instead of a generated one. + :ivar call_delay: Number of seconds to delay the verification call (0-60). + :ivar status_callback: URL to receive status callback events. + :ivar status_callback_method: HTTP method for status callback requests. + :ivar extension: Phone extension to dial after connecting. + :ivar custom_success_message: Custom message to play after successful verification. + """ + + def __init__(self, payload: Dict[str, Any]): + + self.phone_number: Optional[str] = payload.get("phone_number") + self.friendly_name: Optional[str] = payload.get("friendly_name") + self.custom_code: Optional[str] = payload.get("custom_code") + self.call_delay: Optional[str] = payload.get("call_delay") + self.status_callback: Optional[str] = payload.get("status_callback") + self.status_callback_method: Optional[str] = payload.get( + "status_callback_method" + ) + self.extension: Optional[str] = payload.get("extension") + self.custom_success_message: Optional[str] = payload.get( + "custom_success_message" + ) + + def to_dict(self): + return { + "phone_number": self.phone_number, + "friendly_name": self.friendly_name, + "custom_code": self.custom_code, + "call_delay": self.call_delay, + "status_callback": self.status_callback, + "status_callback_method": self.status_callback_method, + "extension": self.extension, + "custom_success_message": self.custom_success_message, + } + def __init__(self, version: Version): """ Initialize the VoiceVerificationList @@ -62,77 +141,107 @@ def __init__(self, version: Version): self._uri = "/CallerIds/VoiceVerifications" - def _create(self) -> tuple: + def _create( + self, numbers_v1_voice_verification_request: NumbersV1VoiceVerificationRequest + ) -> tuple: """ Internal helper for create operation Returns: tuple: (payload, status_code, headers) """ + data = numbers_v1_voice_verification_request.to_dict() headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + headers["Content-Type"] = "application/json" + headers["Accept"] = "application/json" return self._version.create_with_response_info( - method="POST", uri=self._uri, headers=headers + method="POST", uri=self._uri, data=data, headers=headers ) - def create(self) -> VoiceVerificationInstance: + def create( + self, numbers_v1_voice_verification_request: NumbersV1VoiceVerificationRequest + ) -> VoiceVerificationInstance: """ Create the VoiceVerificationInstance + :param numbers_v1_voice_verification_request: :returns: The created VoiceVerificationInstance """ - payload, _, _ = self._create() + payload, _, _ = self._create( + numbers_v1_voice_verification_request=numbers_v1_voice_verification_request + ) return VoiceVerificationInstance(self._version, payload) - def create_with_http_info(self) -> ApiResponse: + def create_with_http_info( + self, numbers_v1_voice_verification_request: NumbersV1VoiceVerificationRequest + ) -> ApiResponse: """ Create the VoiceVerificationInstance and return response metadata + :param numbers_v1_voice_verification_request: :returns: ApiResponse with instance, status code, and headers """ - payload, status_code, headers = self._create() + payload, status_code, headers = self._create( + numbers_v1_voice_verification_request=numbers_v1_voice_verification_request + ) instance = VoiceVerificationInstance(self._version, payload) return ApiResponse(data=instance, status_code=status_code, headers=headers) - async def _create_async(self) -> tuple: + async def _create_async( + self, numbers_v1_voice_verification_request: NumbersV1VoiceVerificationRequest + ) -> tuple: """ Internal async helper for create operation Returns: tuple: (payload, status_code, headers) """ + data = numbers_v1_voice_verification_request.to_dict() headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) + headers["Content-Type"] = "application/json" + headers["Accept"] = "application/json" return await self._version.create_with_response_info_async( - method="POST", uri=self._uri, headers=headers + method="POST", uri=self._uri, data=data, headers=headers ) - async def create_async(self) -> VoiceVerificationInstance: + async def create_async( + self, numbers_v1_voice_verification_request: NumbersV1VoiceVerificationRequest + ) -> VoiceVerificationInstance: """ Asynchronously create the VoiceVerificationInstance + :param numbers_v1_voice_verification_request: :returns: The created VoiceVerificationInstance """ - payload, _, _ = await self._create_async() + payload, _, _ = await self._create_async( + numbers_v1_voice_verification_request=numbers_v1_voice_verification_request + ) return VoiceVerificationInstance(self._version, payload) - async def create_with_http_info_async(self) -> ApiResponse: + async def create_with_http_info_async( + self, numbers_v1_voice_verification_request: NumbersV1VoiceVerificationRequest + ) -> ApiResponse: """ Asynchronously create the VoiceVerificationInstance and return response metadata + :param numbers_v1_voice_verification_request: :returns: ApiResponse with instance, status code, and headers """ - payload, status_code, headers = await self._create_async() + payload, status_code, headers = await self._create_async( + numbers_v1_voice_verification_request=numbers_v1_voice_verification_request + ) instance = VoiceVerificationInstance(self._version, payload) return ApiResponse(data=instance, status_code=status_code, headers=headers) diff --git a/twilio/rest/numbers/v1/voice_verification_check.py b/twilio/rest/numbers/v1/voice_verification_check.py deleted file mode 100644 index 28d201e55..000000000 --- a/twilio/rest/numbers/v1/voice_verification_check.py +++ /dev/null @@ -1,139 +0,0 @@ -r""" - This code was generated by - ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ - | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ - | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ - - Twilio - Numbers - This is the public Twilio REST API. - - NOTE: This class is auto generated by OpenAPI Generator. - https://openapi-generator.tech - Do not edit the class manually. -""" - -from typing import Any, Dict, Optional -from twilio.base import values -from twilio.base.api_response import ApiResponse - -from twilio.base.instance_resource import InstanceResource -from twilio.base.list_resource import ListResource -from twilio.base.version import Version - - -class VoiceVerificationCheckInstance(InstanceResource): - """ - :ivar to: The phone number that was verified in E.164 format. - :ivar caller_id_sid: The Caller ID SID created upon successful verification. - """ - - def __init__(self, version: Version, payload: Dict[str, Any]): - super().__init__(version) - - self.to: Optional[str] = payload.get("to") - self.caller_id_sid: Optional[str] = payload.get("callerIdSid") - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - - return "" - - -class VoiceVerificationCheckList(ListResource): - - def __init__(self, version: Version): - """ - Initialize the VoiceVerificationCheckList - - :param version: Version that contains the resource - - """ - super().__init__(version) - - self._uri = "/CallerIds/VoiceVerificationChecks" - - def _create(self) -> tuple: - """ - Internal helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - - headers["Accept"] = "application/json" - - return self._version.create_with_response_info( - method="POST", uri=self._uri, headers=headers - ) - - def create(self) -> VoiceVerificationCheckInstance: - """ - Create the VoiceVerificationCheckInstance - - - :returns: The created VoiceVerificationCheckInstance - """ - payload, _, _ = self._create() - return VoiceVerificationCheckInstance(self._version, payload) - - def create_with_http_info(self) -> ApiResponse: - """ - Create the VoiceVerificationCheckInstance and return response metadata - - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = self._create() - instance = VoiceVerificationCheckInstance(self._version, payload) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - async def _create_async(self) -> tuple: - """ - Internal async helper for create operation - - Returns: - tuple: (payload, status_code, headers) - """ - - headers = values.of({"Content-Type": "application/x-www-form-urlencoded"}) - - headers["Accept"] = "application/json" - - return await self._version.create_with_response_info_async( - method="POST", uri=self._uri, headers=headers - ) - - async def create_async(self) -> VoiceVerificationCheckInstance: - """ - Asynchronously create the VoiceVerificationCheckInstance - - - :returns: The created VoiceVerificationCheckInstance - """ - payload, _, _ = await self._create_async() - return VoiceVerificationCheckInstance(self._version, payload) - - async def create_with_http_info_async(self) -> ApiResponse: - """ - Asynchronously create the VoiceVerificationCheckInstance and return response metadata - - - :returns: ApiResponse with instance, status code, and headers - """ - payload, status_code, headers = await self._create_async() - instance = VoiceVerificationCheckInstance(self._version, payload) - return ApiResponse(data=instance, status_code=status_code, headers=headers) - - def __repr__(self) -> str: - """ - Provide a friendly representation - - :returns: Machine friendly representation - """ - return "" diff --git a/twilio/rest/numbers/v2/application.py b/twilio/rest/numbers/v2/application.py index 3b9115d33..de1b10e4e 100644 --- a/twilio/rest/numbers/v2/application.py +++ b/twilio/rest/numbers/v2/application.py @@ -43,8 +43,8 @@ def __init__(self, payload: Dict[str, Any]): ApplicationList.CreateShortCodeApplicationRequestBusinessInformation( payload.get("business_information") ) - if payload.get("business_information") is not None - else None + if isinstance(payload.get("business_information"), dict) + else payload.get("business_information") ) self.setup: Optional[ ApplicationList.CreateShortCodeApplicationRequestSetup @@ -52,8 +52,8 @@ def __init__(self, payload: Dict[str, Any]): ApplicationList.CreateShortCodeApplicationRequestSetup( payload.get("setup") ) - if payload.get("setup") is not None - else None + if isinstance(payload.get("setup"), dict) + else payload.get("setup") ) def to_dict(self): @@ -246,8 +246,8 @@ def __init__(self, payload: Dict[str, Any]): ApplicationList.CreateShortCodeApplicationRequestBusinessInformation( payload.get("business_information") ) - if payload.get("business_information") is not None - else None + if isinstance(payload.get("business_information"), dict) + else payload.get("business_information") ) self.setup: Optional[ ApplicationList.CreateShortCodeApplicationRequestSetup @@ -255,8 +255,8 @@ def __init__(self, payload: Dict[str, Any]): ApplicationList.CreateShortCodeApplicationRequestSetup( payload.get("setup") ) - if payload.get("setup") is not None - else None + if isinstance(payload.get("setup"), dict) + else payload.get("setup") ) def to_dict(self): @@ -456,8 +456,8 @@ def __init__(self, payload: Dict[str, Any]): ApplicationList.CreateShortCodeApplicationRequestBusinessInformation( payload.get("business_information") ) - if payload.get("business_information") is not None - else None + if isinstance(payload.get("business_information"), dict) + else payload.get("business_information") ) self.setup: Optional[ ApplicationList.CreateShortCodeApplicationRequestSetup @@ -465,8 +465,8 @@ def __init__(self, payload: Dict[str, Any]): ApplicationList.CreateShortCodeApplicationRequestSetup( payload.get("setup") ) - if payload.get("setup") is not None - else None + if isinstance(payload.get("setup"), dict) + else payload.get("setup") ) def to_dict(self): diff --git a/twilio/rest/preview/hosted_numbers/authorization_document/__init__.py b/twilio/rest/preview/hosted_numbers/authorization_document/__init__.py index 27ff55c37..cd868149d 100644 --- a/twilio/rest/preview/hosted_numbers/authorization_document/__init__.py +++ b/twilio/rest/preview/hosted_numbers/authorization_document/__init__.py @@ -89,6 +89,42 @@ def _proxy(self) -> "AuthorizationDocumentContext": ) return self._context + def delete(self) -> bool: + """ + Deletes the AuthorizationDocumentInstance + + + :returns: True if delete succeeds, False otherwise + """ + return self._proxy.delete() + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the AuthorizationDocumentInstance + + + :returns: True if delete succeeds, False otherwise + """ + return await self._proxy.delete_async() + + def delete_with_http_info(self) -> ApiResponse: + """ + Deletes the AuthorizationDocumentInstance with HTTP info + + + :returns: ApiResponse with success boolean, status code, and headers + """ + return self._proxy.delete_with_http_info() + + async def delete_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine that deletes the AuthorizationDocumentInstance with HTTP info + + + :returns: ApiResponse with success boolean, status code, and headers + """ + return await self._proxy.delete_with_http_info_async() + def fetch(self) -> "AuthorizationDocumentInstance": """ Fetch the AuthorizationDocumentInstance @@ -297,6 +333,74 @@ def __init__(self, version: Version, sid: str): DependentHostedNumberOrderList ] = None + def _delete(self) -> tuple: + """ + Internal helper for delete operation + + Returns: + tuple: (success_boolean, status_code, headers) + """ + + headers = values.of({}) + + return self._version.delete_with_response_info( + method="DELETE", uri=self._uri, headers=headers + ) + + def delete(self) -> bool: + """ + Deletes the AuthorizationDocumentInstance + + + :returns: True if delete succeeds, False otherwise + """ + success, _, _ = self._delete() + return success + + def delete_with_http_info(self) -> ApiResponse: + """ + Deletes the AuthorizationDocumentInstance and return response metadata + + + :returns: ApiResponse with success boolean, status code, and headers + """ + success, status_code, headers = self._delete() + return ApiResponse(data=success, status_code=status_code, headers=headers) + + async def _delete_async(self) -> tuple: + """ + Internal async helper for delete operation + + Returns: + tuple: (success_boolean, status_code, headers) + """ + + headers = values.of({}) + + return await self._version.delete_with_response_info_async( + method="DELETE", uri=self._uri, headers=headers + ) + + async def delete_async(self) -> bool: + """ + Asynchronous coroutine that deletes the AuthorizationDocumentInstance + + + :returns: True if delete succeeds, False otherwise + """ + success, _, _ = await self._delete_async() + return success + + async def delete_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine that deletes the AuthorizationDocumentInstance and return response metadata + + + :returns: ApiResponse with success boolean, status code, and headers + """ + success, status_code, headers = await self._delete_async() + return ApiResponse(data=success, status_code=status_code, headers=headers) + def _fetch(self) -> tuple: """ Internal helper for fetch operation diff --git a/twilio/rest/preview_iam/versionless/organization/user.py b/twilio/rest/preview_iam/versionless/organization/user.py index c5587ad92..db3213a2a 100644 --- a/twilio/rest/preview_iam/versionless/organization/user.py +++ b/twilio/rest/preview_iam/versionless/organization/user.py @@ -165,8 +165,8 @@ def __init__(self, payload: Dict[str, Any]): self.display_name: Optional[str] = payload.get("displayName") self.name: Optional[UserList.ScimName] = ( UserList.ScimName(payload.get("name")) - if payload.get("name") is not None - else None + if isinstance(payload.get("name"), dict) + else payload.get("name") ) self.emails: Optional[List[UserList.ScimEmailAddress]] = ( [ @@ -182,8 +182,8 @@ def __init__(self, payload: Dict[str, Any]): self.schemas: Optional[List[str]] = payload.get("schemas") self.meta: Optional[UserList.ScimMeta] = ( UserList.ScimMeta(payload.get("meta")) - if payload.get("meta") is not None - else None + if isinstance(payload.get("meta"), dict) + else payload.get("meta") ) self.detail: Optional[str] = payload.get("detail") self.scim_type: Optional[str] = payload.get("scimType") @@ -607,8 +607,8 @@ def __init__(self, payload: Dict[str, Any]): self.display_name: Optional[str] = payload.get("displayName") self.name: Optional[UserList.ScimName] = ( UserList.ScimName(payload.get("name")) - if payload.get("name") is not None - else None + if isinstance(payload.get("name"), dict) + else payload.get("name") ) self.emails: Optional[List[UserList.ScimEmailAddress]] = ( [ @@ -624,8 +624,8 @@ def __init__(self, payload: Dict[str, Any]): self.schemas: Optional[List[str]] = payload.get("schemas") self.meta: Optional[UserList.ScimMeta] = ( UserList.ScimMeta(payload.get("meta")) - if payload.get("meta") is not None - else None + if isinstance(payload.get("meta"), dict) + else payload.get("meta") ) self.detail: Optional[str] = payload.get("detail") self.scim_type: Optional[str] = payload.get("scimType") @@ -1306,8 +1306,8 @@ def __init__(self, payload: Dict[str, Any]): self.display_name: Optional[str] = payload.get("displayName") self.name: Optional[UserList.ScimName] = ( UserList.ScimName(payload.get("name")) - if payload.get("name") is not None - else None + if isinstance(payload.get("name"), dict) + else payload.get("name") ) self.emails: Optional[List[UserList.ScimEmailAddress]] = ( [ @@ -1323,8 +1323,8 @@ def __init__(self, payload: Dict[str, Any]): self.schemas: Optional[List[str]] = payload.get("schemas") self.meta: Optional[UserList.ScimMeta] = ( UserList.ScimMeta(payload.get("meta")) - if payload.get("meta") is not None - else None + if isinstance(payload.get("meta"), dict) + else payload.get("meta") ) self.detail: Optional[str] = payload.get("detail") self.scim_type: Optional[str] = payload.get("scimType") diff --git a/twilio/rest/routes/v3/__init__.py b/twilio/rest/routes/v3/__init__.py index 07d47c0f6..e4458c94b 100644 --- a/twilio/rest/routes/v3/__init__.py +++ b/twilio/rest/routes/v3/__init__.py @@ -15,6 +15,7 @@ from typing import Optional from twilio.base.version import Version from twilio.base.domain import Domain +from twilio.rest.routes.v3.iso_country_code import IsoCountryCodeList from twilio.rest.routes.v3.phone_number import PhoneNumberList @@ -29,6 +30,22 @@ def __init__(self, domain: Domain): super().__init__(domain, "v3") self._phone_numbers: Optional[PhoneNumberList] = None + def iso_country_code( + self, iso_country_code: str, short_code: str, iso_country_code_id: str = None + ): + """ + Access the IsoCountryCodeList resource + + :param iso_country_code: The ISO country code of the short code + + :param short_code: The short code + + :param iso_country_code_id: Optional instance ID to directly access IsoCountryCodeContext + :returns: IsoCountryCodeList instance if iso_country_code_id is None, otherwise IsoCountryCodeContext + """ + list_instance = IsoCountryCodeList(self) + return list_instance(iso_country_codeshort_code) + @property def phone_numbers(self) -> PhoneNumberList: if self._phone_numbers is None: diff --git a/twilio/rest/routes/v3/iso_country_code.py b/twilio/rest/routes/v3/iso_country_code.py new file mode 100644 index 000000000..7f6f770d2 --- /dev/null +++ b/twilio/rest/routes/v3/iso_country_code.py @@ -0,0 +1,518 @@ +r""" + This code was generated by + ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __ + | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/ + | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \ + + Twilio - Routes + This is the public Twilio REST API. + + NOTE: This class is auto generated by OpenAPI Generator. + https://openapi-generator.tech + Do not edit the class manually. +""" + +from __future__ import annotations + +from datetime import datetime +from typing import Any, Dict, Optional, Union +from twilio.base import deserialize, values +from twilio.base.api_response import ApiResponse +from twilio.base.instance_context import InstanceContext +from twilio.base.instance_resource import InstanceResource +from twilio.base.list_resource import ListResource +from twilio.base.version import Version + + +class IsoCountryCodeInstance(InstanceResource): + """ + :ivar iso_country_code: The ISO country code of the short code + :ivar short_code: The short code + :ivar url: The absolute URL of the resource. + :ivar account_sid: The unique SID identifier of the Account. + :ivar friendly_name: A human readable description of the Inbound Processing Region assignment for this short code, up to 64 characters. + :ivar messaging_region: The Inbound Processing Region used for this short code for messaging. + :ivar date_created: The date that this short code was assigned an Inbound Processing Region, given in ISO 8601 format. + :ivar date_updated: The date that the Inbound Processing Region was updated for this short code, given in ISO 8601 format. + """ + + def __init__( + self, + version: Version, + payload: Dict[str, Any], + iso_country_code: Optional[str] = None, + short_code: Optional[str] = None, + ): + super().__init__(version) + + self.iso_country_code: Optional[str] = payload.get("isoCountryCode") + self.short_code: Optional[str] = payload.get("shortCode") + self.url: Optional[str] = payload.get("url") + self.account_sid: Optional[str] = payload.get("accountSid") + self.friendly_name: Optional[str] = payload.get("friendlyName") + self.messaging_region: Optional[str] = payload.get("messagingRegion") + self.date_created: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("dateCreated") + ) + self.date_updated: Optional[datetime] = deserialize.iso8601_datetime( + payload.get("dateUpdated") + ) + + # Only set _solution if path params are provided (not None) + if iso_country_code is not None or short_code is not None: + self._solution = { + "iso_country_code": iso_country_code, + "short_code": short_code, + } + + self._context: Optional[IsoCountryCodeContext] = None + + @property + def _proxy(self) -> "IsoCountryCodeContext": + """ + Generate an instance context for the instance, the context is capable of + performing various actions. All instance actions are proxied to the context + + :returns: IsoCountryCodeContext for this IsoCountryCodeInstance + """ + if self._context is None: + self._context = IsoCountryCodeContext( + self._version, + iso_country_code=self._solution["iso_country_code"], + short_code=self._solution["short_code"], + ) + return self._context + + def fetch(self) -> "IsoCountryCodeInstance": + """ + Fetch the IsoCountryCodeInstance + + + :returns: The fetched IsoCountryCodeInstance + """ + return self._proxy.fetch() + + async def fetch_async(self) -> "IsoCountryCodeInstance": + """ + Asynchronous coroutine to fetch the IsoCountryCodeInstance + + + :returns: The fetched IsoCountryCodeInstance + """ + return await self._proxy.fetch_async() + + def fetch_with_http_info(self) -> ApiResponse: + """ + Fetch the IsoCountryCodeInstance with HTTP info + + + :returns: ApiResponse with instance, status code, and headers + """ + return self._proxy.fetch_with_http_info() + + async def fetch_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine to fetch the IsoCountryCodeInstance with HTTP info + + + :returns: ApiResponse with instance, status code, and headers + """ + return await self._proxy.fetch_with_http_info_async() + + def update( + self, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> "IsoCountryCodeInstance": + """ + Update the IsoCountryCodeInstance + + :param messaging_region: The Processing Region used for this short code for messaging + :param friendly_name: A human readable description of this resource, up to 64 characters. + + :returns: The updated IsoCountryCodeInstance + """ + return self._proxy.update( + messaging_region=messaging_region, + friendly_name=friendly_name, + ) + + async def update_async( + self, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> "IsoCountryCodeInstance": + """ + Asynchronous coroutine to update the IsoCountryCodeInstance + + :param messaging_region: The Processing Region used for this short code for messaging + :param friendly_name: A human readable description of this resource, up to 64 characters. + + :returns: The updated IsoCountryCodeInstance + """ + return await self._proxy.update_async( + messaging_region=messaging_region, + friendly_name=friendly_name, + ) + + def update_with_http_info( + self, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> ApiResponse: + """ + Update the IsoCountryCodeInstance with HTTP info + + :param messaging_region: The Processing Region used for this short code for messaging + :param friendly_name: A human readable description of this resource, up to 64 characters. + + :returns: ApiResponse with instance, status code, and headers + """ + return self._proxy.update_with_http_info( + messaging_region=messaging_region, + friendly_name=friendly_name, + ) + + async def update_with_http_info_async( + self, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> ApiResponse: + """ + Asynchronous coroutine to update the IsoCountryCodeInstance with HTTP info + + :param messaging_region: The Processing Region used for this short code for messaging + :param friendly_name: A human readable description of this resource, up to 64 characters. + + :returns: ApiResponse with instance, status code, and headers + """ + return await self._proxy.update_with_http_info_async( + messaging_region=messaging_region, + friendly_name=friendly_name, + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class IsoCountryCodeContext(InstanceContext): + + def __init__(self, version: Version, iso_country_code: str, short_code: str): + """ + Initialize the IsoCountryCodeContext + + :param version: Version that contains the resource + :param iso_country_code: The ISO country code of the short code + :param short_code: The short code + """ + super().__init__(version) + + # Path Solution + self._solution = { + "iso_country_code": iso_country_code, + "short_code": short_code, + } + self._uri = "/ShortCodes/{iso_country_code}/{short_code}".format( + **self._solution + ) + + def _fetch(self) -> tuple: + """ + Internal helper for fetch operation + + Returns: + tuple: (payload, status_code, headers) + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + return self._version.fetch_with_response_info( + method="GET", uri=self._uri, headers=headers + ) + + def fetch(self) -> IsoCountryCodeInstance: + """ + Fetch the IsoCountryCodeInstance + + + :returns: The fetched IsoCountryCodeInstance + """ + payload, _, _ = self._fetch() + return IsoCountryCodeInstance( + self._version, + payload, + iso_country_code=self._solution["iso_country_code"], + short_code=self._solution["short_code"], + ) + + def fetch_with_http_info(self) -> ApiResponse: + """ + Fetch the IsoCountryCodeInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._fetch() + instance = IsoCountryCodeInstance( + self._version, + payload, + iso_country_code=self._solution["iso_country_code"], + short_code=self._solution["short_code"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _fetch_async(self) -> tuple: + """ + Internal async helper for fetch operation + + Returns: + tuple: (payload, status_code, headers) + """ + + headers = values.of({}) + + headers["Accept"] = "application/json" + + return await self._version.fetch_with_response_info_async( + method="GET", uri=self._uri, headers=headers + ) + + async def fetch_async(self) -> IsoCountryCodeInstance: + """ + Asynchronous coroutine to fetch the IsoCountryCodeInstance + + + :returns: The fetched IsoCountryCodeInstance + """ + payload, _, _ = await self._fetch_async() + return IsoCountryCodeInstance( + self._version, + payload, + iso_country_code=self._solution["iso_country_code"], + short_code=self._solution["short_code"], + ) + + async def fetch_with_http_info_async(self) -> ApiResponse: + """ + Asynchronous coroutine to fetch the IsoCountryCodeInstance and return response metadata + + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._fetch_async() + instance = IsoCountryCodeInstance( + self._version, + payload, + iso_country_code=self._solution["iso_country_code"], + short_code=self._solution["short_code"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def _update( + self, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> tuple: + """ + Internal helper for update operation + + Returns: + tuple: (payload, status_code, headers) + """ + + data = values.of( + { + "messagingRegion": messaging_region, + "friendlyName": friendly_name, + } + ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + return self._version.update_with_response_info( + method="POST", uri=self._uri, data=data, headers=headers + ) + + def update( + self, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> IsoCountryCodeInstance: + """ + Update the IsoCountryCodeInstance + + :param messaging_region: The Processing Region used for this short code for messaging + :param friendly_name: A human readable description of this resource, up to 64 characters. + + :returns: The updated IsoCountryCodeInstance + """ + payload, _, _ = self._update( + messaging_region=messaging_region, friendly_name=friendly_name + ) + return IsoCountryCodeInstance( + self._version, + payload, + iso_country_code=self._solution["iso_country_code"], + short_code=self._solution["short_code"], + ) + + def update_with_http_info( + self, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> ApiResponse: + """ + Update the IsoCountryCodeInstance and return response metadata + + :param messaging_region: The Processing Region used for this short code for messaging + :param friendly_name: A human readable description of this resource, up to 64 characters. + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = self._update( + messaging_region=messaging_region, friendly_name=friendly_name + ) + instance = IsoCountryCodeInstance( + self._version, + payload, + iso_country_code=self._solution["iso_country_code"], + short_code=self._solution["short_code"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + async def _update_async( + self, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> tuple: + """ + Internal async helper for update operation + + Returns: + tuple: (payload, status_code, headers) + """ + + data = values.of( + { + "messagingRegion": messaging_region, + "friendlyName": friendly_name, + } + ) + headers = values.of({}) + + headers["Content-Type"] = "application/x-www-form-urlencoded" + + headers["Accept"] = "application/json" + + return await self._version.update_with_response_info_async( + method="POST", uri=self._uri, data=data, headers=headers + ) + + async def update_async( + self, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> IsoCountryCodeInstance: + """ + Asynchronous coroutine to update the IsoCountryCodeInstance + + :param messaging_region: The Processing Region used for this short code for messaging + :param friendly_name: A human readable description of this resource, up to 64 characters. + + :returns: The updated IsoCountryCodeInstance + """ + payload, _, _ = await self._update_async( + messaging_region=messaging_region, friendly_name=friendly_name + ) + return IsoCountryCodeInstance( + self._version, + payload, + iso_country_code=self._solution["iso_country_code"], + short_code=self._solution["short_code"], + ) + + async def update_with_http_info_async( + self, + messaging_region: Union[str, object] = values.unset, + friendly_name: Union[str, object] = values.unset, + ) -> ApiResponse: + """ + Asynchronous coroutine to update the IsoCountryCodeInstance and return response metadata + + :param messaging_region: The Processing Region used for this short code for messaging + :param friendly_name: A human readable description of this resource, up to 64 characters. + + :returns: ApiResponse with instance, status code, and headers + """ + payload, status_code, headers = await self._update_async( + messaging_region=messaging_region, friendly_name=friendly_name + ) + instance = IsoCountryCodeInstance( + self._version, + payload, + iso_country_code=self._solution["iso_country_code"], + short_code=self._solution["short_code"], + ) + return ApiResponse(data=instance, status_code=status_code, headers=headers) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + context = " ".join("{}={}".format(k, v) for k, v in self._solution.items()) + return "".format(context) + + +class IsoCountryCodeList(ListResource): + + def __init__(self, version: Version): + """ + Initialize the IsoCountryCodeList + + :param version: Version that contains the resource + + """ + super().__init__(version) + + def get(self, iso_country_code: str, short_code: str) -> IsoCountryCodeContext: + """ + Constructs a IsoCountryCodeContext + + :param iso_country_code: The ISO country code of the short code + :param short_code: The short code + """ + return IsoCountryCodeContext( + self._version, iso_country_code=iso_country_code, short_code=short_code + ) + + def __call__(self, iso_country_code: str, short_code: str) -> IsoCountryCodeContext: + """ + Constructs a IsoCountryCodeContext + + :param iso_country_code: The ISO country code of the short code + :param short_code: The short code + """ + return IsoCountryCodeContext( + self._version, iso_country_code=iso_country_code, short_code=short_code + ) + + def __repr__(self) -> str: + """ + Provide a friendly representation + + :returns: Machine friendly representation + """ + return "" diff --git a/twilio/rest/verify/v2/service/approve_challenge.py b/twilio/rest/verify/v2/service/approve_challenge.py index d6d7e26ac..9d39ee76c 100644 --- a/twilio/rest/verify/v2/service/approve_challenge.py +++ b/twilio/rest/verify/v2/service/approve_challenge.py @@ -47,8 +47,8 @@ def __init__(self, payload: Dict[str, Any]): ApproveChallengeList.ApprovePasskeysChallengeRequestResponse( payload.get("response") ) - if payload.get("response") is not None - else None + if isinstance(payload.get("response"), dict) + else payload.get("response") ) def to_dict(self): @@ -177,8 +177,8 @@ def __init__(self, payload: Dict[str, Any]): ApproveChallengeList.ApprovePasskeysChallengeRequestResponse( payload.get("response") ) - if payload.get("response") is not None - else None + if isinstance(payload.get("response"), dict) + else payload.get("response") ) def to_dict(self): diff --git a/twilio/rest/verify/v2/service/new_factor.py b/twilio/rest/verify/v2/service/new_factor.py index de42d178d..e19603962 100644 --- a/twilio/rest/verify/v2/service/new_factor.py +++ b/twilio/rest/verify/v2/service/new_factor.py @@ -41,8 +41,8 @@ def __init__(self, payload: Dict[str, Any]): NewFactorList.CreateNewPasskeysFactorRequestConfig( payload.get("config") ) - if payload.get("config") is not None - else None + if isinstance(payload.get("config"), dict) + else payload.get("config") ) def to_dict(self): @@ -68,8 +68,8 @@ def __init__(self, payload: Dict[str, Any]): NewFactorList.CreateNewPasskeysFactorRequestConfigRelyingParty( payload.get("relying_party") ) - if payload.get("relying_party") is not None - else None + if isinstance(payload.get("relying_party"), dict) + else payload.get("relying_party") ) self.authenticator_attachment: Optional[str] = payload.get( "authenticator_attachment" @@ -185,8 +185,8 @@ def __init__(self, payload: Dict[str, Any]): NewFactorList.CreateNewPasskeysFactorRequestConfig( payload.get("config") ) - if payload.get("config") is not None - else None + if isinstance(payload.get("config"), dict) + else payload.get("config") ) def to_dict(self): @@ -212,8 +212,8 @@ def __init__(self, payload: Dict[str, Any]): NewFactorList.CreateNewPasskeysFactorRequestConfigRelyingParty( payload.get("relying_party") ) - if payload.get("relying_party") is not None - else None + if isinstance(payload.get("relying_party"), dict) + else payload.get("relying_party") ) self.authenticator_attachment: Optional[str] = payload.get( "authenticator_attachment" diff --git a/twilio/rest/verify/v2/service/new_verify_factor.py b/twilio/rest/verify/v2/service/new_verify_factor.py index ef884eb98..4153c2bdb 100644 --- a/twilio/rest/verify/v2/service/new_verify_factor.py +++ b/twilio/rest/verify/v2/service/new_verify_factor.py @@ -47,8 +47,8 @@ def __init__(self, payload: Dict[str, Any]): NewVerifyFactorList.VerifyPasskeysFactorRequestResponse( payload.get("response") ) - if payload.get("response") is not None - else None + if isinstance(payload.get("response"), dict) + else payload.get("response") ) def to_dict(self): @@ -158,8 +158,8 @@ def __init__(self, payload: Dict[str, Any]): NewVerifyFactorList.VerifyPasskeysFactorRequestResponse( payload.get("response") ) - if payload.get("response") is not None - else None + if isinstance(payload.get("response"), dict) + else payload.get("response") ) def to_dict(self): diff --git a/twilio/rest/voice/v2/recording.py b/twilio/rest/voice/v2/recording.py index 9f4ea179f..04ff95bac 100644 --- a/twilio/rest/voice/v2/recording.py +++ b/twilio/rest/voice/v2/recording.py @@ -62,8 +62,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingCompositionPolicy( payload.get("compositionPolicy") ) - if payload.get("compositionPolicy") is not None - else None + if isinstance(payload.get("compositionPolicy"), dict) + else payload.get("compositionPolicy") ) self.call_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback @@ -71,8 +71,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingStatusCallback( payload.get("callRecordingStatusCallback") ) - if payload.get("callRecordingStatusCallback") is not None - else None + if isinstance(payload.get("callRecordingStatusCallback"), dict) + else payload.get("callRecordingStatusCallback") ) self.conference_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback @@ -80,8 +80,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingStatusCallback( payload.get("conferenceRecordingStatusCallback") ) - if payload.get("conferenceRecordingStatusCallback") is not None - else None + if isinstance(payload.get("conferenceRecordingStatusCallback"), dict) + else payload.get("conferenceRecordingStatusCallback") ) self.features: Optional[ List[RecordingList.VoiceV2ConfigurationRecordingFeature] @@ -160,8 +160,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) def to_dict(self): @@ -444,8 +444,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingCompositionPolicy( payload.get("compositionPolicy") ) - if payload.get("compositionPolicy") is not None - else None + if isinstance(payload.get("compositionPolicy"), dict) + else payload.get("compositionPolicy") ) self.call_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback @@ -453,8 +453,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingStatusCallback( payload.get("callRecordingStatusCallback") ) - if payload.get("callRecordingStatusCallback") is not None - else None + if isinstance(payload.get("callRecordingStatusCallback"), dict) + else payload.get("callRecordingStatusCallback") ) self.conference_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback @@ -462,8 +462,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingStatusCallback( payload.get("conferenceRecordingStatusCallback") ) - if payload.get("conferenceRecordingStatusCallback") is not None - else None + if isinstance(payload.get("conferenceRecordingStatusCallback"), dict) + else payload.get("conferenceRecordingStatusCallback") ) self.features: Optional[ List[RecordingList.VoiceV2ConfigurationRecordingFeature] @@ -542,8 +542,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) def to_dict(self): @@ -944,8 +944,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingCompositionPolicy( payload.get("compositionPolicy") ) - if payload.get("compositionPolicy") is not None - else None + if isinstance(payload.get("compositionPolicy"), dict) + else payload.get("compositionPolicy") ) self.call_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback @@ -953,8 +953,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingStatusCallback( payload.get("callRecordingStatusCallback") ) - if payload.get("callRecordingStatusCallback") is not None - else None + if isinstance(payload.get("callRecordingStatusCallback"), dict) + else payload.get("callRecordingStatusCallback") ) self.conference_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback @@ -962,8 +962,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingStatusCallback( payload.get("conferenceRecordingStatusCallback") ) - if payload.get("conferenceRecordingStatusCallback") is not None - else None + if isinstance(payload.get("conferenceRecordingStatusCallback"), dict) + else payload.get("conferenceRecordingStatusCallback") ) self.features: Optional[ List[RecordingList.VoiceV2ConfigurationRecordingFeature] @@ -1042,8 +1042,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) def to_dict(self): diff --git a/twilio/rest/voice/v2/recording_account_default_configuration.py b/twilio/rest/voice/v2/recording_account_default_configuration.py index 6e24166aa..c88fc475f 100644 --- a/twilio/rest/voice/v2/recording_account_default_configuration.py +++ b/twilio/rest/voice/v2/recording_account_default_configuration.py @@ -39,8 +39,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingAccountDefaultConfigurationList.VoiceV2ConfigurationRecordingConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) def to_dict(self): @@ -71,8 +71,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingCompositionPolicy( payload.get("compositionPolicy") ) - if payload.get("compositionPolicy") is not None - else None + if isinstance(payload.get("compositionPolicy"), dict) + else payload.get("compositionPolicy") ) self.call_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback @@ -80,8 +80,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingStatusCallback( payload.get("callRecordingStatusCallback") ) - if payload.get("callRecordingStatusCallback") is not None - else None + if isinstance(payload.get("callRecordingStatusCallback"), dict) + else payload.get("callRecordingStatusCallback") ) self.conference_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback @@ -89,8 +89,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingStatusCallback( payload.get("conferenceRecordingStatusCallback") ) - if payload.get("conferenceRecordingStatusCallback") is not None - else None + if isinstance(payload.get("conferenceRecordingStatusCallback"), dict) + else payload.get("conferenceRecordingStatusCallback") ) self.features: Optional[ List[RecordingList.VoiceV2ConfigurationRecordingFeature] @@ -412,8 +412,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingAccountDefaultConfigurationList.VoiceV2ConfigurationRecordingConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) def to_dict(self): @@ -444,8 +444,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingCompositionPolicy( payload.get("compositionPolicy") ) - if payload.get("compositionPolicy") is not None - else None + if isinstance(payload.get("compositionPolicy"), dict) + else payload.get("compositionPolicy") ) self.call_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback @@ -453,8 +453,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingStatusCallback( payload.get("callRecordingStatusCallback") ) - if payload.get("callRecordingStatusCallback") is not None - else None + if isinstance(payload.get("callRecordingStatusCallback"), dict) + else payload.get("callRecordingStatusCallback") ) self.conference_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback @@ -462,8 +462,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingStatusCallback( payload.get("conferenceRecordingStatusCallback") ) - if payload.get("conferenceRecordingStatusCallback") is not None - else None + if isinstance(payload.get("conferenceRecordingStatusCallback"), dict) + else payload.get("conferenceRecordingStatusCallback") ) self.features: Optional[ List[RecordingList.VoiceV2ConfigurationRecordingFeature] @@ -944,8 +944,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingAccountDefaultConfigurationList.VoiceV2ConfigurationRecordingConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) def to_dict(self): @@ -976,8 +976,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingCompositionPolicy( payload.get("compositionPolicy") ) - if payload.get("compositionPolicy") is not None - else None + if isinstance(payload.get("compositionPolicy"), dict) + else payload.get("compositionPolicy") ) self.call_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback @@ -985,8 +985,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingStatusCallback( payload.get("callRecordingStatusCallback") ) - if payload.get("callRecordingStatusCallback") is not None - else None + if isinstance(payload.get("callRecordingStatusCallback"), dict) + else payload.get("callRecordingStatusCallback") ) self.conference_recording_status_callback: Optional[ RecordingList.VoiceV2ConfigurationRecordingStatusCallback @@ -994,8 +994,8 @@ def __init__(self, payload: Dict[str, Any]): RecordingList.VoiceV2ConfigurationRecordingStatusCallback( payload.get("conferenceRecordingStatusCallback") ) - if payload.get("conferenceRecordingStatusCallback") is not None - else None + if isinstance(payload.get("conferenceRecordingStatusCallback"), dict) + else payload.get("conferenceRecordingStatusCallback") ) self.features: Optional[ List[RecordingList.VoiceV2ConfigurationRecordingFeature] diff --git a/twilio/rest/voice/v2/transcription.py b/twilio/rest/voice/v2/transcription.py index 7c8dedda3..0c8959b90 100644 --- a/twilio/rest/voice/v2/transcription.py +++ b/twilio/rest/voice/v2/transcription.py @@ -49,8 +49,8 @@ def __init__(self, payload: Dict[str, Any]): TranscriptionList.VoiceV2ConfigurationTranscriptionStatusCallback( payload.get("transcriptionStatusCallback") ) - if payload.get("transcriptionStatusCallback") is not None - else None + if isinstance(payload.get("transcriptionStatusCallback"), dict) + else payload.get("transcriptionStatusCallback") ) self.conversation_configuration_id: Optional[str] = payload.get( "conversationConfigurationId" @@ -130,8 +130,8 @@ def __init__(self, payload: Dict[str, Any]): TranscriptionList.VoiceV2ConfigurationTranscriptionConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) def to_dict(self): @@ -398,8 +398,8 @@ def __init__(self, payload: Dict[str, Any]): TranscriptionList.VoiceV2ConfigurationTranscriptionStatusCallback( payload.get("transcriptionStatusCallback") ) - if payload.get("transcriptionStatusCallback") is not None - else None + if isinstance(payload.get("transcriptionStatusCallback"), dict) + else payload.get("transcriptionStatusCallback") ) self.conversation_configuration_id: Optional[str] = payload.get( "conversationConfigurationId" @@ -479,8 +479,8 @@ def __init__(self, payload: Dict[str, Any]): TranscriptionList.VoiceV2ConfigurationTranscriptionConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) def to_dict(self): @@ -865,8 +865,8 @@ def __init__(self, payload: Dict[str, Any]): TranscriptionList.VoiceV2ConfigurationTranscriptionStatusCallback( payload.get("transcriptionStatusCallback") ) - if payload.get("transcriptionStatusCallback") is not None - else None + if isinstance(payload.get("transcriptionStatusCallback"), dict) + else payload.get("transcriptionStatusCallback") ) self.conversation_configuration_id: Optional[str] = payload.get( "conversationConfigurationId" @@ -946,8 +946,8 @@ def __init__(self, payload: Dict[str, Any]): TranscriptionList.VoiceV2ConfigurationTranscriptionConfiguration( payload.get("configuration") ) - if payload.get("configuration") is not None - else None + if isinstance(payload.get("configuration"), dict) + else payload.get("configuration") ) def to_dict(self): diff --git a/twilio/rest/voice/v3/transcription.py b/twilio/rest/voice/v3/transcription.py index 7d557f734..bb0e3d46b 100644 --- a/twilio/rest/voice/v3/transcription.py +++ b/twilio/rest/voice/v3/transcription.py @@ -388,8 +388,8 @@ def __init__(self, payload: Dict[str, Any]): VoiceV3TranscriptionTranscriptionStatusCallback( payload.get("transcriptionStatusCallback") ) - if payload.get("transcriptionStatusCallback") is not None - else None + if isinstance(payload.get("transcriptionStatusCallback"), dict) + else payload.get("transcriptionStatusCallback") ) self.conversation_configuration_id: Optional[str] = payload.get( "conversationConfigurationId"